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}`
|
||||
],
|
||||
env: {
|
||||
node: true,
|
||||
web: true,
|
||||
es6: true
|
||||
browser: true,
|
||||
es6: true,
|
||||
node: true
|
||||
},
|
||||
parserOptions: {
|
||||
project: [
|
||||
|
|
25
package-lock.json
generated
25
package-lock.json
generated
|
@ -8,14 +8,14 @@
|
|||
"name": "connect-force",
|
||||
"version": "0.0.0",
|
||||
"devDependencies": {
|
||||
"@manuth/eslint-plugin-typescript": "^4.0.0",
|
||||
"@manuth/eslint-plugin-typescript": "^4.0.1",
|
||||
"@manuth/tsconfig": "^3.0.2",
|
||||
"@types/browser-sync": "^2.26.3",
|
||||
"@types/gulp": "^4.0.10",
|
||||
"@types/node": "^18.11.10",
|
||||
"@types/node": "^18.11.11",
|
||||
"browser-sync": "^2.27.10",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.23.1",
|
||||
"eslint": "^8.29.0",
|
||||
"gulp": "^4.0.2",
|
||||
"rimraf": "^3.0.2",
|
||||
"ts-node": "^10.9.1",
|
||||
|
@ -253,14 +253,15 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@manuth/eslint-plugin-typescript": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@manuth/eslint-plugin-typescript/-/eslint-plugin-typescript-4.0.0.tgz",
|
||||
"integrity": "sha512-eQITp5hiEiAQa8CGZvHVOqL8isMqf/eYM1352/i3cl9hS+vCd7OI5x/ynDE+lLtxJki8ANq8FGsY1jasWncH+A==",
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@manuth/eslint-plugin-typescript/-/eslint-plugin-typescript-4.0.1.tgz",
|
||||
"integrity": "sha512-fakcZ0Rq/6Sv/haU7X/pHSwgrdxr5no2u2dQ1AVWsr6k7fzzGjSSwaSLzIu7yB3FPUGd0jv0Mgj9tNmoLpYEWg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@types/eslint": "^8.4.6",
|
||||
"@typescript-eslint/typescript-estree": "^5.37.0",
|
||||
"lodash.merge": "^4.6.2",
|
||||
"ts-keyof": "^1.3.0",
|
||||
"tslint": "^6.1.3",
|
||||
"upath": "^2.0.1"
|
||||
},
|
||||
|
@ -460,9 +461,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "18.11.10",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.10.tgz",
|
||||
"integrity": "sha512-juG3RWMBOqcOuXC643OAdSA525V44cVgGV6dUDuiFtss+8Fk5x1hI93Rsld43VeJVIeqlP9I7Fn9/qaVqoEAuQ==",
|
||||
"version": "18.11.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.11.tgz",
|
||||
"integrity": "sha512-KJ021B1nlQUBLopzZmPBVuGU9un7WJd/W4ya7Ih02B4Uwky5Nja0yGYav2EfYIk0RR2Q9oVhf60S2XR1BCWJ2g==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/parse-glob": {
|
||||
|
@ -8234,6 +8235,12 @@
|
|||
"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": {
|
||||
"version": "10.9.1",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz",
|
||||
|
|
|
@ -15,14 +15,14 @@
|
|||
"prepare": "npm run rebuild"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@manuth/eslint-plugin-typescript": "^4.0.0",
|
||||
"@manuth/eslint-plugin-typescript": "^4.0.1",
|
||||
"@manuth/tsconfig": "^3.0.2",
|
||||
"@types/browser-sync": "^2.26.3",
|
||||
"@types/gulp": "^4.0.10",
|
||||
"@types/node": "^18.11.10",
|
||||
"@types/node": "^18.11.11",
|
||||
"browser-sync": "^2.27.10",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^8.23.1",
|
||||
"eslint": "^8.29.0",
|
||||
"gulp": "^4.0.2",
|
||||
"rimraf": "^3.0.2",
|
||||
"ts-node": "^10.9.1",
|
||||
|
|
|
@ -7,53 +7,7 @@
|
|||
<script type="module" src="./js/main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="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 class="board" id="board">
|
||||
</div>
|
||||
</body>
|
||||
</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)
|
||||
{
|
||||
if (typeof child != "string")
|
||||
if (typeof child !== "string")
|
||||
{
|
||||
node.appendChild(child);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { initializeBoard } from "./board.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