Ejemplo n.º 1
0
 public P_ChiaChiihPuTien() : base(CardName)
 {
     Point = 5;
     Index = 27;
     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 = 10,
                 Condition = (PGame Game) => {
                     int MinMoney = PMath.Min(Game.PlayerList.FindAll((PPlayer _Player) => _Player.IsAlive), (PPlayer _Player) => _Player.Money).Value;
                     return Player.Equals(Game.NowPlayer) && (Player.IsAI || Game.Logic.WaitingForEndFreeTime()) && Player.Money == MinMoney;
                 },
                 AICondition = (PGame Game) => {
                     return PAiMapAnalyzer.OutOfGameExpect(Game, Player, true) > 0 && Game.NowPeriod.Equals(PPeriod.FirstFreeTime.During);
                 },
                 Effect = MakeNormalEffect(Player, Card, AIEmitTargets, AIEmitTargets,
                                           (PGame Game, PPlayer User, PPlayer Target) => {
                     Target.Tags.CreateTag(PTag.OutOfGameTag);
                 })
             });
         });
     }
 }
Ejemplo n.º 2
0
    /// <summary>
    /// 返回最低价值的房屋
    /// </summary>
    /// <param name="Game"></param>
    /// <param name="Player">房屋所有者</param>
    /// <param name="StartFromZero">是否允许土地上实际没有房屋</param>
    /// <param name="Concentrate">是否优先选取房屋数量少的土地的房屋</param>
    /// <returns></returns>
    public static KeyValuePair <PBlock, int> MinValueHouse(PGame Game, PPlayer Player, bool StartFromZero = false, bool Concentrate = false)
    {
        KeyValuePair <PBlock, int> Test = PMath.Min(Game.Map.BlockList.FindAll((PBlock Block) => Player.Equals(Block.Lord) && (StartFromZero || Block.HouseNumber > 0)), (PBlock Block) => {
            return(HouseValue(Game, Player, Block) * 1000 +
                   (Concentrate ? Block.HouseNumber : 0));
        });

        return(new KeyValuePair <PBlock, int>(Test.Key, Test.Value / 1000));
    }
Ejemplo n.º 3
0
    public List <PPlayer> AIEmitTargets(PGame Game, PPlayer Player)
    {
        PPlayer Target1 = PMath.Min(Game.Enemies(Player).FindAll((PPlayer _Player) => !_Player.HasEquipment <P_YooHsi>() && !(_Player.General is P_LiuJi)), (PPlayer _Player) => _Player.Money).Key;
        PPlayer Target2 = PMath.Min(Game.Enemies(Player).FindAll((PPlayer _Player) => !_Player.Equals(Target1) && !_Player.HasEquipment <P_YooHsi>() && !(_Player.General is P_LiuJi)), (PPlayer _Player) => _Player.Money).Key;

        return(new List <PPlayer>()
        {
            Target1, Target2
        });
    }
Ejemplo n.º 4
0
    /// <summary>
    /// 这个函数用来弃牌/转化牌,因此花木兰的装备value会被-3500计算
    /// </summary>
    /// <param name="Game"></param>
    /// <param name="Player">用来衡量价值的主视角</param>
    /// <param name="TargetPlayer">衡量对象区域的所有者</param>
    /// <param name="AllowHandCards"></param>
    /// <param name="AllowEquipment"></param>
    /// <param name="AllowAmbush"></param>
    /// <param name="CanSee"></param>
    /// <param name="Condition"></param>
    /// <returns></returns>
    public static KeyValuePair <PCard, int> FindLeastValuable(PGame Game, PPlayer Player, PPlayer TargetPlayer, bool AllowHandCards = true, bool AllowEquipment = true, bool AllowAmbush = false, bool CanSee = false, Predicate <PCard> Condition = null)
    {
        KeyValuePair <PCard, int> HandCardResult = AllowHandCards ?  PMath.Min(TargetPlayer.Area.HandCardArea.CardList.FindAll((PCard Card) => {
            return(Condition == null || Condition(Card));
        }), (PCard Card) => {
            if (CanSee)
            {
                return(Card.Model.AIInHandExpectation(Game, Player));
            }
            else
            {
                return(2000 + PMath.RandInt(-10, 10));
            }
        }) : new KeyValuePair <PCard, int>(null, int.MaxValue);
        KeyValuePair <PCard, int> EquipResult = AllowEquipment ? PMath.Min(TargetPlayer.Area.EquipmentCardArea.CardList.FindAll((PCard Card) => {
            return(Condition == null || Condition(Card));
        }), (PCard Card) => {
            int MulanCof = (TargetPlayer.General is P_HuaMulan ? 3500 : 0);
            if (CanSee)
            {
                int Current  = Card.Model.AIInEquipExpectation(Game, TargetPlayer);
                int MaxEquip = PMath.Max(Player.Area.HandCardArea.CardList, (PCard _Card) => _Card.Model.AIInEquipExpectation(Game, Player)).Value;
                if (Current <= MaxEquip)
                {
                    return(500 - MulanCof);
                }
                else
                {
                    return(Current - Math.Max(0, MaxEquip) - MulanCof);
                }
            }
            else
            {
                return(Card.Model.AIInEquipExpectation(Game, Player) - MulanCof);
            }
        }) : new KeyValuePair <PCard, int>(null, int.MaxValue);
        KeyValuePair <PCard, int> AmbushResult = AllowAmbush ? PMath.Min(TargetPlayer.Area.AmbushCardArea.CardList.FindAll((PCard Card) => {
            return(Condition == null || Condition(Card));
        }), (PCard Card) => {
            return(Card.Model.AIInAmbushExpectation(Game, TargetPlayer));
        }) : new KeyValuePair <PCard, int>(null, int.MaxValue);
        KeyValuePair <PCard, int> Temp = HandCardResult.Value <= EquipResult.Value ? HandCardResult : EquipResult;

        Temp = Temp.Value <= AmbushResult.Value ? Temp : AmbushResult;
        if (Temp.Key == null)
        {
            return(new KeyValuePair <PCard, int>(null, 0));
        }
        return(Temp);
    }
Ejemplo n.º 5
0
    public override int AIInHandExpectation(PGame Game, PPlayer Player)
    {
        int Basic = 1400;

        if (Player.General is P_LiuJi)
        {
            Basic = 2400;
        }
        int MinEnemyMoney = PMath.Min(Game.Enemies(Player), (PPlayer Test) => Test.Money).Value;

        if (MinEnemyMoney <= 1200)
        {
            Basic += 5000 * (7 - MinEnemyMoney / 200);
        }
        return(Math.Max(Basic, base.AIInHandExpectation(Game, Player)));
    }
Ejemplo n.º 6
0
 public P_IITaiLao() : base(CardName)
 {
     Point = 1;
     Index = 4;
     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 = 21,
                 Condition = (PGame Game) => {
                     return Player.Equals(Game.NowPlayer) && (Player.IsAI || Game.Logic.WaitingForEndFreeTime());
                 },
                 AICondition = (PGame Game) => {
                     if (Player.General is P_WuZhao && Player.RemainLimit(PSkillInfo.女权.Name))
                     {
                         return false;
                     }
                     return PMath.Min(Player.Area.HandCardArea.CardList.FindAll((PCard _Card) => !_Card.Equals(Card)).ConvertAll((PCard _Card) => _Card.AIInHandExpectation(Game, Player))) <= 1000;
                 },
                 Effect = MakeMultiTargetNormalEffect(Player, Card, AIEmitTargets,
                                                      PTrigger.NoCondition,
                                                      (PGame Game, PPlayer User, PPlayer Target) => {
                     PCard Got = Game.GetCard(Target);
                     #region 成就:躺尸
                     if (Got.Model is P_ChiehShihHuanHun && User.Area.HandCardArea.CardList.Contains(Got))
                     {
                         PArch.Announce(Game, User, "躺尸");
                     }
                     #endregion
                     Game.ThrowCard(Target, Target);
                 })
             });
         });
     }
 }
Ejemplo n.º 7
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));
    }
Ejemplo n.º 8
0
 public P_PaaoChuanYinYoo() : base(CardName)
 {
     Point = 3;
     Index = 17;
     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 = 140,
                 Condition = (PGame Game) => {
                     return Player.Equals(Game.NowPlayer) && (Player.IsAI || Game.Logic.WaitingForEndFreeTime()) && Game.Map.BlockList.Exists((PBlock Block) => Player.Equals(Block.Lord)) && (Player.Area.EquipmentCardArea.CardNumber > 0 || Player.Area.HandCardArea.CardList.Exists((PCard _Card) => Card.Type.IsEquipment())) && AIEmitTargets(Game, Player).Count > 0;
                 },
                 AICondition = (PGame Game) => {
                     if (Player.General is P_WuZhao && Player.RemainLimit(PSkillInfo.女权.Name))
                     {
                         return false;
                     }
                     return Player.Area.HandCardArea.CardList.Exists((PCard _Card) => Card.Type.IsEquipment()) && AIInHandExpectation(Game, Player) > 2000;
                 },
                 Effect = MakeNormalEffect(Player, Card, AIEmitTargets, AIEmitTargets,
                                           (PGame Game, PPlayer User, PPlayer Target) => {
                     if (Target.HasHouse)
                     {
                         PBlock TargetBlock = null;
                         if (Target.IsAI)
                         {
                             TargetBlock = PAiMapAnalyzer.MinValueHouse(Game, Target).Key;
                         }
                         else
                         {
                             TargetBlock = PNetworkManager.NetworkServer.ChooseManager.AskToChooseBlock(Target, "选择一座房屋以交给" + User.Name, (PBlock Block) => Target.Equals(Block.Lord) && Block.HouseNumber > 0);
                         }
                         if (TargetBlock != null)
                         {
                             Game.LoseHouse(TargetBlock, 1);
                             TargetBlock = null;
                             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);
                             }
                         }
                     }
                 }, (PGame Game, PPlayer User, List <PPlayer> Targets) => {
                     PCard TargetCard = null;
                     if (User.IsAI)
                     {
                         TargetCard = PMath.Min(User.Area.HandCardArea.CardList.FindAll((PCard _Card) => _Card.Type.IsEquipment()), (PCard _Card) => _Card.Model.AIInHandExpectation(Game, User)).Key;
                     }
                     else
                     {
                         do
                         {
                             TargetCard = PNetworkManager.NetworkServer.ChooseManager.AskToChooseOwnCard(User, CardName + "[选择一张装备牌]", true, true);
                         } while (!TargetCard.Type.IsEquipment());
                     }
                     Game.CardManager.MoveCard(TargetCard, User.Area.HandCardArea.CardList.Contains(TargetCard) ? User.Area.HandCardArea : User.Area.EquipmentCardArea, Game.CardManager.ThrownCardHeap);
                 })
             });
         });
     }
 }
Ejemplo n.º 9
0
 public P_YooenChiaoChinKung() : base(CardName)
 {
     Point = 4;
     Index = 23;
     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 = 75,
                 Condition = (PGame Game) => {
                     return Player.Equals(Game.NowPlayer) && (Player.IsAI || Game.Logic.WaitingForEndFreeTime());
                 },
                 AICondition = (PGame Game) => {
                     return AIEmitTargets(Game, Player)[0] != null;
                 },
                 Effect = MakeNormalEffect(Player, Card, AIEmitTargets, PTrigger.Except(Player),
                                           (PGame Game, PPlayer User, PPlayer Target) => {
                     Game.GetCard(Target);
                     PPlayer Another = null;
                     if (User.IsAI)
                     {
                         if (Game.Enemies(User).Exists((PPlayer _Player) => _Player.Money <= 1000) || User.Money > 15000)
                         {
                             Another = PMath.Min(Game.Enemies(User), (PPlayer _Player) => _Player.Money).Key;
                         }
                         else
                         {
                             Another = User;
                         }
                     }
                     else
                     {
                         Another = PNetworkManager.NetworkServer.ChooseManager.AskForTargetPlayer(User, PTrigger.Except(Target), "远交近攻[第二目标]");
                     }
                     if (Another != null)
                     {
                         if (Another.Equals(User))
                         {
                             Game.GetMoney(Another, 1000);
                         }
                         else
                         {
                             Game.LoseMoney(Another, 1000);
                             #region 成就:翻云覆雨
                             if (!Another.IsAlive)
                             {
                                 PArch.Announce(Game, User, "翻云覆雨");
                             }
                             #endregion
                         }
                     }
                 })
             });
         });
     }
 }
Ejemplo n.º 10
0
    public P_XuanWu() : base("玄武")
    {
        Sex         = PSex.Male;
        Age         = PAge.Ancient;
        Index       = 1004;
        Cost        = 1;
        Tips        = string.Empty;
        CanBeChoose = false;

        //PSkill ShenShou = new PSkill("神兽") {
        //    Lock = true
        //};
        //SkillList.Add(ShenShou
        //    .AddTrigger(
        //    (PPlayer Player, PSkill Skill) => {
        //        return new PTrigger(ShenShou.Name) {
        //            IsLocked = true,
        //            Player = Player,
        //            Time = PTime.StartGameTime,
        //            AIPriority = 100,
        //            Effect = (PGame Game) => {
        //                ShenShou.AnnouceUseSkill(Player);
        //                Game.GetMoney(Player, 30000);
        //            }
        //        };
        //    })
        //    .AddTrigger(
        //    (PPlayer Player, PSkill Skill) => {
        //        return new PTrigger(ShenShou.Name) {
        //            IsLocked = true,
        //            Player = Player,
        //            Time = PPeriod.StartTurn.During,
        //            AIPriority = 100,
        //            Condition = (PGame Game) => {
        //                return Player.Equals(Game.NowPlayer);
        //            },
        //            Effect = (PGame Game) => {
        //                ShenShou.AnnouceUseSkill(Player);
        //                Game.GetMoney(Player, 500);
        //            }
        //        };
        //    }));

        PSkill XuanWu = new PSkill("玄武")
        {
            Lock = true
        };

        SkillList.Add(XuanWu
                      .AddTrigger(
                          (PPlayer Player, PSkill Skill) => {
            return(new PTrigger(XuanWu.Name)
            {
                IsLocked = true,
                Player = Player,
                Time = PTime.Injure.AcceptInjure,
                AIPriority = 250,
                Condition = (PGame Game) => {
                    PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
                    return InjureTag.Injure > 0 && Player.Equals(InjureTag.ToPlayer) && InjureTag.InjureSource is PBlock && Player.LandNumber > 0;
                },
                Effect = (PGame Game) => {
                    PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName);
                    XuanWu.AnnouceUseSkill(Player);
                    int MinHouse = PMath.Min(Game.Map.FindBlock(Player), (PBlock Block) => Block.HouseNumber).Value;
                    PBlock Target = PMath.Max(Game.Map.FindBlock(Player).FindAll((PBlock Block) => Block.HouseNumber == MinHouse), (PBlock Block) => PAiMapAnalyzer.HouseValue(Game, Player, Block)).Key;
                    Game.GetHouse(Target, 1);
                }
            });
        }));
    }
Ejemplo n.º 11
0
 protected PEquipmentCardModel(string _Name, PCardType CardType) : base(_Name)
 {
     Type = CardType;
     foreach (PTime Time in new PTime[] {
         PPeriod.FirstFreeTime.During,
         PPeriod.SecondFreeTime.During
     })
     {
         MoveInHandTriggerList.Add((PPlayer Player, PCard Card) => {
             return(new PTrigger("挂上装备")
             {
                 IsLocked = false,
                 Player = Player,
                 Time = Time,
                 AIPriority = 180,
                 Condition = (PGame Game) => {
                     return Player.Equals(Game.NowPlayer) && (Player.IsAI || Game.Logic.WaitingForEndFreeTime());
                 },
                 AICondition = (PGame Game) => {
                     KeyValuePair <PCard, int> MaxCard = PMath.Max(Player.Area.HandCardArea.CardList, (PCard _Card) => _Card.Model.AIInEquipExpectation(Game, Player));
                     KeyValuePair <PCard, int> MinCard = PMath.Min(Player.Area.HandCardArea.CardList.FindAll((PCard _Card) => _Card.Type.IsEquipment()),
                                                                   (PCard _Card) => _Card.Model.AIInEquipExpectation(Game, Player));
                     PCard CurrentCard = Player.GetEquipment(CardType);
                     if (Player.General is P_HuaXiong)
                     {
                         return CurrentCard == null && Card.Equals(MinCard.Key);
                     }
                     if (Player.General is P_TangYin)
                     {
                         return CurrentCard == null;
                     }
                     if (Player.General is P_LvMeng)
                     {
                         return CurrentCard == null;
                     }
                     if (Player.General is P_Gryu && CurrentCard != null && CurrentCard.Point % 2 == 0)
                     {
                         return false;
                     }
                     int HuaMulanCof = Player.General is P_HuaMulan ? 3500 : 0;
                     return Card.Equals(MaxCard.Key) && (CurrentCard == null || MaxCard.Value + HuaMulanCof > CurrentCard.Model.AIInEquipExpectation(Game, Player)) && MaxCard.Value > 0;
                 },
                 Effect = (PGame Game) => {
                     List <PPlayer> Targets = new List <PPlayer> {
                         Player
                     };
                     Game.Monitor.CallTime(PTime.Card.AfterEmitTargetTime, new PUseCardTag(Card, Player, Targets));
                     Game.Monitor.CallTime(PTime.Card.AfterBecomeTargetTime, new PUseCardTag(Card, Player, Targets));
                     if (Targets.Count > 0)
                     {
                         Game.CardManager.MoveCard(Card, Player.Area.HandCardArea, Targets[0].Area.EquipmentCardArea);
                     }
                     else
                     {
                         Game.CardManager.MoveCard(Card, Player.Area.HandCardArea, Game.CardManager.ThrownCardHeap);
                     }
                     Game.Monitor.CallTime(PTime.Card.EndSettleTime, new PUseCardTag(Card, Player, Targets));
                 }
             });
         });
     }
 }