Exemple #1
0
 public override void Process(Player source, List<Player> dests, ICard card, ReadOnlyCard readonlyCard)
 {
     DeckType wuguDeck = new DeckType("WuGu");
     DeckType wuguFakeDeck = new DeckType("WuGuFake");
     CardsMovement move = new CardsMovement();
     move.Cards = new List<Card>();
     for (int i = 0; i < dests.Count; i++)
     {
         Game.CurrentGame.SyncImmutableCardAll(Game.CurrentGame.PeekCard(0));
         Card c = Game.CurrentGame.DrawCard();
         move.Cards.Add(c);
     }
     move.To = new DeckPlace(null, wuguDeck);
     Game.CurrentGame.MoveCards(move);
     fakeMapping = new Dictionary<Card, Card>();
     Game.CurrentGame.Decks[null, wuguFakeDeck].Clear();
     foreach (var c in Game.CurrentGame.Decks[null, wuguDeck])
     {
         var faked = new Card(c);
         faked.Place = new DeckPlace(null, wuguFakeDeck);
         Game.CurrentGame.Decks[null, wuguFakeDeck].Add(faked);
         fakeMapping.Add(faked, c);
     }
     Game.CurrentGame.NotificationProxy.NotifyWuGuStart(new DeckPlace(null, wuguFakeDeck));
     base.Process(source, dests, card, readonlyCard);
     Game.CurrentGame.NotificationProxy.NotifyWuGuEnd();
     Game.CurrentGame.Decks[null, wuguFakeDeck].Clear();
     if (Game.CurrentGame.Decks[null, wuguDeck].Count > 0)
     {
         move = new CardsMovement();
         move.Cards = new List<Card>(Game.CurrentGame.Decks[null, wuguDeck]);
         move.To = new DeckPlace(null, DeckType.Discard);
         Game.CurrentGame.MoveCards(move);
     }
 }
Exemple #2
0
        protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard, GameEventArgs inResponseTo)
        {
            IUiProxy ui = Game.CurrentGame.UiProxies[source];
            if (source.IsDead) return;
            List<DeckPlace> places = new List<DeckPlace>();
            places.Add(new DeckPlace(dest, DeckType.Hand));
            places.Add(new DeckPlace(dest, DeckType.Equipment));
            places.Add(new DeckPlace(dest, DeckType.DelayedTools));
            List<string> resultDeckPlace = new List<string>();
            resultDeckPlace.Add(ResultDeckName);
            List<int> resultDeckMax = new List<int>();
            resultDeckMax.Add(1);
            List<List<Card>> answer;
            if (!ui.AskForCardChoice(new CardChoicePrompt(ChoicePrompt), places, resultDeckPlace, resultDeckMax, new RequireOneCardChoiceVerifier(true), out answer))
            {
                Trace.TraceInformation("Player {0} Invalid answer", source.Id);
                answer = new List<List<Card>>();
                answer.Add(Game.CurrentGame.PickDefaultCardsFrom(places));
            }
            Card theCard = answer[0][0];

            if (ShunChaiDest(source, dest).DeckType == DeckType.Discard)
            {
                Game.CurrentGame.HandleCardDiscard(dest, new List<Card>() { theCard });
            }
            else
            {
                Game.CurrentGame.HandleCardTransferToHand(dest, source, new List<Card>() { theCard });
            }
        }
Exemple #3
0
 protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard)
 {
     IUiProxy ui = Game.CurrentGame.UiProxies[dest];
     HuoGongCardChoiceVerifier v1 = new HuoGongCardChoiceVerifier();
     ISkill s;
     List<Player> p;
     List<Card> cards;
     if (dest.IsDead) return;
     if (!ui.AskForCardUsage(new CardUsagePrompt("HuoGong", source), v1, out s, out cards, out p))
     {
         Trace.TraceInformation("Player {0} Invalid answer", dest);
         cards = new List<Card>();
         if (Game.CurrentGame.Decks[dest, DeckType.Hand].Count == 0)
         {
             Trace.TraceError("HuoGong Cannot Show Card! This should NOT have happened!");
             return;
         }
         cards.Add(Game.CurrentGame.Decks[dest, DeckType.Hand][0]);
     }
     Trace.TraceInformation("Player {0} HuoGong showed {1}, ", dest.Id, cards[0].Suit);
     if (source.IsDead) return;
     ui = Game.CurrentGame.UiProxies[source];
     HuoGongCardMatchVerifier v2 = new HuoGongCardMatchVerifier(cards[0].Suit);
     v2.Owner = source;
     if (ui.AskForCardUsage(new CardUsagePrompt("HuoGong2", dest, cards[0].Suit), v2, out s, out cards, out p))
     {
         Game.CurrentGame.HandleCardDiscard(source, cards);
         Game.CurrentGame.DoDamage(source, dest, 1, DamageElement.Fire, card, readonlyCard);
     }
     else
     {
         Trace.TraceInformation("HuoGong aborted, failed to provide card");
     }
 }
Exemple #4
0
 public override void Activate(Player p, Card c)
 {
     while (true)
     {
         GameEventArgs args = new GameEventArgs();
         args.Source = null;
         args.Targets = new List<Player>() { p };
         args.Card = c;
         args.ReadonlyCard = new ReadOnlyCard(c);
         try
         {
             Game.CurrentGame.Emit(GameEvent.CardUsageBeforeEffected, args);
         }
         catch (TriggerResultException e)
         {
             Trace.Assert(e.Status == TriggerResult.End);
             break;
         }
         ReadOnlyCard result = Game.CurrentGame.Judge(p, null, c, (judgeResultCard) => { return judgeResultCard.Suit == SuitType.Spade && judgeResultCard.Rank >= 2 && judgeResultCard.Rank <= 9; });
         if (result.Suit == SuitType.Spade && result.Rank >= 2 && result.Rank <= 9)
         {
             var roc = new ReadOnlyCard(c);
             CardsMovement move = new CardsMovement();
             move.Cards = new List<Card>();
             move.Cards.Add(c);
             move.To = new DeckPlace(null, DeckType.Discard);
             Game.CurrentGame.MoveCards(move);
             Game.CurrentGame.DoDamage(null, p, 3, DamageElement.Lightning, c, roc);
             return;
         }
         break;
     }
     RecursiveShanDianDriver(p, p, c);
 }
Exemple #5
0
 public override void Process(Player source, List<Player> dests, ICard card, ReadOnlyCard cardr)
 {
     Trace.Assert(dests == null || dests.Count == 0);
     Trace.Assert(card is Card);
     Card c = (Card)card;
     Install(source, c);
 }
Exemple #6
0
 protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard, GameEventArgs inResponseTo)
 {
     DeckType wuguDeck = new DeckType("WuGu");
     DeckType wuguFakeDeck = new DeckType("WuGuFake");
     List<List<Card>> answer;
     if (!Game.CurrentGame.UiProxies[dest].AskForCardChoice(new CardChoicePrompt("WuGuFengDeng"),
             new List<DeckPlace>() { new DeckPlace(null, wuguFakeDeck) },
             new List<string>() { "WuGu" },
             new List<int>() { 1 },
             new WuGuCardChoiceVerifier(FakeMapping),
             out answer,
             new AdditionalCardChoiceOptions() { IsWuGu = true }))
     {
         Trace.TraceInformation("Invalid answer for WuGu, choosing for you");
         answer = new List<List<Card>>();
         answer.Add(new List<Card>());
         answer[0].Add(Game.CurrentGame.Decks[null, wuguDeck][0]);
     }
     else
     {
         if (!FakeMapping.ContainsKey(answer[0][0]) || FakeMapping[answer[0][0]] == null)
         {
             answer[0] = new List<Card>() { Game.CurrentGame.Decks[null, wuguDeck][0] };
         }
         var theCard = answer[0][0];
         answer[0] = new List<Card>() { FakeMapping[theCard] };
         FakeMapping[theCard] = null;
     }
     Game.CurrentGame.HandleCardTransferToHand(null, dest, answer[0], new MovementHelper() { IsWuGu = true });
 }
Exemple #7
0
 protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard)
 {
     if (dest.Health >= dest.MaxHealth)
     {
         return;
     }
     Game.CurrentGame.RecoverHealth(source, dest, 1);
 }
Exemple #8
0
 protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard, GameEventArgs inResponseTo)
 {
     if (readonlyCard[EatOneGetAnotherFreeCoupon] == 1)
     {
         Game.CurrentGame.RecoverHealth(source, dest, 2);
     }
     else
     {
         Game.CurrentGame.RecoverHealth(source, dest, 1);
     }
 }
Exemple #9
0
 protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard, GameEventArgs inResponseTo)
 {
     if (Game.CurrentGame.DyingPlayers.Count > 0)
     {
         Game.CurrentGame.RecoverHealth(source, dest, 1);
     }
     else
     {
         dest[JiuUsed] = 1;
         dest[Drank] = 1;
     }
 }
Exemple #10
0
 protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard)
 {
     if (Game.CurrentGame.IsDying.Count > 0)
     {
         Game.CurrentGame.RecoverHealth(source, dest, 1);
     }
     else
     {
         source[JiuUsed] = 1;
         source[Drank] = 1;
     }
 }
Exemple #11
0
 protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard, GameEventArgs inResponseTo)
 {
     SingleCardUsageVerifier v1 = responseCardVerifier;
     List<Player> sourceList = new List<Player>();
     sourceList.Add(source);
     GameEventArgs args = new GameEventArgs();
     args.Source = dest;
     args.Targets = sourceList;
     args.Card = new CompositeCard();
     args.Card.Type = RequiredCard();
     args.ReadonlyCard = readonlyCard;
     try
     {
         Game.CurrentGame.Emit(GameEvent.PlayerRequireCard, args);
     }
     catch (TriggerResultException e)
     {
         if (e.Status == TriggerResult.Success)
         {
             Game.CurrentGame.HandleCardPlay(dest, args.Skill, args.Cards, sourceList);
             return;
         }
     }
     while (true)
     {
         IUiProxy ui = Game.CurrentGame.UiProxies[dest];
         ISkill skill;
         List<Player> p;
         List<Card> cards;
         if (!ui.AskForCardUsage(new CardUsagePrompt(UsagePromptString, source),
                                               v1, out skill, out cards, out p))
         {
             Trace.TraceInformation("Player {0} Invalid answer", dest);
             Game.CurrentGame.DoDamage(source.IsDead ? null : source, dest, 1, DamageElement.None, card, readonlyCard);
         }
         else
         {
             if (!Game.CurrentGame.HandleCardPlay(dest, skill, cards, sourceList))
             {
                 continue;
             }
             Trace.TraceInformation("Player {0} Responded. ", dest.Id);
         }
         break;
     }
 }
Exemple #12
0
 void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     ISkill skill;
     List<Card> cards;
     List<Player> players;
     DamageEventArgs args = eventArgs as DamageEventArgs;
     if (Game.CurrentGame.UiProxies[Owner].AskForCardUsage(new CardUsagePrompt("TianXiang"), new TianXiangVerifier(),
         out skill, out cards, out players))
     {
         NotifySkillUse(players);
         Game.CurrentGame.HandleCardDiscard(Owner, cards);
         ReadOnlyCard ncard = new ReadOnlyCard(args.ReadonlyCard);
         ncard[TianXiangDamage] = 1;
         players[0][TianXiangTarget]++;
         Game.CurrentGame.DoDamage(args.Source, players[0], Owner, args.Magnitude, args.Element, args.Card, ncard);
         throw new TriggerResultException(TriggerResult.End);
     }
 }
        protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard, GameEventArgs inResponseTo)
        {
            if (source.IsDead) return;
            if (dest.HandCards().Count + dest.Equipments().Count == 0) return; // ShunChai -> WuXie(from target) -> WuXie(soemone else) -> target has no card
            List<string> resultDeckPlace = new List<string>();
            resultDeckPlace.Add("GuoHeChaiQiao");
            List<int> resultDeckMax = new List<int>();
            resultDeckMax.Add(1);
            List<List<Card>> answer;
            bool doHandCard = true;
            if (dest.Equipments().Count != 0)
            {
                int result = 0;
                source.AskForMultipleChoice(new MultipleChoicePrompt("GuoHeChaiQiao2"), new List<OptionPrompt>() { new OptionPrompt("ShouPai"), new OptionPrompt("ZhuangBeiPai") }, out result);
                if (result == 1) doHandCard = false;
            }
            if (doHandCard)
            {
                Game.CurrentGame.SyncImmutableCards(source, Game.CurrentGame.Decks[dest, DeckType.Hand]);
                Game.CurrentGame.HandCardVisibility[source].Add(dest);
                var places = new List<DeckPlace>() { new DeckPlace(dest, DeckType.Hand) };
                if (!source.AskForCardChoice(new CardChoicePrompt("GuoHeChaiQiao2"), places, resultDeckPlace, resultDeckMax, new RequireOneCardChoiceVerifier(true), out answer))
                {
                    Trace.TraceInformation("Player {0} Invalid answer", source.Id);
                    answer = new List<List<Card>>();
                    answer.Add(Game.CurrentGame.PickDefaultCardsFrom(places));
                }
                foreach (Card c in dest.HandCards()) Game.CurrentGame.HideHandCard(c);
                Game.CurrentGame.HandCardVisibility[source].Remove(dest);
                Game.CurrentGame.HandleCardDiscard(dest, answer[0]);
            }
            else
            {
                var places = new List<DeckPlace>() { new DeckPlace(dest, DeckType.Equipment) };
                if (!source.AskForCardChoice(new CardChoicePrompt("GuoHeChaiQiao2"), places, resultDeckPlace, resultDeckMax, new RequireOneCardChoiceVerifier(true), out answer))
                {
                    Trace.TraceInformation("Player {0} Invalid answer", source.Id);
                    answer = new List<List<Card>>();
                    answer.Add(Game.CurrentGame.PickDefaultCardsFrom(places));
                }
                Game.CurrentGame.HandleCardDiscard(dest, answer[0]);

            }
        }
Exemple #14
0
        protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard)
        {
            DeckType wuguDeck = new DeckType("WuGu");
            List<List<Card>> answer;
            if (!Game.CurrentGame.UiProxies[dest].AskForCardChoice(new CardChoicePrompt("WuGuFengDeng"),
                    new List<DeckPlace>() { new DeckPlace(null, wuguDeck) },
                    new List<string>() { "WuGu" },
                    new List<int>() { 1 },
                    new RequireOneCardChoiceVerifier(),
                    out answer))
            {
                Trace.TraceInformation("Invalid answer for WuGu, choosing for you");
                answer = new List<List<Card>>();
                answer.Add(new List<Card>());
                answer[0].Add(Game.CurrentGame.Decks[null, wuguDeck][0]);
            }

            Game.CurrentGame.HandleCardTransferToHand(null, dest, answer[0]);
        }
Exemple #15
0
 public override void Process(Player source, List<Player> dests, ICard card, ReadOnlyCard readonlyCard)
 {
     DeckType wuguDeck = new DeckType("WuGu");
     CardsMovement move = new CardsMovement();
     move.Cards = new List<Card>();
     for (int i = 0; i < dests.Count; i++)
     {
         Game.CurrentGame.SyncImmutableCardAll(Game.CurrentGame.PeekCard(0));
         Card c = Game.CurrentGame.DrawCard();
         move.Cards.Add(c);
     }
     move.To = new DeckPlace(null, wuguDeck);
     Game.CurrentGame.MoveCards(move);
     base.Process(source, dests, card, readonlyCard);
     if (Game.CurrentGame.Decks[null, wuguDeck].Count > 0)
     {
         move = new CardsMovement();
         move.Cards = new List<Card>(Game.CurrentGame.Decks[null, wuguDeck]);
         move.To = new DeckPlace(null, DeckType.Discard);
         Game.CurrentGame.MoveCards(move);
     }
 }
Exemple #16
0
        protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard)
        {
            IUiProxy ui = Game.CurrentGame.UiProxies[source];
            if (source.IsDead) return;
            List<DeckPlace> places = new List<DeckPlace>();
            places.Add(new DeckPlace(dest, DeckType.Hand));
            places.Add(new DeckPlace(dest, DeckType.Equipment));
            places.Add(new DeckPlace(dest, DeckType.DelayedTools));
            List<string> resultDeckPlace = new List<string>();
            resultDeckPlace.Add(ResultDeckName);
            List<int> resultDeckMax = new List<int>();
            resultDeckMax.Add(1);
            List<List<Card>> answer;
            int windowId = 0;
            if (!ui.AskForCardChoice(new CardChoicePrompt(ChoicePrompt), places, resultDeckPlace, resultDeckMax, new RequireOneCardChoiceVerifier(), out answer, new List<bool>() { false }, ref windowId))
            {
                Trace.TraceInformation("Player {0} Invalid answer", source.Id);
                answer = new List<List<Card>>();
                answer.Add(new List<Card>());
                var collection = Game.CurrentGame.Decks[dest, DeckType.Hand].Concat
                                 (Game.CurrentGame.Decks[dest, DeckType.DelayedTools].Concat
                                 (Game.CurrentGame.Decks[dest, DeckType.Equipment]));
                answer[0].Add(collection.First());
            }
            Card theCard = answer[0][0];
            Game.CurrentGame.SyncCardAll(ref theCard);
            Trace.Assert(answer.Count == 1 && answer[0].Count == 1);

            if (ShunChaiDest(source, dest).DeckType == DeckType.Discard)
            {
                Game.CurrentGame.HandleCardDiscard(dest, new List<Card>() { theCard });
            }
            else
            {
                Game.CurrentGame.HandleCardTransferToHand(dest, source, new List<Card>() { theCard });
            }
        }
 protected override void Process(Players.Player source, Players.Player dest, ICard card, ReadOnlyCard cardr, GameEventArgs inResponseTo)
 {
     throw new NotImplementedException();
 }
Exemple #18
0
 public override void Process(Player source, List<Player> dests, ICard card, ReadOnlyCard readonlyCard)
 {
     Trace.Assert(dests.Count == 1);
     AttachTo(source, dests[0], card);
 }
Exemple #19
0
 protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard)
 {
     throw new NotImplementedException();
 }
Exemple #20
0
 public static bool ArmorIsValid(Player player, Player source, ReadOnlyCard card)
 {
     return((source == null || player[PlayerIgnoreArmor[source]] == 0) &&
            player[UnconditionalIgnoreArmor] == 0 &&
            (card == null || (card[Armor.IgnoreAllArmor] == 0 && card[IgnorePlayerArmor[player]] == 0)));
 }
Exemple #21
0
 protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard, GameEventArgs eventArgs)
 {
     if (eventArgs != null)
     {
         eventArgs.ReadonlyCard[ShaCancelling.ShaCancellationCount]--;
     }
 }
 protected abstract void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard, GameEventArgs inResponseTo);
Exemple #23
0
            public override void Run(GameEvent gameEvent, GameEventArgs eventArgs)
            {
                List<Card> computeBackup;
                ICard c;
                if (eventArgs.Skill != null)
                {
                    CompositeCard card;
                    CardTransformSkill s = (CardTransformSkill)eventArgs.Skill;
                    if (!s.Transform(eventArgs.Cards, null, out card, eventArgs.Targets))
                    {
                        throw new TriggerResultException(TriggerResult.Retry);
                    }
                    c = card;
                }
                else
                {
                    Trace.Assert(eventArgs.Cards.Count == 1);
                    c = eventArgs.Cards[0];
                }

                // if it's delayed tool or equipment, we can't move it to compute area. call handlers directly
                if (CardCategoryManager.IsCardCategory(c.Type.Category, CardCategory.DelayedTool)
                    || CardCategoryManager.IsCardCategory(c.Type.Category, CardCategory.Equipment))
                {
                    c.Type.Process(eventArgs.Source, eventArgs.Targets, c, null);
                    return;
                }
                var rdonlyCard = new ReadOnlyCard(c);
                computeBackup = new List<Card>(Game.CurrentGame.Decks[DeckType.Compute]);
                Game.CurrentGame.Decks[DeckType.Compute].Clear();
                CardsMovement m = new CardsMovement();
                if (c is CompositeCard)
                {
                    m.Cards = new List<Card>(((CompositeCard)c).Subcards);
                }
                else
                {
                    m.Cards = new List<Card>(eventArgs.Cards);
                }
                m.To = new DeckPlace(null, DeckType.Compute);
                m.Helper = new MovementHelper();
                Player isDoingAFavor = eventArgs.Source;
                foreach (var checkFavor in m.Cards)
                {
                    if (checkFavor.Owner != eventArgs.Source)
                    {
                        Trace.TraceInformation("Acting on behalf of others");
                        isDoingAFavor = checkFavor.Owner;
                    }
                }
                bool runTrigger = !c.Type.IsReforging(eventArgs.Source, eventArgs.Skill, m.Cards, eventArgs.Targets);
                c.Type.TagAndNotify(eventArgs.Source, eventArgs.Targets, c);
                Game.CurrentGame.MoveCards(m);
                if (isDoingAFavor != eventArgs.Source)
                {
                    Game.CurrentGame.PlayerPlayedCard(isDoingAFavor, eventArgs.Card);
                    Game.CurrentGame.PlayerLostCard(isDoingAFavor, eventArgs.Cards);
                    Game.CurrentGame.PlayerPlayedCard(isDoingAFavor, eventArgs.Card);
                }
                else
                {
                    Game.CurrentGame.PlayerLostCard(eventArgs.Source, eventArgs.Cards);
                }
                Player savedSource = eventArgs.Source;

                GameEventArgs arg = new GameEventArgs();
                arg.Source = eventArgs.Source;
                arg.Targets = c.Type.ActualTargets(arg.Source, eventArgs.Targets, c);
                arg.Card = c;
                arg.ReadonlyCard = rdonlyCard;
                arg.InResponseTo = eventArgs.InResponseTo;
                if (runTrigger)
                {
                    try
                    {
                        Game.CurrentGame.Emit(GameEvent.PlayerUsedCard, arg);
                        Game.CurrentGame.Emit(GameEvent.CardUsageTargetConfirming, arg);
                        Game.CurrentGame.Emit(GameEvent.CardUsageTargetConfirmed, arg);
                    }
                    catch (TriggerResultException)
                    {
                        throw new NotImplementedException();
                    }
                }

                if (arg.InResponseTo != null)
                {
                    c.Type.Process(arg.Source, arg.Targets, c, arg.ReadonlyCard, arg.InResponseTo);
                }
                else
                {
                    c.Type.Process(arg.Source, arg.Targets, c, arg.ReadonlyCard);
                }

                if (Game.CurrentGame.Decks[DeckType.Compute].Count > 0)
                {
                    m.Cards = Game.CurrentGame.Decks[DeckType.Compute];
                    m.To = new DeckPlace(null, DeckType.Discard);
                    m.Helper = new MovementHelper();
                    Game.CurrentGame.PlayerAboutToDiscardCard(savedSource, m.Cards, DiscardReason.Use);
                    Game.CurrentGame.MoveCards(m);
                    Game.CurrentGame.PlayerDiscardedCard(savedSource, m.Cards, DiscardReason.Use);
                }
                Trace.Assert(Game.CurrentGame.Decks[DeckType.Compute].Count == 0);
                Game.CurrentGame.Decks[DeckType.Compute].AddRange(computeBackup);
            }
Exemple #24
0
 public void CopyFrom(GameEventArgs another)
 {
     source = another.source;
     targets = new List<Player>(another.targets);
     cards = new List<Card>(another.cards);
     card = another.card;
     readonlyCard = another.readonlyCard;
 }
Exemple #25
0
        /// <summary>
        /// 造成伤害
        /// </summary>
        /// <param name="source">伤害来源</param>
        /// <param name="dest">伤害目标</param>
        /// <param name="magnitude">伤害点数</param>
        /// <param name="elemental">伤害属性</param>
        /// <param name="cards">造成伤害的牌</param>
        public void DoDamage(Player source, Player dest, int magnitude, DamageElement elemental, ICard card, ReadOnlyCard readonlyCard)
        {
            var damageArgs = new DamageEventArgs() { Source = source, Targets = new List<Player>(), Magnitude = magnitude, Element = elemental };
            HealthChangedEventArgs healthChangedArgs;
            int ironShackledDamage = 0;
            DamageElement ironShackledDamageElement = DamageElement.None;
            damageArgs.ReadonlyCard = readonlyCard;
            if (card is CompositeCard)
            {
                if ((card as CompositeCard).Subcards != null)
                {
                    damageArgs.Cards = new List<Card>((card as CompositeCard).Subcards);
                }
            }
            else if (card is Card)
            {
                damageArgs.Cards = new List<Card>() { card as Card };
            }
            else
            {
                damageArgs.Cards = new List<Card>();
            }
            damageArgs.Targets.Add(dest);
            damageArgs.Card = card;

            try
            {
                Game.CurrentGame.Emit(GameEvent.DamageSourceConfirmed, damageArgs);
                Game.CurrentGame.Emit(GameEvent.DamageElementConfirmed, damageArgs);
                Game.CurrentGame.Emit(GameEvent.BeforeDamageComputing, damageArgs);
                Game.CurrentGame.Emit(GameEvent.DamageComputingStarted, damageArgs);
                Game.CurrentGame.Emit(GameEvent.DamageCaused, damageArgs);
                Game.CurrentGame.Emit(GameEvent.DamageInflicted, damageArgs);
                if (damageArgs.Magnitude == 0)
                {
                    Trace.TraceInformation("Damage is 0, aborting");
                    return;
                }
                if (damageArgs.Targets[0].IsIronShackled && damageArgs.Element != DamageElement.None)
                {
                    ironShackledDamage = damageArgs.Magnitude;
                    Trace.TraceInformation("IronShackled damage {0}", ironShackledDamage);
                    ironShackledDamageElement = damageArgs.Element;
                    damageArgs.Targets[0].IsIronShackled = false;
                }
                healthChangedArgs = new HealthChangedEventArgs(damageArgs);
                Game.CurrentGame.Emit(GameEvent.BeforeHealthChanged, healthChangedArgs);
                damageArgs.Magnitude = -healthChangedArgs.Delta;
            }
            catch (TriggerResultException e)
            {
                if (e.Status == TriggerResult.End)
                {
                    Trace.TraceInformation("Damage Aborted");
                    return;
                }
                Trace.Assert(false);
                return;
            }

            Trace.Assert(damageArgs.Targets.Count == 1);
            damageArgs.Targets[0].Health -= damageArgs.Magnitude;
            Trace.TraceInformation("Player {0} Lose {1} hp, @ {2} hp", damageArgs.Targets[0].Id, damageArgs.Magnitude, damageArgs.Targets[0].Health);
            NotificationProxy.NotifyDamage(source, damageArgs.Targets[0], damageArgs.Magnitude, damageArgs.Element);

            try
            {
                Game.CurrentGame.Emit(GameEvent.AfterHealthChanged, healthChangedArgs);
            }
            catch (TriggerResultException)
            {
            }
            Game.CurrentGame.Emit(GameEvent.AfterDamageCaused, damageArgs);
            Game.CurrentGame.Emit(GameEvent.AfterDamageInflicted, damageArgs);
            Game.CurrentGame.Emit(GameEvent.DamageComputingFinished, damageArgs);
            if (ironShackledDamage != 0)
            {
                List<Player> toProcess = new List<Player>(Game.CurrentGame.AlivePlayers);
                Game.CurrentGame.SortByOrderOfComputation(damageArgs.Targets[0], toProcess);
                foreach (Player p in toProcess)
                {
                    if (p.IsIronShackled)
                    {
                        DoDamage(damageArgs.Source, p, ironShackledDamage, ironShackledDamageElement, card, readonlyCard);
                    }
                }
            }
        }
 protected override void Process(Players.Player source, Players.Player dest, ICard card, ReadOnlyCard cardr, GameEventArgs inResponseTo)
 {
     throw new NotImplementedException();
 }
Exemple #27
0
 protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard, GameEventArgs inResponseTo)
 {
     Game.CurrentGame.DoDamage(source, dest, 1, ShaDamageElement, card, readonlyCard);
 }
Exemple #28
0
 public override void Run(GameEvent gameEvent, GameEventArgs eventArgs)
 {
     if (!eventArgs.Targets.Contains(Owner)) return;
     DamageEventArgs damageArgs = eventArgs as DamageEventArgs;
     ReadOnlyCard rCard = new ReadOnlyCard(damageArgs.ReadonlyCard);
     rCard[ShiChouDamage] = 1;
     target[ShiChouTarget[Owner]] ++;
     Game.CurrentGame.DoDamage(damageArgs.Source, target, Owner, damageArgs.Magnitude, damageArgs.Element, damageArgs.Card, rCard);
     throw new TriggerResultException(TriggerResult.End);
 }
Exemple #29
0
 void ZhaoLieProcess(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     ZhaoLieUsed = false;
     basicCards.Clear();
     notBasicCards.Clear();
     List<Card> tao = new List<Card>();
     DeckType ZhaoLieDeck = new DeckType("ZhaoLie");
     CardsMovement move = new CardsMovement();
     move.Cards = new List<Card>();
     int toDraw = 3;
     for (int i = 0; i < toDraw; i++)
     {
         Game.CurrentGame.SyncImmutableCardAll(Game.CurrentGame.PeekCard(0));
         Card c = Game.CurrentGame.DrawCard();
         c.Log.SkillAction = this;
         c.Log.Source = Owner;
         move.Cards.Add(c);
         Game.CurrentGame.NotificationProxy.NotifyShowCard(null, c);
         if (c.Type is Tao) tao.Add(c);
         else if (c.Type.IsCardCategory(CardCategory.Basic)) basicCards.Add(c);
         else notBasicCards.Add(c);
     }
     move.To = new DeckPlace(null, ZhaoLieDeck);
     Game.CurrentGame.MoveCards(move);
     int answer = 0;
     List<OptionPrompt> prompts = new List<OptionPrompt>();
     prompts.Add(new OptionPrompt("ZhaoLieShangHai", notBasicCards.Count, basicCards.Count));
     prompts.Add(new OptionPrompt("ZhaoLieQiPai", notBasicCards.Count, basicCards.Count));
     while (true)
     {
         if (ZhaoLieTarget.HandCards().Count + ZhaoLieTarget.Equipments().Count < notBasicCards.Count) break;
         ZhaoLieTarget.AskForMultipleChoice(new MultipleChoicePrompt("ZhaoLie"), prompts, out answer);
         break;
     }
     List<Card> toDiscard = new List<Card>();
     toDiscard.AddRange(notBasicCards);
     toDiscard.AddRange(tao);
     foreach (Card c in toDiscard)
     {
         c.Log = new ActionLog();
         c.Log.SkillAction = this;
         c.Log.GameAction = GameAction.PlaceIntoDiscard;
     }
     Game.CurrentGame.PlaceIntoDiscard(null, toDiscard);
     if (answer == 0)
     {
         if (notBasicCards.Count == 0) Game.CurrentGame.HandleCardTransferToHand(null, ZhaoLieTarget, basicCards);
         else
         {
             ReadOnlyCard rCard = new ReadOnlyCard(new Card() { Place = new DeckPlace(null, null) });
             rCard[ZhaoLieDamage] = 1;
             Game.CurrentGame.DoDamage(Owner, ZhaoLieTarget, notBasicCards.Count, DamageElement.None, null, rCard);
         }
     }
     else
     {
         for (int i = 0; i < notBasicCards.Count; i++)
         {
             Game.CurrentGame.ForcePlayerDiscard(ZhaoLieTarget, (pl, d) => { return 1 - d; }, true);
         }
         Game.CurrentGame.HandleCardTransferToHand(null, Owner, basicCards);
     }
     ZhaoLieTarget = null;
 }
Exemple #30
0
 protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard)
 {
 }
Exemple #31
0
 protected abstract void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard, GameEventArgs inResponseTo);
Exemple #32
0
        /// <summary>
        /// 造成伤害
        /// </summary>
        /// <param name="source">伤害来源</param>
        /// <param name="dest">伤害目标</param>
        /// <param name="originalTarget">最初的伤害目标</param>
        /// <param name="magnitude">伤害点数</param>
        /// <param name="elemental">伤害属性</param>
        /// <param name="cards">造成伤害的牌</param>
        public void DoDamage(Player source, Player dest, Player originalTarget, int magnitude, DamageElement elemental, ICard card, ReadOnlyCard readonlyCard)
        {
            if (dest.IsDead) return;
            var damageArgs = new DamageEventArgs() { Source = source, OriginalTarget = originalTarget, Targets = new List<Player>(), Magnitude = magnitude, Element = elemental };
            HealthChangedEventArgs healthChangedArgs;
            int ironShackledDamage = 0;
            DamageElement ironShackledDamageElement = DamageElement.None;
            if (readonlyCard == null)
            {
                readonlyCard = new ReadOnlyCard(new Card() { Place = new DeckPlace(null, null) });
            }
            damageArgs.ReadonlyCard = readonlyCard;
            if (card is CompositeCard)
            {
                if ((card as CompositeCard).Subcards != null)
                {
                    damageArgs.Cards = new List<Card>((card as CompositeCard).Subcards);
                }
            }
            else if (card is Card)
            {
                damageArgs.Cards = new List<Card>() { card as Card };
            }
            else
            {
                damageArgs.Cards = new List<Card>();
            }
            damageArgs.Targets.Add(dest);
            damageArgs.Card = card;

            try
            {
                //伤害来源与基数、属性的确定发生在伤害结算前,连环,以及转移的伤害不会重新确定来源与基数,所以不会多次触发【裸衣】,以及【酒】
                while (damageArgs.ReadonlyCard[SourceAndElementIsConfirmed] == 0)
                {
                    Emit(GameEvent.DamageSourceConfirmed, damageArgs);
                    Emit(GameEvent.DamageElementConfirmed, damageArgs);
                    damageArgs.ReadonlyCard[SourceAndElementIsConfirmed] = 1;
                    break;
                }
                Emit(GameEvent.BeforeDamageComputing, damageArgs);
                Emit(GameEvent.DamageComputingStarted, damageArgs);
                Emit(GameEvent.DamageCaused, damageArgs);
                Emit(GameEvent.DamageInflicted, damageArgs);
                if (damageArgs.Magnitude == 0)
                {
                    Trace.TraceInformation("Damage is 0, aborting");
                    return;
                }
                if (damageArgs.Targets[0].IsIronShackled && damageArgs.Element != DamageElement.None)
                {
                    ironShackledDamage = damageArgs.Magnitude;
                    Trace.TraceInformation("IronShackled damage {0}", ironShackledDamage);
                    ironShackledDamageElement = damageArgs.Element;
                    damageArgs.Targets[0].IsIronShackled = false;
                    // if this is TieSuo damage already, prevent itself from spreading...
                    if (readonlyCard[IsIronShackleDamage] == 1) ironShackledDamage = 0;
                }
                healthChangedArgs = new HealthChangedEventArgs(damageArgs);
                Emit(GameEvent.BeforeHealthChanged, healthChangedArgs);
                damageArgs.Magnitude = -healthChangedArgs.Delta;
            }
            catch (TriggerResultException e)
            {
                if (e.Status == TriggerResult.End)
                {
                    //伤害结算完毕事件应该总是被触发
                    //受到伤害的角色如果存活能发动的技能/会执行的技能效果:【酒诗②】、执行【天香】摸牌的效果。
                    Emit(GameEvent.DamageComputingFinished, damageArgs);
                    Trace.TraceInformation("Damage Aborted");
                    return;
                }
                Trace.Assert(false);
                return;
            }

            Trace.Assert(damageArgs.Targets.Count == 1);
            damageArgs.Targets[0].Health -= damageArgs.Magnitude;
            Trace.TraceInformation("Player {0} Lose {1} hp, @ {2} hp", damageArgs.Targets[0].Id, damageArgs.Magnitude, damageArgs.Targets[0].Health);
            NotificationProxy.NotifyDamage(source, damageArgs.Targets[0], damageArgs.Magnitude, damageArgs.Element);

            try
            {
                Emit(GameEvent.AfterHealthChanged, healthChangedArgs);
            }
            catch (TriggerResultException)
            {
            }
            Emit(GameEvent.AfterDamageCaused, damageArgs);
            Emit(GameEvent.AfterDamageInflicted, damageArgs);
            Emit(GameEvent.DamageComputingFinished, damageArgs);
            if (ironShackledDamage != 0)
            {
                List<Player> toProcess = new List<Player>(AlivePlayers);
                SortByOrderOfComputation(CurrentPlayer, toProcess);
                foreach (Player p in toProcess)
                {
                    if (p.IsIronShackled)
                    {
                        GameDelays.Delay(GameDelayTypes.TieSuoDamage);
                        readonlyCard[IsIronShackleDamage] = 1;
                        DoDamage(damageArgs.Source, p, originalTarget, ironShackledDamage, ironShackledDamageElement, card, readonlyCard);
                    }
                }
            }
        }
        public virtual void Process(GameEventArgs handlerArgs)
        {
            var   source        = handlerArgs.Source;
            var   dests         = handlerArgs.Targets;
            var   readonlyCard  = handlerArgs.ReadonlyCard;
            var   inResponseTo  = handlerArgs.InResponseTo;
            var   card          = handlerArgs.Card;
            ICard attributeCard = new Card();

            Game.CurrentGame.SortByOrderOfComputation(Game.CurrentGame.CurrentPlayer, dests);
            foreach (var player in dests)
            {
                if (player.IsDead && IgnoreDeath)
                {
                    continue;
                }
                GameEventArgs args = new GameEventArgs();
                args.Source  = source;
                args.Targets = new List <Player>()
                {
                    player
                };
                args.Card         = card;
                args.ReadonlyCard = readonlyCard;
                try
                {
                    Game.CurrentGame.Emit(GameEvent.CardUsageTargetValidating, args);
                }
                catch (TriggerResultException e)
                {
                    Trace.Assert(e.Status == TriggerResult.End);
                    Game.CurrentGame.NotificationProxy.NotifyLogEvent(new LogEvent("CardInvalid", this, player), args.Targets, false);
                    continue;
                }
                try
                {
                    Game.CurrentGame.Emit(GameEvent.CardUsageBeforeEffected, args);
                }
                catch (TriggerResultException e)
                {
                    Trace.Assert(e.Status == TriggerResult.End);
                    continue;
                }
                if (player.IsDead)
                {
                    continue;
                }
                ReadOnlyCard newCard = new ReadOnlyCard(readonlyCard);
                Process(source, player, card, newCard, inResponseTo);
                if (newCard.Attributes != null)
                {
                    foreach (var attr in newCard.Attributes)
                    {
                        attributeCard[attr.Key] = attr.Value;
                    }
                }
            }
            if (attributeCard.Attributes != null)
            {
                foreach (var attr in attributeCard.Attributes)
                {
                    readonlyCard[attr.Key] = attr.Value;
                }
            }
        }
Exemple #34
0
 protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard, GameEventArgs eventArgs)
 {
     if (eventArgs != null)
     {
         eventArgs.ReadonlyCard[CardAttribute.Register(CardAttribute.TargetRequireTwoResponses + source.Id)]--;
     }
 }