Ejemplo n.º 1
0
 public BattleMessage(Guid UserId, Card Card, ActionInfo Action, object data = null)
     : base(MessageType.BattleMessage, data)
 {
     this.UserId = UserId;
     this.Card = Card;
     this.Action = Action;
 }
Ejemplo n.º 2
0
 static Card InstanateRace(string name)
 {
     Card card = new Card();
     card.Id = Cards.Count + 1;
     card.Name = name;
     card.Type = CardType.Dungeon;
     card.OnUseMechanics.Add(new SetRaceMechanic());
     card.Class = CardClass.Race;
     return card;
 }
Ejemplo n.º 3
0
 static Card InstanateMonster(string name)
 {
     Card card = new Card();
     card.Id = Cards.Count + 1;
     card.Name = name;
     card.Type = CardType.Dungeon;
     card.OnUseMechanics.Add(new KillPlayerMechanic());
     card.Class = CardClass.Monster;
     return card;
 }
Ejemplo n.º 4
0
        public bool AddCard(Card card)
        {
            if (card == null)
                return false;

            if (GetCardById(card.Id) != null)
                return false;

            Cards.Add(card);
            return true;
        }
Ejemplo n.º 5
0
        public bool RemoveCard(Card card)
        {
            if (card == null)
                return false;

            Card playerCard = GetCardById(card.Id);
            if (playerCard == null)
                return false;

            Cards.Remove(playerCard);
            return true;
        }
Ejemplo n.º 6
0
 public string SetRace(Player player, Card card)
 {
     Race c;
     try
     {
         c = (Race)Enum.Parse(typeof(Race), card.Name);
     }
     catch
     {
         return ACTION_ERROR;
     }
     if (player.Race == c)
         return ACTION_ERROR;
     player.Race = c;
     player.Board.Cards.Add(card);
     return ACTION_DONE;
 }
Ejemplo n.º 7
0
 public string SetClass(Player player, Card card)
 {
     Class c;
     try
     {
         c = (Class)Enum.Parse(typeof(Class), card.Name);
     }
     catch
     {
         return ACTION_ERROR;
     }
     if (player.Class == c)
         return ACTION_ERROR;
     player.Class = c;
     player.Board.Cards.Add(card);
     return ACTION_DONE;
 }
Ejemplo n.º 8
0
        public string RemoveAfterUse(BoardState state, Card card)
        {
            state.Field.Cards.Remove(card);

            return ACTION_DONE;
        }
Ejemplo n.º 9
0
        bool ProcessMoveCardAction(ActionInfo info, out Card outCard)
        {
            Card card = null;
            if (info.TargetEntry == ActionEntryType.Field && info.SourceEntry == ActionEntryType.Deck)
            {
                if (info.SourceParam == 0)
                    info.Source = match.BoardState.DoorDeck;
                else
                    info.Source = match.BoardState.TreasureDeck;

                card = info.Source.GetRandomCard();

                info.Target = match.BoardState.Field;

                if (card.Class == CardClass.Monster)
                    match.BoardState.TurnStep = TurnStep.Battle;
                else
                    match.BoardState.TurnStep = TurnStep.Waiting;
            }
            if (info.TargetEntry == ActionEntryType.Hand && info.SourceEntry == ActionEntryType.Deck)
            {
                if (info.SourceParam == 0)
                    info.Source = match.BoardState.DoorDeck;
                else
                    info.Source = match.BoardState.TreasureDeck;

                card = info.Source.GetRandomCard();

                info.Target = info.Invoker.Hand;
                match.BoardState.TurnStep = TurnStep.Ending;
            }
            if (info.SourceEntry == ActionEntryType.Hand && info.TargetEntry == ActionEntryType.Field)
            {
                info.Target = match.BoardState.Field;
                info.Source = info.Invoker.Hand;
                card = info.Source.GetCardById(info.CardId);
                foreach (var m in card.OnUseMechanics)
                    m.Execute(match.BoardState, info.Invoker, card);
            }
            if (info.SourceEntry == ActionEntryType.Hand && info.TargetEntry == ActionEntryType.Slot)
            {
                info.Target = info.Invoker.Board;
                info.Source = info.Invoker.Hand;

                card = info.Source.GetCardById(info.CardId);

                if (!info.Invoker.TryEquip(card))
                {
                    outCard = null;
                    return false;
                }

                if (card.Class == CardClass.Race || card.Class == CardClass.Class)
                    card.OnUseMechanics.ElementAt(0).Execute(match.BoardState, info.Invoker, card);
            }

            if (card != null)
            {
                info.Source.RemoveCard(card);
                info.Target.AddCard(card);

                if (info.TargetEntry == ActionEntryType.Field)
                    foreach (var m in card.OnUseMechanics)
                        m.Execute(match.BoardState, info.Invoker, card);
            }

            outCard = card;
            return true;
        }
Ejemplo n.º 10
0
        internal bool TryEquip(Card card)
        {
            if (card == null)
                return false;

            if (card.Class == CardClass.Class || card.Class == CardClass.Race)
            {
                int cardCount = Board.Cards.Count(c => c.Class == card.Class) + 1;
                int maxCards = 1;

                var combo = CardClass.ClassCombo;
                if (card.Class == CardClass.Race)
                    combo = CardClass.RaceCombo;

                if (Board.Cards.Count(c => c.Class == combo) > 0)
                    maxCards = 2;

                if (cardCount > maxCards)
                    return false;
            }
            else if (card.Class == CardClass.ClassCombo || card.Class == CardClass.RaceCombo)
            {
                if (Board.Cards.Count(c => c.Class == card.Class) > 0)
                    return false;
            }
            return true;
        }
Ejemplo n.º 11
0
 static Card InstanateSpell(string name)
 {
     Card card = new Card();
     card.Id = Cards.Count + 1;
     card.Name = name;
     card.Type = CardType.Treasure;
     card.OnUseMechanics.Add(new EvadeMonstersMechanic());
     card.AfterUseMechanics.Add(new RemoveAfterUseMechanic());
     card.Class = CardClass.Spell;
     return card;
 }