Example #1
0
    /// <summary>
    /// 用于交给队友有价值的牌和弃置敌人的高价值牌
    /// </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>
    /// <returns></returns>
    public static KeyValuePair <PCard, int> FindMostValuable(PGame Game, PPlayer Player, PPlayer TargetPlayer, bool AllowHandCards = true, bool AllowEquipment = true, bool AllowAmbush = false, bool CanSee = false)
    {
        int Cof = Player.TeamIndex == TargetPlayer.TeamIndex ? 1 : -1;
        KeyValuePair <PCard, int> HandCardResult = AllowHandCards ? PMath.Max(TargetPlayer.Area.HandCardArea.CardList, (PCard Card) => {
            if (CanSee)
            {
                return(Card.Model.AIInHandExpectation(Game, Player));
            }
            else
            {
                return(2000 + PMath.RandInt(-10, 10));
            }
        }) : new KeyValuePair <PCard, int>(null, int.MinValue);
        KeyValuePair <PCard, int> EquipResult = AllowEquipment ? PMath.Max(TargetPlayer.Area.EquipmentCardArea.CardList, (PCard Card) => {
            return(Card.Model.AIInEquipExpectation(Game, TargetPlayer) + (TargetPlayer.General is P_HuaMulan ? 3500 * Cof : 0));
        }) : new KeyValuePair <PCard, int>(null, int.MinValue);
        KeyValuePair <PCard, int> AmbushResult = AllowAmbush ? PMath.Max(TargetPlayer.Area.AmbushCardArea.CardList, (PCard Card) => {
            return(Card.Model.AIInAmbushExpectation(Game, TargetPlayer));
        }) : new KeyValuePair <PCard, int>(null, int.MinValue);
        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);
    }
Example #2
0
    public static KeyValuePair <PCard, int> FindMostValuableToGet(PGame Game, PPlayer Player, PPlayer TargetPlayer, bool AllowHandCards = true, bool AllowEquipment = true, bool AllowAmbush = false, bool CanSee = false)
    {
        int Cof         = Player.TeamIndex == TargetPlayer.TeamIndex ? -1 : 1;
        int YangToowCof = TargetPlayer.Traffic != null && TargetPlayer.Traffic.Model is P_HsiYooYangToow && !Player.Age.Equals(TargetPlayer.Age) ? 0 : 1;
        KeyValuePair <PCard, int> HandCardResult = AllowHandCards ? PMath.Max(TargetPlayer.Area.HandCardArea.CardList, (PCard Card) => {
            if (CanSee)
            {
                return(Card.Model.AIInHandExpectation(Game, Player) * YangToowCof + Cof * Card.Model.AIInHandExpectation(Game, TargetPlayer));
            }
            else
            {
                return(Cof < 0 ? 0 : 2000 * YangToowCof + 2000 * Cof + PMath.RandInt(0, 10));
            }
        }) : new KeyValuePair <PCard, int>(null, int.MinValue);
        KeyValuePair <PCard, int> EquipResult = AllowEquipment ? PMath.Max(TargetPlayer.Area.EquipmentCardArea.CardList, (PCard Card) => {
            return(Card.Model.AIInHandExpectation(Game, Player) + Cof * Card.Model.AIInEquipExpectation(Game, TargetPlayer) - (TargetPlayer.General is P_HuaMulan ? 3500 * Cof : 0));
        }) : new KeyValuePair <PCard, int>(null, int.MinValue);
        KeyValuePair <PCard, int> AmbushResult = AllowAmbush ? PMath.Max(TargetPlayer.Area.AmbushCardArea.CardList, (PCard Card) => {
            return(Card.Model.AIInHandExpectation(Game, Player) + Cof * Card.Model.AIInAmbushExpectation(Game, TargetPlayer));
        }) : new KeyValuePair <PCard, int>(null, int.MinValue);
        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);
    }
Example #3
0
    public override int AIInHandExpectation(PGame Game, PPlayer Player)
    {
        int Basic = Player.Area.HandCardArea.CardList.Exists((PCard Card) => Card.Type.IsEquipment()) ? 2000 : 0;
        int Test  = 1000 * PMath.Max(Game.Enemies(Player), (PPlayer _Player) => _Player.Area.EquipmentCardArea.CardNumber).Value;

        Basic = Math.Max(Basic, Test);
        return(Math.Max(Basic, base.AIInHandExpectation(Game, Player)));
    }
 public List<PPlayer> AIEmitTargets(PGame Game, PPlayer Player) {
     PPlayer Target = PMath.Max(Game.Enemies(Player).FindAll((PPlayer _Player) => _Player.HasHouse && 
     (_Player.Defensor == null || !(_Player.Defensor.Model is P_ChiiHsingPaao)) && 
     !_Player.Area.AmbushCardArea.CardList.Exists((PCard _Card) => _Card.Model.Name.Equals(CardName)) &&
     !(_Player.General is P_LiuJi)),
     (PPlayer _Player) => PAiMapAnalyzer.MinValueHouse(Game, _Player).Value + PMath.RandInt(0, 10)).Key;
     return new List<PPlayer>() { Target};
 }
Example #5
0
 public List <PPlayer> AIEmitTargets(PGame Game, PPlayer Player)
 {
     return(new List <PPlayer>()
     {
         PMath.Max(Game.Enemies(Player), (PPlayer _Player) => {
             return -PAiMapAnalyzer.OutOfGameExpect(Game, _Player);
         }, true).Key
     });
 }
Example #6
0
    public override int AIInHandExpectation(PGame Game, PPlayer Player)
    {
        int Basic = PAiMapAnalyzer.MaxValueHouse(Game, Player).Value;

        Basic = Math.Max(1000, PMath.Max(Game.Enemies(Player), (PPlayer _Player) => {
            return(PAiMapAnalyzer.MaxValueHouse(Game, _Player).Value + Basic);
        }, true).Value);
        return(Math.Max(Basic, base.AIInHandExpectation(Game, Player)));
    }
Example #7
0
    public override int AIInHandExpectation(PGame Game, PPlayer Player)
    {
        int Basic = 2500;
        int Test  = PMath.Max(Game.Map.BlockList.FindAll((PBlock Block) => Block.Lord != null && Block.Lord.TeamIndex == Player.TeamIndex), (PBlock Block) => {
            return(PAiMapAnalyzer.HouseValue(Game, Block.Lord, Block));
        }).Value;

        Basic = Math.Max(Basic, Test);
        return(Math.Max(Basic, base.AIInHandExpectation(Game, Player)));
    }
Example #8
0
    public override int AIInHandExpectation(PGame Game, PPlayer Player)
    {
        int Basic           = 0;
        int OutOfGameExpect = PMath.Max(Game.Enemies(Player), (PPlayer _Player) => {
            return(-PAiMapAnalyzer.OutOfGameExpect(Game, _Player));
        }, true).Value;

        Basic = Math.Max(Basic, OutOfGameExpect);
        return(Math.Max(Basic, base.AIInHandExpectation(Game, Player)));
    }
Example #9
0
    private KeyValuePair <PPlayer, int> FindTarget(PGame Game, PPlayer Player)
    {
        int Basic = PAiMapAnalyzer.MaxValueHouse(Game, Player).Value;

        return(PMath.Max(Game.Enemies(Player).FindAll((PPlayer _Player) => _Player.Area.EquipmentCardArea.CardNumber > 0), (PPlayer _Player) => {
            int HouseValue = _Player.HasHouse ?  PAiMapAnalyzer.MaxValueHouse(Game, _Player).Value + Basic : 30000;
            int EquipValue = PMath.Max(_Player.Area.EquipmentCardArea.CardList, (PCard Card ) => Card.Model.AIInEquipExpectation(Game, _Player) + Card.Model.AIInHandExpectation(Game, Player)).Value;
            return Math.Min(HouseValue, EquipValue);
        }, true));
    }
Example #10
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 #11
0
 public P_ToouShihChi() : base(CardName, PCardType.WeaponCard)
 {
     Point = 6;
     Index = 48;
     AnnouceOnce(CardName);
     foreach (PTime Time in new PTime[] {
         PPeriod.FirstFreeTime.During,
         PPeriod.SecondFreeTime.During
     })
     {
         MoveInEquipTriggerList.Add((PPlayer Player, PCard Card) => {
             return(new PTrigger(CardName)
             {
                 IsLocked = false,
                 Player = Player,
                 Time = Time,
                 CanRepeat = true,
                 Condition = (PGame Game) => {
                     PUsedTag UsedTag = Player.Tags.FindPeekTag <PUsedTag>(PUsedTag.TagNamePrefix + CardName);
                     if (UsedTag == null)
                     {
                         Player.Tags.CreateTag(UsedTag = new PUsedTag(CardName, 1));
                     }
                     return Player.Equals(Game.NowPlayer) && (Player.IsAI || Game.Logic.WaitingForEndFreeTime()) && UsedTag != null && UsedTag.Count < UsedTag.Limit && Player.Money > 3000 && Game.Map.BlockList.Exists((PBlock Block ) => Block.HouseNumber > 0);
                 },
                 AICondition = (PGame Game) => {
                     return Game.Map.BlockList.Exists((PBlock Block) => Block.Lord != null && Block.Lord.TeamIndex != Player.TeamIndex && Block.HouseNumber > 1 && Block.BusinessType.Equals(PBusinessType.Castle)) && Player.Money >= 6000;
                 },
                 Effect = (PGame Game) => {
                     AnnouceUseEquipmentSkill(Player);
                     PBlock TargetBlock = null;
                     if (Player.IsAI)
                     {
                         TargetBlock = PMath.Max(Game.Map.BlockList.FindAll((PBlock Block) => Block.Lord != null && Block.Lord.TeamIndex != Player.TeamIndex && Block.BusinessType.Equals(PBusinessType.Castle)), (PBlock Block) => Block.HouseNumber).Key;
                     }
                     else
                     {
                         TargetBlock = PNetworkManager.NetworkServer.ChooseManager.AskToChooseBlock(Player, CardName + "之目标", (PBlock Block) => Block.HouseNumber > 0);
                     }
                     if (TargetBlock != null)
                     {
                         Game.LoseMoney(Player, 3000);
                         Game.LoseHouse(TargetBlock, 1);
                         if (TargetBlock.BusinessType.Equals(PBusinessType.Castle))
                         {
                             Game.LoseHouse(TargetBlock, Game.Judge(Player, 6));
                         }
                         Player.Tags.FindPeekTag <PUsedTag>(PUsedTag.TagNamePrefix + CardName).Count++;
                     }
                 }
             });
         });
     }
 }
Example #12
0
 public P_ChiehShihHuanHun() : base(CardName)
 {
     Point = 3;
     Index = 14;
     foreach (PTime Time in new PTime[] {
         PPeriod.FirstFreeTime.During,
         PPeriod.SecondFreeTime.During,
         PTime.EnterDyingTime
     })
     {
         MoveInHandTriggerList.Add((PPlayer Player, PCard Card) => {
             return(new PTrigger(CardName)
             {
                 IsLocked = false,
                 Player = Player,
                 Time = Time,
                 AIPriority = Time.Equals(PTime.EnterDyingTime) ? 10 : 90,
                 Condition = (PGame Game) => {
                     return Time.Equals(PTime.EnterDyingTime) ? Game.TagManager.FindPeekTag <PDyingTag>(PDyingTag.TagName).Player.Equals(Player) : Player.Equals(Game.NowPlayer) && (Player.IsAI || Game.Logic.WaitingForEndFreeTime());
                 },
                 AICondition = (PGame Game) => {
                     return Time.Equals(PTime.EnterDyingTime) || AIInHandExpectation(Game, Player) > 5000;
                 },
                 Effect = MakeNormalEffect(Player, Card, AIEmitTargets, AIEmitTargets,
                                           (PGame Game, PPlayer User, PPlayer Target) => {
                     PPlayer Another = null;
                     if (Target.IsAI)
                     {
                         Another = PMath.Max(Game.PlayerList.FindAll((PPlayer _Player) => !_Player.Equals(Player)), (PPlayer _Player) => {
                             return _Player.Money;
                         }).Key;
                     }
                     else
                     {
                         Another = PNetworkManager.NetworkServer.ChooseManager.AskForTargetPlayer(Target, PTrigger.Except(Target), CardName + "[与其金钱相同]");
                     }
                     Game.CardManager.ThrowAll(Target.Area);
                     if (Another != null)
                     {
                         if (Another.Money > Target.Money)
                         {
                             Game.GetMoney(Target, Math.Min(10000, Another.Money - Target.Money));
                         }
                         else if (Another.Money < Target.Money)
                         {
                             Game.LoseMoney(Target, Target.Money - Another.Money);
                         }
                     }
                 })
             });
         });
     }
 }
Example #13
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);
    }
Example #14
0
    public static List <int> DirectionExpectations(PGame Game, PPlayer Player, PBlock Block)
    {
        /*
         * AI决策商业用地类型的机制:
         * 购物中心收益:2*(40%*max(1,20*建房次数上限/环长)+20%)*地价*敌方人数
         * 研究所收益  :牌堆期望收益*2*己方人数
         * 公园收益    :(max(1,20*建房次数上限/环长)*60%+50%)*地价
         * 城堡收益    :(50%+敌方人数*20%)*赠送房屋数量*地价
         * 当铺收益    :2000*己方人数
         *
         * 特殊计算:
         * 杨玉环:研究所+4000
         */
        int RingLength        = PAiMapAnalyzer.GetRingLength(Game, Block);
        int MaxOperationCount = Player.PurchaseLimit;
        int MikuBias          = (Player.General is P_IzayoiMiku && Player.RemainLimit("轮舞曲")) ? 1 : 0;

        int ShoppingCenterExpectation = 2 * PMath.Percent(Block.Price, 40 * Math.Max(1, 20 * MaxOperationCount / RingLength) + 20) * Game.Enemies(Player).Count;
        int InsituteExpectation       = 2000 * 2 * Game.Teammates(Player).Count;
        int ParkExpectation           = PMath.Percent(Block.Price, 60 * Math.Max(1, 20 * MaxOperationCount / RingLength) + 50);
        int CastleExpectation         = Game.Enemies(Player).Exists((PPlayer _Player) => _Player.Money > 3000 && _Player.Weapon != null && _Player.Weapon.Model is P_ToouShihChi) ? 0: PMath.Percent(Block.Price, 50 + 20 * Game.Enemies(Player).Count) * Game.GetBonusHouseNumberOfCastle(Player, Block);

        if (MikuBias == 1 && Game.GetBonusHouseNumberOfCastle(Player, Block) >= PMath.Max(Game.Map.BlockList.FindAll((PBlock _Block) => _Block.IsBusinessLand && _Block.Lord != null && _Block.Lord.TeamIndex == Player.TeamIndex).ConvertAll((PBlock _Block) => _Block.HouseNumber)))
        {
            CastleExpectation = PMath.Percent(Block.Price, 50 + 40 * Game.Enemies(Player).Count) * Game.GetBonusHouseNumberOfCastle(Player, Block);
        }

        int PawnshopExpectation = 2000 * Game.Teammates(Player).Count;
        int AltarExpectation    = 1000 * 20 * 6 / RingLength * Game.Enemies(Player).Count;

        if (Player.General is P_YangYuHuan)
        {
            InsituteExpectation += 4000;
        }
        if (Player.General is P_Xdyu || Player.General is P_Gryu)
        {
            ShoppingCenterExpectation += 4000;
        }

        List <int> ExpectationList = new List <int>()
        {
            ShoppingCenterExpectation,
            InsituteExpectation,
            ParkExpectation,
            CastleExpectation,
            AltarExpectation
        };

        return(ExpectationList);
    }
Example #15
0
    public override int AIInHandExpectation(PGame Game, PPlayer Player)
    {
        int Test = PMath.Max(Game.Enemies(Player), (PPlayer _Player) => {
            if (_Player.General is P_LiuJi)
            {
                return(0);
            }
            return(_Player.Area.HandCardArea.CardNumber / 2 * 2000 * 5 / 6);
        }).Value;
        int Base  = 3500;
        int Basic = Math.Max(Base, Test);

        return(Math.Max(Basic, base.AIInHandExpectation(Game, Player)));
    }
Example #16
0
    public List <PPlayer> AIEmitTargets(PGame Game, PPlayer Player)
    {
        PPlayer Target = PMath.Max(Game.Enemies(Player).FindAll(
                                       (PPlayer _Player) => _Player.Area.HandCardArea.CardNumber >= 4 &&
                                       (_Player.Defensor == null || !(_Player.Defensor.Model is P_ChiiHsingPaao)) &&
                                       !_Player.Area.AmbushCardArea.CardList.Exists((PCard _Card) =>
                                                                                    _Card.Model.Name.Equals(CardName)) &&
                                       !(_Player.General is P_LiuJi))
                                   , (PPlayer _Player) => _Player.Area.HandCardArea.CardNumber * 100 + PMath.RandInt(0, 10)).Key;

        return(new List <PPlayer>()
        {
            Target
        });
    }
Example #17
0
 public P_MuNiuLiuMa() : base(CardName, PCardType.TrafficCard)
 {
     Point = 6;
     Index = 60;
     AnnouceOnce(CardName);
     foreach (PTime Time in new PTime[] {
         PPeriod.FirstFreeTime.During,
         PPeriod.SecondFreeTime.During
     })
     {
         MoveInEquipTriggerList.Add((PPlayer Player, PCard Card) => {
             return(new PTrigger(CardName)
             {
                 IsLocked = true,
                 Player = Player,
                 Time = Time,
                 AIPriority = 180,
                 CanRepeat = true,
                 Condition = (PGame Game) => {
                     return Player.Equals(Game.NowPlayer) && (Player.IsAI || Game.Logic.WaitingForEndFreeTime()) && Player.RemainLimit(CardName) && Player.Money > 2000;
                 },
                 AICondition = (PGame Game) => {
                     return Game.Teammates(Player, false).Count > 0 && (Player.Money >= 20000 || (Player.Money >= 10000 && PMath.RandTest(0.5)));
                 },
                 Effect = (PGame Game ) => {
                     AnnouceUseEquipmentSkill(Player);
                     Game.LoseMoney(Player, 2000);
                     PPlayer Target = null;
                     if (Player.IsAI)
                     {
                         Target = PMath.Max(Game.Teammates(Player, false), (PPlayer _Player) => _Player.AiCardExpectation).Key;
                     }
                     else
                     {
                         Target = PNetworkManager.NetworkServer.ChooseManager.AskForTargetPlayer(Player, PTrigger.Except(Player), CardName);
                     }
                     if (Target != null)
                     {
                         Game.GetCard(Target, 1);
                     }
                     Player.Tags.FindPeekTag <PUsedTag>(PUsedTag.TagNamePrefix + CardName).Count++;
                 }
             });
         });
     }
 }
Example #18
0
 public P_AnTuCheevnTsaang() : base(CardName)
 {
     Point = 2;
     Index = 8;
     foreach (PTime Time in new PTime[] {
         PPeriod.FirstFreeTime.End
     })
     {
         MoveInHandTriggerList.Add((PPlayer Player, PCard Card) => {
             return(new PTrigger(CardName)
             {
                 IsLocked = false,
                 Player = Player,
                 Time = Time,
                 AIPriority = 120,
                 Condition = (PGame Game) => {
                     return Game.NowPlayer.Equals(Player);
                 },
                 AICondition = (PGame Game) => {
                     int Ideal = PMath.Max(Game.Map.BlockList, (PBlock Block) => PAiMapAnalyzer.StartFromExpect(Game, Player, Block)).Value;
                     int Current = PAiMapAnalyzer.StartFromExpect(Game, Player, Player.Position);
                     return (Ideal - Current >= 2000) || (-Current >= Player.Money && -Ideal < Player.Money);
                 },
                 Effect = MakeNormalEffect(Player, Card, AIEmitTargets, AIEmitTargets,
                                           (PGame Game, PPlayer User, PPlayer Target) => {
                     PBlock TargetBlock = Target.Position;
                     if (Target.IsAI)
                     {
                         TargetBlock = PMath.Max(Game.Map.BlockList, (PBlock Block) => PAiMapAnalyzer.StartFromExpect(Game, Player, Block)).Key;
                     }
                     else
                     {
                         TargetBlock = PNetworkManager.NetworkServer.ChooseManager.AskToChooseBlock(Target, "[暗度陈仓]选择目标格子");
                     }
                     if (TargetBlock != null)
                     {
                         PNetworkManager.NetworkServer.TellClients(new PHighlightBlockOrder(TargetBlock.Index.ToString()));
                         Game.MovePosition(Target, Target.Position, TargetBlock);
                     }
                 })
             });
         });
     }
 }
Example #19
0
    public List <PPlayer> AIEmitTargets(PGame Game, PPlayer Player)
    {
        List <PPlayer> Targets = new List <PPlayer>();

        int Cal(PPlayer _Player)
        {
            int Base = 1000;

            Base += Math.Max(0, (20000 - _Player.Money) / 10);
            bool Positive = !_Player.Tags.ExistTag(PTag.LockedTag.Name);

            Positive ^= Player.TeamIndex == _Player.TeamIndex;
            return(Base * (Positive ? 1 : -1));
        }

        Targets.Add(PMath.Max(Game.PlayerList.FindAll((PPlayer _Player) => _Player.IsAlive && !(_Player.Defensor != null && _Player.Defensor.Model is P_YooHsi)), Cal, true).Key);
        Targets.Add(PMath.Max(Game.PlayerList.FindAll((PPlayer _Player) => _Player.IsAlive && !_Player.Equals(Targets[0]) && !(_Player.Defensor != null && _Player.Defensor.Model is P_YooHsi)), Cal, true).Key);
        return(Targets);
    }
Example #20
0
 public static KeyValuePair <PPlayer, int> Target(PGame Game, PPlayer Player, int Base = 0)
 {
     return(PMath.Max(Game.PlayerList.FindAll((PPlayer _Player) => _Player.IsAlive && !_Player.Equals(Player) && _Player.Distance(Player) <= 3 && !_Player.NoLadder), (PPlayer _Player) => {
         PBlock ExpectBlock = _Player.Position;
         if (_Player.Traffic != null && _Player.Traffic.Model is P_ChiihTuu)
         {
             ExpectBlock = ExpectBlock.NextBlock;
         }
         int Value = PAiMapAnalyzer.Expect(Game, _Player, ExpectBlock);
         if (_Player.TeamIndex == Player.TeamIndex)
         {
             return Value - Base;
         }
         else
         {
             return -Value - Base;
         }
     }, true));
 }
    static public List <PPlayer> AIEmitTargets(PGame Game, PPlayer Player, int BaseValue)
    {
        int     MaxMoney = PMath.Max(Game.PlayerList, (PPlayer _Player) => _Player.Money).Value;
        PPlayer Target   = PMath.Max(Game.PlayerList.FindAll((PPlayer _Player) => _Player.Money == MaxMoney), (PPlayer _Player) => {
            if (Player.TeamIndex == _Player.TeamIndex)
            {
                return(PAiMapAnalyzer.ChangeFaceExpect(Game, _Player) - BaseValue);
            }
            else
            {
                return(-PAiMapAnalyzer.ChangeFaceExpect(Game, _Player) - BaseValue);
            }
        }, true).Key;

        return(new List <PPlayer>()
        {
            Target
        });
    }
Example #22
0
    public override int AIInHandExpectation(PGame Game, PPlayer Player)
    {
        int Basic = 3000;
        int Delta = PMath.Max(Game.PlayerList, (PPlayer _Player) => {
            return(_Player.Money);
        }).Value - Player.Money;

        Delta = Math.Min(10000, Delta);
        if (Player.Money <= 2000)
        {
            Delta *= 3;
        }
        else if (Player.Money <= 5000)
        {
            Delta *= 2;
        }
        Delta -= 2000 * Player.Area.HandCardArea.CardNumber;
        Delta -= (int)PMath.Sum(Player.Area.EquipmentCardArea.CardList.ConvertAll((PCard _Card) => (double)_Card.Model.AIInEquipExpectation(Game, Player)));
        Basic  = Math.Max(Delta, Basic);
        return(Math.Max(Basic, base.AIInHandExpectation(Game, Player)));
    }
Example #23
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));
    }
 public P_ChiinTsevChiinWang() : base(CardName)
 {
     Point = 3;
     Index = 18;
     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 = 25,
                 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,
                                           (PGame Game, PPlayer _Player) => {
                     int MaxMoney = PMath.Max(Game.PlayerList, (PPlayer __Player) => __Player.Money).Value;
                     return _Player.Money == MaxMoney;
                 },
                                           (PGame Game, PPlayer User, PPlayer Target) => {
                     Game.ChangeFace(Target);
                     #region 成就:草头天子
                     if (User.Equals(Target))
                     {
                         PArch.Announce(Game, User, "草头天子");
                     }
                     #endregion
                 })
             });
         });
     }
 }
Example #25
0
    public List <PPlayer> AIEmitTargets(PGame Game, PPlayer Player)
    {
        // 情况1:选择队友,当自己有多余的装备可以放在队友的空装备栏时且队友不会死时
        // 情况2:选择敌人,
        //        A、当可以杀死敌人时
        //        B、当可以换上更差的装备时

        KeyValuePair <PPlayer, int> TeammateTarget = PMath.Max(Game.Teammates(Player, false), (PPlayer _Player) => {
            return(TeammateValueCard(Game, Player, _Player).Value);
        }, true);

        KeyValuePair <PPlayer, int> EnemyTarget = PMath.Max(Game.Enemies(Player), (PPlayer _Player) => {
            return(EnemyValueCard(Game, Player, _Player).Value);
        }, true);

        PPlayer Target = TeammateTarget.Value > EnemyTarget.Value ? TeammateTarget.Key : EnemyTarget.Key;

        return(new List <PPlayer>()
        {
            Target
        });
    }
Example #26
0
    public List <PPlayer> AIEmitTargets(PGame Game, PPlayer Player)
    {
        PPlayer Target = PMath.Max(Game.PlayerList.FindAll((PPlayer _Player) => _Player.IsAlive && !_Player.Equals(Player) && (_Player.Defensor == null || !(_Player.Defensor.Model is P_ChiiHsingPaao)) && !_Player.Area.AmbushCardArea.CardList.Exists((PCard _Card) => _Card.Model.Name.Equals(CardName))), (PPlayer _Player) => {
            int Base = AIExpect(Game, Player, _Player.Position);
            if (_Player.General is P_LiuJi)
            {
                if (Player.TeamIndex == _Player.TeamIndex)
                {
                    Base += 1200;
                }
                else
                {
                    Base = 0;
                }
            }
            return(Base - 4000);
        }, true).Key;

        return(new List <PPlayer>()
        {
            Target
        });
    }
Example #27
0
    public P_HuaMulan() : base("花木兰")
    {
        Sex   = PSex.Female;
        Age   = PAge.Renaissance;
        Index = 23;
        Cost  = 20;
        Tips  = "定位:爆发\n" +
                "难度:简单\n" +
                "史实:出自经典诗歌《木兰辞》。中国古代替父从军的女英雄。\n" +
                "攻略:\n花木兰是一名拥有不俗爆发能力的武将。【枭姬】的存在使得花木兰极度依赖装备牌,因此能够与唐寅、时迁等武将配合,同时也能够对这些武将形成强大的威慑力。【枭姬】往往能够提供绝地反杀的能力,或能使花木兰东山再起,因此在针对花木兰时必须注意其队伍的研究所或给牌武将,同时慎用【落凤弓】、【借刀杀人】等牌,从一定程度上来说提供了花木兰一定的防御力。【易装】是一个强大的爆发技能,不仅能与队友交换装备达成爆发,还能抢夺敌方的大量装备,形成局势逆转,因此可在一定程度上克制关羽。【易装】还可用来转换性别,从而使敌方的【百花裙】等装备失效。针对花木兰必须阻止其装备成形,因此吕蒙是一个不错的选择。";

        PSkill XiaoJi = new PSkill("枭姬")
        {
            SoftLockOpen = true
        };

        SkillList.Add(XiaoJi
                      .AddTrigger((PPlayer Player, PSkill Skill) => {
            return(new PTrigger(XiaoJi.Name)
            {
                IsLocked = false,
                Player = Player,
                Time = PTime.Card.LeaveAreaTime,
                AIPriority = 200,
                Condition = (PGame Game) => {
                    PMoveCardTag MoveCardTag = Game.TagManager.FindPeekTag <PMoveCardTag>(PMoveCardTag.TagName);
                    return Player.Area.EquipmentCardArea.Equals(MoveCardTag.Source) && !Player.Equals(MoveCardTag.Destination.Owner);
                },
                Effect = (PGame Game) => {
                    XiaoJi.AnnouceUseSkill(Player);
                    Game.GetCard(Player);
                    Game.GetMoney(Player, 1500);
                }
            });
        }));

        PPlayer YiZhuangTarget(PGame Game, PPlayer Player)
        {
            return(PMath.Max(Game.AlivePlayers(Player), (PPlayer TargetPlayer) => {
                int Profit = 0;
                PSex OriginalSex = Player.Sex;
                Player.Sex = PSex.Male;
                foreach (PCardType CardType in new PCardType[] {
                    PCardType.WeaponCard, PCardType.DefensorCard, PCardType.TrafficCard
                })
                {
                    PCard Card = Player.GetEquipment(CardType);
                    PCard TargetCard = TargetPlayer.GetEquipment(CardType);
                    if (Card != null)
                    {
                        Profit += 2000;
                        Profit -= Card.Model.AIInEquipExpectation(Game, Player);
                        Profit += Card.Model.AIInEquipExpectation(Game, TargetPlayer) * (Player.TeamIndex == TargetPlayer.TeamIndex ? 1 : -1);
                    }
                    if (TargetCard != null)
                    {
                        Profit += TargetCard.Model.AIInEquipExpectation(Game, Player);
                        Profit -= TargetCard.Model.AIInEquipExpectation(Game, TargetPlayer) * (Player.TeamIndex == TargetPlayer.TeamIndex ? 1 : -1);
                    }
                }
                Player.Sex = OriginalSex;
                return Profit - 7500;
            }, true).Key);
        }

        PSkill YiZhuang = new PSkill("易装")
        {
            Initiative = true
        };

        SkillList.Add(YiZhuang
                      .AnnounceGameOnce()
                      .AddTimeTrigger(
                          new PTime[] {
            PPeriod.FirstFreeTime.During,
            PPeriod.SecondFreeTime.During
        },
                          (PTime Time, PPlayer Player, PSkill Skill) => {
            return(new PTrigger(YiZhuang.Name)
            {
                IsLocked = false,
                Player = Player,
                Time = Time,
                AIPriority = 280,
                CanRepeat = true,
                Condition = (PGame Game) => {
                    return Player.Equals(Game.NowPlayer) && (Player.IsAI || Game.Logic.WaitingForEndFreeTime()) && Player.RemainLimit(YiZhuang.Name);
                },
                AICondition = (PGame Game) => {
                    if (Game.Teammates(Player).Exists((PPlayer _Player) => _Player.General is P_WuZhao))
                    {
                        PPlayer _Player = Game.PlayerList.Find((PPlayer __Player) => __Player.General is P_WuZhao);
                        if (_Player.RemainLimit("女权"))
                        {
                            return false;
                        }
                        else if (Player.Tags.ExistTag(P_WuZhao.NvQuanTag.Name))
                        {
                            return false;
                        }
                    }
                    return YiZhuangTarget(Game, Player) != null;
                },
                Effect = (PGame Game) => {
                    YiZhuang.AnnouceUseSkill(Player);
                    PPlayer Target = null;
                    if (Player.IsAI)
                    {
                        Target = YiZhuangTarget(Game, Player);
                    }
                    else
                    {
                        Target = PNetworkManager.NetworkServer.ChooseManager.AskForTargetPlayer(Player, PTrigger.Except(Player), YiZhuang.Name);
                    }
                    if (Target != null)
                    {
                        List <PCard> MulanEquipments = new List <PCard>();
                        foreach (PCard Card in Player.Area.EquipmentCardArea.CardList)
                        {
                            MulanEquipments.Add(Card);
                        }
                        List <PCard> TargetEquipements = new List <PCard>();
                        foreach (PCard Card in Target.Area.EquipmentCardArea.CardList)
                        {
                            TargetEquipements.Add(Card);
                        }
                        foreach (PCard Card in MulanEquipments)
                        {
                            Game.CardManager.MoveCard(Card, Player.Area.EquipmentCardArea, Game.CardManager.SettlingArea);
                        }
                        foreach (PCard Card in TargetEquipements)
                        {
                            Game.CardManager.MoveCard(Card, Target.Area.EquipmentCardArea, Game.CardManager.SettlingArea);
                        }
                        foreach (PCard Card in MulanEquipments)
                        {
                            Game.CardManager.MoveCard(Card, Game.CardManager.SettlingArea, Target.Area.EquipmentCardArea);
                        }
                        foreach (PCard Card in TargetEquipements)
                        {
                            Game.CardManager.MoveCard(Card, Game.CardManager.SettlingArea, Player.Area.EquipmentCardArea);
                        }
                        Player.Sex = PSex.Male;
                        Player.Tags.CreateTag(new PTag(YiZhuang.Name));
                        YiZhuang.DeclareUse(Player);
                    }
                }
            });
        }));
    }
Example #28
0
 public static PBlock AIEmitTarget(PGame Game, PPlayer Player)
 {
     return(PMath.Max(Game.Map.BlockList.FindAll((PBlock Block) => Block.Lord != null && Block.Lord.TeamIndex == Player.TeamIndex), (PBlock Block) => {
         return PAiMapAnalyzer.HouseValue(Game, Block.Lord, Block);
     }).Key);
 }
Example #29
0
    public P_ShuShangKaaiHua() : base(CardName)
    {
        Point = 5;
        Index = 29;
        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 = 100,
                    Condition = (PGame Game) => {
                        return Player.Equals(Game.NowPlayer) && (Player.IsAI || Game.Logic.WaitingForEndFreeTime()) && Game.Map.BlockList.Exists((PBlock Block) => Block.Lord != null);
                    },
                    AICondition = (PGame Game) => {
                        return PMath.Max(Game.Map.BlockList.FindAll((PBlock Block) => Block.Lord != null && Block.Lord.TeamIndex == Player.TeamIndex), (PBlock Block) => {
                            return PAiMapAnalyzer.HouseValue(Game, Block.Lord, Block);
                        }).Value >= 2500;
                    },
                    Effect = (PGame Game) => {
                        List <PPlayer> Targets = new List <PPlayer>();
                        Game.Monitor.CallTime(PTime.Card.AfterEmitTargetTime, new PUseCardTag(Card, Player, Targets));
                        if (Player.Area.EquipmentCardArea.CardList.Contains(Card))
                        {
                            Game.CardManager.MoveCard(Card, Player.Area.EquipmentCardArea, Game.CardManager.SettlingArea);
                        }
                        else
                        {
                            Game.CardManager.MoveCard(Card, Player.Area.HandCardArea, Game.CardManager.SettlingArea);
                        }
                        Game.Monitor.CallTime(PTime.Card.AfterBecomeTargetTime, new PUseCardTag(Card, Player, Targets));

                        PBlock Target = null;
                        if (Player.IsAI)
                        {
                            Target = AIEmitTarget(Game, Player);
                        }
                        else
                        {
                            Target = PNetworkManager.NetworkServer.ChooseManager.AskToChooseBlock(Player, "树上开花[选择有主土地]", (PBlock Block) => Block.Lord != null);
                        }
                        if (Target != null)
                        {
                            PNetworkManager.NetworkServer.TellClients(new PHighlightBlockOrder(Target.Index.ToString()));
                            Game.GetHouse(Target, 1);
                            #region 成就:花开富贵
                            if (Target.BusinessType.Equals(PBusinessType.Park))
                            {
                                PArch.Announce(Game, Player, "花开富贵");
                            }
                            #endregion
                        }

                        Game.CardManager.MoveCard(Card, Game.CardManager.SettlingArea, Game.CardManager.ThrownCardHeap);
                        Game.Monitor.CallTime(PTime.Card.EndSettleTime, new PUseCardTag(Card, Player, Targets));
                    }
                });
            });
        }
    }
Example #30
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="Game"></param>
 /// <param name="Player"></param>
 /// <param name="Condition"></param>
 /// <param name="ExpectedMoney"></param>
 /// <returns></returns>
 public static PPlayer InjureTarget(PGame Game, PPlayer FromPlayer, PPlayer Player, PTrigger.PlayerCondition Condition = null, int ExpectedMoney = 0, PObject Source = null, bool AllowNegative = false)
 {
     return(PMath.Max(Game.PlayerList.FindAll((PPlayer Target) => Target.IsAlive && (Condition == null || Condition(Game, Target))), (PPlayer Target) => {
         return InjureExpect(Game, Player, FromPlayer, Target, ExpectedMoney, Source) + PMath.RandInt(0, 10);
     }, !AllowNegative).Key);
 }