ticTacToe initial commit
This commit is contained in:
parent
a4a6eebb12
commit
e5ee0b34e5
@ -17,6 +17,7 @@ import TournamentPageView from "./views/tournament/TournamentPageView.js";
|
|||||||
import TournamentsView from "./views/tournament/TournamentsListView.js";
|
import TournamentsView from "./views/tournament/TournamentsListView.js";
|
||||||
import TournamentCreateView from "./views/tournament/TournamentCreateView.js";
|
import TournamentCreateView from "./views/tournament/TournamentCreateView.js";
|
||||||
import AuthenticationView from "./views/accounts/AuthenticationView.js";
|
import AuthenticationView from "./views/accounts/AuthenticationView.js";
|
||||||
|
import TicTacToeView from "./views/TicTacToeView.js";
|
||||||
|
|
||||||
let client = new Client(location.origin);
|
let client = new Client(location.origin);
|
||||||
let lang = client.lang;
|
let lang = client.lang;
|
||||||
@ -88,6 +89,7 @@ const router = async(uri) => {
|
|||||||
{ path: "/matchmaking", view: MatchMakingView },
|
{ path: "/matchmaking", view: MatchMakingView },
|
||||||
{ path: "/games/offline", view: GameOfflineView },
|
{ path: "/games/offline", view: GameOfflineView },
|
||||||
{ path: "/games/:id", view: GameView },
|
{ path: "/games/:id", view: GameView },
|
||||||
|
{ path: "/tictactoe", view: TicTacToeView },
|
||||||
];
|
];
|
||||||
|
|
||||||
// Test each route for potential match
|
// Test each route for potential match
|
||||||
|
@ -37,5 +37,6 @@
|
|||||||
"profileUnblock": "Quoicoudebloquer",
|
"profileUnblock": "Quoicoudebloquer",
|
||||||
"profileBlock": "Quoicoubloquer",
|
"profileBlock": "Quoicoubloquer",
|
||||||
"gameGoalTaken": "Tu es quoicoucringe",
|
"gameGoalTaken": "Tu es quoicoucringe",
|
||||||
"gamePlayersListName": "Crampteurs"
|
"gamePlayersListName": "Crampteurs",
|
||||||
|
"ticTacToe": "Quoicoumorpion"
|
||||||
}
|
}
|
||||||
|
@ -37,5 +37,6 @@
|
|||||||
"profileUnblock": "Unblock",
|
"profileUnblock": "Unblock",
|
||||||
"profileBlock": "Block",
|
"profileBlock": "Block",
|
||||||
"gameGoalTaken": "Goal Taken",
|
"gameGoalTaken": "Goal Taken",
|
||||||
"gamePlayersListName": "Players"
|
"gamePlayersListName": "Players",
|
||||||
|
"ticTacToe": "Morpion"
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
"profileDenyRequest": "ante e ijo ni",
|
"profileDenyRequest": "ante e ijo ni",
|
||||||
"profileAcceptRequest": "kama jo e ijo ni",
|
"profileAcceptRequest": "kama jo e ijo ni",
|
||||||
"profileUnblock": "Tawa ala e nimi pi jan ni",
|
"profileUnblock": "Tawa ala e nimi pi jan ni",
|
||||||
"profileBlock": "Tawa e nimi pi jan ni"
|
"profileBlock": "Tawa e nimi pi jan ni",
|
||||||
|
"ticTacToe": "TicTacToe"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ export default class extends AbstractAuthenticatedView {
|
|||||||
<h1>${lang.get('homeTitle', 'Home')}</h1>
|
<h1>${lang.get('homeTitle', 'Home')}</h1>
|
||||||
<a href="/matchmaking" data-link>${lang.get('homeOnline', 'Play online')}</a>
|
<a href="/matchmaking" data-link>${lang.get('homeOnline', 'Play online')}</a>
|
||||||
<a href="/games/offline" data-link>${lang.get('homeOffline', 'Play offline')}</a>
|
<a href="/games/offline" data-link>${lang.get('homeOffline', 'Play offline')}</a>
|
||||||
|
<a href="/tictactoe" data-link>${lang.get('ticTacToe')}</a>
|
||||||
<a href="/settings" data-link>${lang.get('homeSettings', 'Settings')}</a>
|
<a href="/settings" data-link>${lang.get('homeSettings', 'Settings')}</a>
|
||||||
<a href="/logout" data-link>${lang.get('homeLogout', 'Logout')}</a>
|
<a href="/logout" data-link>${lang.get('homeLogout', 'Logout')}</a>
|
||||||
`;
|
`;
|
||||||
|
57
frontend/static/js/views/TicTacToeView.js
Normal file
57
frontend/static/js/views/TicTacToeView.js
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
import { lang } from "../index.js";
|
||||||
|
import AbstractView from "./abstracts/AbstractView.js";
|
||||||
|
|
||||||
|
export default class extends AbstractView
|
||||||
|
{
|
||||||
|
constructor(params)
|
||||||
|
{
|
||||||
|
super(params, lang.get('ticTacToe'));
|
||||||
|
this.width = 660;
|
||||||
|
this.height = 660;
|
||||||
|
}
|
||||||
|
|
||||||
|
async postInit()
|
||||||
|
{
|
||||||
|
let morpion = [[],[],[],[],[],[],[],[],[]];
|
||||||
|
let currMorpion = 4;
|
||||||
|
let gap = 30;
|
||||||
|
for (let i = 0; i < 9; i++)
|
||||||
|
for (let j = 0; j < 9; j++)
|
||||||
|
morpion[i].push(-1);
|
||||||
|
const canvas = document.getElementById("Morpion");
|
||||||
|
this.ctx = canvas.getContext("2d");
|
||||||
|
this.ctx.fillStyle = "white";
|
||||||
|
this.ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||||
|
for (let i = 1, x = gap, y = gap; i <= 9; i++)
|
||||||
|
{
|
||||||
|
this.DrawMorpion(x, y);
|
||||||
|
x += 180 + gap;
|
||||||
|
if (i % 3 == 0)
|
||||||
|
{
|
||||||
|
y += 180 + gap;
|
||||||
|
x = gap;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawMorpion(start_x, start_y)
|
||||||
|
{
|
||||||
|
for (let i = 1, x = 0, y = 0; i <= 9; i++)
|
||||||
|
{
|
||||||
|
this.ctx.strokeRect(start_x + x, start_y + y, 60, 60);
|
||||||
|
x += 60;
|
||||||
|
if (i % 3 == 0)
|
||||||
|
{
|
||||||
|
y += 60;
|
||||||
|
x = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async getHtml()
|
||||||
|
{
|
||||||
|
return `
|
||||||
|
<h1>${lang.get('ticTacToe')}</h1>
|
||||||
|
<canvas id="Morpion" width="${this.width}" height="${this.height}"></canvas>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user