Skip to content

Commit

Permalink
testing linter
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdcvlsc committed Jun 30, 2023
1 parent c8202ea commit 342d362
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 23 deletions.
14 changes: 14 additions & 0 deletions .github/linters/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"printWidth": 120,
"useTabs": false,
"semi": true,
"singleQuote": true,
"jsxSingleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"bracketSameLine": false,
"arrowParens": "avoid",
"singleAttributePerLine": false,
"tabWidth": 2,
"endOfLine": "auto"
}
10 changes: 6 additions & 4 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fetch-depth: 0

- name: Lint Code Base
uses: super-linter/super-linter@v4
uses: super-linter/super-linter@v5
env:
# https://github.com/super-linter/super-linter#environment-variables

Expand All @@ -28,15 +28,17 @@ jobs:

# this decides whether Super Linter should lint the whole codebase
# or just the changes introduced with that commit.
VALIDATE_ALL_CODEBASE: false
VALIDATE_ALL_CODEBASE: true

# to add a specific language linter,the format is: VALIDATE_{LANGUAGE}_{LINTER}
# setting to true will run only the linter.
# setting to false will run all linters except it.
VALIDATE_JAVASCRIPT_ES: true
JAVASCRIPT_DEFAULT_STYLE: standard/prettier

# VALIDATE_PYTHON_BLACK: true
# VALIDATE_HTML: true
VALIDATE_JAVASCRIPT_ES: true
VALIDATE_HTML: true
VALIDATE_CSS: true

# where your linter config files should go like;
# .prettierrc.json, .clang-fromat, .eslintrc.yml, .htmlhintrc, etc.
Expand Down
3 changes: 3 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const app = fastify({
logger: false,
});




import fastifyStatic from '@fastify/static';

app.register(fastifyStatic.default, {
Expand Down
50 changes: 43 additions & 7 deletions public/TicTacToe.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,63 @@
'use strict';
console.log('TicTacToe.js: loaded.');
console.log('TicTacToe.js: loaded.'





);

/** Empty square value, Not Available ` `. */
const NA = 0;
const NOWINNER = 0;
const NOWINNER =













0;

/** Player 1 square value `X`. */
const P1 = 1;

/** Player 2 square value `O`. */
const P2 = 2;
const CELL_PIECE = ['', 'X', 'O'];
const CELL_PIECE = ['',
'X', 'O'

];

const MOVE_SUCCESS = 1;
const MOVE_INVALID = 0;

const MOVE_INVALID =
0;

/** A single thread tic-tac-toe game representation that can uses
* `minimax` algorithm to search for the best possible move.
*/
class TicTacToe {
constructor(gridLength, player = P1) {
this.grid = gridLength;
constructor(gridLength, player = P1){this.grid = gridLength;
this.winner = 0;
this.board = new Uint8Array(gridLength * gridLength);

this.board = new Uint8Array(



gridLength * gridLength





);
this.currentPlayer = P1;
this.turns = gridLength * gridLength;

Expand Down
48 changes: 37 additions & 11 deletions public/script.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,50 @@
// =================== tic-tac-toe minimax ===================
import { TicTacToe } from './TicTacToe.js';
import { TicTacToe











} from './TicTacToe.js';

let game = new TicTacToe(3);

const PIECE = [' ', '✕', '◯'];
const PIECE = [' ', '✕', '◯'];

const SUCCESS = 1;
const SUCCESS =
1;
const INVALID = 0;

function announceResult(flag) {









console.log(flag);



if (game.winner === 0) {
htmlMessage.innerText = 'Game ended in a draw.';
htmlMessage.style.color = 'yellow';
htmlMessage.style.fontSize = '1.15em';
htmlMessage.style.fontWeight = 'bolder';
htmlMessage.innerText = 'Game ended in a draw.';
htmlMessage.style.color = 'yellow';
htmlMessage.style.fontSize = '1.15em';
htmlMessage.style.fontWeight = 'bolder';
} else {
htmlMessage.innerHTML = `Player ${PIECE[game.winner]} won.`;
htmlMessage.style.color = 'lightgreen';
htmlMessage.style.fontSize = '1.15em';
htmlMessage.style.fontWeight = 'bolder';
htmlMessage.innerHTML = `Player ${PIECE[game.winner]} won.`;
htmlMessage.style.color = 'lightgreen';
htmlMessage.style.fontSize = '1.15em';
htmlMessage.style.fontWeight = 'bolder';
}
}

Expand Down
3 changes: 3 additions & 0 deletions shownet.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ function showLocalNetworkIP(PORT) {
console.log('no IP found for sharing over the network');
}
}



export { showLocalNetworkIP };
10 changes: 9 additions & 1 deletion tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@ import { TicTacToe, NA, P1, P2 } from './public/TicTacToe.js';
const t = new TicTacToe(3);
let failedTests = 0;

const winners = [NA, P1, P1, P1, P1, P1, P1, P2, P2, P2, P2, P2, P2, P1, P1, P2, P2];
const winners = [NA,
P1,
P1,
P1,

P1, P1, P1, P2, P2, P2, P2, P2, P2, P1, P1, P2, P2];




const winBoardStates = [
[NA, NA, NA, NA, NA, NA, NA, NA, NA],
Expand Down

0 comments on commit 342d362

Please sign in to comment.