Ejemplo n.º 1
0
        public override void Visit(PlayASpellFromHandAction action)
        {
            GameManager.PlayersAliveBeforeAction = GameManager.UserDict.Keys.ToList().Where(c => GameManager.GetPlayer(c).IsAlive).ToList();
            OnCardPlayedVisitor visitor = new OnCardPlayedVisitor(GameManager);
            Player    p     = GameManager.GetPlayer(action.Caller);
            SpellCard spell = p.PlayASpellFromHand(action.PlayedCardId);

            visitor.Targets = action.Targets;
            p.PlayedSpell.Add(spell);
            spell.Visit(visitor, p.Character);
            foreach (CharacterEnum target in GameManager.UserDict.Keys.ToList())
            {
                GameManager.UserDict[target].Write(new ResponseMessage(new PlayASpellResponse(action.Caller, spell, action.Targets)));
            }
            foreach (KeyValuePair <CharacterEnum, Response> kvp in visitor.SuccessiveResponse)
            {
                GameManager.UserDict[kvp.Key].Write(new ResponseMessage(kvp.Value));
            }
            // visitor must take care of players which he kills
            foreach (CharacterEnum ch in GameManager.PlayersAliveBeforeAction)
            {
                if (!GameManager.GetPlayer(ch).IsAlive)
                {
                    GameManager.KillPlayer(p.Character, ch);
                }
            }
        }
Ejemplo n.º 2
0
        public override void Visit(PlayACreatureFromHandAction action)
        {
            OnCardPlayedVisitor visitor = new OnCardPlayedVisitor(GameManager);
            Player       p        = GameManager.GetPlayer(action.Caller);
            CreatureCard creature = p.PlayACreatureFromHand(action.PlayedCardId, action.Place);

            creature.Visit(visitor, p.Character);
            foreach (CharacterEnum target in GameManager.UserDict.Keys.ToList())
            {
                GameManager.UserDict[target].Write(new ResponseMessage(new PlayACreatureResponse(action.Caller, creature, action.Place, action.TablePos)));
            }
        }