Exemplo n.º 1
0
        public override VerifierResult TryTransform(List <Card> cards, List <Player> arg, out CompositeCard card, bool isPlay)
        {
            card          = new CompositeCard();
            card.Subcards = new List <Card>();
            card.Type     = AdditionalType;
            card[TieSuoLianHuan.ProhibitReforging] = 1;
            if (AdditionalType == null)
            {
                return(VerifierResult.Partial);
            }
            if (!CardCategoryManager.IsCardCategory(AdditionalType.Category, CardCategory.Basic) &&
                !CardCategoryManager.IsCardCategory(AdditionalType.Category, CardCategory.ImmediateTool))
            {
                return(VerifierResult.Fail);
            }
            if (cards == null || cards.Count == 0)
            {
                return(VerifierResult.Partial);
            }
            if (cards != null && cards.Count != 1)
            {
                return(VerifierResult.Fail);
            }
            if (cards[0].Place.DeckType != DeckType.Hand)
            {
                return(VerifierResult.Fail);
            }

            card.Subcards.Add(cards[0]);
            return(VerifierResult.Success);
        }
Exemplo n.º 2
0
        public WeiMu()
        {
            Triggers.Add(GameEvent.PlayerCanBeTargeted, new RelayTrigger(
                             (p, e, a) =>
            {
                return(CardCategoryManager.IsCardCategory(a.Card.Type.Category, CardCategory.Tool) && a.Card.SuitColor == SuitColorType.Black);
            },
                             (p, e, a) =>
            {
                if (a.Card.Place.DeckType == DeckType.DelayedTools)
                {
                    NotifySkillUse();
                }
                throw new TriggerResultException(TriggerResult.Fail);
            },
                             TriggerCondition.OwnerIsTarget
                             ));

            var notify = new AutoNotifyPassiveSkillTrigger(
                this,
                (p, e, a) => { return(a.Source != p && a.ReadonlyCard.Type is Aoe && a.ReadonlyCard.SuitColor == SuitColorType.Black); },
                (p, e, a) => { },
                TriggerCondition.Global
                );

            Triggers.Add(GameEvent.PlayerUsedCard, notify);
            IsEnforced = true;
        }
Exemplo n.º 3
0
        void CardUseStopper(Player Owner, GameEvent gameEvent, GameEventArgs eventArgs)
        {
            bool hasBasic     = false;
            bool hasTool      = false;
            bool hasEquipment = false;

            foreach (var card in Game.CurrentGame.Decks[Owner, ZuiXiangDeck])
            {
                if (CardCategoryManager.IsCardCategory(card.Type.Category, CardCategory.Basic))
                {
                    hasBasic = true;
                }
                if (CardCategoryManager.IsCardCategory(card.Type.Category, CardCategory.Tool))
                {
                    hasTool = true;
                }
                if (card.Type.IsCardCategory(CardCategory.Equipment))
                {
                    hasEquipment = true;
                }
            }
            if (CardCategoryManager.IsCardCategory(eventArgs.Card.Type.Category, CardCategory.Basic) && hasBasic)
            {
                throw new TriggerResultException(TriggerResult.Fail);
            }
            if (CardCategoryManager.IsCardCategory(eventArgs.Card.Type.Category, CardCategory.Tool) && hasTool)
            {
                throw new TriggerResultException(TriggerResult.Fail);
            }
            if (eventArgs.Card.Type.IsCardCategory(CardCategory.Equipment) && hasEquipment)
            {
                throw new TriggerResultException(TriggerResult.Fail);
            }
        }
Exemplo n.º 4
0
            public VerifierResult Verify(List <List <Card> > answer)
            {
                if ((answer != null && answer.Count > 1) || (answer != null && answer[0] != null && answer[0].Count > 1))
                {
                    return(VerifierResult.Fail);
                }
                if (answer == null || answer.Count == 0 || answer[0] == null || answer[0].Count == 0)
                {
                    return(VerifierResult.Partial);
                }
                Card theCard = answer[0][0];

                if (theCard.Place.DeckType == DeckType.DelayedTools)
                {
                    Player toCheck;
                    if (theCard.Place.Player == source)
                    {
                        toCheck = dest;
                    }
                    else
                    {
                        toCheck = source;
                    }
                    if (!Game.CurrentGame.PlayerCanBeTargeted(null, new List <Player>()
                    {
                        toCheck
                    }, theCard))
                    {
                        return(VerifierResult.Fail);
                    }
                    if ((theCard.Type as DelayedTool).DelayedToolConflicting(toCheck))
                    {
                        return(VerifierResult.Fail);
                    }
                }
                if (theCard.Place.DeckType == DeckType.Equipment)
                {
                    Player toCheck;
                    if (theCard.Place.Player == source)
                    {
                        toCheck = dest;
                    }
                    else
                    {
                        toCheck = source;
                    }
                    foreach (var c in Game.CurrentGame.Decks[toCheck, DeckType.Equipment])
                    {
                        if (CardCategoryManager.IsCardCategory(c.Type.Category, theCard.Type.Category))
                        {
                            return(VerifierResult.Fail);
                        }
                    }
                }
                return(VerifierResult.Success);
            }
Exemplo n.º 5
0
        public QiCai()
        {
            var trigger = new AutoNotifyPassiveSkillTrigger(
                this,
                (p, e, a) => { return(CardCategoryManager.IsCardCategory(a.Card.Type.Category, CardCategory.Tool)); },
                (p, e, a) => { (a as AdjustmentEventArgs).AdjustmentAmount += 500; },
                TriggerCondition.OwnerIsSource
                )
            {
                IsAutoNotify = false
            };

            Triggers.Add(GameEvent.CardRangeModifier, trigger);
            IsEnforced = true;
        }
Exemplo n.º 6
0
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item == null)
            {
                return(base.SelectTemplate(item, container));
            }

            CardViewModel viewModel = item as CardViewModel;

            if (viewModel == null)
            {
                Trace.TraceWarning("Trying to apply card tooltip template on an object that is not CardViewModel");
            }
            else if (viewModel.Card != null)
            {
                if (CardCategoryManager.IsCardCategory(viewModel.Category, CardCategory.Weapon))
                {
                    return(WeaponToolTipTemplate);
                }
                else if (CardCategoryManager.IsCardCategory(viewModel.Category, CardCategory.Armor))
                {
                    return(ArmorToolTipTemplate);
                }
                else if (CardCategoryManager.IsCardCategory(viewModel.Category, CardCategory.DefensiveHorse))
                {
                    return(DefensiveHorseToolTipTemplate);
                }
                else if (CardCategoryManager.IsCardCategory(viewModel.Category, CardCategory.OffensiveHorse))
                {
                    return(OffensiveHorseToolTipTemplate);
                }
                else if (CardCategoryManager.IsCardCategory(viewModel.Category, CardCategory.Hero))
                {
                    return(HeroToolTipTemplate);
                }
                else
                {
                    return(BasicCardToolTipTemplate);
                }
            }

            return(base.SelectTemplate(item, container));
        }
Exemplo n.º 7
0
        public WuMou()
        {
            var trigger = new AutoNotifyPassiveSkillTrigger(
                this,
                (p, e, a) => { return(CardCategoryManager.IsCardCategory(a.Card.Type.Category, CardCategory.ImmediateTool)); },
                (p, e, a) =>
            {
                if (Owner[KuangBao.BaoNuMark] == 0)
                {
                    Game.CurrentGame.LoseHealth(Owner, 1);
                }
                else
                {
                    int answer = 0;
                    Owner.AskForMultipleChoice(
                        new MultipleChoicePrompt("WuMou"),
                        new List <OptionPrompt>()
                    {
                        new OptionPrompt("WuMouMark"), new OptionPrompt("WuMouHealth")
                    },
                        out answer);
                    if (answer == 0)
                    {
                        Owner[KuangBao.BaoNuMark]--;
                    }
                    else
                    {
                        Game.CurrentGame.LoseHealth(Owner, 1);
                    }
                }
            },
                TriggerCondition.OwnerIsSource
                )
            {
                Type = TriggerType.Skill
            };

            Triggers.Add(GameEvent.PlayerUsedCard, trigger);
            IsEnforced = true;
        }
Exemplo n.º 8
0
        public override VerifierResult TryTransform(List <Card> cards, List <Player> arg, out CompositeCard card, bool isPlay)
        {
            card          = new CompositeCard();
            card.Subcards = new List <Card>();
            card.Type     = AdditionalType;
            card[TieSuoLianHuan.ProhibitReforging] = 1;
            if (Owner[QiCeUsed] == 1)
            {
                return(VerifierResult.Fail);
            }
            if (Game.CurrentGame.CurrentPhase != TurnPhase.Play)
            {
                return(VerifierResult.Fail);
            }
            if (Game.CurrentGame.CurrentPlayer != Owner)
            {
                return(VerifierResult.Fail);
            }
            if (Owner.HandCards().Count == 0)
            {
                return(VerifierResult.Fail);
            }
            if (AdditionalType == null)
            {
                return(VerifierResult.Partial);
            }
            if (!CardCategoryManager.IsCardCategory(AdditionalType.Category, CardCategory.ImmediateTool) || AdditionalType is WuXieKeJi)
            {
                return(VerifierResult.Fail);
            }
            if (cards != null && cards.Count > 0)
            {
                return(VerifierResult.Fail);
            }

            card.Subcards.AddRange(Owner.HandCards());
            return(VerifierResult.Success);
        }
Exemplo n.º 9
0
            public override void Run(GameEvent gameEvent, GameEventArgs eventArgs)
            {
                if (eventArgs.Source != Owner)
                {
                    return;
                }
                List <Card> toExamine = new List <Card>();

                if (eventArgs.Card is Card)
                {
                    toExamine.Add(eventArgs.Card as Card);
                }
                if (eventArgs.Card is CompositeCard)
                {
                    if ((eventArgs.Card as CompositeCard).Subcards != null)
                    {
                        toExamine.AddRange((eventArgs.Card as CompositeCard).Subcards);
                    }
                }
                foreach (Card c in toExamine)
                {
                    if (c.Place.DeckType == DeckType.Hand)
                    {
                        if (CardCategoryManager.IsCardCategory(eventArgs.Card.Type.Category, CardCategory.Basic) && type == 0)
                        {
                            throw new TriggerResultException(TriggerResult.Fail);
                        }
                        if (CardCategoryManager.IsCardCategory(eventArgs.Card.Type.Category, CardCategory.Tool) && type == 1)
                        {
                            throw new TriggerResultException(TriggerResult.Fail);
                        }
                        if (CardCategoryManager.IsCardCategory(eventArgs.Card.Type.Category, CardCategory.Equipment) && type == 2)
                        {
                            throw new TriggerResultException(TriggerResult.Fail);
                        }
                    }
                }
            }
Exemplo n.º 10
0
        /// <summary>
        /// Transform a set of cards.
        /// </summary>
        /// <param name="cards">Cards to be transformed.</param>
        /// <param name="arg">Additional args to help the transformation.</param>
        /// <returns>False if transform is aborted.</returns>
        /// <exception cref="CardTransformFailureException"></exception>
        public bool Transform(List <Card> cards, object arg, out CompositeCard card, List <Player> targets, bool isPlay = false)
        {
            if (TryTransform(cards, targets, out card, isPlay) != VerifierResult.Success)
            {
                throw new CardTransformFailureException();
            }
            NotifyAction(Owner, targets, card);
            bool ret = DoTransformSideEffect(card, arg, targets, isPlay);

            if (ret)
            {
                card.Owner = Owner;
                foreach (Card c in card.Subcards)
                {
                    if (c.Place.Player != null && c.Place.DeckType == DeckType.Equipment && CardCategoryManager.IsCardCategory(c.Type.Category, CardCategory.Equipment))
                    {
                        Equipment e = c.Type as Equipment;
                        e.UnregisterTriggers(c.Place.Player);
                    }
                    c.Type = card.Type;
                }
            }
            return(ret);
        }
Exemplo n.º 11
0
 public BaiYinJiZhi()
 {
     Triggers.Add(GameEvent.PlayerUsedCard, new AutoNotifyPassiveSkillTrigger(this,
                                                                              (p, e, a) => { return(p[RenJie.RenMark] > 0 && CardCategoryManager.IsCardCategory(a.Card.Type.Category, CardCategory.ImmediateTool)); },
                                                                              (p, e, a) => { p[RenJie.RenMark]--;  Game.CurrentGame.DrawCards(p, 1); },
                                                                              TriggerCondition.OwnerIsSource
                                                                              ));
 }
Exemplo n.º 12
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());

            v1.Helper.ExtraTimeOutSeconds = -9;
            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 && card[WuXieKeJi.CannotBeCountered[promptPlayer]] == 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;
                }
                foreach (var p in Game.CurrentGame.AlivePlayers)
                {
                    Game.CurrentGame.Emit(GameEvent.PlayerIsAboutToPlayCard, new PlayerIsAboutToUseOrPlayCardEventArgs()
                    {
                        Source = p, Verifier = v1
                    });
                }
                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);
            }
        }
Exemplo n.º 13
0
 protected override bool?AdditionalVerify(Player source, List <Card> cards, List <Player> players)
 {
     if (cards != null && cards.Count > 0)
     {
         if (players != null && players.Count > 0)
         {
             if (Game.CurrentGame.Decks[players[0], DeckType.Equipment].Any(cd => CardCategoryManager.IsCardCategory(cd.Type.Category, cards[0].Type.Category)))
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Exemplo n.º 14
0
 protected override bool VerifyCard(Player source, Card card)
 {
     return(card.Place.DeckType == DeckType.Hand && CardCategoryManager.IsCardCategory(card.Type.Category, CardCategory.Equipment));
 }
Exemplo n.º 15
0
 public override bool VerifyInput(Card card, object arg)
 {
     return(card.SuitColor == SuitColorType.Black && (CardCategoryManager.IsCardCategory(card.Type.Category, CardCategory.Basic) || CardCategoryManager.IsCardCategory(card.Type.Category, CardCategory.Equipment)));
 }
Exemplo n.º 16
0
 public JiZhi()
 {
     Triggers.Add(GameEvent.PlayerUsedCard, new AutoNotifyPassiveSkillTrigger(this,
                                                                              (p, e, a) => { return(CardCategoryManager.IsCardCategory(a.Card.Type.Category, CardCategory.ImmediateTool)); },
                                                                              (p, e, a) => { Game.CurrentGame.DrawCards(p, 1); },
                                                                              TriggerCondition.OwnerIsSource
                                                                              )
     {
         Type = TriggerType.Skill
     });
     IsAutoInvoked = true;
 }
Exemplo n.º 17
0
 protected override bool VerifyCard(Player source, Card card)
 {
     return(CardCategoryManager.IsCardCategory(card.Type.Category, CardCategory.Basic));
 }