private void ProcessAttack(CardSlotDTO attacker, CardSlotDTO target, GameDTO game, int targetIndex, int attackerIndex) { target.card = CalculateRemainingHp(attacker.card, target.card); attacker.card = CalculateRemainingHp(target.card, attacker.card); if (target.card.health <= 0) { game.connectedPlayers[1].boardrow.cardSlotList[targetIndex].card = null; ObtainDeathessence(game); } else { game.connectedPlayers[1].boardrow.cardSlotList[targetIndex] = target; } if (attacker.card.health <= 0) { game.connectedPlayers[0].boardrow.cardSlotList[attackerIndex].card = null; } else { game.connectedPlayers[0].boardrow.cardSlotList[attackerIndex] = attacker; attacker.card.isSleeping = true; } }
public GameDTO AttackCard() { GameDTO game = new GameDTO(); // get game from parameter int attacker = 1; // get attacker from parameter int target = 1; // get tartget from parameter if (!CheckForTurn(game)) { return(game); } CardSlotDTO attackersCardslot = game.connectedPlayers[0].boardrow.cardSlotList[attacker]; CardSlotDTO targetCardslot = game.connectedPlayers[1].boardrow.cardSlotList[target]; if (!attackersCardslot.card.isSleeping) { if (OpponentHasTaunt(game)) { if (TargetIsTaunt(game, target)) { ProcessAttack(attackersCardslot, targetCardslot, game, target, attacker); } else { //send error function "You must target the card with taunt.") return(game); } } else { ProcessAttack(attackersCardslot, targetCardslot, game, target, attacker); } return(game); } //send error function "This card is still asleep. Give it a turn to get ready." return(game); }