Example #1
0
    public override int AIInHandExpectation(PGame Game, PPlayer Player)
    {
        PCard Current = Player.GetEquipment(Type);
        int   Exp     = AIInEquipExpectation(Game, Player);
        int   Base    = 0;
        int   Basic   = 0;

        if (Player.General is P_HuaXiong)
        {
            Base += 1000;
        }
        if (Player.General is P_TangYin)
        {
            Base += 500;
        }
        if (Player.General is P_HuaMulan)
        {
            Base += 3500;
        }
        if (Player.General is P_LvMeng)
        {
            Base += 1000;
        }
        if (Current != null && Exp <= Current.Model.AIInEquipExpectation(Game, Player))
        {
            Basic = 500 + Base;
        }
        else
        {
            Basic = Exp + Base;
        }
        return(Math.Max(Basic, base.AIInHandExpectation(Game, Player)));
    }
Example #2
0
 private KeyValuePair <PCard, int> TeammateValueCard(PGame Game, PPlayer Player, PPlayer _Player)
 {
     return(PMath.Max(Player.Area.HandCardArea.CardList.FindAll((PCard Card) => Card.Type.IsEquipment()), (PCard Card) => {
         int New = Card.Model.AIInEquipExpectation(Game, _Player);
         PCard CurrentEquip = _Player.GetEquipment(Card.Type);
         int Current = CurrentEquip == null ? 0 : CurrentEquip.Model.AIInEquipExpectation(Game, _Player);
         int Delta = (_Player.Area.EquipmentCardArea.CardNumber + (CurrentEquip == null ? 1 : 0)) * 500;
         return New - Current + PAiTargetChooser.InjureExpect(Game, Player, Player, _Player, Delta, Instantiate())
         + Math.Max(0, PAiCardExpectation.FindMostValuableToGet(Game, Player, _Player).Value);
     }));
 }
Example #3
0
    private PCard ChooseCard(PPlayer Player, PPlayer TargetPlayer, string Title, bool AllowHandCards = true, bool AllowEquipment = true, bool AllowAmbush = false, bool IsGet = false)
    {
        PCard TargetCard = null;

        if (Player.IsUser)
        {
            if (Player.Equals(TargetPlayer))
            {
                TargetCard = PNetworkManager.NetworkServer.ChooseManager.AskToChooseOwnCard(Player, Title, AllowHandCards, AllowEquipment, AllowAmbush);
            }
            else
            {
                if (!AllowEquipment)
                {
                    if (AllowHandCards)
                    {
                        TargetCard = TargetPlayer.Area.HandCardArea.RandomCard();
                    }
                }
                else
                {
                    TargetCard = PNetworkManager.NetworkServer.ChooseManager.AskToChooseOthersCard(Player, TargetPlayer, Title, AllowHandCards, AllowAmbush);
                }
            }
        }
        else
        {
            if (IsGet)
            {
                if (!Player.Age.Equals(TargetPlayer.Age) && TargetPlayer.HasEquipment <P_HsiYooYangToow>() && AllowEquipment)
                {
                    TargetCard = TargetPlayer.GetEquipment(PCardType.TrafficCard);
                }
                else
                {
                    TargetCard = PAiCardExpectation.FindMostValuableToGet(this, Player, TargetPlayer, AllowHandCards, AllowEquipment, AllowAmbush, Player.Equals(TargetPlayer)).Key;
                }
            }
            else
            {
                if (Player.TeamIndex == TargetPlayer.TeamIndex)
                {
                    TargetCard = PAiCardExpectation.FindLeastValuable(this, Player, TargetPlayer, AllowHandCards, AllowEquipment, AllowAmbush, Player.Equals(TargetPlayer)).Key;
                }
                else
                {
                    TargetCard = PAiCardExpectation.FindMostValuable(this, Player, TargetPlayer, AllowHandCards, AllowEquipment, AllowAmbush).Key;
                }
            }
        }
        return(TargetCard);
    }
Example #4
0
    public static KeyValuePair <PCard, int> EquipToThrow(PGame Game, PPlayer Player)
    {
        Dictionary <PCard, int> Dict = new Dictionary <PCard, int>();
        PCard Answer      = null;
        int   AnswerValue = -1;

        foreach (PCardType CardType in new PCardType[] {
            PCardType.WeaponCard, PCardType.DefensorCard, PCardType.TrafficCard
        })
        {
            PCard CurrentCard = Player.GetEquipment(CardType);
            if (CurrentCard != null)
            {
                List <PCard> AvailableCardList = Player.Area.HandCardArea.CardList.FindAll((PCard _Card) => _Card.Type.Equals(CardType));
                if (AvailableCardList.Count > 0)
                {
                    KeyValuePair <PCard, int> MinCard = PMath.Min(AvailableCardList, (PCard _Card) => _Card.Model.AIInEquipExpectation(Game, Player));
                    KeyValuePair <PCard, int> MaxCard = PMath.Max(AvailableCardList, (PCard _Card) => _Card.Model.AIInEquipExpectation(Game, Player));
                    int CurrentValue = CurrentCard.Model.AIInEquipExpectation(Game, Player);
                    if (CurrentValue > MinCard.Value)
                    {
                        Dict.Add(MinCard.Key, 0);
                    }
                    if (CurrentValue < MaxCard.Value)
                    {
                        Dict.Add(CurrentCard, MaxCard.Value - CurrentValue);
                    }
                }
            }
        }
        foreach (KeyValuePair <PCard, int> Record in Dict)
        {
            if (Record.Value > AnswerValue)
            {
                AnswerValue = Record.Value;
                Answer      = Record.Key;
            }
        }
        return(new KeyValuePair <PCard, int>(Answer, AnswerValue));
    }
Example #5
0
    public P_TangYin() : base("唐寅")
    {
        Sex   = PSex.Male;
        Age   = PAge.Industrial;
        Index = 20;
        Cost  = 25;
        Tips  = "定位:攻击\n" +
                "难度:简单\n" +
                "史实:明代画家、书法家、诗人,“明四家”和“吴中四才子”之一。以风流之名传于世,后代有“唐伯虎点秋香”等传说。\n" +
                "攻略:\n唐寅是一个上手简单的攻击型武将,并且具有一定的防御能力。【风流】作为主要输出技能,能够保持前期的经济压制和后期的装备压制,并可通过伤害类计策触发,因此【浑水摸鱼】【关门捉贼】等牌都是关键牌。【浪子】作为防御技能,能够在后期积累了一定装备的基础上避开关键区域,防止崩盘,因此唐寅对装备牌的需求也较大。唐寅可通过对队友造成伤害以获得装备;反之,【风流】的输出也会受到装备的限制,对手可以通过给唐寅没用的装备,替换唐寅原本的装备,降低【风流】的收益甚至令其变为负收益。";

        PSkill LangZi = new PSkill("浪子");

        SkillList.Add(LangZi
                      .AddTimeTrigger(
                          new PTime[] {
            PPeriod.DiceStage.Start
        },
                          (PTime Time, PPlayer Player, PSkill Skill) => {
            return(new PTrigger(LangZi.Name)
            {
                IsLocked = false,
                Player = Player,
                Time = Time,
                AIPriority = 10,
                Condition = (PGame Game) => {
                    return Player.Equals(Game.NowPlayer) &&
                    Player.HasEquipInArea();
                },
                AICondition = (PGame Game) => {
                    KeyValuePair <PCard, int> CardValue = PAiCardExpectation.EquipToThrow(Game, Player);
                    KeyValuePair <int, int> SkillValue = LangZiBannedNumber(Game, Player);
                    return CardValue.Key != null && SkillValue.Key > 0 && SkillValue.Value >= 100 && SkillValue.Value + CardValue.Value >= 300;
                },
                Effect = (PGame Game) => {
                    LangZi.AnnouceUseSkill(Player);
                    PCard TargetCard = null;
                    if (Player.IsAI)
                    {
                        TargetCard = PAiCardExpectation.EquipToThrow(Game, Player).Key;
                    }
                    else
                    {
                        do
                        {
                            TargetCard = PNetworkManager.NetworkServer.ChooseManager.AskToChooseOwnCard(Player, LangZi.Name + "[选择一张装备牌]", true, true);
                        } while (!TargetCard.Type.IsEquipment());
                    }
                    if (TargetCard != null)
                    {
                        int BannedNumber = 0;
                        if (Player.IsAI)
                        {
                            BannedNumber = LangZiBannedNumber(Game, Player).Key;
                        }
                        else
                        {
                            BannedNumber = PNetworkManager.NetworkServer.ChooseManager.Ask1To6(Player, LangZi.Name + "[选择不会被掷出的数字]");
                        }
                        if (BannedNumber > 0)
                        {
                            Game.CardManager.MoveCard(TargetCard, Player.Area.HandCardArea.CardList.Contains(TargetCard) ? Player.Area.HandCardArea : Player.Area.EquipmentCardArea, Game.CardManager.ThrownCardHeap);
                            Player.Tags.CreateTag(new PNumberedTag(LangZi.Name, BannedNumber));
                        }
                    }
                }
            });
        })
                      .AddTrigger((PPlayer Player, PSkill Skill) => {
            return(new PTrigger(LangZi.Name + "[掷骰无效触发]")
            {
                IsLocked = true,
                Player = Player,
                Time = PPeriod.DiceStage.During,
                Condition = (PGame Game) => {
                    return Player.Equals(Game.NowPlayer) && Player.Tags.ExistTag(LangZi.Name);
                },
                Effect = (PGame Game) => {
                    int BannedNumber = Player.Tags.PopTag <PNumberedTag>(LangZi.Name).Value;
                    PDiceResultTag DiceResult = Game.TagManager.FindPeekTag <PDiceResultTag>(PDiceResultTag.TagName);
                    if (BannedNumber == DiceResult.DiceResult)
                    {
                        LangZi.AnnouceUseSkill(Player);
                        int NewNumber = BannedNumber;
                        while (NewNumber == BannedNumber)
                        {
                            NewNumber = PMath.RandInt(1, 6);
                        }
                        PNetworkManager.NetworkServer.TellClients(new PShowInformationOrder("掷骰结果更改为" + NewNumber.ToString()));
                        DiceResult.DiceResult = NewNumber;
                    }
                }
            });
        })
                      );
        PSkill    FengLiu       = new PSkill("风流");
        const int FengLiuInjure = 600;

        SkillList.Add(FengLiu
                      .AddTimeTrigger(
                          new PTime[] {
            PTime.Injure.EmitInjure
        },
                          (PTime Time, PPlayer Player, PSkill Skill) => {
            return(new PTrigger(FengLiu.Name)
            {
                IsLocked = false,
                Player = Player,
                Time = Time,
                AIPriority = 150,
                Condition = (PGame Game) => {
                    PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
                    return InjureTag.Injure > 0 && Player.Equals(InjureTag.FromPlayer) && InjureTag.ToPlayer != null && !Player.Equals(InjureTag.ToPlayer);
                },
                AICondition = (PGame Game) => {
                    PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
                    PPlayer ToPlayer = InjureTag.ToPlayer;
                    if (ToPlayer.TeamIndex == Player.TeamIndex)
                    {
                        if (ToPlayer.Money > FengLiuInjure + InjureTag.Injure && ToPlayer.Money > Player.Money)
                        {
                            return true;
                        }
                        else if (ToPlayer.Money <= InjureTag.Injure)
                        {
                            return true;
                        }
                        else if (ToPlayer.Area.EquipmentCardArea.CardNumber == 0)
                        {
                            return false;
                        }
                    }
                    foreach (PCardType CardType in new PCardType[] {
                        PCardType.WeaponCard, PCardType.DefensorCard, PCardType.TrafficCard
                    })
                    {
                        PCard CurrentCard = Player.GetEquipment(CardType);
                        PCard TestCard = ToPlayer.GetEquipment(CardType);
                        if (ToPlayer.TeamIndex == Player.TeamIndex)
                        {
                            if (CurrentCard == null && TestCard != null && TestCard.Model.AIInEquipExpectation(Game, Player) > TestCard.Model.AIInEquipExpectation(Game, ToPlayer))
                            {
                                return true;
                            }
                        }
                        else if (CurrentCard != null && TestCard != null && CurrentCard.Model.AIInEquipExpectation(Game, Player) >= TestCard.Model.AIInEquipExpectation(Game, Player) + TestCard.Model.AIInEquipExpectation(Game, ToPlayer))
                        {
                            return false;
                        }
                    }
                    return ToPlayer.TeamIndex != Player.TeamIndex;
                },
                Effect = (PGame Game) => {
                    FengLiu.AnnouceUseSkill(Player);
                    PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
                    PPlayer ToPlayer = InjureTag.ToPlayer;
                    int Answer = 0;
                    PCard TargetCard = null;
                    if (ToPlayer.Area.EquipmentCardArea.CardNumber == 0)
                    {
                        Answer = 1;
                    }
                    else
                    {
                        if (ToPlayer.IsAI)
                        {
                            if (ToPlayer.TeamIndex == Player.TeamIndex)
                            {
                                if (ToPlayer.Money <= InjureTag.Injure)
                                {
                                    Answer = 1;
                                }
                                else if (PAiCardExpectation.FindMostValuable(Game, Player, ToPlayer, false, true, false, true).Value > 0)
                                {
                                    Answer = 1;
                                }
                            }
                            else
                            {
                                int Value = FengLiuInjure * 2;
                                if (ToPlayer.Money <= InjureTag.Injure)
                                {
                                    Value -= FengLiuInjure;
                                }
                                else if (ToPlayer.Money <= InjureTag.Injure + FengLiuInjure)
                                {
                                    Value += 30000;
                                }

                                foreach (PCard TestCard in ToPlayer.Area.EquipmentCardArea.CardList)
                                {
                                    int NowValue = TestCard.Model.AIInEquipExpectation(Game, ToPlayer);
                                    int GiveValue = TestCard.Model.AIInEquipExpectation(Game, Player);
                                    int OverrideValue = 0;
                                    if (Player.GetEquipment(TestCard.Type) != null)
                                    {
                                        OverrideValue = Player.GetEquipment(TestCard.Type).Model.AIInEquipExpectation(Game, Player);
                                    }
                                    int ExtraValue = ToPlayer.General is P_HuaMulan ? 3500 : 0;
                                    if (Value > NowValue + GiveValue - OverrideValue - ExtraValue)
                                    {
                                        Value = NowValue + GiveValue - OverrideValue - ExtraValue;
                                        TargetCard = TestCard;
                                    }
                                }
                                if (TargetCard == null)
                                {
                                    Answer = 1;
                                }
                            }
                        }
                        else
                        {
                            Answer = PNetworkManager.NetworkServer.ChooseManager.Ask(ToPlayer, FengLiu.Name, new string[] { "交给" + Player.Name + "一件装备", "受到的伤害+" + FengLiuInjure.ToString() });
                        }
                    }
                    if (Answer == 0)
                    {
                        Game.GiveCardTo(ToPlayer, Player, false, true, false, true);
                    }
                    else
                    {
                        InjureTag.Injure += FengLiuInjure;
                    }
                }
            });
        })
                      );
    }