Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Made summoning creatures cost actions. Made replacing creature have i…
Browse files Browse the repository at this point in the history
…t go to discard pile.
  • Loading branch information
browntj16 committed Apr 25, 2024
1 parent beb1b28 commit 7da5275
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,17 +468,31 @@ export class Game extends AbstractGame {
/**
* summons a creature to the side of player id at position number
*/
summonCard(playerId: number, position: number, card: Creature){

summonCard(playerId: number, position: number, card: Creature, player: Player){
let pos = this.board.getBoardPosByOwnerId(playerId, position);
pos.creature=card;
if(pos?.creature.name === "Null"){
pos.creature=card;
}
else{
player.discardPile.push(pos?.creature);
pos.creature=card;
}

}

/**
* basic helper function i made that removes card from players hand and places it on board
* @param playerId
* @param boardPosition
* @param handPosition
*/
summonCardFromHand(playerId: number, boardPosition: number, handPosition: number){
let player = this.getPlayerById(playerId);
let card = player.hand[handPosition];
player.hand.splice(handPosition, 1);
this.summonCard(playerId, boardPosition, card);
if(player.actions >= card.getCost()){
player.actions -= card.getCost();
player.hand.splice(handPosition, 1);
this.summonCard(playerId, boardPosition, card, player);
}
}

playCard(card: Card, playerId: number): boolean {
Expand Down

0 comments on commit 7da5275

Please sign in to comment.