public void OnConfirmationAttack(int attackID, int defenseID, int bonusID, string enemyName) { var message = new PlayerTurnFinishMessage(); message.attackCardPosition = attackID; message.defenseCardPosition = defenseID; message.bonusCardPosition = bonusID; message.enemyName = enemyName; message.attackerName = nameInput.text; //Had to move it to GameClient as UnityEvent can only support sending 4 arguments total message.attackingAce = (playingField.targetCard == battleField.enemyAce.transform.GetChild(0).GetComponent <CardDisplay>()); client.Send(AceMsgTypes.BattlePhase_PlayerTurnFinish, message); }
private void ProcessTurn(PlayerTurnFinishMessage turn) { var attacker = lobbyManager.GetPlayerByName(turn.attackerName); var defender = lobbyManager.GetPlayerByName(turn.enemyName); var message = new TurnResultMessage(); int cardAttacking = GetCardAtPosition(attacker, turn.attackCardPosition, true); message.attackerCard = cardAttacking; message.attackerName = attacker.playerName; message.defenderName = defender.playerName; if (turn.attackingAce) { message.attackingAce = turn.attackingAce; defender.GameOver(); if (gameManager.PlayersAlive() == 1) { message.gameEnder = true; observer.ShowEndScreen(attacker.playerName); } SendTurnResultsToClients(attacker, defender, message); return; } message.attackCardPosition = turn.attackCardPosition; message.defenseCardPosition = turn.defenseCardPosition; message.bonusCardPosition = turn.bonusCardPosition; //atm hard-coded to be -7, cause it looks like a J if (turn.attackCardPosition == -7) { defender.discardPile.Add(defender.bonusField[turn.bonusCardPosition, 0]); defender.bonusField[turn.bonusCardPosition, 0] = 0; defender.bonusField[turn.bonusCardPosition, 1] = 0; attacker.discardPile.Add(attacker.GetAssassin()); attacker.RemoveAssassin(); } /*else if (turn.defenseCardPosition == -1 && turn.bonusCardPosition == -1) { * if (!defender.HasAnyDefenseCards()) { * defender.GameOver(); * } else { * gameManager.LogInfo("HEY HEY, NO CHEATERS AROUND HERE, OK?"); * //attacker.GameOver(); * } * }*/ else { //Regular attack on defense card int cardDefending = GetCardAtPosition(defender, turn.defenseCardPosition, false); message.defenderCard = cardDefending; message.attackerWon = (GetCardStrength(attacker, turn.attackCardPosition, true) > GetCardStrength(defender, turn.defenseCardPosition, false)); //gameManager.LogInfo(GetCardStrength(attacker, turn.attackCardPosition, true) + " == " + GetCardStrength(defender, turn.defenseCardPosition, false)); message.tie = (GetCardStrength(attacker, turn.attackCardPosition, true) == GetCardStrength(defender, turn.defenseCardPosition, false)); if (AceRules.Two_Kills_All) { if (cardAttacking == 2) { if (AceRules.Two_Suicide_Effect) { message.tie = true; } message.attackerWon = true; } else if (cardDefending == 2) { if (AceRules.Two_Suicide_Effect) { message.tie = true; } message.attackerWon = false; } } else { if (cardAttacking == 2 && cardDefending == 10) { message.attackerWon = true; if (AceRules.Two_Suicide_Effect) { message.tie = true; } } else if (cardDefending == 2 && cardAttacking == 10) { message.attackerWon = false; if (AceRules.Two_Suicide_Effect) { message.tie = true; } } } if (message.tie) { attacker.discardPile.Add(attacker.attackField[turn.attackCardPosition]); attacker.attackField[turn.attackCardPosition] = 0; defender.discardPile.Add(defender.defenseField[turn.defenseCardPosition]); defender.defenseField[turn.defenseCardPosition] = 0; } else if (defender.hasAce) { if (message.attackerWon) { defender.discardPile.Add(defender.defenseField[turn.defenseCardPosition]); defender.defenseField[turn.defenseCardPosition] = 0; } else { attacker.discardPile.Add(attacker.attackField[turn.attackCardPosition]); attacker.attackField[turn.attackCardPosition] = 0; } } } SendTurnResultsToClients(attacker, defender, message); }