public static string PrintPlayerCellText(CellInf cell) { var c = GetColorOfGroup(cell.Group); var CellName = string.Format(ColorGroupCell, c.R, c.G, c.B, cell.Name); var IsMortg = cell.IsMortgage ? "(M)" : ""; var HousesCount = cell.PrintHouses; return string.Format("{0}{1}{2}", CellName, IsMortg, HousesCount); }
public static int GetPlayerAssets(int pid, int money, CellInf[] cells, bool needMonop = true) { var userCells = cells.Where(x => x.Owner == pid && !x.IsMortgage); int sum = 0; foreach (var item in userCells) { if (needMonop) { sum += item.MortgageAmount; if (item.HousesCount > 0) { sum += item.HousesCount * item.HouseCostWhenSell; } } else { if (!item.IsMonopoly) sum += item.Cost; } } return sum + money; }
public void UpdateCell(CellInf cell) { var mm = g.Map.CellsByUserByGroup(cell.Owner.Value, cell.Group); cell.OwGrCount = mm.Count(); }
public void SetOwner(Player p, CellInf cell) { cell.Owner = p.Id; cell.IsMortgage = false; p.Money -= cell.Cost; UpdateMap(); }
public static double FactorOfBuy(Game g, Player p, CellInf cell) { double isNeedBuy = 0; if (GameHelper.GetPlayerAssets(g, p.Id) < cell.Cost) return 0; var groupsWithHouses = BotBrainHouses.GetGroupsWhereNeedBuildHouses(g, p); var needBuild = groupsWithHouses.Any(); //--buy var gg = g.Map.CellsByGroup(cell.Group); //other monopoly var notMine = gg.Where(x => x.Owner.HasValue && x.Owner != p.Id); var myCount = gg.Count(x => x.Owner == p.Id); int aCount = 0; int? owPid = null; if (notMine.Any()) { aCount = notMine.Max(x => x.OwGrCount); owPid = notMine.First(x => x.OwGrCount == aCount).Owner; } var manualFactor = GetManualFactor(g.AucRules, cell.Group, myCount, aCount, groupsWithHouses); if (manualFactor.HasValue) return manualFactor.Value; var cg = cell.Group; //if another monopoly if (aCount == 2 && owPid.HasValue) { var sum = g.GetPlayerCash(owPid.Value); if (cg == 2 && sum > 4000000) return 100; if (cg == 3 && sum > 4000000) return 100; if (cg == 4 && sum > 5000000) return 100; if (cg == 5 && sum > 7000000) return 100; if (cell.Type == 1) return 1.7; } if (needBuild) return 0; if (cg == 1 || cg == 8) isNeedBuy = Factor_1_8(cg, aCount); if (cg == 11 && !needBuild) { if (aCount > 2) isNeedBuy = 2; else isNeedBuy = 1.5; } if (cg == 33) isNeedBuy = Factor_11_33(cg, aCount); //my second cell if (myCount == 1) isNeedBuy = 2.2; //my monopoly if (myCount == 2) isNeedBuy = 3; if (aCount == 1 && cell.Group != 1 && cell.Group != 8) isNeedBuy = 2; //first land if (gg.Count(x => x.Owner == null) == 3 && !needBuild) isNeedBuy = 1.4; return isNeedBuy; }
public static bool NeedBuy(Game g, Player p, CellInf cell) { var fact = BotBrain.FactorOfBuy(g, p, cell); bool needBuy = false; if (fact >= 100) needBuy = BotBrain.MortgageSell(g, p, cell.Cost); else if (fact >= 1) needBuy = BotBrain.Mortgage(g, p, cell.Cost); return needBuy; }
public static void ProcessLand(Game g, Player p, CellInf cell) { if (cell.Owner == null) { g.ToCanBuy(); } else if (cell.Owner != p.Id) { if (cell.IsMortgage) { g.Tlogp("ProcessLand.CellIsMortgaged", "земля {0} заложена", "land {0} is mortgaged ", cell.Name); g.FinishStep("cell_mortgaged"); } else { //pay rent g.PayToUserId = cell.Owner.Value; g.ToPay(cell.Rent); } } else if (cell.Owner == p.Id) { g.Tlogp("ProcessLand.MyCell", "ваше поле {0}", "your cell {0} ", cell.Name); g.FinishStep("mycell"); } }