|
|
|
|
@ -802,24 +802,33 @@ class Board{
|
|
|
|
|
// Run board commands here for testing
|
|
|
|
|
let board = new Board;
|
|
|
|
|
|
|
|
|
|
// Await DB promise for decks before loading the game
|
|
|
|
|
requestGetCards(); // TODO: Make actually wait for the DB response before continuing...
|
|
|
|
|
|
|
|
|
|
// Fill each players deck with their cards
|
|
|
|
|
createDecks();
|
|
|
|
|
// Board is now async (initialisation)
|
|
|
|
|
// Everything beyond initialisation shouldn't be required so no need to wait
|
|
|
|
|
// At least I think, for now. May need more stuff in future
|
|
|
|
|
async function loadBoard() {
|
|
|
|
|
// TODO: Figure out how to wait for requestDeck to responnd
|
|
|
|
|
// Have tried wrapping the function in a newPromise doodad, but that didn't
|
|
|
|
|
// change anything TODO TODO !IMPORTANT
|
|
|
|
|
console.log(await requestDeck());
|
|
|
|
|
//console.log(await requestGetCards(1, 2)); // Deck 1 for Player 2
|
|
|
|
|
//const dbLoaded = await loadDBElements();
|
|
|
|
|
|
|
|
|
|
// Fill each players deck with their cards
|
|
|
|
|
createDecks();
|
|
|
|
|
|
|
|
|
|
// Play shield from top of each players deck to the maximum allowed (4 typically)
|
|
|
|
|
for(let currentPlayer = 0; currentPlayer <= players-1; currentPlayer++){
|
|
|
|
|
board.playShield(1, 'deck', currentPlayer, maxShield);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Play shield from top of each players deck to the maximum allowed (4 typically)
|
|
|
|
|
for(let currentPlayer = 0; currentPlayer <= players-1; currentPlayer++){
|
|
|
|
|
board.playShield(1, 'deck', currentPlayer, maxShield);
|
|
|
|
|
// Draw the graphics of the board/game
|
|
|
|
|
// Wait for the cardArt to load on first load
|
|
|
|
|
// Otherwise it'll be boxes, and art will flash in on first click event triggered
|
|
|
|
|
cardArt.onload = function(){
|
|
|
|
|
board.drawBoard(true);
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Draw the graphics of the board/game
|
|
|
|
|
// Wait for the cardArt to load on first load
|
|
|
|
|
// Otherwise it'll be boxes, and art will flash in on first click event triggered
|
|
|
|
|
cardArt.onload = function(){
|
|
|
|
|
board.drawBoard(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
loadBoard();
|
|
|
|
|
|
|
|
|
|
// Right Click, Rightclick, rightclick, right click
|
|
|
|
|
canvas.addEventListener('contextmenu', function(event) {
|
|
|
|
|
|