コード例 #1
0
ファイル: CardRules.cs プロジェクト: YangStillWater/HuaXueSha
 public void Defend(int cardIndex)
 {
     defenderCard = currentTarget.Cards[cardIndex];
     bool canDefend=false;
     if (_gctx.TurnCtx.IsFor硅藻土 && _gctx.TurnCtx.needCardType == null)
     {
         if (defenderCard is Acid || defenderCard is Base)
         {
             canDefend = true;
             _gctx.TurnCtx.needCardType = defenderCard.GetType();
         }
     }
     else if (_gctx.TurnCtx.needCardType != null)
     {
         canDefend = defenderCard.GetType() == _gctx.TurnCtx.needCardType;
     }
     else
     {
         canDefend = CanDefend(offenderCard, defenderCard);
     }
     if (canDefend)
     {
         currentTarget.Cards.Remove(defenderCard);
         _gctx.droppedCards.Add(defenderCard);
         _gctx.autoEvent.Set();
     }
     else
     {
         OnWrongCard(this, new EventArgs());
     }
 }
コード例 #2
0
        public static Card generateCard(int min, int max)
        {
            var c = new Card();
            c.Name = "Creature_" + index.ToString();
            c.Attack = rand.Next(min, max);
            c.Defence = rand.Next(min, max);

            index++;

            return c;
        }
コード例 #3
0
 void DisplayCards(Card[] cards, string title)
 {
     Console.WriteLine(title);
     for (var i = 0; i < cards.Length; i++)
     {
         var c = cards[i];
         var cardDisplay = string.Format("[{0}] {1}", (i + 1), c);
         Console.WriteLine(cardDisplay);
     }
     Console.WriteLine();
 }
コード例 #4
0
        public Defence Defend(State state, Card[] attackingCards)
        {
            var d = new Defence();
            if (_hand.Cards.Count < 3)
            {
                return d;
            }
            if (attackingCards.Count<Card>() > 1)
            {
                d.Response[attackingCards[0]] = new Card[] { _hand.Cards[0] };
                d.Response[attackingCards[1]] = new Card[] { _hand.Cards[1] };
            }

            return d;
        }
コード例 #5
0
ファイル: CardRules.cs プロジェクト: YangStillWater/HuaXueSha
 public bool CanDefend(Card offender, Card defender)
 {
     if (offender is Acid)
     {
         return defender is Base;
     }
     else if (offender is Base)
     {
         return defender is Acid;
     }
     else if (offender is KitCard)
     {
         return defender is EDTA;
     }
     return false;
 }
コード例 #6
0
        public Defence Defend(State state, Card[] attackingCards)
        {
            // Show attackers
            Console.WriteLine("### YOU'RE UNDER ATTACK!!! ###");
            Console.WriteLine();
            DisplayCards(attackingCards, "Attackers:");

            // Show hand
            DisplayCards(_hand.Cards.ToArray(), "Hand:");

            // Loop over attackers and request defenders for each attacker
            var defence = new Defence();
            foreach (Card c in attackingCards)
            {
                Console.WriteLine("Input the Numbers of Defending Cards for [{0}] separated by spaces", c);
                var defenders = SelectCards(_hand.Cards.ToArray());
                defence.Response[c] = defenders;
            }

            // Return defenders
            return defence;
        }
コード例 #7
0
ファイル: CardRules.cs プロジェクト: YangStillWater/HuaXueSha
 public void Respond()
 {
     offenderCard = _gctx.cardDress.VirtualCard;
     foreach (var t in _gctx.targets)
     {
         currentTarget = t;
         RespondOne();
     }
 }
コード例 #8
0
ファイル: CardDress.cs プロジェクト: YangStillWater/HuaXueSha
 public CardDress(List<Card> actualCards, Card virtualCard)
 {
     ActualCards = actualCards;
     VirtualCard = virtualCard;
 }
コード例 #9
0
ファイル: CardDress.cs プロジェクト: YangStillWater/HuaXueSha
 public CardDress(Card dealedCard)
 {
     ActualCards.Add(dealedCard);
     VirtualCard = dealedCard;
 }
コード例 #10
0
 private void AddCards(Card card, int count)
 {
     for (int i = 0; i < count; i++)
     {
         availableCards.Add(card);
     }
 }
コード例 #11
0
ファイル: Game.cs プロジェクト: Bloblblobl/Spell_Slingers
        private void PopulateCardsDatabase()
        {
            var texture = Content.Load<Texture2D>("arrowed");
            var card = new Card { Attack = 3, Defence = 4, Cost = 5, Name = "arrowed" };
            _cardsDB.Add(card, texture);

            texture = Content.Load<Texture2D>("bleeding-heart");
            card = new Card { Attack = 4, Defence = 5, Cost = 3, Name = "heart" };
            _cardsDB.Add(card, texture);

            texture = Content.Load<Texture2D>("boiling-bubbles");
            card = new Card { Attack = 5, Defence = 3, Cost = 4, Name = "bubbles" };
            _cardsDB.Add(card, texture);
        }
コード例 #12
0
        private Card[] SelectCards(Card[] cards)
        {
            var input = Console.ReadLine();
            var selectNumbers = input.Split(' ');
            var selected = new Card[selectNumbers.Length];

            if (selectNumbers[0] == "")
            {
                return null;
            }

            for (var i = 0; i < selectNumbers.Length; i++)
            {
                var index = int.Parse(selectNumbers[i]) - 1;
                selected[i] = cards[index];
            }
            return selected;
        }
コード例 #13
0
 public Texture2D LookupTexture(Card card)
 {
     return _cardsDB[card];
 }
コード例 #14
0
 public void Add(Card card, Texture2D texture)
 {
     _cardsDB.Add(card, texture);
 }