Пример #1
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;
 }
Пример #2
0
 protected bool AskForSkillUse(ICardUsageVerifier verifier, out List<Card> cards, out List<Player> players, Prompt prompt = null)
 {
     ISkill skill;
     if (prompt == null) prompt = new CardUsagePrompt(this.GetType().Name, this);
     var ret = Game.CurrentGame.UiProxies[Owner].AskForCardUsage(
             prompt, verifier, out skill, out cards, out players);
     Trace.Assert(skill == null);
     return ret;
 }
Пример #3
0
        protected void Run(Player owner, GameEvent gameEvent, GameEventArgs eventArgs)
        {
            List<Card> cards;
            List<Player> players;
            ISkill skill;
            int halfHC = Game.CurrentGame.Decks[owner, DeckType.Hand].Count / 2;

            int minHC = int.MaxValue;
            List<Player> minHCPlayers = new List<Player>();
            var alivePlayers = Game.CurrentGame.AlivePlayers;
            foreach (var pl in alivePlayers)
            {
                if (pl == owner) continue;
                int count = Game.CurrentGame.Decks[pl, DeckType.Hand].Count;
                if (count < minHC)
                {
                    minHC = count;
                    minHCPlayers.Clear();
                    minHCPlayers.Add(pl);
                }
                else if (count == minHC)
                {
                    minHCPlayers.Add(pl);
                }
            }

            Trace.Assert(minHCPlayers.Count > 0);
            CardUsagePrompt prompt;
            if (minHCPlayers.Count == 1) prompt = new CardUsagePrompt("HaoShi1", halfHC, minHCPlayers[0]);
            else prompt = new CardUsagePrompt("HaoShi", halfHC);

            if (!Game.CurrentGame.UiProxies[owner].AskForCardUsage(prompt, new HaoShiVerifier(halfHC, minHCPlayers), out skill, out cards, out players))
            {
                cards = new List<Card>();
                cards.AddRange(Game.CurrentGame.Decks[owner, DeckType.Hand].GetRange(0, halfHC));
                Player p = minHCPlayers[0];
                players = new List<Player>() { p };
            }
            Game.CurrentGame.HandleCardTransferToHand(owner, players[0], cards);
        }
Пример #4
0
 void Run(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
 {
     ISkill skill;
     List<Card> cards;
     List<Player> players;
     bool shensu1 = gameEvent == GameEvent.PhaseOutEvents[TurnPhase.Start];
     CardUsagePrompt shensu1Prompt = new CardUsagePrompt("ShenSu1", this);
     CardUsagePrompt shensu2Prompt = new CardUsagePrompt("ShenSu2", this);
     if (Owner.AskForCardUsage(shensu1 ? shensu1Prompt : shensu2Prompt, new ShenSuVerifier(shensu1, verifier), out skill, out cards, out players))
     {
         NotifySkillUse();
         if (!shensu1) Game.CurrentGame.HandleCardDiscard(Owner, cards);
         GameEventArgs args = new GameEventArgs();
         Owner[Sha.NumberOfShaUsed]--;
         args.Source = Owner;
         args.Targets = players;
         args.Skill = skill == null ? new CardWrapper(Owner, new RegularSha(), false) : skill;
         args.Cards = new List<Card>();
         CardTransformSkill transformSkill = skill as CardTransformSkill;
         if (transformSkill != null)
         {
             CompositeCard card;
             transformSkill.TryTransform(new List<Card>() { new Card() { Type = new RegularSha(), Place = new DeckPlace(null, DeckType.None) } }, null, out card);
             card.Subcards.Clear();
             args.Card = card;
         }
         Game.CurrentGame.Emit(GameEvent.CommitActionToTargets, args);
         if (shensu1)
         {
             Game.CurrentGame.PhasesSkipped.Add(TurnPhase.Judge);
             Game.CurrentGame.PhasesSkipped.Add(TurnPhase.Draw);
         }
         else Game.CurrentGame.PhasesSkipped.Add(TurnPhase.Play);
     }
 }
Пример #5
0
 public override void Run(GameEvent gameEvent, GameEventArgs eventArgs)
 {
     ReadOnlyCard card = eventArgs.ReadonlyCard;
     SingleCardUsageVerifier v1 = new SingleCardUsageVerifier((c) => { return c.Type is WuXieKeJi; }, true, new WuXieKeJi());
     List<Card> cards;
     List<Player> players;
     ISkill skill;
     Player responder;
     bool WuXieSuccess = false;
     Trace.Assert(eventArgs.Targets.Count == 1);
     Player promptPlayer = eventArgs.Targets[0];
     ICard promptCard = eventArgs.ReadonlyCard;
     if (card != null && CardCategoryManager.IsCardCategory(card.Type.Category, CardCategory.Tool) && card[WuXieKeJi.CannotBeCountered] == 0)
     {
         bool askWuXie = false;
         foreach (var p in Game.CurrentGame.AlivePlayers)
         {
             foreach (var c in Game.CurrentGame.Decks[p, DeckType.Hand])
             {
                 if (c.Type is WuXieKeJi)
                 {
                     askWuXie = true;
                     break;
                 }
             }
             foreach (var sk in p.ActionableSkills)
             {
                 CardTransformSkill cts = sk as CardTransformSkill;
                 if (cts != null)
                 {
                     if (cts.PossibleResults == null)
                     {
                         askWuXie = true;
                         break;
                     }
                     foreach (var pr in cts.PossibleResults)
                     {
                         if (pr is WuXieKeJi)
                         {
                             askWuXie = true;
                             break;
                         }
                     }
                 }
             }
             if (askWuXie) break;
         }
         Game.CurrentGame.SyncConfirmationStatus(ref askWuXie);
         if (!askWuXie) return;
         while (true)
         {
             Prompt prompt = new CardUsagePrompt("WuXieKeJi", promptPlayer, promptCard);
             if (Game.CurrentGame.GlobalProxy.AskForCardUsage(
                 prompt, v1, out skill, out cards, out players, out responder))
             {
                 try
                 {
                     GameEventArgs args = new GameEventArgs();
                     args.Source = responder;
                     args.Targets = players;
                     args.Skill = skill;
                     args.Cards = cards;
                     Game.CurrentGame.Emit(GameEvent.CommitActionToTargets, args);
                 }
                 catch (TriggerResultException e)
                 {
                     Trace.Assert(e.Status == TriggerResult.Retry);
                     continue;
                 }
                 promptPlayer = responder;
                 promptCard = new CompositeCard();
                 promptCard.Type = new WuXieKeJi();
                 (promptCard as CompositeCard).Subcards = null;
                 WuXieSuccess = !WuXieSuccess;
             }
             else
             {
                 break;
             }
         }
     }
     if (WuXieSuccess)
     {
         throw new TriggerResultException(TriggerResult.End);
     }
 }
Пример #6
0
 protected override void Process(Player source, Player dest, ICard card, ReadOnlyCard readonlyCard)
 {
     Player current = dest;
     bool firstTime = true;
     while (true)
     {
         List<Player> sourceList = new List<Player>();
         if (current == dest)
         {
             sourceList.Add(source);
         }
         else
         {
             sourceList.Add(dest);
         }
         IUiProxy ui = Game.CurrentGame.UiProxies[current];
         SingleCardUsageVerifier v1 = new SingleCardUsageVerifier((c) => { return c.Type is Sha; }, false);
         ISkill skill;
         List<Player> p;
         List<Card> cards;
         CardUsagePrompt prompt;
         if (current.IsDead) return;
         if (firstTime)
         {
             prompt = new CardUsagePrompt("JueDou", source);;
         }
         else
         {
             prompt = new CardUsagePrompt("JueDou2", current == dest ? source : dest);
             firstTime = false;
         }
         int numberOfShaRequired = current == dest ? readonlyCard[CardAttribute.TargetRequireTwoResponses] + 1 : readonlyCard[CardAttribute.SourceRequireTwoResponses] + 1;
         bool cannotProvideSha = false;
         while (numberOfShaRequired > 0)
         {
             if (!ui.AskForCardUsage(prompt, v1, out skill, out cards, out p))
             {
                 Trace.TraceInformation("Player {0} Invalid answer", current);
                 cannotProvideSha = true;
                 break;
             }
             if (!Game.CurrentGame.HandleCardPlay(current, skill, cards, sourceList))
             {
                 continue;
             }
             numberOfShaRequired--;
         }
         if (cannotProvideSha) break;
         Trace.TraceInformation("Player {0} SHA, ", current.Id);
         if (current == dest)
         {
             current = source;
         }
         else
         {
             current = dest;
         }
     }
     Player won = current == dest ? source : dest;
     Game.CurrentGame.DoDamage(won, current, 1, DamageElement.None, card, readonlyCard);
 }