Inheritance: INotifyPropertyChanged
Esempio n. 1
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);
 }
Esempio n. 2
0
        public WeiDi()
        {
            var trigger = new AutoNotifyPassiveSkillTrigger(
                this,
                (p, e, a) => { return a.Source == ruler; },
                (p, e, a) =>
                {
                    bool nothingChanged = true;
                    foreach (var sk in a.Source.ActionableSkills)
                    {
                        if (sk.IsRulerOnly)
                        {
                            if (!theSkills.ContainsKey(sk))
                                nothingChanged = false;
                        }
                    }
                    foreach (var sk in theSkills)
                    {
                        if (!a.Source.ActionableSkills.Contains(sk.Key))
                            nothingChanged = false;
                    }
                    if (!nothingChanged)
                    {
                        UninstallSkills();
                        InstallSkills(p);
                    }
                },
                TriggerCondition.Global
            ) { AskForConfirmation = false, IsAutoNotify = false };
            Triggers.Add(GameEvent.PlayerSkillSetChanged, trigger);

            IsEnforced = true;
            ruler = null;
            theSkills = new Dictionary<ISkill, ISkill>();
        }
Esempio n. 3
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;
 }
Esempio n. 4
0
File: Jiu.cs Progetto: maplegh/sgs
 protected override VerifierResult Verify(Player source, ICard card, List<Player> targets)
 {
     if (Game.CurrentGame.IsDying.Count == 0 && targets != null && targets.Count >= 1)
     {
         return VerifierResult.Fail;
     }
     if (Game.CurrentGame.IsDying.Count > 0 && (targets == null || targets.Count != 1))
     {
         return VerifierResult.Fail;
     }
     if (Game.CurrentGame.IsDying.Count == 0)
     {
         if (source[JiuUsed] == 1)
         {
             return VerifierResult.Fail;
         }
     }
     else
     {
         if (targets[0] != source)
         {
             return VerifierResult.Fail;
         }
     }
     return VerifierResult.Success;
 }
Esempio n. 5
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);
         }
     }
 }
Esempio n. 6
0
 bool TianMingProcess(Player player)
 {
     int discardedCount = Math.Min(player.HandCards().Count + player.Equipments().Count, 2);
     ISkill skill;
     List<Card> cards;
     List<Player> players;
     CardUsagePrompt prompt = new CardUsagePrompt("TianMing");
     CardUsagePrompt otherPrompt = new CardUsagePrompt("TianMingOther", discardedCount);
     CardUsagePrompt otherIsNakedPrompt = new CardUsagePrompt("TianMingOtherIsNaked");
     if (player.AskForCardUsage(player == Owner ? prompt : (discardedCount == 0 ? otherIsNakedPrompt : otherPrompt), new TianMingVerifier(discardedCount), out skill, out cards, out players))
     {
         if (player == Owner)
         {
             TianMingEffect = 0;
         }
         else if (player.IsMale)
         {
             TianMingEffect = 1;
         }
         else
         {
             TianMingEffect = 2;
         }
         NotifySkillUse();
         if (cards.Count > 0)
         {
             Game.CurrentGame.HandleCardDiscard(player, cards);
         }
         Game.CurrentGame.DrawCards(player, 2);
         return true;
     }
     return false;
 }
Esempio n. 7
0
File: Tao.cs Progetto: h1398123/sgs
 protected override VerifierResult Verify(Player source, ICard card, List<Player> targets)
 {
     if (Game.CurrentGame.IsDying.Count == 0 && targets != null && targets.Count >= 1)
     {
         return VerifierResult.Fail;
     }
     if (Game.CurrentGame.IsDying.Count > 0 && (targets == null || targets.Count != 1))
     {
         return VerifierResult.Fail;
     }
     Player p;
     if (Game.CurrentGame.IsDying.Count == 0)
     {
         p = source;
     }
     else
     {
         p = targets[0];
     }
     if (p.Health >= p.MaxHealth)
     {
         return VerifierResult.Fail;
     }
     return VerifierResult.Success;
 }
Esempio n. 8
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 });
            }
        }
Esempio n. 9
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 });
 }
Esempio n. 10
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);
 }
Esempio n. 11
0
 protected override VerifierResult Verify(Player source, ICard card, List<Player> targets)
 {
     if (targets == null || targets.Count == 0)
     {
         return VerifierResult.Partial;
     }
     if (targets.Count > 1)
     {
         return VerifierResult.Fail;
     }
     Player player = targets[0];
     if (player == source)
     {
         return VerifierResult.Fail;
     }
     if (!ShunChaiAdditionalCheck(source, player, card))
     {
         return VerifierResult.Fail;
     }
     if (Game.CurrentGame.Decks[player, DeckType.Hand].Count == 0 &&
         Game.CurrentGame.Decks[player, DeckType.DelayedTools].Count == 0 &&
         Game.CurrentGame.Decks[player, DeckType.Equipment].Count == 0)
     {
         return VerifierResult.Fail;
     }
     return VerifierResult.Success;
 }
Esempio n. 12
0
File: DaWu.cs Progetto: 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);
 }
Esempio n. 13
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 });
            }
        }
Esempio n. 14
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);
 }
Esempio n. 15
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);
        }
Esempio n. 16
0
 public override void CardRevealPolicy(Player p, List<Card> cards, List<Player> players)
 {
     foreach (Card c in cards)
     {
         c.RevealOnce = true;
     }
 }
Esempio n. 17
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");
     }
 }
Esempio n. 18
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 });
         }
     }
 }
Esempio n. 19
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);
                     }
                 }
             }
         }
     }
 }
Esempio n. 20
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);
        }
Esempio n. 21
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);
 }
Esempio n. 22
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 });
 }
Esempio n. 23
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++;
     }
 }
Esempio n. 24
0
        /// <summary>
        /// 给某个玩家穿装备
        /// </summary>
        /// <param name="p"></param>
        /// <param name="card"></param>
        public void Install(Player p, Card card)
        {
            ParentCard = card;
            CardsMovement attachMove = new CardsMovement();
            attachMove.Cards = new List<Card>();
            attachMove.Cards.Add(card);
            attachMove.To = new DeckPlace(p, DeckType.Equipment);
            foreach (Card c in Game.CurrentGame.Decks[p, DeckType.Equipment])
            {
                if (CardCategoryManager.IsCardCategory(c.Type.Category, this.Category))
                {
                    Equipment e = (Equipment)c.Type;
                    Trace.Assert(e != null);
                    Game.CurrentGame.EnterAtomicContext();
                    Game.CurrentGame.PlayerLostCard(p, new List<Card>() { card });
                    Game.CurrentGame.HandleCardDiscard(p, new List<Card> () {c});
                    Game.CurrentGame.MoveCards(attachMove);
                    Game.CurrentGame.ExitAtomicContext();
                    return;
                }
            }

            Game.CurrentGame.MoveCards(attachMove);
            Game.CurrentGame.PlayerLostCard(p, new List<Card>() {card});
            return;
        }
Esempio n. 25
0
File: TuXi.cs Progetto: 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);
     }
 }
Esempio n. 26
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);
 }
Esempio n. 27
0
File: TuXi.cs Progetto: pxoylngx/sgs
 public override VerifierResult FastVerify(Player source, ISkill skill, List<Card> cards, List<Player> players)
 {
     if (skill != null || (cards != null && cards.Count != 0))
     {
         return VerifierResult.Fail;
     }
     if (players == null || players.Count == 0)
     {
         return VerifierResult.Partial;
     }
     foreach (Player p in players)
     {
         if (p == source)
         {
             return VerifierResult.Fail;
         }
         if (Game.CurrentGame.Decks[p, DeckType.Hand].Count == 0)
         {
             return VerifierResult.Fail;
         }
     }
     if (players.Count > 2)
     {
         return VerifierResult.Fail;
     }
     return VerifierResult.Success;
 }
Esempio n. 28
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);
 }
Esempio n. 29
0
        public List<Card> this[Player player, DeckType type]
        {
            get
            {
                if (player == null)
                {
                    player = GameAsPlayer.Instance;
                }
                if (!gameDecks.ContainsKey(player))
                {
                    gameDecks[player] = new Dictionary<DeckType, List<Card>>();
                }
                if (!gameDecks[player].ContainsKey(type))
                {
                    gameDecks[player][type] = new List<Card>();
                }
                return gameDecks[player][type];
            }

            set
            {
                if (player == null)
                {
                    player = GameAsPlayer.Instance;
                }
                if (!gameDecks.ContainsKey(player))
                {
                    gameDecks[player] = new Dictionary<DeckType, List<Card>>();
                }
                if (!gameDecks[player].ContainsKey(type))
                {
                    gameDecks[player][type] = value;
                }
            }
        }
Esempio n. 30
0
File: WeiDi.cs Progetto: maplegh/sgs
 protected override void UninstallTriggers(Player owner)
 {
     foreach (var sk in theSkill)
     {
         owner.LoseAdditionalSkill(sk);
     }
 }
Esempio n. 31
0
 protected override void InstallTriggers(Sanguosha.Core.Players.Player owner)
 {
     owner[Player.RangePlus]++;
 }