diff --git a/public/board.js b/public/board.js index 3f474cb..3051e48 100644 --- a/public/board.js +++ b/public/board.js @@ -1087,7 +1087,8 @@ function createDeckList(playerId){ item.push(itemCount); // Set card data for new item // Use the ID from the deckList of player, and return the card of that ID from cardList/DB - cardData[itemCount] = cardArray[deckList[deckItem]]; + // ID 1 was adding id 0 as array index. Changed to +1 for now (will correct in DB form) + cardData[itemCount] = cardArray[deckList[deckItem]+1]; // Set to base position of 'deck' boardElement[itemCount] = 'deck'; // Set Attack, ManaCost, ManaColours TODO: When these are implemented seperately @@ -1313,12 +1314,18 @@ function getItemsAndPrintFrontEnd(){ if(cardStatusId == ""){ cardStatusId = null; } let listPositionId = document.getElementById("listPositionId").value; if(listPositionId == ""){ listPositionId = null; } - getItemsAndPrint(boardElementId, playerId, cardStatusId, listPositionId); + let itemOrCard = document.getElementById("itemOrCardData").value; + getItemsAndPrint(boardElementId, playerId, cardStatusId, listPositionId, itemOrCard); } -function getItemsAndPrint(boardElementId = null, playerId = null, cardStatusId = null, listPositionId = null){ +function getItemsAndPrint(boardElementId = null, playerId = null, cardStatusId = null, listPositionId = null, itemOrCard = 'item'){ let items = board.getItems(boardElementId, playerId, cardStatusId, listPositionId); - console.log('----- Items -----'); - printECSData(items); + if(itemOrCard == 'card'){ + console.log('----- CardData -----'); + printCardData(items); + }else{ + console.log('----- ItemData -----'); + printECSData(items); + } console.log('Items array length: '+items.length); } function printECSData(items){ @@ -1335,6 +1342,15 @@ function printECSData(items){ ); } } +function printCardData(items){ + let cardArray = []; + for(let item = 0; item < items.length; item++){ + let itemKey = items[item]; + cardArray.push(cardData[itemKey]); + } + console.log(cardArray); + +} function echoCards(){ console.log(cardArray); } diff --git a/public/index.html b/public/index.html index 528d4f9..8cc583f 100644 --- a/public/index.html +++ b/public/index.html @@ -49,6 +49,11 @@ + +