Ejemplo n.º 1
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);
    }
Ejemplo n.º 2
0
    public void GiveCardTo(PPlayer Player, PPlayer TargetPlayer, bool AllowHandCards = true, bool AllowEquipment = true, bool AllowJudge = false, bool Directly = false)
    {
        string Title = "请选择给出一张" + (AllowHandCards ? "[手牌]" : string.Empty) + (AllowEquipment ? "[装备]" : string.Empty) + (AllowJudge ? "[伏兵]" : string.Empty);
        PCard  Card  = null;

        if (Player.IsAI)
        {
            if (Player.TeamIndex == TargetPlayer.TeamIndex)
            {
                Card = PAiCardExpectation.FindMostValuable(this, TargetPlayer, Player, AllowHandCards, AllowEquipment, AllowJudge, true).Key;
            }
            else
            {
                Card = PAiCardExpectation.FindLeastValuable(this, TargetPlayer, Player, AllowHandCards, AllowEquipment, AllowJudge, true).Key;
            }
        }
        else
        {
            Card = PNetworkManager.NetworkServer.ChooseManager.AskToChooseOwnCard(Player, Title, AllowHandCards, AllowEquipment, AllowJudge);
        }
        if (Card != null)
        {
            PNetworkManager.NetworkServer.TellClients(new PShowInformationOrder(Player.Name + "交给了" + TargetPlayer.Name + (Player.Area.HandCardArea.CardList.Contains(Card) ? "1张手牌" : Card.Name)));
            if (Player.Area.HandCardArea.CardList.Contains(Card))
            {
                CardManager.MoveCard(Card, Player.Area.HandCardArea, TargetPlayer.Area.HandCardArea);
            }
            else if (Player.Area.EquipmentCardArea.CardList.Contains(Card))
            {
                if (Directly)
                {
                    CardManager.MoveCard(Card, Player.Area.EquipmentCardArea, TargetPlayer.Area.EquipmentCardArea);
                }
                else
                {
                    CardManager.MoveCard(Card, Player.Area.EquipmentCardArea, TargetPlayer.Area.HandCardArea);
                }
            }
            else if (Player.Area.AmbushCardArea.CardList.Contains(Card))
            {
                CardManager.MoveCard(Card, Player.Area.AmbushCardArea, TargetPlayer.Area.HandCardArea);
            }
        }
    }
Ejemplo n.º 3
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;
                    }
                }
            });
        })
                      );
    }
Ejemplo n.º 4
0
 public P_ChiehTaoShaJevn() : base(CardName)
 {
     Point = 1;
     Index = 3;
     foreach (PTime Time in new PTime[] {
         PPeriod.FirstFreeTime.During,
         PPeriod.SecondFreeTime.During
     })
     {
         MoveInHandTriggerList.Add((PPlayer Player, PCard Card) => {
             return(new PTrigger(CardName)
             {
                 IsLocked = false,
                 Player = Player,
                 Time = Time,
                 AIPriority = 110,
                 Condition = (PGame Game) => {
                     return Player.Equals(Game.NowPlayer) && (Player.IsAI || Game.Logic.WaitingForEndFreeTime()) && Game.PlayerList.Exists((PPlayer _Player ) => !_Player.Equals(Player) && _Player.Area.EquipmentCardArea.CardNumber > 0);
                 },
                 AICondition = (PGame Game) => {
                     return AIEmitTargets(Game, Player)[0] != null;
                 },
                 Effect = MakeNormalEffect(Player, Card, AIEmitTargets, (PGame Game, PPlayer _Player) => {
                     return !_Player.Equals(Player) && _Player.Area.EquipmentCardArea.CardNumber > 0;
                 },
                                           (PGame Game, PPlayer User, PPlayer Target) => {
                     int ChosenResult = -1;
                     if (!Target.HasHouse || User.LandNumber == 0)
                     {
                         if (Target.Area.EquipmentCardArea.CardNumber > 0)
                         {
                             ChosenResult = 1;
                         }
                     }
                     else if (Target.Area.EquipmentCardArea.CardNumber == 0)
                     {
                         ChosenResult = 0;
                     }
                     else
                     {
                         if (Target.IsAI)
                         {
                             ChosenResult = PAiMapAnalyzer.MaxValueHouse(Game, Target).Value > PAiCardExpectation.FindMostValuable(Game, Target, Target, false).Value ? 1 : 0;
                         }
                         else
                         {
                             ChosenResult = PNetworkManager.NetworkServer.ChooseManager.Ask(Target, CardName + "-选择一项", new string[] {
                                 "令" + User.Name + "获得你1座房屋",
                                 "令" + User.Name + "获得你1张装备"
                             });
                         }
                     }
                     if (ChosenResult == 0)
                     {
                         PBlock TargetBlock = null;
                         if (User.IsAI)
                         {
                             TargetBlock = PAiMapAnalyzer.MaxValueHouse(Game, Target).Key;
                         }
                         else
                         {
                             TargetBlock = PNetworkManager.NetworkServer.ChooseManager.AskToChooseBlock(User, "选择一座" + Target.Name + "的房屋", (PBlock Block) => Target.Equals(Block.Lord) && Block.HouseNumber > 0);
                         }
                         if (TargetBlock != null)
                         {
                             Game.LoseHouse(TargetBlock, 1);
                             if (User.IsAI)
                             {
                                 TargetBlock = PAiMapAnalyzer.MaxValueHouse(Game, User, true).Key;
                             }
                             else
                             {
                                 TargetBlock = PNetworkManager.NetworkServer.ChooseManager.AskToChooseBlock(User, "选择一处你的土地放置房屋", (PBlock Block) => User.Equals(Block.Lord));
                             }
                             if (TargetBlock != null)
                             {
                                 Game.GetHouse(TargetBlock, 1);
                             }
                         }
                     }
                     else if (ChosenResult == 1)
                     {
                         PCard Got = Game.GetCardFrom(User, Target, false);
                         #region 成就:老司机
                         if (Got.Model is P_ToouShihChi && User.Area.HandCardArea.CardList.Contains(Got))
                         {
                             PArch.Announce(Game, User, "老司机");
                         }
                         #endregion
                     }
                 })
             });
         });
     }
 }
Ejemplo n.º 5
0
    public P_LvZhi() : base("吕雉")
    {
        Sex        = PSex.Female;
        Age        = PAge.Classic;
        Index      = 29;
        Cost       = 30;
        NewGeneral = true;
        Tips       = "定位:攻击\n" +
                     "难度:简单\n" +
                     "史实:汉高祖刘邦的皇后,惠帝、二少帝时的皇太后。统治时期实行与民休息的政策,为文景之治奠定了基础。\n" +
                     "攻略:\n-";

        PSkill ZhenSha = new PSkill("鸩杀")
        {
            Initiative = true
        };

        PPlayer ZhenShaTarget(PGame Game, PPlayer Player)
        {
            List <PPlayer> PossibleTargets = Game.AlivePlayers(Player).FindAll((PPlayer _Player) => _Player.Distance(Player) <= 1);
            PPlayer        Target          = PMath.Max(PossibleTargets, (PPlayer _Player) => {
                int InjureValue = PAiTargetChooser.InjureExpect(Game, Player, Player, _Player, ZhenShaInjure, ZhenSha);
                if (_Player.TeamIndex == Player.TeamIndex)
                {
                    KeyValuePair <PCard, int> MaxValueCard = PAiCardExpectation.FindMostValuable(Game, _Player, Player, true, false, false, true);
                    int MaxValue = MaxValueCard.Value - MaxValueCard.Key.AIInHandExpectation(Game, Player);
                    return(MaxValue + InjureValue);
                }
                else
                {
                    KeyValuePair <PCard, int> MinValueCard = PAiCardExpectation.FindLeastValuable(Game, _Player, Player, true, false, false, true);
                    int MinValue = MinValueCard.Value + MinValueCard.Key.AIInHandExpectation(Game, Player);
                    return(-MinValue + InjureValue);
                }
            }, true).Key;

            return(Target);
        }

        SkillList.Add(ZhenSha
                      .AnnounceTurnOnce()
                      .AddTimeTrigger(
                          new PTime[] {
            PPeriod.FirstFreeTime.During,
            PPeriod.SecondFreeTime.During
        },
                          (PTime Time, PPlayer Player, PSkill Skill) => {
            return(new PTrigger(ZhenSha.Name)
            {
                IsLocked = false,
                Player = Player,
                Time = Time,
                AIPriority = 40,
                CanRepeat = true,
                Condition = (PGame Game) => {
                    return Player.Equals(Game.NowPlayer) && (Player.IsAI || Game.Logic.WaitingForEndFreeTime()) && Player.RemainLimit(ZhenSha.Name) && Player.Area.HandCardArea.CardNumber > 0 && Game.AlivePlayers(Player).Exists((PPlayer _Player) => _Player.Distance(Player) <= 1);
                },
                AICondition = (PGame Game) => {
                    return ZhenShaTarget(Game, Player) != null;
                },
                Effect = (PGame Game) => {
                    ZhenSha.AnnouceUseSkill(Player);
                    PPlayer Target = null;
                    if (Player.IsAI)
                    {
                        Target = ZhenShaTarget(Game, Player);
                    }
                    else
                    {
                        Target = PNetworkManager.NetworkServer.ChooseManager.AskForTargetPlayer(Player, (PGame _Game, PPlayer _Player) => _Player.Distance(Player) <= 1 && !_Player.Equals(Player), ZhenSha.Name, true);
                    }
                    if (Target != null)
                    {
                        Game.GiveCardTo(Player, Target, true, false);
                        Game.Injure(Player, Target, 1500, ZhenSha);
                        ZhenSha.DeclareUse(Player);
                    }
                }
            });
        }));
        PSkill XuMou = new PSkill("蓄谋")
        {
            Lock = true
        };

        SkillList.Add(XuMou
                      .AddTrigger(
                          (PPlayer Player, PSkill Skill) => {
            return(new PTrigger(XuMou.Name)
            {
                IsLocked = true,
                Player = Player,
                Time = PTime.LeaveDyingTime,
                AIPriority = 100,
                Condition = (PGame Game) => {
                    PDyingTag DyingTag = Game.TagManager.FindPeekTag <PDyingTag>(PDyingTag.TagName);
                    return Player.Equals(DyingTag.Killer) && !Player.Equals(DyingTag.Player);
                },
                Effect = (PGame Game) => {
                    XuMou.AnnouceUseSkill(Player);
                    PDyingTag DyingTag = Game.TagManager.FindPeekTag <PDyingTag>(PDyingTag.TagName);
                    DyingTag.Player.Money = 0;
                    Game.Die(DyingTag.Player, DyingTag.Killer);
                }
            });
        }));
    }