From f753d5d3df9cbf5a34f654406580cdca92fd1b52 Mon Sep 17 00:00:00 2001 From: Nathan Date: Thu, 10 Oct 2024 18:36:17 +0100 Subject: [PATCH] Add beginning of DO/ECS --- public/board.js | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/public/board.js b/public/board.js index dc20c75..e08064c 100644 --- a/public/board.js +++ b/public/board.js @@ -15,7 +15,19 @@ clickableItems['board'] = []; clickableItems['hand'] = []; clickableItems['opponentHand'] = []; -// TODO: Uniform the arrays to player and opponent/different playesr +// Array of items, the 'Entity Manager' as such +let item = []; +let itemCount = 0; +// Component 1: Where on the board, hand, deck, mana, shield, etc. +// send back item, itemCount and individual comp. from server? +let boardElement = {}; +let cardData = {}; +let position = {}; +let size = {}; +//let shape = {}; +let cardStatus = {}; // tapped, attacking, inspected, untargettable +let player = {}; + let playerHand = []; let opponentHand = []; let playerBoard = []; @@ -421,7 +433,6 @@ class Board{ this.drawBoard(); } playCardToBoardFromDeckOpponent(){ - // Random card from deck let cardToDraw = Math.floor(Math.random() * deckCount); let cardPlayed = opponentDeck[cardToDraw]; @@ -641,8 +652,8 @@ class Board{ } // TEMP!! -createDeckList(playerDeck, deckCount); -createDeckList(opponentDeck, deckCountOpponent); +createDeckList(playerDeck, deckCount, 0); +createDeckList(opponentDeck, deckCountOpponent, 1); // Run board commands here for testing let board = new Board; @@ -821,14 +832,17 @@ function clickableCheck(x,y,clickable){ // TEMP: Create a deck of X different cards that can be drawn/played // for UI development, will be done on server and not shown to clients -function createDeckList(deck, deckCount){ +function createDeckList(deck, deckCount, playerId){ for(let i = 0; i < deckCount; i++){ // Randomise colour let colour = Math.floor(Math.random() * 2); let effect = Math.floor(Math.random() * 5); if(effect == 0){ effect = 'effect here'; } else{ effect = null } - deck.push({ + + item.push[itemCount]; + boardElement[itemCount] = 'deck'; + cardData[itemCount] = { 'name':'CardName '+(i+1) , 'cost':1 , 'atk':1 @@ -838,7 +852,12 @@ function createDeckList(deck, deckCount){ , 'type':'human' , 'colour':colour , 'tapped':false - }); + }; + player[playerId]; + // Previous iteration, kept to prevent errors for now + deck.push(cardData[itemCount]); + + itemCount++; } }