adding game mode button to matchmaking view
This commit is contained in:
@ -5,8 +5,8 @@ import Search from "./views/Search.js";
|
||||
import HomeView from "./views/HomeView.js";
|
||||
import LogoutView from "./views/accounts/LogoutView.js";
|
||||
import GameOfflineView from "./views/GameOfflineView.js";
|
||||
//import GameView from "./views/GameView.js";
|
||||
import GameView from "./views/GameView3D.js";
|
||||
import GameView2D from "./views/GameView.js";
|
||||
import GameView3D from "./views/GameView3D.js";
|
||||
|
||||
import PageNotFoundView from './views/PageNotFoundView.js'
|
||||
|
||||
@ -88,7 +88,8 @@ const router = async(uri) => {
|
||||
{ path: "/settings", view: SettingsView },
|
||||
{ path: "/matchmaking", view: MatchMakingView },
|
||||
{ path: "/games/offline", view: GameOfflineView },
|
||||
{ path: "/games/:id", view: GameView },
|
||||
{ path: "/games/0/:id", view: GameView2D },
|
||||
{ path: "/games/1/:id", view: GameView3D },
|
||||
];
|
||||
|
||||
// Test each route for potential match
|
||||
|
@ -5,7 +5,8 @@ import AbstractAuthenticatedView from "./abstracts/AbstractAuthenticatedView.js"
|
||||
export default class extends AbstractAuthenticatedView {
|
||||
constructor(params)
|
||||
{
|
||||
super(params, "Matchmaking");
|
||||
super(params, "Matchmaking");
|
||||
this.game_mode = 0; // 0 -> 2D; 1 -> 3D
|
||||
}
|
||||
|
||||
async press_button()
|
||||
@ -25,6 +26,20 @@ export default class extends AbstractAuthenticatedView {
|
||||
}
|
||||
}
|
||||
|
||||
async press_button_game_mode()
|
||||
{
|
||||
if(this.game_mode === 0)
|
||||
{
|
||||
document.getElementById("game-mode").value = "3D";
|
||||
this.game_mode = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById("game-mode").value = "2D";
|
||||
this.game_mode = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ondisconnect(event)
|
||||
{
|
||||
if (event.code === 1000)
|
||||
@ -36,7 +51,7 @@ export default class extends AbstractAuthenticatedView {
|
||||
{
|
||||
if (data.detail === "game_found")
|
||||
{
|
||||
navigateTo(`/games/${data.game_id}`);
|
||||
navigateTo(`/games/${this.game_mode}/${data.game_id}`);
|
||||
return;
|
||||
}
|
||||
this.display_data(data)
|
||||
@ -51,6 +66,7 @@ export default class extends AbstractAuthenticatedView {
|
||||
async postInit()
|
||||
{
|
||||
document.getElementById("button").onclick = this.press_button.bind(this)
|
||||
document.getElementById("game-mode").onclick = this.press_button_game_mode.bind(this)
|
||||
}
|
||||
|
||||
async getHtml() {
|
||||
@ -58,6 +74,7 @@ export default class extends AbstractAuthenticatedView {
|
||||
<h1>Select mode</h1>
|
||||
<input type="number" value="2" id="nb_players-input">
|
||||
<input type="button" value="Find a game" id="button">
|
||||
<input type="button" value="2D" id="game-mode">
|
||||
<span id="detail"></span>
|
||||
`;
|
||||
}
|
||||
|
Reference in New Issue
Block a user