private KeyValuePair <KeyValuePair <PBlock, PBlock>, int> MaxLandPair(PGame Game, PPlayer Player) { int Test = int.MinValue; List <PBlock> LandList = Game.Map.BlockList.FindAll((PBlock Block) => Block.Lord != null && !Block.IsBusinessLand); PBlock Ans1 = null; PBlock Ans2 = null; foreach (PBlock Land1 in LandList) { foreach (PBlock Land2 in LandList) { if (Land1.Index < Land2.Index) { int HouseCount1 = Land1.HouseNumber; int HouseCount2 = Land2.HouseNumber; int ValueBefore = PAiMapAnalyzer.HouseValue(Game, Player, Land1) * HouseCount1 + PAiMapAnalyzer.HouseValue(Game, Player, Land2) * HouseCount2; int ValueAfter = PAiMapAnalyzer.HouseValue(Game, Player, Land1) * HouseCount2 + PAiMapAnalyzer.HouseValue(Game, Player, Land2) * HouseCount1; if (ValueAfter - ValueBefore > Test) { Test = ValueAfter - ValueBefore; Ans1 = Land1; Ans2 = Land2; } } } } return(new KeyValuePair <KeyValuePair <PBlock, PBlock>, int>(new KeyValuePair <PBlock, PBlock>(Ans1, Ans2), Test)); }
public static List <PBlock> NextBlocks(PGame Game, PPlayer Player, PBlock StartBlock = null) { if (StartBlock == null) { StartBlock = Player.Position; } List <PBlock> Answer = new List <PBlock>(); PBlock Block = StartBlock; if (!Player.NoLadder) { Block = Block.NextBlock; } if (Player.Traffic != null && Player.Traffic.Model is P_ChiihTuu) { Block = Block.NextBlock; } if (Player.NoLadder) { Answer.Add(Block); } else { for (int i = 0; i < 6; ++i, Block = Block.NextBlock) { Answer.Add(Block); } } return(Answer); }
// 这个是Client端的StartGame // Server的StartGame在PGame里 public void StartGame(List <PGeneral> DefaultGenerals = null) { #region 初始化玩家列表 PlayerList = new List <PPlayer>(); for (int i = 0; i < PlayerNumber; ++i) { PlayerList.Add(new PPlayer() { Index = i, Name = PSystem.CurrentRoom.PlayerList[i].PlayerType.Equals(PPlayerType.Player) ? PSystem.CurrentRoom.PlayerList[i].Nickname : "P" + (i + 1).ToString(), IsAlive = true, Money = PPlayer.Config.DefaultMoney, TeamIndex = GameMode.Seats[i].Party - 1, Tags = null }); PBlock Position = Map.BlockList.Find((PBlock Block) => Block.StartPointIndex == i % Map.StartPointNumber); if (Position != null) { PlayerList[i].Position = Position; } else { PlayerList[i].Position = Map.BlockList[0]; } } #endregion NowPlayer = null; NowPeriod = null; }
public int AIExpect(PGame Game, PPlayer Player, PBlock Block) { int[] dx = { 1, -1, 0, 0 }; int[] dy = { 0, 0, 1, -1 }; int OriginalX = Block.X; int OriginalY = Block.Y; int sum, x, y; sum = PAiMapAnalyzer.HouseValue(Game, Player, Block); for (int i = 0; i < 4; ++i) { x = OriginalX; y = OriginalY; do { x += dx[i]; y += dy[i]; PBlock TempBlock = Game.Map.FindBlockByCoordinate(x, y); if (TempBlock != null) { if (TempBlock.Lord != null) { sum += PAiMapAnalyzer.HouseValue(Game, Player, TempBlock); } } else { break; } } while (true); } return(sum); }
/// <summary> /// 建造城堡可以获得的赠送房屋数量 /// </summary> /// <param name="Player"></param> /// <param name="Block"></param> /// <returns></returns> public int GetBonusHouseNumberOfCastle(PPlayer Player, PBlock Block) { int[] dx = { 1, -1, 0, 0 }; int[] dy = { 0, 0, 1, -1 }; int OriginalX = Block.X; int OriginalY = Block.Y; int sum = 0, x, y; for (int i = 0; i < 4; ++i) { x = OriginalX; y = OriginalY; do { x += dx[i]; y += dy[i]; PBlock TempBlock = Map.FindBlockByCoordinate(x, y); if (TempBlock != null) { if (TempBlock.Lord != null && !TempBlock.Lord.Equals(Player)) { sum += TempBlock.HouseNumber; } } else { break; } } while (true); } return(sum); }
public PTollTag(PPlayer FromPlayer, PPlayer ToPlayer, int Toll, PBlock Block) : base(TagName) { AppendField(FromPlayerFieldName, FromPlayer); AppendField(ToPlayerFieldName, ToPlayer); AppendField(TollFieldName, Toll); AppendField(BlockFieldName, Block); }
/// <summary> /// 弃一座房屋(没有则不弃) /// </summary> /// <param name="Player"></param> /// <param name="TargetPlayer"></param> /// <param name="Title"></param> public void ThrowHouse(PPlayer Player, PPlayer TargetPlayer, string Title) { if (TargetPlayer.HasHouse) { PBlock TargetBlock = null; if (Player.IsAI) { if (Player.TeamIndex == TargetPlayer.TeamIndex) { TargetBlock = PAiMapAnalyzer.MinValueHouse(this, TargetPlayer).Key; } else { TargetBlock = PAiMapAnalyzer.MaxValueHouse(this, TargetPlayer).Key; } } else { TargetBlock = PNetworkManager.NetworkServer.ChooseManager.AskToChooseBlock(Player, "[" + Title + "]选择" + TargetPlayer.Name + "的房屋", (PBlock Block) => TargetPlayer.Equals(Block.Lord) && Block.HouseNumber > 0); } if (TargetBlock != null) { PNetworkManager.NetworkServer.TellClients(new PHighlightBlockOrder(TargetBlock.Index.ToString())); LoseHouse(TargetBlock, 1); } } }
public P_BaiQi() : base("白起") { Sex = PSex.Male; Age = PAge.Classic; Index = 9; Cost = 25; Tips = "定位:爆发\n" + "难度:简单\n" + "史实:战国时期秦国名将,“战国四大名将”之一,曾在伊阙之战、长平之战中大败三晋军队,歼敌数十万,功封武安君。\n" + "攻略:\n白起是一个强制命中系武将,白起的存在使得对方无法通过【李代桃僵】、【指桑骂槐】一类的牌免除伤害,或通过【八卦阵】、【龙胆】等方式减少伤害,而必须硬吃下伤害的100%(通常这个数字比伤害值高)。随之带来的损失则是收费地的地价永久性减少,很多时候这是不值的,但在必杀一击上,白起一点都不会含糊。"; PSkill CanSha = new PSkill("残杀"); SkillList.Add(CanSha .AddTrigger( (PPlayer Player, PSkill Skill) => { return(new PTrigger(CanSha.Name) { IsLocked = false, Player = Player, Time = PTime.Injure.EmitInjure, AIPriority = 100, Condition = (PGame Game) => { PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName); return InjureTag.Injure > 0 && InjureTag.ToPlayer != null && Player.Equals(InjureTag.FromPlayer) && InjureTag.InjureSource is PBlock && ((PBlock)InjureTag.InjureSource).Price >= 1000; }, AICondition = (PGame Game) => { PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName); if (InjureTag.ToPlayer.TeamIndex != Player.TeamIndex) { int Benefit = PMath.Percent(InjureTag.Injure, 100); if (Benefit + InjureTag.Injure >= InjureTag.ToPlayer.Money) { // 一击必杀 return true; } if (Benefit >= 2000) { PBlock Source = (PBlock)InjureTag.InjureSource; int Cost = 1000 + PAiMapAnalyzer.HouseValue(Game, Player, Source) * Source.HouseNumber * 1000 / Source.Price; if (Cost < Benefit) { return true; } } } return false; }, Effect = (PGame Game) => { CanSha.AnnouceUseSkill(Player); PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName); PBlock Source = (PBlock)InjureTag.InjureSource; Source.Price -= 1000; PNetworkManager.NetworkServer.TellClients(new PRefreshBlockBasicOrder(Source)); Game.LoseMoney(InjureTag.ToPlayer, PMath.Percent(InjureTag.Injure, 100)); } }); })); }
public void MovePosition(PPlayer Player, PBlock Source, PBlock Destination) { if (Player == null || !Player.IsAlive) { return; } Monitor.CallTime(PTime.MovePositionTime, new PTransportTag(Player, Source, Destination)); }
public P_FanKeevWeiChu() : base(CardName) { Point = 5; Index = 30; foreach (PTime Time in new PTime[] { PTime.Injure.AfterAcceptInjure }) { MoveInHandTriggerList.Add((PPlayer Player, PCard Card) => { return(new PTrigger(CardName) { IsLocked = false, Player = Player, Time = Time, AIPriority = 100, Condition = (PGame Game) => { PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName); if (!(InjureTag.InjureSource is PBlock)) { return false; } else { PBlock Block = (PBlock)InjureTag.InjureSource; return Player.Equals(InjureTag.ToPlayer) && InjureTag.Injure > 0 && InjureTag.InjureSource != null && !Player.Equals(Block.Lord) && Block.HouseNumber == 1; } }, AICondition = (PGame Game) => { PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName); PBlock Block = (PBlock)InjureTag.InjureSource; return Player.TeamIndex != Block.Lord.TeamIndex; }, Effect = (PGame Game) => { List <PPlayer> Targets = new List <PPlayer>(); Game.Monitor.CallTime(PTime.Card.AfterEmitTargetTime, new PUseCardTag(Card, Player, Targets)); Game.CardManager.MoveCard(Card, Player.Area.HandCardArea, Game.CardManager.SettlingArea); Game.Monitor.CallTime(PTime.Card.AfterBecomeTargetTime, new PUseCardTag(Card, Player, Targets)); PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName); PBlock Block = (PBlock)InjureTag.InjureSource; Block.Lord = Player; PNetworkManager.NetworkServer.TellClients(new PHighlightBlockOrder(Block.Index.ToString())); PNetworkManager.NetworkServer.TellClients(new PRefreshBlockBasicOrder(Block)); #region 成就:我的地盘我做主 if (Block.BusinessType.Equals(PBusinessType.Castle)) { 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)); } }); }); } }
public void InitializeBlock(PBlock Block) { BlockName.text = GetInformationText(Block); BlockNumber.text = Block.CanPurchase && Block.Lord != null?Block.HouseNumber.ToString() : string.Empty; BlockType.text = Block.BusinessType.Equals(PBusinessType.NoType) ? string.Empty : Block.BusinessType.Name; UIBackgroundImage.position = GetSpacePosition(Block); SetColor(Block.Lord == null ? Config.DefaultBlockColor : PPlayerScene.Config.PlayerColors[Block.Lord.Index]); }
public PBlock NextStepBlock(PBlock StartPoint, int StepCount) { PBlock Answer = StartPoint; for (int i = 0; i < StepCount; ++i) { Answer = Answer.NextBlock; } return(Answer); }
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++; } } }); }); } }
public static PBusinessType ChooseDirection(PGame Game, PPlayer Player, PBlock Block) { List <int> ExpectationList = DirectionExpectations(Game, Player, Block); List <double> Weights = ExpectationList.ConvertAll((int Raw) => Math.Pow(Math.E, (double)Raw / 1000)); return(new PBusinessType[] { PBusinessType.ShoppingCenter, PBusinessType.Institute, PBusinessType.Park, PBusinessType.Castle, PBusinessType.Altar }[PMath.RandomIndex(Weights)]); }
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); }
public PMovePositionOrder() : base("move_position", null, (string[] args) => { int PlayerIndex = int.Parse(args[1]); int DestinationIndex = int.Parse(args[2]); if (0 <= PlayerIndex && PlayerIndex < PNetworkManager.NetworkClient.GameStatus.PlayerNumber && 0 <= DestinationIndex && DestinationIndex < PNetworkManager.NetworkClient.GameStatus.Map.BlockList.Count) { PBlock DestinationBlock = PNetworkManager.NetworkClient.GameStatus.Map.BlockList[DestinationIndex]; PPlayer Player = PNetworkManager.NetworkClient.GameStatus.PlayerList[PlayerIndex]; Player.Position = DestinationBlock; Vector3 DestinationSpacePosition = PPlayerScene.GetSpacePosition(Player); PUIManager.GetUI <PMapUI>().Scene.PlayerGroup.MovePlayer(PlayerIndex, DestinationSpacePosition); } }) { }
public void PurchaseLand(PPlayer Player, PBlock Block) { PPurchaseLandTag PurchaseLandTag = Monitor.CallTime(PTime.PurchaseLandTime, new PPurchaseLandTag(Player, Block)); Player = PurchaseLandTag.Player; Block = PurchaseLandTag.Block; int LandPrice = PurchaseLandTag.LandPrice; if (Player != null && Block != null && Player.IsAlive) { LoseMoney(Player, LandPrice); Block.Lord = Player; GetHouse(Block, 1); PNetworkManager.NetworkServer.TellClients(new PRefreshBlockBasicOrder(Block)); if (Block.IsBusinessLand && Block.BusinessType.Equals(PBusinessType.NoType)) { PBusinessType ChosenType = PBusinessType.NoType; List <PBusinessType> Types = new List <PBusinessType>() { PBusinessType.ShoppingCenter, PBusinessType.Institute, PBusinessType.Altar, PBusinessType.Castle, PBusinessType.Park }; if (Player.IsUser) { ChosenType = Types[PNetworkManager.NetworkServer.ChooseManager.Ask(Player, "选择商业用地的发展方向", Types.ConvertAll((PBusinessType BusinessType) => BusinessType.Name).ToArray(), Types.ConvertAll((PBusinessType BusinessType) => BusinessType.ToolTip).ToArray())]; } else { ChosenType = PAiBusinessChooser.ChooseDirection(this, Player, Block); } Block.BusinessType = ChosenType; if (ChosenType.Equals(PBusinessType.Park)) { GetMoney(Player, PMath.Percent(Block.Price, 50)); } else if (ChosenType.Equals(PBusinessType.Castle)) { GetHouse(Block, GetBonusHouseNumberOfCastle(Player, Block)); } PNetworkManager.NetworkServer.TellClients(new PRefreshBlockBasicOrder(Block)); } else { Block.BusinessType = PBusinessType.NoType; } PNetworkManager.NetworkServer.TellClients(new PShowInformationOrder(Player.Name + "购买了" + Block.Name)); } }
public void GetHouse(PBlock Block, int HouseCount) { if (HouseCount <= 0) { return; } PGetHouseTag GetHouseTag = Monitor.CallTime(PTime.GetHouseTime, new PGetHouseTag(Block, HouseCount)); PBlock GetHouseBlock = GetHouseTag.Block; int GetHouseCount = GetHouseTag.House; if (GetHouseBlock != null && GetHouseCount > 0) { GetHouseBlock.HouseNumber += GetHouseCount; PNetworkManager.NetworkServer.TellClients(new PRefreshBlockBasicOrder(GetHouseBlock)); } }
public static KeyValuePair <PBlock, int> Grx_Next(PGame Game, PBlock Block) { if (Block.HouseNumber > 0) { return(new KeyValuePair <PBlock, int>(Block, 0)); } PBlock Answer = Block.NextBlock; int Count = 1; for (; Count < 6 && !Game.AlivePlayers().Exists((PPlayer _Player) => _Player.Position.Equals(Answer)) && Answer.HouseNumber == 0; ++Count) { Answer = Answer.NextBlock; } return(new KeyValuePair <PBlock, int>(Answer, Count)); }
public PRefreshBlockBasicOrder() : base("refresh_block_basic", null, (string[] args) => { int BlockIndex = Convert.ToInt32(args[1]); int LordIndex = Convert.ToInt32(args[2]); int HouseNumber = Convert.ToInt32(args[3]); int Price = Convert.ToInt32(args[5]); PBusinessType BusinessType = FindInstance <PBusinessType>(args[4]); PBlock Block = PNetworkManager.NetworkClient.GameStatus.Map.FindBlock(BlockIndex); PPlayer Lord = PNetworkManager.NetworkClient.GameStatus.FindPlayer(LordIndex); if (Block != null && BusinessType != null) { PAnimation.AddAnimation("刷新格子基本信息", () => { PPlayer OriginalLord = Block.Lord; Block.Lord = Lord; Block.Price = Price; Block.HouseNumber = HouseNumber; Block.BusinessType = BusinessType; PUIManager.GetUI <PMapUI>().Scene.BlockGroup.GroupUIList[BlockIndex].InitializeBlock(Block); if (OriginalLord != null) { if (Block.IsBusinessLand) { OriginalLord.BusinessLandNumber--; } else { OriginalLord.NormalLandNumber--; } PUIManager.GetUI <PMapUI>().PlayerInformationGroup.Update(OriginalLord.Index); } if (Lord != null) { if (Block.IsBusinessLand) { Lord.BusinessLandNumber++; } else { Lord.NormalLandNumber++; } PUIManager.GetUI <PMapUI>().PlayerInformationGroup.Update(Lord.Index); } }); } }) { }
public void LoseHouse(PBlock Block, int HouseCount) { if (HouseCount <= 0) { return; } PLoseHouseTag LoseHouseTag = Monitor.CallTime(PTime.LoseHouseTime, new PLoseHouseTag(Block, HouseCount)); PBlock LoseHouseBlock = LoseHouseTag.Block; int LoseHouseCount = LoseHouseTag.House; if (LoseHouseBlock != null && LoseHouseCount > 0) { LoseHouseBlock.HouseNumber -= LoseHouseCount; LoseHouseBlock.HouseNumber = Math.Max(0, LoseHouseBlock.HouseNumber); PNetworkManager.NetworkServer.TellClients(new PRefreshBlockBasicOrder(LoseHouseBlock)); } }
public P_FuTiChoouHsin() : base(CardName) { Point = 4; Index = 19; foreach (PTime Time in new PTime[] { PTime.Injure.AfterAcceptInjure }) { MoveInHandTriggerList.Add((PPlayer Player, PCard Card) => { return(new PTrigger(CardName) { IsLocked = false, Player = Player, Time = Time, AIPriority = 60, Condition = (PGame Game) => { PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName); return Player.Equals(InjureTag.ToPlayer) && InjureTag.FromPlayer != null && InjureTag.Injure > 0 && InjureTag.InjureSource != null && (InjureTag.InjureSource is PBlock) && ((PBlock)InjureTag.InjureSource).HouseNumber > 0; }, AICondition = (PGame Game) => { PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName); PBlock Block = (PBlock)InjureTag.InjureSource; return Block.Lord != null && Block.Lord.TeamIndex != Player.TeamIndex && (PAiMapAnalyzer.HouseValue(Game, Block.Lord, Block) >= 5400 || Player.Money <= 3000); }, Effect = (PGame Game) => { List <PPlayer> Targets = new List <PPlayer>(); Game.Monitor.CallTime(PTime.Card.AfterEmitTargetTime, new PUseCardTag(Card, Player, Targets)); Game.CardManager.MoveCard(Card, Player.Area.HandCardArea, Game.CardManager.SettlingArea); Game.Monitor.CallTime(PTime.Card.AfterBecomeTargetTime, new PUseCardTag(Card, Player, Targets)); PInjureTag InjureTag = Game.TagManager.FindPeekTag <PInjureTag>(PInjureTag.TagName); PBlock Block = (PBlock)InjureTag.InjureSource; #region 成就:破釜沉舟 if (Block.HouseNumber >= 10) { PArch.Announce(Game, Player, "破釜沉舟"); } #endregion Game.LoseHouse(Block, Block.HouseNumber); Game.CardManager.MoveCard(Card, Game.CardManager.SettlingArea, Game.CardManager.ThrownCardHeap); Game.Monitor.CallTime(PTime.Card.EndSettleTime, new PUseCardTag(Card, Player, Targets)); } }); }); } }
public override void AnnouceInvokeJudge(PGame Game, PPlayer Player, PCard Card) { base.AnnouceInvokeJudge(Game, Player, Card); int Result = Game.Judge(Player, new Func <int>(() => { if (AIExpect(Game, Player, Player.Position) < -1000) { return(1); } return(6); })()); if (Result != 1) { PBlock Block = Player.Position; int[] dx = { 1, -1, 0, 0 }; int[] dy = { 0, 0, 1, -1 }; int OriginalX = Block.X; int OriginalY = Block.Y; int x, y; Game.GetHouse(Block, 1); for (int i = 0; i < 4; ++i) { x = OriginalX; y = OriginalY; do { x += dx[i]; y += dy[i]; PBlock TempBlock = Game.Map.FindBlockByCoordinate(x, y); if (TempBlock != null) { if (TempBlock.Lord != null) { Game.GetHouse(TempBlock, 1); } } else { break; } } while (true); } } Game.CardManager.MoveCard(Card, Player.Area.AmbushCardArea, Game.CardManager.ThrownCardHeap); }
public static int HouseValue(PGame Game, PPlayer Player, PBlock Block) { if (Block.Lord == null) { return(0); } int EnemyCount = Game.Enemies(Block.Lord).Count; int Value = PMath.Percent(Block.Price, 50 + 20 * EnemyCount * (Block.BusinessType.Equals(PBusinessType.ShoppingCenter) ? 2 : 1) * (Block.BusinessType.Equals(PBusinessType.Club) ? 2 : 1)); if (Player.TeamIndex == Block.Lord.TeamIndex) { return(Value); } else { return(-Value); } }
public void Toll(PPlayer FromPlayer, PPlayer ToPlayer, PBlock Block) { PNetworkManager.NetworkServer.TellClients(new PShowInformationOrder(FromPlayer.Name + "向" + ToPlayer.Name + "收取过路费")); PTollTag TollTag = Monitor.CallTime(PTime.Toll.AfterEmitTarget, new PTollTag(FromPlayer, ToPlayer, Block.Toll, Block)); if (TollTag.ToPlayer != null && TollTag.ToPlayer.IsAlive && TollTag.Toll > 0) { TollTag = Monitor.CallTime(PTime.Toll.AfterAcceptTarget, TollTag); if (TollTag.ToPlayer != null && TollTag.ToPlayer.IsAlive && TollTag.Toll > 0) { Injure(TollTag.FromPlayer, TollTag.ToPlayer, TollTag.Toll, TollTag.Block); if (Block.BusinessType.Equals(PBusinessType.Club)) { ChangeFace(ToPlayer); } } } }
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); } }) }); }); } }
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)); }
public PBlock AskToChooseBlock(PPlayer Player, string Title, Predicate <PBlock> Condition = null) { PGame Game = PNetworkManager.NetworkServer.Game; PBlock Answer = null; Game.TagManager.CreateTag(new PChooseBlockTag(Player, null)); PNetworkManager.NetworkServer.TellClient(Player, new PShowInformationOrder(Title)); while (Answer == null) { PThread.WaitUntil(() => Game.TagManager.FindPeekTag <PChooseBlockTag>(PChooseBlockTag.TagName).Block != null); Answer = Game.TagManager.FindPeekTag <PChooseBlockTag>(PChooseBlockTag.TagName).Block; if (Condition != null && !Condition(Answer)) { Answer = null; PThread.Delay(0.2f); } } return(Game.TagManager.PopTag <PChooseBlockTag>(PChooseBlockTag.TagName).Block); }
public void PurchaseHouse(PPlayer Player, PBlock Block) { PPurchaseHouseTag PurchaseHouseTag = Monitor.CallTime(PTime.PurchaseHouseTime, new PPurchaseHouseTag(Player, Block)); Player = PurchaseHouseTag.Player; Block = PurchaseHouseTag.Block; int HousePrice = PurchaseHouseTag.HousePrice; if (Player != null && Block != null && Player.IsAlive) { PNetworkManager.NetworkServer.TellClients(new PShowInformationOrder(Player.Name + "购买了1座房屋")); PNetworkManager.NetworkServer.TellClients(new PHighlightBlockOrder(Block.Index.ToString())); if (Block.HousePrice > 0) { LoseMoney(Player, HousePrice); } GetHouse(Block, 1); PNetworkManager.NetworkServer.TellClients(new PRefreshBlockBasicOrder(Block)); } }
public P_Newton() : base("牛顿") { Sex = PSex.Male; Age = PAge.Renaissance; Index = 19; Cost = 40; Tips = "定位:防御\n" + "难度:中等\n" + "史实:英国物理学家、数学家。主要贡献包括但不限于发现万有引力定律、牛顿运动定律、光的色散原理,提出微积分、牛顿迭代法、二项式定理,发明反射式望远镜等。代表作《自然哲学的数学原理》。\n" + "攻略:\n牛顿是一个趣味性十足的武将,技能应用十分灵活,【惯性】的存在使其拥有极强的移动能力,能够灵活规避各种危险,同时在前期迅速攫取土地,中后期能够更快经过奖励处,从而拥有一定的续航能力。牛顿可以配合队友的上屋抽梯或逃避敌人的【剑舞】或【霸王】,需要较强的预判力。"; PSkill Grx_ = new PSkill("惯性"); SkillList.Add(Grx_ .AddTrigger( (PPlayer Player, PSkill Skill) => { return(new PTrigger(Grx_.Name) { IsLocked = false, Player = Player, Time = PPeriod.WalkingStage.Start, AIPriority = 10, Condition = (PGame Game) => { return Game.NowPlayer.Equals(Player) && Player.Position.HouseNumber == 0 && Player.Money > 500; }, AICondition = (PGame Game) => { PStepCountTag StepCountTag = Game.TagManager.FindPeekTag <PStepCountTag>(PStepCountTag.TagName); int Current = PAiMapAnalyzer.Expect(Game, Player, Game.Map.NextStepBlock(Player.Position, StepCountTag.StepCount)); PBlock NewtonTarget = Grx_Next(Game, Player.Position).Key; int Possible = PAiMapAnalyzer.Expect(Game, Player, Game.Map.NextStepBlock(NewtonTarget, StepCountTag.StepCount)); return Possible - Current > 500; }, Effect = (PGame Game) => { Grx_.AnnouceUseSkill(Player); Game.LoseMoney(Player, 500); Game.MovePosition(Player, Player.Position, Grx_Next(Game, Player.Position).Key); } }); })); }
public AThisArrayPropertyDecl( PVisibilityModifier _visibility_modifier_, PType _type_, TThis _token_, PType _arg_type_, TIdentifier _arg_name_, PBlock _getter_, PBlock _setter_ ) { SetVisibilityModifier(_visibility_modifier_); SetType(_type_); SetToken(_token_); SetArgType(_arg_type_); SetArgName(_arg_name_); SetGetter(_getter_); SetSetter(_setter_); }
public APropertyDecl( PVisibilityModifier _visibility_modifier_, TStatic _static_, PType _type_, TIdentifier _name_, PBlock _getter_, PBlock _setter_ ) { SetVisibilityModifier(_visibility_modifier_); SetStatic(_static_); SetType(_type_); SetName(_name_); SetGetter(_getter_); SetSetter(_setter_); }
public ASwitchCaseStm( PSwitchCaseType _type_, PBlock _block_ ) { SetType(_type_); SetBlock(_block_); }
internal override void RemoveChild(Node child) { if (_token_ == child) { _token_ = null; return; } if (_initializer_param_.Contains(child)) { _initializer_param_.Remove(child); return; } if (_body_ == child) { _body_ = null; return; } }
public AFunction( TKeywordFunc _keyword_func_, TOperatorOpeningParenthesis _operator_opening_parenthesis_, TOperatorClosingParenthesis _operator_closing_parenthesis_, PType _type_, PBlock _block_ ) { SetKeywordFunc (_keyword_func_); SetOperatorOpeningParenthesis (_operator_opening_parenthesis_); SetOperatorClosingParenthesis (_operator_closing_parenthesis_); SetType (_type_); SetBlock (_block_); }
public AFunctiondeclaration( TKeywordFunc _keyword_func_, TIdentifier _identifier_, TOperatorOpeningParenthesis _operator_opening_parenthesis_, PParameterlist _parameterlist_, TOperatorClosingParenthesis _operator_closing_parenthesis_, PBlock _block_ ) { SetKeywordFunc (_keyword_func_); SetIdentifier (_identifier_); SetOperatorOpeningParenthesis (_operator_opening_parenthesis_); SetParameterlist (_parameterlist_); SetOperatorClosingParenthesis (_operator_closing_parenthesis_); SetBlock (_block_); }
public AInitializerDecl( TInitializer _token_, IList _initializer_param_, PBlock _body_ ) { SetToken(_token_); this._initializer_param_ = new TypedList(new InitializerParam_Cast(this)); this._initializer_param_.Clear(); this._initializer_param_.AddAll(_initializer_param_); SetBody(_body_); }
public void SetEvents(PBlock node) { if (_events_ != null) { _events_.Parent(null); } if (node != null) { if (node.Parent() != null) { node.Parent().RemoveChild(node); } node.Parent(this); } _events_ = node; }
public ABlockStm( TLBrace _token_, PBlock _block_ ) { SetToken(_token_); SetBlock(_block_); }
internal override void RemoveChild(Node child) { if ( _keyword_for_ == child ) { _keyword_for_ = null; return; } if ( _identifier_ == child ) { _identifier_ = null; return; } if ( _keyword_from_ == child ) { _keyword_from_ = null; return; } if ( _a_ == child ) { _a_ = null; return; } if ( _keyword_to_ == child ) { _keyword_to_ = null; return; } if ( _b_ == child ) { _b_ = null; return; } if ( _block_ == child ) { _block_ = null; return; } }
public ATriggerDecl( PVisibilityModifier _visibility_modifier_, TIdentifier _name_, TEvents _event_token_, PBlock _events_, TConditions _conditions_token_, PBlock _conditions_, TActions _actions_token_, PBlock _actions_ ) { SetVisibilityModifier(_visibility_modifier_); SetName(_name_); SetEventToken(_event_token_); SetEvents(_events_); SetConditionsToken(_conditions_token_); SetConditions(_conditions_); SetActionsToken(_actions_token_); SetActions(_actions_); }
public AIf( TKeywordIf _keyword_if_, PIfexpr _ifexpr_, PBlock _block_ ) { SetKeywordIf (_keyword_if_); SetIfexpr (_ifexpr_); SetBlock (_block_); }
internal override void RemoveChild(Node child) { if ( _keyword_func_ == child ) { _keyword_func_ = null; return; } if ( _identifier_ == child ) { _identifier_ = null; return; } if ( _operator_opening_parenthesis_ == child ) { _operator_opening_parenthesis_ = null; return; } if ( _parameterlist_ == child ) { _parameterlist_ = null; return; } if ( _operator_closing_parenthesis_ == child ) { _operator_closing_parenthesis_ = null; return; } if ( _block_ == child ) { _block_ = null; return; } }
public AForrange( TKeywordFor _keyword_for_, TIdentifier _identifier_, TKeywordFrom _keyword_from_, PSimple _a_, TKeywordTo _keyword_to_, PSimple _b_, PBlock _block_ ) { SetKeywordFor (_keyword_for_); SetIdentifier (_identifier_); SetKeywordFrom (_keyword_from_); SetA (_a_); SetKeywordTo (_keyword_to_); SetB (_b_); SetBlock (_block_); }
public void SetSetter(PBlock node) { if (_setter_ != null) { _setter_.Parent(null); } if (node != null) { if (node.Parent() != null) { node.Parent().RemoveChild(node); } node.Parent(this); } _setter_ = node; }
public ADeconstructorDecl( PVisibilityModifier _visibility_modifier_, TIdentifier _name_, IList _formals_, PBlock _block_ ) { SetVisibilityModifier(_visibility_modifier_); SetName(_name_); this._formals_ = new TypedList(new Formals_Cast(this)); this._formals_.Clear(); this._formals_.AddAll(_formals_); SetBlock(_block_); }
internal override void RemoveChild(Node child) { if (_visibility_modifier_ == child) { _visibility_modifier_ = null; return; } if (_type_ == child) { _type_ = null; return; } if (_token_ == child) { _token_ = null; return; } if (_arg_type_ == child) { _arg_type_ = null; return; } if (_arg_name_ == child) { _arg_name_ = null; return; } if (_getter_ == child) { _getter_ = null; return; } if (_setter_ == child) { _setter_ = null; return; } }
public AElse( TKeywordElse _keyword_else_, PBlock _block_ ) { SetKeywordElse (_keyword_else_); SetBlock (_block_); }
public void SetConditions(PBlock node) { if (_conditions_ != null) { _conditions_.Parent(null); } if (node != null) { if (node.Parent() != null) { node.Parent().RemoveChild(node); } node.Parent(this); } _conditions_ = node; }
public AAElif( TKeywordElif _keyword_elif_, PIfexpr _ifexpr_, PBlock _block_ ) { SetKeywordElif (_keyword_elif_); SetIfexpr (_ifexpr_); SetBlock (_block_); }
internal override void RemoveChild(Node child) { if (_visibility_modifier_ == child) { _visibility_modifier_ = null; return; } if (_name_ == child) { _name_ = null; return; } if (_event_token_ == child) { _event_token_ = null; return; } if (_events_ == child) { _events_ = null; return; } if (_conditions_token_ == child) { _conditions_token_ = null; return; } if (_conditions_ == child) { _conditions_ = null; return; } if (_actions_token_ == child) { _actions_token_ = null; return; } if (_actions_ == child) { _actions_ = null; return; } }
internal override void RemoveChild(Node child) { if ( _keyword_if_ == child ) { _keyword_if_ = null; return; } if ( _ifexpr_ == child ) { _ifexpr_ = null; return; } if ( _block_ == child ) { _block_ = null; return; } }
internal override void RemoveChild(Node child) { if (_token_ == child) { _token_ = null; return; } if (_block_ == child) { _block_ = null; return; } }
public AMethodDecl( PVisibilityModifier _visibility_modifier_, TTrigger _trigger_, TStatic _static_, TNative _native_, TInline _inline_, TDelegate _delegate_, PType _return_type_, TIdentifier _name_, IList _formals_, PBlock _block_ ) { SetVisibilityModifier(_visibility_modifier_); SetTrigger(_trigger_); SetStatic(_static_); SetNative(_native_); SetInline(_inline_); SetDelegate(_delegate_); SetReturnType(_return_type_); SetName(_name_); this._formals_ = new TypedList(new Formals_Cast(this)); this._formals_.Clear(); this._formals_.AddAll(_formals_); SetBlock(_block_); }
internal override void RemoveChild(Node child) { if (_visibility_modifier_ == child) { _visibility_modifier_ = null; return; } if (_name_ == child) { _name_ = null; return; } if (_formals_.Contains(child)) { _formals_.Remove(child); return; } if (_block_ == child) { _block_ = null; return; } }
internal override void RemoveChild(Node child) { if (_visibility_modifier_ == child) { _visibility_modifier_ = null; return; } if (_trigger_ == child) { _trigger_ = null; return; } if (_static_ == child) { _static_ = null; return; } if (_native_ == child) { _native_ = null; return; } if (_inline_ == child) { _inline_ = null; return; } if (_delegate_ == child) { _delegate_ = null; return; } if (_return_type_ == child) { _return_type_ = null; return; } if (_name_ == child) { _name_ = null; return; } if (_formals_.Contains(child)) { _formals_.Remove(child); return; } if (_block_ == child) { _block_ = null; return; } }
public void SetBody(PBlock node) { if (_body_ != null) { _body_.Parent(null); } if (node != null) { if (node.Parent() != null) { node.Parent().RemoveChild(node); } node.Parent(this); } _body_ = node; }
public AOperatorDecl( PVisibilityModifier _visibility_modifier_, TStatic _static_, PType _return_type_, TOperator _token_, PBinop _operator_, IList _formals_, PBlock _block_ ) { SetVisibilityModifier(_visibility_modifier_); SetStatic(_static_); SetReturnType(_return_type_); SetToken(_token_); SetOperator(_operator_); this._formals_ = new TypedList(new Formals_Cast(this)); this._formals_.Clear(); this._formals_.AddAll(_formals_); SetBlock(_block_); }
internal override void RemoveChild(Node child) { if (_visibility_modifier_ == child) { _visibility_modifier_ = null; return; } if (_static_ == child) { _static_ = null; return; } if (_return_type_ == child) { _return_type_ = null; return; } if (_token_ == child) { _token_ = null; return; } if (_operator_ == child) { _operator_ = null; return; } if (_formals_.Contains(child)) { _formals_.Remove(child); return; } if (_block_ == child) { _block_ = null; return; } }
internal override void RemoveChild(Node child) { if ( _keyword_func_ == child ) { _keyword_func_ = null; return; } if ( _operator_opening_parenthesis_ == child ) { _operator_opening_parenthesis_ = null; return; } if ( _operator_closing_parenthesis_ == child ) { _operator_closing_parenthesis_ = null; return; } if ( _type_ == child ) { _type_ = null; return; } if ( _block_ == child ) { _block_ = null; return; } }