Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
 public void UpdateCell(CellInf cell)
 {
     var mm = g.Map.CellsByUserByGroup(cell.Owner.Value, cell.Group);
     cell.OwGrCount = mm.Count();
 }
Ejemplo n.º 4
0
 public void SetOwner(Player p, CellInf cell)
 {
     cell.Owner = p.Id;
     cell.IsMortgage = false;
     p.Money -= cell.Cost;
     UpdateMap();
 }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
0
        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");
            }
        }