//------------------ // affecting players //------------------ public bool CanHenchmanAttackTargetPlayer(BoardSpaceEnum henchmanSpace, PlayerManager target) { HenchmanCard henchman = board[henchmanSpace]; if (henchman != null) { if (!henchman.HasActedThisTurn()) { if (henchman.GetController() != target) { return(true); } else { Debug.Log("Henchman can't attack a player because the player is its controller..."); } } else { Debug.Log("Henchman can't attack a player because it already acted this turn..."); } } else { Debug.Log("Henchman can't attack a player because it doesn't exist..."); } return(false); }
/* * This method is called whenever the player clicks a henchman in play. It will cause the * RoTStateMachine to move to the AttackingWithHenchmanState as long as the henchman is * controlled by the active player and can still attack this turn. * * NOTE: Any behaviors related to clicking a henchman that has attacked or a henchman * controlled by the opponent should be implemented in this method. */ private void HandleHenchmanInPlaySelected(HenchmanCard henchman) { if (henchman.GetController() == rsm.GetActivePlayer()) { if (!henchman.HasActedThisTurn()) { rsm.SetAttackingHenchman(henchman); rsm.ChangeState <AttackingWithHenchmanState>(); } } }
//------------------------ // affecting cards in play //------------------------ public bool CanPutHenchmanAtSpace(HenchmanCard henchman, BoardSpaceEnum space) { //henchman can be placed if the space is on it's controller's side bool onControllersSide = false; if (henchman.GetController() == player) { if ((space == BoardSpaceEnum.P1) || (space == BoardSpaceEnum.P2) || (space == BoardSpaceEnum.P3) || (space == BoardSpaceEnum.P4) || (space == BoardSpaceEnum.P5)) { onControllersSide = true; } } else if (henchman.GetController() == opponent) { if ((space == BoardSpaceEnum.O1) || (space == BoardSpaceEnum.O2) || (space == BoardSpaceEnum.O3) || (space == BoardSpaceEnum.O4) || (space == BoardSpaceEnum.O5)) { onControllersSide = true; } } else { Debug.Log("The henchman trying to be placed has a controller that's neither the player nor the opponent..."); } if (onControllersSide) { //the space must also be empty return(board[space] == null); } else { return(false); } }
//NOTE: Should be called before switching the active player! public void HandleEndOfTurn(PlayerManager activePlayer) { //call HandleEndOfTurn() on all HenchmanCards in play, in the order they came into play RemoveQueue <BoardSpaceEnum> newOrder = new RemoveQueue <BoardSpaceEnum>(); while (!henchmenOrder.IsEmpty()) { BoardSpaceEnum henchmanSpace = henchmenOrder.Dequeue(); HenchmanCard henchman = board[henchmanSpace]; if (henchman.GetController() == activePlayer) { henchman.HandleEndOfTurn(); } newOrder.Enqueue(henchmanSpace); } henchmenOrder = newOrder; }
//--------------------- // responding to events //--------------------- private void TriggerVengeanceEvents(PlayerManager prizeCardRecipient) { //invoke vengeance events on relevant henchman, in the order they came into play RemoveQueue <BoardSpaceEnum> newOrder = new RemoveQueue <BoardSpaceEnum>(); while (!henchmenOrder.IsEmpty()) { BoardSpaceEnum henchmanSpace = henchmenOrder.Dequeue(); HenchmanCard henchman = board[henchmanSpace]; if (henchman.GetController() != prizeCardRecipient) { //only invoke the event if the recipient of the prize card was not the henchman's controller henchman.VengeanceEvent.Invoke(); } newOrder.Enqueue(henchmanSpace); } henchmenOrder = newOrder; }
//should only be called if CanRemoveHenchmanFromBoard() returns true public void RemoveHenchmanFromBoard(BoardSpaceEnum space) { HenchmanCard henchman = board[space]; //remove it from the board board[space] = null; henchman.SetPlayState(PlayStateEnum.DONE); henchman.SetLocation(BoardSpaceEnum.NONE); //remove it from the order henchmenOrder.RemoveArbitrary(space); //remove the henchman visually henchman.gameObject.SetActive(false); //set up the henchman to be destroyed henchman.GetController().GetDeck().DestroyCard(henchman); //invoke its closing-act event henchman.ClosingActEvent.Invoke(); }
//should only be called if CanHenchmanFight() returns true public void HaveHenchmenFight(BoardSpaceEnum playerSpace, BoardSpaceEnum opponentSpace) { HenchmanCard playerHenchman = board[playerSpace]; HenchmanCard opponentHenchman = board[opponentSpace]; //check if any damage needs to trample over int excess = (int)playerHenchman.GetAttack() - opponentHenchman.GetHealth(); if ((excess > 0) && playerHenchman.IsOverAchiever()) { Debug.Log("ROLLING DAMAGE OVER"); uint reduction = playerHenchman.GetAttack() - (uint)excess; HaveHenchmanAttackTargetPlayer(playerSpace, opponentHenchman.GetController(), damageReduction: reduction); } //apply damage to the henchmen after applying trample damage to prevent issues arising from the //trampler dying after taking damage from the other henchman, then not being at playerSpace anymore //FIXME: find a more elegant solution, since this could cause some unintuitive interactions with // triggered effects on the other henchman, since it technically won't "die" until after // damage has trampled over playerHenchman.ApplyDamage((int)opponentHenchman.GetAttack()); opponentHenchman.ApplyDamage((int)playerHenchman.GetAttack()); playerHenchman.ActionTaken(); }