public override EventWitness getWitness(TouhouCardEngine.CardEngine engine, Player player)
        {
            EventWitness witness = new AttackWitness();

            witness.setVar("playerIndex", engine.getPlayerIndex(this.player));
            witness.setVar("cardRID", card.id);
            witness.setVar("targetCardRID", targetCard.id);
            return(witness);
        }
Пример #2
0
        public void attack(int playerIndex, int cardRID, int targetCardRID)
        {
            Player player = engine.getPlayerAt(playerIndex);

            if (engine.getProp <Player>("currentPlayer") != player)
            {
                EventWitness witness = new AttackWitness();
                witness.setVar("error", true);
                witness.setVar("code", ErrorCode.attack_NotYourTurn);
                sendWitness(witness);
                return;
            }
            Card card = engine.getCard(cardRID);

            if (!card.getProp <bool>("isReady"))
            {
                EventWitness witness = new AttackWitness();
                witness.setVar("error", true);
                witness.setVar("code", ErrorCode.attack_waitOneTurn);
                sendWitness(witness);
                return;
            }
            if (card.getProp <int>("attackTimes") > 0)
            {
                EventWitness witness = new AttackWitness();
                witness.setVar("error", true);
                witness.setVar("code", ErrorCode.attack_AlreadyAttacked);
                sendWitness(witness);
                return;
            }
            Card targetCard = engine.getCard(targetCardRID);

            if (targetCard.pile.owner["Field"].Any(c => { return(c.getProp <bool>("taunt")); }) && targetCard.getProp <bool>("taunt") == false)
            {
                EventWitness witness = new AttackWitness();
                witness.setVar("error", true);
                witness.setVar("code", ErrorCode.attack_AttackTauntFirst);
                sendWitness(witness);
                return;
            }
            engine.attack(player, card, targetCard);
        }