Compare commits
4 commits
aaac8f1912
...
4717a6e4e9
Author | SHA1 | Date | |
---|---|---|---|
Manuel Thalmann | 4717a6e4e9 | ||
Manuel Thalmann | 6e6eceab2b | ||
Manuel Thalmann | 1c58ac04a4 | ||
Manuel Thalmann | 427e704a61 |
|
@ -6,9 +6,9 @@ module.exports = {
|
||||||
`plugin:${PluginName}/${PresetName.RecommendedWithTypeChecking}`
|
`plugin:${PluginName}/${PresetName.RecommendedWithTypeChecking}`
|
||||||
],
|
],
|
||||||
env: {
|
env: {
|
||||||
node: true,
|
browser: true,
|
||||||
web: true,
|
es6: true,
|
||||||
es6: true
|
node: true
|
||||||
},
|
},
|
||||||
parserOptions: {
|
parserOptions: {
|
||||||
project: [
|
project: [
|
||||||
|
|
25
package-lock.json
generated
25
package-lock.json
generated
|
@ -8,14 +8,14 @@
|
||||||
"name": "connect-force",
|
"name": "connect-force",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@manuth/eslint-plugin-typescript": "^4.0.0",
|
"@manuth/eslint-plugin-typescript": "^4.0.1",
|
||||||
"@manuth/tsconfig": "^3.0.2",
|
"@manuth/tsconfig": "^3.0.2",
|
||||||
"@types/browser-sync": "^2.26.3",
|
"@types/browser-sync": "^2.26.3",
|
||||||
"@types/gulp": "^4.0.10",
|
"@types/gulp": "^4.0.10",
|
||||||
"@types/node": "^18.11.10",
|
"@types/node": "^18.11.11",
|
||||||
"browser-sync": "^2.27.10",
|
"browser-sync": "^2.27.10",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"eslint": "^8.23.1",
|
"eslint": "^8.29.0",
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
|
@ -253,14 +253,15 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@manuth/eslint-plugin-typescript": {
|
"node_modules/@manuth/eslint-plugin-typescript": {
|
||||||
"version": "4.0.0",
|
"version": "4.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/@manuth/eslint-plugin-typescript/-/eslint-plugin-typescript-4.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@manuth/eslint-plugin-typescript/-/eslint-plugin-typescript-4.0.1.tgz",
|
||||||
"integrity": "sha512-eQITp5hiEiAQa8CGZvHVOqL8isMqf/eYM1352/i3cl9hS+vCd7OI5x/ynDE+lLtxJki8ANq8FGsY1jasWncH+A==",
|
"integrity": "sha512-fakcZ0Rq/6Sv/haU7X/pHSwgrdxr5no2u2dQ1AVWsr6k7fzzGjSSwaSLzIu7yB3FPUGd0jv0Mgj9tNmoLpYEWg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/eslint": "^8.4.6",
|
"@types/eslint": "^8.4.6",
|
||||||
"@typescript-eslint/typescript-estree": "^5.37.0",
|
"@typescript-eslint/typescript-estree": "^5.37.0",
|
||||||
"lodash.merge": "^4.6.2",
|
"lodash.merge": "^4.6.2",
|
||||||
|
"ts-keyof": "^1.3.0",
|
||||||
"tslint": "^6.1.3",
|
"tslint": "^6.1.3",
|
||||||
"upath": "^2.0.1"
|
"upath": "^2.0.1"
|
||||||
},
|
},
|
||||||
|
@ -460,9 +461,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "18.11.10",
|
"version": "18.11.11",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.10.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.11.tgz",
|
||||||
"integrity": "sha512-juG3RWMBOqcOuXC643OAdSA525V44cVgGV6dUDuiFtss+8Fk5x1hI93Rsld43VeJVIeqlP9I7Fn9/qaVqoEAuQ==",
|
"integrity": "sha512-KJ021B1nlQUBLopzZmPBVuGU9un7WJd/W4ya7Ih02B4Uwky5Nja0yGYav2EfYIk0RR2Q9oVhf60S2XR1BCWJ2g==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/parse-glob": {
|
"node_modules/@types/parse-glob": {
|
||||||
|
@ -8234,6 +8235,12 @@
|
||||||
"node": ">=0.6"
|
"node": ">=0.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/ts-keyof": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/ts-keyof/-/ts-keyof-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-Lxqyx+UTzuSxBeCHaEWsmGIuKHBNpt5/m/UBJTEthadibAlopB7njL6XQRV2BJ7/YCyxra6gqUuAG8ftZyC7tA==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"node_modules/ts-node": {
|
"node_modules/ts-node": {
|
||||||
"version": "10.9.1",
|
"version": "10.9.1",
|
||||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz",
|
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz",
|
||||||
|
|
|
@ -15,14 +15,14 @@
|
||||||
"prepare": "npm run rebuild"
|
"prepare": "npm run rebuild"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@manuth/eslint-plugin-typescript": "^4.0.0",
|
"@manuth/eslint-plugin-typescript": "^4.0.1",
|
||||||
"@manuth/tsconfig": "^3.0.2",
|
"@manuth/tsconfig": "^3.0.2",
|
||||||
"@types/browser-sync": "^2.26.3",
|
"@types/browser-sync": "^2.26.3",
|
||||||
"@types/gulp": "^4.0.10",
|
"@types/gulp": "^4.0.10",
|
||||||
"@types/node": "^18.11.10",
|
"@types/node": "^18.11.11",
|
||||||
"browser-sync": "^2.27.10",
|
"browser-sync": "^2.27.10",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"eslint": "^8.23.1",
|
"eslint": "^8.29.0",
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
"rimraf": "^3.0.2",
|
"rimraf": "^3.0.2",
|
||||||
"ts-node": "^10.9.1",
|
"ts-node": "^10.9.1",
|
||||||
|
|
|
@ -7,53 +7,7 @@
|
||||||
<script type="module" src="./js/main.js"></script>
|
<script type="module" src="./js/main.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="board">
|
<div class="board" id="board">
|
||||||
<div class="field">
|
|
||||||
<div class="blue piece"></div>
|
|
||||||
</div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field">
|
|
||||||
<div class="red piece"></div>
|
|
||||||
</div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
<div class="field"></div>
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
13
src/js/Constants.js
Normal file
13
src/js/Constants.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
/**
|
||||||
|
* Provides constants for the project.
|
||||||
|
*/
|
||||||
|
export class Constants
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The IDs of the players.
|
||||||
|
*/
|
||||||
|
static PLAYER_NAMES = [
|
||||||
|
"red",
|
||||||
|
"blue"
|
||||||
|
];
|
||||||
|
}
|
40
src/js/board.js
Normal file
40
src/js/board.js
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
import { Constants } from "./Constants.js";
|
||||||
|
import { elt } from "./elt.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the game board.
|
||||||
|
*
|
||||||
|
* @param {string} id
|
||||||
|
* The id of the element to add the board to.
|
||||||
|
*/
|
||||||
|
export function initializeBoard(id)
|
||||||
|
{
|
||||||
|
let board = document.getElementById(id);
|
||||||
|
|
||||||
|
for (let i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
for (let i = 0; i < 7; i++)
|
||||||
|
{
|
||||||
|
/** @type {Node[]} */
|
||||||
|
let children = [];
|
||||||
|
let playerId = Math.floor(Math.random() * 3);
|
||||||
|
|
||||||
|
if (playerId > 0)
|
||||||
|
{
|
||||||
|
children.push(elt(
|
||||||
|
"div",
|
||||||
|
{
|
||||||
|
class: `piece ${Constants.PLAYER_NAMES[playerId - 1]}`
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
board.appendChild(
|
||||||
|
elt(
|
||||||
|
"div",
|
||||||
|
{
|
||||||
|
class: "field"
|
||||||
|
},
|
||||||
|
...children));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,7 +25,7 @@ export function elt(type, attrs, ...children)
|
||||||
|
|
||||||
for (let child of children)
|
for (let child of children)
|
||||||
{
|
{
|
||||||
if (typeof child != "string")
|
if (typeof child !== "string")
|
||||||
{
|
{
|
||||||
node.appendChild(child);
|
node.appendChild(child);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { initializeBoard } from "./board.js";
|
||||||
import { elt } from "./elt.js";
|
import { elt } from "./elt.js";
|
||||||
|
|
||||||
elt("a", { href: "https://startpage.com/" }, "This is a test");
|
document.documentElement.appendChild(elt("a", { href: "https://startpage.com/" }, "This is a test"));
|
||||||
|
initializeBoard("board");
|
||||||
|
|
Loading…
Reference in a new issue