You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
127 lines
2.8 KiB
JavaScript
127 lines
2.8 KiB
JavaScript
// Passive effects (just does stuff)
|
|
let flight = {};
|
|
let reach = {};
|
|
let equipped = {}; // Entity x has [a,b,c] equipped to it
|
|
|
|
|
|
// Actives to add passives
|
|
function giveFlight(card){
|
|
flight[card] = true;
|
|
}
|
|
function removeFlight(card){
|
|
// If the card has flight delete entity component
|
|
if(card in flight){
|
|
delete flight[card];
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function giveReach(card){
|
|
reach[card] = true;
|
|
}
|
|
function removeReach(card){
|
|
if(card in reach){
|
|
delete reach[card];
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// Active
|
|
function equip(){
|
|
// Equip card to another unit
|
|
|
|
}
|
|
function unequip(){
|
|
// Remove card from its equipped to unit
|
|
|
|
}
|
|
|
|
function drawCard(drawAmount, player){
|
|
board.drawACard(player, drawAmount);
|
|
}
|
|
|
|
function heal(healAmount, healPlayer){
|
|
// For each heal 1..4
|
|
for(let i = 0; i < healAmount; i++){
|
|
// Loop shield
|
|
let items = this.getItems('shield', healPlayer, null, null);
|
|
for(let item = 0; item < items.length; item++){
|
|
|
|
let itemKey = items[item];
|
|
// If a shield is tapped, untap it to 'heal'
|
|
if(board.isTapped(itemKey)){
|
|
board.untapCard(itemKey);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
function hurt(hurtDamage, hurtTarget = null, hurtPlayer = null){
|
|
// Deal X000 damage to unit this turn, or deal Y to opponent's shield
|
|
|
|
// Set player/element
|
|
if(hurtPlayer == null && hurtTarget != null){
|
|
hurtPlayer = player[hurtTarget];
|
|
hurtElement = boardElement[hurtTarget];
|
|
}else{
|
|
hurtElement = 'shield'
|
|
}
|
|
|
|
switch(hurtElement){
|
|
case 'board':
|
|
// TODO: Make temp damage this turn as well
|
|
if(hurtDamage >= cardAttack[hurtTarget][0]){
|
|
board.sendToGrave(hurtTarget);
|
|
}
|
|
break;
|
|
|
|
case 'shield':
|
|
let destroyCount = cardAttackToShieldDamage(hurtDamage);
|
|
console.log(destroyCount);
|
|
// TODO: loop player's shield, tap if they can be tapped, destroy
|
|
// if all already tapped
|
|
|
|
// While there's still damage to deal
|
|
while(destroyCount > 0){
|
|
|
|
// Keep looping through the shield belonging to target user
|
|
let items = board.getItems('shield', hurtPlayer, null, null);
|
|
let tappedItems = board.getItems('shield', hurtPlayer, 'tapped', null);
|
|
|
|
for(let item = 0; item < items.length; item++){
|
|
|
|
// If nothing more to destroy, exit loop
|
|
if(destroyCount <= 0){ break; }
|
|
|
|
let itemKey = items[item];
|
|
console.log(itemKey);
|
|
console.log(cardStatus[itemKey]);
|
|
|
|
// If there's anything to tap, tap it
|
|
if(cardStatus[itemKey] == null){
|
|
console.log('been tapped');
|
|
board.tapCard(itemKey);
|
|
destroyCount--;
|
|
continue;
|
|
}
|
|
|
|
// If there's nothing to tap, destroy it
|
|
if(items.length == tappedItems.length){
|
|
console.log('been destroyed');
|
|
board.destroyShield(itemKey);
|
|
destroyCount--;
|
|
continue;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
board.drawBoard();
|
|
break; // end case 'shield'
|
|
|
|
}
|
|
}
|
|
|