コード例 #1
0
ファイル: PlayerAction.cs プロジェクト: kolyan1981by/monop
        public static void Buy(Game g)
        {
            if (g.State != GameState.CanBuy) return;

            var p = g.Curr;

            var cell = g.CurrCell;

            if (cell.IsLand)
            {
                if (cell.Owner == null)
                {
                    //--buy
                    var ff = BotBrain.FactorOfBuy(g, p, cell);

                    bool needBuy = ff >= 1;

                    if (p.IsBot)
                    {
                        if (ff >= 1 && p.Money < cell.Cost)
                            needBuy = BotBrain.MortgageSell(g, cell.Cost);
                    }
                    else
                    {
                        if (p.Money < cell.Cost)
                        {
                            g.ToCantPay();
                            return;
                        }
                    }

                    if (needBuy)
                    {
                        g.Map.SetOwner(p, cell);
                        g.Tlogp("PlayerAction.Bought", "вы купили {0} за {1}", "You bought {0} for {1}", cell.Name, cell.Cost.PrintMoney());
                        g.FinishStep(string.Format("bought_{0}_f({1})", cell.Id, ff));
                    }
                    else
                    {
                        g.ToAuction();
                    }
                }
            }
        }
コード例 #2
0
ファイル: GameHandlers.cs プロジェクト: kolyan1981by/monop
        public static string Go(Game g, string act, string userName)
        {
            string res = "";

            if (act == "ok") g.FinishStep();

            if (g.Curr.CaughtByPolice)
            {
                if (act == "policekey")
                {
                    g.Curr.FreePoliceKey--;
                    g.Curr.Police = 0;
                    g.ToBeginRound();
                }
                else
                    PlayerAction.PayToPolice(g);
            }

            if (g.State == GameState.CanBuy || g.State == GameState.CantPay)
            {
                if (act == "auc")
                {
                    g.ToAuction();
                    res = GameRender.RenderAuction(g, userName);
                }
                else
                {
                    PlayerAction.Buy(g);
                }

            }

            if (g.State == GameState.Auction)
            {
                if (act == "auc_y")
                {
                    PlayerAction.MakeAuctionYes(g, userName);
                }
                else if (act == "auc_no")
                {
                    PlayerAction.MakeAuctionNo(g, userName);
                }
                //LogicBot.CheckAuctionJob(g);
            }

            if (g.State == GameState.NeedPay)
                PlayerAction.Pay(g);

            if (g.State == GameState.CantPay)
            {
                PlayerAction.Pay(g);
                if (g.Curr.IsBot)
                {
                    g.Tlogp("LeaveGame", "вы банкрот и покидаете игру", "you are bankrupt");
                    GameManager.LeaveGame(g, g.Curr.Name);
                }
                else
                {

                    res = g.Text("go.CannotPay", "у вас нет денег, попробуйте заложить или продать <br />",
                        "you dont have money,try mortage <br />");

                    res += "<br />" + GameRender.UIParts("ButtonPay");
                }
                //PlayerAction.Pay(g);
            }

            if (g.State == GameState.Trade)
            {
                PlayerAction.MakeTrade(g, userName, act == "tr_y");
            }

            if (g.State == GameState.MoveToCell)
            {
                if (g.Curr.Pos == 30)
                    PlayerStep.MoveFrom30(g);
                else
                    PlayerStep.MoveAfterRandom(g);
            }

            if (g.State == GameState.EndStep)
            {
                g.FinishRound();
            }

            return res;
        }