Example #1
0
 void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     var args = eventArgs as DiscardCardEventArgs;
     if (args.Source == null || args.Source == Owner || args.Reason != DiscardReason.Use)
     {
         return;
     }
     List<Card> cardsToProcess = new List<Card>(eventArgs.Cards);
     foreach (Card c in cardsToProcess)
     {
         if (c.Type is NanManRuQin)
         {
             ActionLog log = new ActionLog();
             log.GameAction = GameAction.None;
             log.SkillAction = this;
             log.Source = Owner;
             log.CardAction = c;
             Game.CurrentGame.NotificationProxy.NotifySkillUse(log);
             List<Card> cc = new List<Card>();
             cc.Add(c);
             Game.CurrentGame.HandleCardTransferToHand(null, Owner, cc);
             eventArgs.Cards.Remove(c);
         }
     }
 }
Example #2
0
 protected void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     Player dest = eventArgs.Targets[0];
     for (int i = 0; i < 2 && Game.CurrentGame.Decks[dest, DeckType.Hand].Concat(Game.CurrentGame.Decks[dest, DeckType.Equipment]).Count() > 0; i++)
     {
         IUiProxy ui = Game.CurrentGame.UiProxies[Owner];
         if (Owner.IsDead) return;
         List<DeckPlace> places = new List<DeckPlace>();
         places.Add(new DeckPlace(dest, DeckType.Hand));
         places.Add(new DeckPlace(dest, DeckType.Equipment));
         List<string> resultDeckPlace = new List<string>();
         resultDeckPlace.Add("HanBing");
         List<int> resultDeckMax = new List<int>();
         resultDeckMax.Add(1);
         List<List<Card>> answer;
         if (!ui.AskForCardChoice(new CardChoicePrompt("HanBing"), places, resultDeckPlace, resultDeckMax, new RequireOneCardChoiceVerifier(), out answer))
         {
             Trace.TraceInformation("Player {0} Invalid answer", Owner.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.Equipment]);
             answer[0].Add(collection.First());
         }
         Trace.Assert(answer.Count == 1 && answer[0].Count == 1);
         Game.CurrentGame.HandleCardDiscard(dest, answer[0]);
     }
     throw new TriggerResultException(TriggerResult.End);
 }
Example #3
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 });
 }
Example #4
0
 public override bool Commit(GameEventArgs arg)
 {
     Owner[FenChengUsed] = 1;
     var toProcess = Game.CurrentGame.AlivePlayers;
     toProcess.Remove(Owner);
     foreach (Player target in toProcess)
     {
         ISkill skill;
         List<Card> cards;
         List<Player> players;
         if (target.IsDead) break;
         int answer = 0;
         if (answer == 0 && Math.Max(1, target.Equipments().Count) <= target.HandCards().Count &&
             Game.CurrentGame.UiProxies[target].AskForCardUsage(new CardUsagePrompt("FenCheng"), new FenChengVerifier(Math.Max(1, target.Equipments().Count)),
             out skill, out cards, out players))
         {
             Game.CurrentGame.HandleCardDiscard(target, cards);
         }
         else
         {
             Game.CurrentGame.DoDamage(null, target, 1, DamageElement.Fire, null, null);
         }
     }
     return true;
 }
Example #5
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.Heart; });
         if (result.Suit != SuitType.Heart)
         {
             var theTrigger = new LeBuSiShuTrigger() { Priority = int.MaxValue };
             theTrigger.Owner = p;
             Game.CurrentGame.RegisterTrigger(GameEvent.PhaseOutEvents[TurnPhase.Draw], theTrigger);
         }
         break;
     }
     CardsMovement move = new CardsMovement();
     move.Cards = new List<Card>();
     move.Cards.Add(c);
     move.To = new DeckPlace(null, DeckType.Discard);
     Game.CurrentGame.MoveCards(move);
 }
Example #6
0
File: TuXi.cs Project: pxoylngx/sgs
 void GetTheirCards(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     ISkill skill;
     List<Card> cards;
     List<Player> players;
     if (Game.CurrentGame.UiProxies[Owner].AskForCardUsage(new CardUsagePrompt("TuXi"), new TuXiVerifier(), out skill, out cards, out players))
     {
         NotifySkillUse(players);
         Game.CurrentGame.EnterAtomicContext();
         foreach (Player p in players)
         {
             List<List<Card>> answer;
             if (!Game.CurrentGame.UiProxies[Owner].AskForCardChoice(new CardChoicePrompt("TuXi"), new List<DeckPlace>() { new DeckPlace(p, DeckType.Hand) },
                 new List<string>() { "TuXi" }, new List<int>() { 1 }, new RequireOneCardChoiceVerifier(), out answer))
             {
                 answer = new List<List<Card>>();
                 answer.Add(new List<Card>());
                 answer[0].Add(Game.CurrentGame.Decks[p, DeckType.Hand][0]);
             }
             Game.CurrentGame.HandleCardTransferToHand(p, Owner, answer[0]);
         }
         Game.CurrentGame.ExitAtomicContext();
         Game.CurrentGame.CurrentPhaseEventIndex++;
         throw new TriggerResultException(TriggerResult.End);
     }
 }
Example #7
0
 public override VerifierResult Validate(GameEventArgs arg)
 {
     if (Owner[FanJianUsed] != 0)
     {
         return VerifierResult.Fail;
     }
     if (Game.CurrentGame.Decks[Owner, DeckType.Hand].Count == 0)
     {
         return VerifierResult.Fail;
     }
     if (arg.Cards != null && arg.Cards.Count != 0)
     {
         return VerifierResult.Fail;
     }
     if (arg.Targets != null && arg.Targets.Count > 1)
     {
         return VerifierResult.Fail;
     }
     if (arg.Targets == null || arg.Targets.Count == 0)
     {
         return VerifierResult.Partial;
     }
     if (arg.Targets != null && arg.Targets[0] == Owner)
     {
         return VerifierResult.Fail;
     }
     return VerifierResult.Success;
 }
Example #8
0
 void Run1(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     MultipleChoicePrompt prompt;
     List<OptionPrompt> options = new List<OptionPrompt>();
     OptionPrompt option1 = new OptionPrompt("MouKuiMoPai");
     int i = 0;
     foreach (var target in eventArgs.Targets)
     {
         options.Clear();
         options.Add(OptionPrompt.NoChoice);
         options.Add(option1);
         options.Add(new OptionPrompt("MouKuiQiZhi", target));
         bool isNaked = target.HandCards().Count + target.Equipments().Count == 0;
         prompt = isNaked ? new MultipleChoicePrompt("MouKuiDrawCardOnly") : new MultipleChoicePrompt("MouKui");
         int answer = 0;
         Owner.AskForMultipleChoice(prompt, isNaked ? OptionPrompt.YesNoChoices : options, out answer);
         if (answer == 0) { i++; continue; }
         MouKuiEffect = 0;
         NotifySkillUse();
         if (answer == 1)
         {
             Game.CurrentGame.DrawCards(Owner, 1);
         }
         else
         {
             Card theCard = Game.CurrentGame.SelectACardFrom(target, Owner, new CardChoicePrompt("MouKui", target, Owner), "QiPaiDui");
             Game.CurrentGame.HandleCardDiscard(target, new List<Card>() { theCard });
         }
         eventArgs.ReadonlyCard[MouKuiCheck[target]] |= (1 << i);
         i++;
     }
 }
Example #9
0
 protected void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     var equipDeck = Game.CurrentGame.Decks[eventArgs.Targets[0], DeckType.Equipment];
     Card c;
     if (equipDeck.Count(s => (s.Type is DefensiveHorse) || (s.Type is OffensiveHorse)) > 1)
     {
         int answer = 0;
         Game.CurrentGame.UiProxies[Owner].AskForMultipleChoice(new MultipleChoicePrompt("QiLinGong", this), new List<String> { Prompt.MultipleChoiceOptionPrefix + "JiaYiZuoJi", Prompt.MultipleChoiceOptionPrefix + "JianYiZuoJi" },
             out answer);
         if (answer == 1)
         {
             var results = from equip in equipDeck where equip.Type is OffensiveHorse select equip;
             Trace.Assert(results.Count() == 1);
             c = results.First();
         }
         else
         {
             Trace.Assert(answer == 0);
             var results = from equip in equipDeck where equip.Type is DefensiveHorse select equip;
             Trace.Assert(results.Count() == 1);
             c = results.First();
         }
     }
     else
     {
         var results = from equip in equipDeck where (equip.Type is DefensiveHorse) || (equip.Type is OffensiveHorse) select equip;
         Trace.Assert(results.Count() == 1);
         c = results.First();
     }
     Game.CurrentGame.HandleCardDiscard(eventArgs.Targets[0], new List<Card>() { c });
 }
Example #10
0
 public override bool Commit(GameEventArgs arg)
 {
     Owner[ShenFenUsed] = 1;
     Owner[KuangBao.BaoNuMark] -= 6;
     var players = Game.CurrentGame.AlivePlayers;
     players.Remove(Owner);
     foreach (Player p in players)
     {
         Game.CurrentGame.DoDamage(Owner, p, 1, DamageElement.None, null, arg.ReadonlyCard);
     }
     foreach (Player p in players)
     {
         List<Card> toDiscard = new List<Card>();
         toDiscard.AddRange(p.Equipments());
         Game.CurrentGame.HandleCardDiscard(p, toDiscard);
         if (p.HandCards().Count() <= 4)
         {
             toDiscard.Clear();
             toDiscard.AddRange(p.HandCards());
             Game.CurrentGame.HandleCardDiscard(p, toDiscard);
         }
         else
         {
             Game.CurrentGame.ForcePlayerDiscard(p, (pl, d) => { return 4 - d; }, false);
         }
     }
     Owner.IsImprisoned = !Owner.IsImprisoned;
     return true;
 }
Example #11
0
 public override VerifierResult Validate(GameEventArgs arg)
 {
     if (Owner[LiHunUsed] != 0)
     {
         return VerifierResult.Fail;
     }
     if (Owner.HandCards().Count == 0)
     {
         return VerifierResult.Fail;
     }
     if (arg.Targets == null || arg.Targets.Count == 0)
     {
         return VerifierResult.Partial;
     }
     if (arg.Targets != null && arg.Targets.Count > 1)
     {
         return VerifierResult.Fail;
     }
     if (arg.Targets != null && (!arg.Targets[0].IsMale || arg.Targets[0].HandCards().Count == 0))
     {
         return VerifierResult.Fail;
     }
     List<Card> cards = arg.Cards;
     if (cards == null && cards.Count == 0)
     {
         return VerifierResult.Partial;
     }
     if (cards != null && cards.Count > 1)
     {
         return VerifierResult.Fail;
     }
     return VerifierResult.Success;
 }
Example #12
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 });
            }
        }
Example #13
0
 public override void Run(GameEvent gameEvent, GameEventArgs eventArgs)
 {
     if (eventArgs.Targets[0] != Owner ||
         !(eventArgs.ReadonlyCard.Type.IsCardCategory(CardCategory.ImmediateTool) || eventArgs.ReadonlyCard.Type is Sha))
         return;
     throw new TriggerResultException(TriggerResult.End);
 }
Example #14
0
 bool canTrigger(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     if (gameEvent == GameEvent.CardsLost)
     {
         foreach (Card card in eventArgs.Cards)
         {
             if (card.HistoryPlace1.Player == Owner && card.HistoryPlace1.DeckType == DeckType.Equipment)
             {
                 return true;
             }
         }
         return false;
     }
     else if (gameEvent == GameEvent.CardsEnteredDiscardDeck)
     {
         if (!(Game.CurrentGame.PhasesOwner == Owner && Game.CurrentGame.CurrentPhase == TurnPhase.Discard && Owner[XuanFengUsed] == 0))
         {
             return false;
         }
         if (eventArgs.Cards != null)
         {
             Owner[XuanFengUsable] += eventArgs.Cards.Count;
         }
         return Owner[XuanFengUsable] >= 2;
     }
     return true;
 }
Example #15
0
 public override VerifierResult Validate(GameEventArgs arg)
 {
     PlayerAttribute HuangTianUsed = PlayerAttribute.Register("HuangTianUsed" + Master.Id, true);
     if (Owner[HuangTianUsed] != 0)
     {
         return VerifierResult.Fail;
     }
     if (arg.Targets != null && arg.Targets.Count > 0)
     {
         return VerifierResult.Fail;
     }
     List<Card> cards = arg.Cards;
     if (cards != null && cards.Count > 1)
     {
         return VerifierResult.Fail;
     }
     if (cards != null && cards.Count > 0 && !(cards[0].Type is Shan || cards[0].Type is ShanDian))
     {
         return VerifierResult.Fail;
     }
     if (cards == null || cards.Count == 0)
     {
         return VerifierResult.Partial;
     }
     return VerifierResult.Success;
 }
Example #16
0
 public void Run(Player owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     Trigger tri = new Trigger();
     int answer = 0;
     List<OptionPrompt> JiangChiQuestion = new List<OptionPrompt>();
     JiangChiQuestion.Add(Prompt.NoChoice);
     JiangChiQuestion.Add(new OptionPrompt("JiangChi1"));
     JiangChiQuestion.Add(new OptionPrompt("JiangChi2"));
     owner.AskForMultipleChoice(new MultipleChoicePrompt("JiangChi"), JiangChiQuestion, out answer);
     if (answer == 0)
     {
         return;
     }
     NotifySkillUse(new List<Player>());
     if (answer == 1)
     {
         owner[Player.DealAdjustment]++;
         tri = new JiangChi1(owner);
         Game.CurrentGame.RegisterTrigger(GameEvent.PlayerCanUseCard, tri);
         Game.CurrentGame.RegisterTrigger(GameEvent.PlayerCanPlayCard, tri);
     }
     else
     {
         owner[Sha.AdditionalShaUsable]++;
         owner[Player.DealAdjustment]--;
         tri = new JiangChi2(owner);
         Game.CurrentGame.RegisterTrigger(Sha.PlayerShaTargetValidation, tri);
     }
     Trigger triRemoval = new JiangChiRemoval(owner, tri, answer == 1);
     Game.CurrentGame.RegisterTrigger(GameEvent.PhasePostEnd, triRemoval);
 }
Example #17
0
 void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     int answer = 0;
     List<OptionPrompt> JiLeiQuestion = new List<OptionPrompt>();
     JiLeiQuestion.Add(new OptionPrompt("JiBen"));
     JiLeiQuestion.Add(new OptionPrompt("JinNang"));
     JiLeiQuestion.Add(new OptionPrompt("ZhuangBei"));
     JiLeiQuestion.Add(Prompt.NoChoice);
     if (Game.CurrentGame.UiProxies[Owner].AskForMultipleChoice(
         new MultipleChoicePrompt("JiLei", eventArgs.Source), JiLeiQuestion, out answer))
     {
         Trace.Assert(answer >= 0 && answer <= 3);
         if (answer != 3)
         {
             NotifySkillUse(new List<Player>());
             eventArgs.Source[JiLeiInEffect] = 1;
             JiLeiImplementation trigger = new JiLeiImplementation(eventArgs.Source, answer);
             Game.CurrentGame.RegisterTrigger(GameEvent.PlayerCanDiscardCard, trigger);
             Game.CurrentGame.RegisterTrigger(GameEvent.PlayerCanUseCard, trigger);
             Game.CurrentGame.RegisterTrigger(GameEvent.PlayerCanPlayCard, trigger);
             JiLeiRemoval trigger2 = new JiLeiRemoval(eventArgs.Source, trigger);
             Game.CurrentGame.RegisterTrigger(GameEvent.PhaseEndEvents[TurnPhase.End], trigger2);
             Game.CurrentGame.NotificationProxy.NotifyLogEvent(new LogEvent("JiLei", eventArgs.Source, JiLeiQuestion[answer]), new List<Player>() { Owner, eventArgs.Source });
         }
     }
 }
Example #18
0
 void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     foreach (Card c in eventArgs.Cards)
     {
         if (c.HistoryPlace1.DeckType == DeckType.Equipment && c.HistoryPlace1.Player == Owner)
         {
             if (Owner.LostHealth == 0)
             {
                 if (AskForSkillUse())
                 {
                     Game.CurrentGame.DrawCards(Owner, 2);
                 }
             }
             else
             {
                 int answer;
                 if (Owner.AskForMultipleChoice(new MultipleChoicePrompt("XiaoJi"), new List<OptionPrompt>() { OptionPrompt.NoChoice, new OptionPrompt("MoPai"), new OptionPrompt("HuiFu") }, out answer))
                 {
                     NotifySkillUse(new List<Player>());
                     if (answer == 1)
                     {
                         Game.CurrentGame.DrawCards(Owner, 2);
                     }
                     if (answer == 2)
                     {
                         Game.CurrentGame.RecoverHealth(Owner, Owner, 1);
                     }
                 }
             }
         }
     }
 }
Example #19
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);
 }
Example #20
0
        public ZhiYan()
        {
            var trigger = new AutoNotifyUsagePassiveSkillTrigger(
                this,
                (p, e, a) => { return true; },
                (p, e, a, c, pls) =>
                {
                    Game.CurrentGame.SyncImmutableCardAll(Game.CurrentGame.PeekCard(0));
                    Card card = Game.CurrentGame.PeekCard(0);
                    Game.CurrentGame.DrawCards(pls[0], 1);
                    Game.CurrentGame.SyncImmutableCardAll(card);
                    if (card.Type.BaseCategory() == CardCategory.Equipment)
                    {
                        Game.CurrentGame.RecoverHealth(pls[0], pls[0], 1);
                        var args = new GameEventArgs();
                        args.Source = pls[0];
                        args.Targets = new List<Player>();
                        args.Skill = null;
                        args.Cards = new List<Card>() { card };
                        Game.CurrentGame.Emit(GameEvent.CommitActionToTargets, args);
                    }
                    else
                    {
                        Game.CurrentGame.HideHandCard(card);
                    }
                },
                TriggerCondition.OwnerIsSource,
                new ZhiYanVerifier()
            ) { };

            Triggers.Add(GameEvent.PhaseBeginEvents[TurnPhase.End], trigger);
        }
Example #21
0
File: DaWu.cs Project: pxoylngx/sgs
 void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     ISkill skill;
     List<Card> cards;
     List<Player> players;
     List<Card> originalCards = new List<Card>(Game.CurrentGame.Decks[Owner, QiXing.QiXingDeck]);
     int qxCount = Game.CurrentGame.Decks[Owner, QiXing.QiXingDeck].Count;
     // hack the cards to owner's hand. do not trigger anything
     CardsMovement move = new CardsMovement();
     move.Cards = new List<Card>(Game.CurrentGame.Decks[Owner, QiXing.QiXingDeck]);
     move.To = new DeckPlace(Owner, DeckType.Hand);
     move.Helper.IsFakedMove = true;
     Game.CurrentGame.MoveCards(move);
     if (Game.CurrentGame.UiProxies[Owner].AskForCardUsage(new CardUsagePrompt("DaWu"), new DaWuVerifier(originalCards), out skill, out cards, out players))
     {
         NotifySkillUse(players);
         foreach (var mark in players)
         {
             mark[DaWuMark] = 1;
         }
         dawuTargets = players;
         foreach (Card cc in cards) originalCards.Remove(cc);
         Game.CurrentGame.HandleCardDiscard(null, cards);
     }
     move.Cards = new List<Card>(originalCards);
     move.To = new DeckPlace(Owner, QiXing.QiXingDeck);
     Game.CurrentGame.MoveCards(move);
 }
Example #22
0
        protected void Run(Player owner, GameEvent gameEvent, GameEventArgs eventArgs)
        {
            var result = Game.CurrentGame.PinDian(owner, eventArgs.Targets[0], this);
            if (result == true && Game.CurrentGame.Decks[eventArgs.Targets[0], DeckType.Hand].Count + Game.CurrentGame.Decks[eventArgs.Targets[0], DeckType.Equipment].Count > 0)
            {
                var dest = eventArgs.Targets[0];
                List<DeckPlace> places = new List<DeckPlace>();
                places.Add(new DeckPlace(dest, DeckType.Hand));
                places.Add(new DeckPlace(dest, DeckType.Equipment));
                List<string> resultDeckPlace = new List<string>();
                resultDeckPlace.Add("LieRen");
                List<int> resultDeckMax = new List<int>();
                resultDeckMax.Add(1);
                List<List<Card>> answer;
                if (!Game.CurrentGame.UiProxies[owner].AskForCardChoice(new CardChoicePrompt("LieRen", dest, owner), places, resultDeckPlace, resultDeckMax, new RequireOneCardChoiceVerifier(true), out answer))
                {
                    Trace.TraceInformation("Player {0} Invalid answer", owner.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);

                Game.CurrentGame.HandleCardTransferToHand(dest, owner, new List<Card>() { theCard });
            }
        }
Example #23
0
 void Run(Player owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     DeckType FuHunDeck = new DeckType("FuHun");
     CardsMovement move = new CardsMovement();
     move.Cards = new List<Card>();
     int toDraw = 2;
     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);
     }
     move.To = new DeckPlace(null, FuHunDeck);
     var result = from c in move.Cards select c.SuitColor;
     bool success = result.Distinct().Count() == toDraw;
     if (success) FuHunEffect = 0;
     else FuHunEffect = 1;
     NotifySkillUse();
     Game.CurrentGame.MoveCards(move, false, Core.Utils.GameDelayTypes.Draw);
     Game.CurrentGame.HandleCardTransferToHand(null, owner, Game.CurrentGame.Decks[null, FuHunDeck]);
     if (success)
     {
         Trigger tri = new RemoveShengPao(owner, fhWuSheng, fhPaoXiao);
         Game.CurrentGame.PlayerAcquireAdditionalSkill(owner, fhWuSheng, HeroTag);
         Game.CurrentGame.PlayerAcquireAdditionalSkill(owner, fhPaoXiao, HeroTag);
         Game.CurrentGame.RegisterTrigger(GameEvent.PhasePostEnd, tri);
     }
     Game.CurrentGame.CurrentPhaseEventIndex++;
     throw new TriggerResultException(TriggerResult.End);
 }
Example #24
0
File: DaHe.cs Project: h1398123/sgs
 public override bool Commit(GameEventArgs arg)
 {
     Owner[DaHeUsed] = 1;
     Card card1, card2;
     Game.CurrentGame.PinDianReturnCards(Owner, arg.Targets[0], out card1, out card2, this);
     bool win = false;
     if (card1.Rank > card2.Rank)
     {
         win = true;
         (linkedPassiveSkill as DaHePassive).DaHePlayer = arg.Targets[0];
         ISkill skill;
         List<Card> cards;
         List<Player> players;
         if (Owner.AskForCardUsage(new CardUsagePrompt("DaHe", arg.Targets[0]), new DaHeVerifier(), out skill, out cards, out players))
         {
             Game.CurrentGame.EnterAtomicContext();
             Game.CurrentGame.PlayerLostCard(Owner, new List<Card>() { card1 });
             Game.CurrentGame.PlayerLostCard(arg.Targets[0], new List<Card>() { card2 });
             Game.CurrentGame.HandleCardTransferToHand(Owner, players[0], new List<Card>() { card2 });
             Game.CurrentGame.ExitAtomicContext();
             return true;
         }
     }
     Game.CurrentGame.EnterAtomicContext();
     Game.CurrentGame.PlaceIntoDiscard(Owner, new List<Card>() { card1 });
     Game.CurrentGame.PlaceIntoDiscard(arg.Targets[0], new List<Card>() { card2 });
     Game.CurrentGame.ExitAtomicContext();
     if (!win && Owner.HandCards().Count > 0)
     {
         Game.CurrentGame.ForcePlayerDiscard(Owner,(p, i) => { return 1 - i; }, false);
         Game.CurrentGame.SyncImmutableCardsAll(Owner.HandCards());
         Game.CurrentGame.ShowHandCards(Owner, Owner.HandCards());
     }
     return true;
 }
Example #25
0
        public void OnAfterDamageInflicted(Player owner, GameEvent gameEvent, GameEventArgs eventArgs)
        {
            NotifySkillUse(new List<Player>() { eventArgs.Source });
            List<DeckPlace> deck = new List<DeckPlace>();
            deck.Add(new DeckPlace(eventArgs.Source, DeckType.Hand));
            deck.Add(new DeckPlace(eventArgs.Source, DeckType.Equipment));
            List<int> max = new List<int>() { 1 };
            List<List<Card>> result;
            List<string> deckname = new List<string>() {"FanKui choice"};
            Card theCard;

            int windowId = 0;
            if (!Game.CurrentGame.UiProxies[Owner].AskForCardChoice(new CardChoicePrompt("FanKui", eventArgs.Source), deck, deckname, max, new RequireOneCardChoiceVerifier(), out result, new List<bool>() { false }, ref windowId))
            {

                Trace.TraceInformation("Invalid choice for FanKui");
                theCard = Game.CurrentGame.Decks[eventArgs.Source, DeckType.Hand]
                    .Concat(Game.CurrentGame.Decks[eventArgs.Source, DeckType.Equipment]).First();
            }
            else
            {
                theCard = result[0][0];
            }
            List<Card> cards = new List<Card>();
            cards.Add(theCard);
            Game.CurrentGame.HandleCardTransferToHand(eventArgs.Source, owner, cards);
        }
Example #26
0
 public override VerifierResult Validate(GameEventArgs arg)
 {
     if (Owner[TianYiUsed] != 0)
     {
         return VerifierResult.Fail;
     }
     List<Card> cards = arg.Cards;
     if (cards != null && cards.Count > 0)
     {
         return VerifierResult.Fail;
     }
     if (arg.Targets != null && arg.Targets.Count > 1)
     {
         return VerifierResult.Fail;
     }
     if (arg.Targets == null || arg.Targets.Count == 0)
     {
         return VerifierResult.Partial;
     }
     if (arg.Targets[0] == Owner || Game.CurrentGame.Decks[arg.Targets[0], DeckType.Hand].Count == 0)
     {
         return VerifierResult.Fail;
     }
     return VerifierResult.Success;
 }
Example #27
0
 public override VerifierResult Validate(GameEventArgs arg)
 {
     if (Owner[HuangTianUsed[Master]] != 0)
     {
         return VerifierResult.Fail;
     }
     if (arg.Targets != null && arg.Targets.Count > 0)
     {
         return VerifierResult.Fail;
     }
     List<Card> cards = arg.Cards;
     if (cards != null && cards.Count > 1)
     {
         return VerifierResult.Fail;
     }
     if (cards != null && cards.Count > 0 && !(cards[0].Type is Shan || cards[0].Type is ShanDian))
     {
         return VerifierResult.Fail;
     }
     if (cards == null || cards.Count == 0)
     {
         return VerifierResult.Partial;
     }
     return VerifierResult.Success;
 }
Example #28
0
 public override bool Commit(GameEventArgs arg)
 {
     PlayerAttribute HuangTianUsed = PlayerAttribute.Register("HuangTianUsed"+Master.Id, true);
     Owner[HuangTianUsed] = 1;
     Game.CurrentGame.HandleCardTransferToHand(Owner, Master, arg.Cards);
     return true;
 }
Example #29
0
File: AnXu.cs Project: h1398123/sgs
 public override VerifierResult Validate(GameEventArgs arg)
 {
     if (Owner[AnXuUsed] != 0)
     {
         return VerifierResult.Fail;
     }
     List<Card> cards = arg.Cards;
     if ((cards == null || cards.Count == 0) && (arg.Targets == null || arg.Targets.Count == 0))
     {
         return VerifierResult.Partial;
     }
     if (cards != null && cards.Count > 0)
     {
         return VerifierResult.Fail;
     }
     if (arg.Targets != null && arg.Targets.Count > 2)
     {
         return VerifierResult.Fail;
     }
     if (arg.Targets.Any(p => p == Owner))
     {
         return VerifierResult.Fail;
     }
     if (arg.Targets != null && arg.Targets.Count == 2)
     {
         if (arg.Targets[0].HandCards().Count == arg.Targets[1].HandCards().Count)
             return VerifierResult.Fail;
     }
     if (arg.Targets == null || arg.Targets.Count < 2)
     {
         return VerifierResult.Partial;
     }
     return VerifierResult.Success;
 }
Example #30
0
        protected void Move(Player player, GameEvent gameEvent, GameEventArgs eventArgs, List<Card> cards, List<Player> players)
        {
            Game.CurrentGame.HandleCardDiscard(player, cards);
            Player source = players[0];
            Player dest = players[1];
            List<DeckPlace> places = new List<DeckPlace>();
            places.Add(new DeckPlace(source, DeckType.Equipment));
            places.Add(new DeckPlace(source, DeckType.DelayedTools));
            places.Add(new DeckPlace(dest, DeckType.Equipment));
            places.Add(new DeckPlace(dest, DeckType.DelayedTools));
            List<string> resultDeckPlace = new List<string>();
            resultDeckPlace.Add("QiaoBian");
            List<int> resultDeckMax = new List<int>();
            resultDeckMax.Add(1);
            List<List<Card>> answer;
            if (Game.CurrentGame.UiProxies[player].AskForCardChoice(new CardChoicePrompt("QiaoBian"), places, resultDeckPlace, resultDeckMax, new QiaoBianMoveVerifier(source, dest), out answer))
            {
                Card theCard = answer[0][0];
                DeckType targetDeck = theCard.Place.DeckType;
                if (theCard.Place.Player == source)
                {
                    Game.CurrentGame.HandleCardTransfer(source, dest, targetDeck, new List<Card>() { theCard });
                }
                else
                {
                    Game.CurrentGame.HandleCardTransfer(dest, source, targetDeck, new List<Card>() { theCard });
                }

            }

            Game.CurrentGame.CurrentPhase++;
            Game.CurrentGame.CurrentPhaseEventIndex = 2;
            throw new TriggerResultException(TriggerResult.End);
        }