Add grave boardElement, Fix unit/unit makeAttack

develop
Nathan Steel 1 year ago
parent 221e621fa4
commit 54f136295d

@ -18,7 +18,7 @@ clickableItems['opponentHand'] = [];
// Counters to keep track of players, and boardElements, may be changed in future
// But once game starts, will be const anyway, so shouldn't need passing
let players = 2; // Player, Opponent for now, but will be up to 6 players for 5v1 boss raids?
let elements = ['deck','board','hand','mana','shield'];
let elements = ['deck','board','hand','mana','shield', 'grave'];
let elementsSizes = {}; // May need to have the base XY WH of board, hand, etc. stored for loop draw
// Array of items, the 'Entity Manager' as such
let item = [];
@ -715,17 +715,17 @@ class Board{
// If card on 'board' attacked
// Compare attackingCard and defendingCard
case 'board':
let atkAttacker = cardData[itemAttacking].attack;
let atkDefender = cardData[itemDefending].attack;
let atkAttacker = cardData[itemAttacking];
let atkDefender = cardData[itemDefending];
// Does Attacker kill Defender
if(atkDefender <= atkAttacker){
// TODO:Send the item to grave, boardElement = 'grave'
this.sendToGrave(itemDefending);
}
// Does Defender kill Attacker
if(atkAttacker <= atkDefender){
// TODO:Send the item to grave
this.sendToGrave(itemAttacking);
this.endAttackFor(itemAttacking);
}else{
// If not, end the attacker cards attack 'phase'
@ -844,6 +844,13 @@ class Board{
//addFromBoardElement(playerFrom, fromPosition, elementFrom, elementTo, toPosition=null, playerTo=null)
this.addFromBoardElement(player[itemKey], listPosition[itemKey], boardElement[itemKey], 'hand', null, null);
}
sendToGrave(itemKey){
console.log('SendToGrave: '+itemKey);
//addFromBoardElement(playerFrom, fromPosition, elementFrom, elementTo, toPosition=null, playerTo=null)
this.addFromBoardElement(player[itemKey], listPosition[itemKey], boardElement[itemKey], 'grave', null, null);
}
tapCard(itemKey){
// Set the cardStatus to tapped
cardStatus[itemKey] = 'tapped';

Loading…
Cancel
Save