Changes to make loadBoard work with new data

develop
Nathan Steel 1 year ago
parent ed2ecdd2c2
commit 47f9290663

@ -344,7 +344,8 @@ function requestDeck(itemData = null){
itemData.listPosition = listPosition; itemData.listPosition = listPosition;
itemData.cardFace = cardFace; itemData.cardFace = cardFace;
itemData.cardColours = cardColours; itemData.cardColours = cardColours;
//itemData.cardSprite = cardSprite; itemData.cardAttack = cardAttack;
itemData.cardSprite = cardSprite;
// item, itemCount, deckData, cardData, boardElement // item, itemCount, deckData, cardData, boardElement
//console.log(cardData); //console.log(cardData);

@ -867,70 +867,8 @@ function loadBoard(data) {
// rewritten/made into generateItems or something, for each match // rewritten/made into generateItems or something, for each match
// Decks can be as-is for getting deckLists for deckselection, but // Decks can be as-is for getting deckLists for deckselection, but
// TODO: for matches need something to generate and return every item, and attribute // TODO: for matches need something to generate and return every item, and attribute
if(false){
// Temp solution
// Loop all items, and set their related missing attributes
// TODO: some more jank to get it 'playable' with DB entries
let player0DeckCount = 0;
let player1DeckCount = 0;
for(let i = 0; i < itemCount; i++){
// Set player for decks (to just be their array index for now) TODO: Properly
if(boardElement[i] == 'realDeck'){
player[i] = i; // Jank...
//player[i] = deckData[i];
//console.log(deckData[i]);
}else{
// Everything else missing in a jank fashion
player[i] = deckIn[i]; // 1-1 here, but likely not in future
}
cardStatus[i] = null; // Just building on first load, as deck gen
// substite at the mo, so all cards are free of status
cardFace[i] = 0; // As above, deck gen sub. Everything starts facedown
// Set position for cards in each deck... // TODO: Loop these for the amount of players in players (and use the correct itemKey)
// TODO: JANK, tidy, remove, make good!!
// using the new player set just above, which in itself is jank
if(player[i] == 0 && boardElement[i] != 'realDeck'){
listPosition[i] = player0DeckCount+1;
player0DeckCount++;
}
// Just an else, as in DB/for this test only 2 decks
// TODO: MAKE BETTER!
else{
listPosition[i] = player0DeckCount+1;
player0DeckCount++;
}
// TODO: JANK IN, CHANGE CODE TO USE NEW ARRAY!!
// Temp jank, set colour to first colour req.
if(cardData[i] !== undefined){ // i may not have carddata, as realDeck
cardData[i].colour = 0;//cardData[itemCount].colour[0];
// Set the artwork (this would be done front-end I think)
cardSprite[i] = [0,0];
// Temp sprite set based on colour TODO: Change to set correct sprite from DB
switch (cardData[i].colour){
case 0: // White
cardSprite[i] = [0,0];
break;
case 1: // Blue
cardSprite[i] = [0,1];
break;
case 2: // Red
cardSprite[i] = [1,0];
break;
case 3: // Green
cardSprite[i] = [1,1];
break;
default:
break;
}
}
}
} // END FALSE/TEMP DISABLE
shuffleDeck(0); // Shuffle player 0 deck shuffleDeck(0); // Shuffle player 0 deck
shuffleDeck(1); // Shuffle player 1 deck shuffleDeck(1); // Shuffle player 1 deck
@ -1026,6 +964,8 @@ canvas.addEventListener('click', function(event) {
if(boardElement[itemKey] == 'deck'){ if(boardElement[itemKey] == 'deck'){
continue; continue;
}else{ }else{
// Will print everything that's clickable (or should be clickable)
// any undefined attributes and such should display with this too
//printECSData([itemKey]); //printECSData([itemKey]);
} }
@ -1221,7 +1161,7 @@ function calculateItemSizePosition(itemKey){
let i = listPosition[itemKey]; let i = listPosition[itemKey];
//console.log('cardName: '+cardData[itemKey].name+' listPosition/i: '+i); //console.log('cardName: '+cardData[itemKey].name+' listPosition/i: '+i);
if(itemPlayer == 1 && itemElement == 'realDeck'){ if(itemPlayer == 1 && itemElement == 'realDeck'){
positionX = 40; positionX = 40;
positionY = 60; positionY = 60;

@ -25,9 +25,11 @@ function setPlayers(playerCount = 2, itemData){
let playerNo = 0 + itemData['itemCount']; // Start loop from current itemCount let playerNo = 0 + itemData['itemCount']; // Start loop from current itemCount
playerCount = playerCount + itemData['itemCount']; // End at playerCount diff from itemCount playerCount = playerCount + itemData['itemCount']; // End at playerCount diff from itemCount
for(playerNo; playerNo < playerCount; playerNo++){ for(playerNo; playerNo < playerCount; playerNo++){
itemData['item'].push(playerNo); // REMOVED PLAYERS AS ITEM, BECAUSE THEY WERE BORKING
itemData['player'][itemData['itemCount']] = playerNo; // The player belongs to itself // TODO: Add back at some point, or don't bother
itemData['itemCount']++; //itemData['item'].push(playerNo);
//itemData['player'][itemData['itemCount']] = playerNo; // The player belongs to itself
//itemData['itemCount']++;
itemData['players'].push(playerNo); // Add player no to array so can be looped itemData['players'].push(playerNo); // Add player no to array so can be looped
} }
// Return related item and item attributes // Return related item and item attributes

Loading…
Cancel
Save