예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="playerIndex"></param>
        /// <param name="cardRID"></param>
        /// <param name="targetPosition"></param>
        /// <param name="targetCardRID"></param>
        public void use(int playerIndex, int cardRID, int targetPosition, int[] targetCardsRID)
        {
            Player player = engine.getPlayerAt(playerIndex);

            if (engine.getProp <Player>("currentPlayer") != player)
            {
                EventWitness witness = new UseWitness();
                witness.setVar("error", true);
                witness.setVar("code", ErrorCode.use_NotYourTurn);
                sendWitness(witness);
                return;
            }
            Card card = player["Hand"].First(c => { return(c.id == cardRID); });

            if (player.getProp <int>("gem") < card.define.getProp <int>("cost"))
            {
                EventWitness witness = new UseWitness();
                witness.setVar("error", true);
                witness.setVar("code", ErrorCode.use_NoEnoughGem);
                sendWitness(witness);
                return;
            }
            Card[] targetCards = targetCardsRID.Select(targetCardRID => { return(targetCardRID > -1 ? engine.getCard(targetCardRID) : null); }).ToArray();
            engine.use(player, card, targetPosition, targetCards);
        }
예제 #2
0
        public override EventWitness getWitness(TouhouCardEngine.CardEngine engine, Player player)
        {
            EventWitness witness = new UseWitness();

            witness.setVar("playerIndex", engine.getPlayerIndex(this.player));
            witness.setVar("cardRID", card.id);
            witness.setVar("cardDID", card.define.id);
            witness.setVar("targetPosition", targetPosition);
            witness.setVar("targetCardsRID", targetCards.Select(targetCard => { return(targetCard != null ? targetCard.id : -1); }).ToArray());
            return(witness);
        }