Пример #1
0
        public static string RenderRollButton(Game g, string uname)
        {
            var pl = g.GetPlayer(uname);

            if (g.State == GameState.BeginStep && pl != null)
                if (!g.IsManualMode)
                {
                    if (pl.Id == g.Curr.Id && !pl.IsBot)
                        return UIParts("ButtonRoll");
                }
                else
                {
                    if (pl.ManRoll != 0)
                    {
                        var tt = g.Text("manRoll.pressed", "вы нажали ", "you pressed ") + pl.ManRoll;
                        return tt;
                    }
                    return UIParts("PartManualRoll");
                }

            return "wait...";
        }
Пример #2
0
        public ActionResult Mortgage(string str)
        {
            g = GetGame();
            var res = "";
            if (g == null) return RedirectToAction("Index", "Home");

            if (Request.IsAuthenticated)
            {
                var actRes = GameHandlers.Mortgage(g, str, CurrUser);
                if (actRes)
                    res = g.Text("mort1", "вы заложили :", "you mortgage:");//+ Lands(ids);
                else
                    res = "error";
            }
            else
            {
                res = "error";
            }

            return RenderLogAndPlayerCells(g);
        }
Пример #3
0
        public static string ShowGameState(Game g, string uname)
        {
            if (g == null) return "";

            var p = g.GetPlayer(uname);

            if (p == null) return g.Text("PlayerState.WatchingGame", "Вы наблюдаете за игрой", "You are watching game");

            string paction = "";

            string rolled = "";// string.Format("roll {0} <br />", g.Curr.PrintLastRoll);

            var IsCurrPlayer = g.IsCurrPlayer(uname);

            if (!IsCurrPlayer && !g.IsManualMode) paction = rolled + g.Text("Map.Waiting", "ждите ход...", "waiting...");

            if (p.IsBot) return rolled + g.Text("Map.RenderBotPlaying", "играет компьютер...", "Bot playing...");

            switch (g.State)
            {
                case GameState.BeginStep:
                    paction = GameRender.RenderStartState(g, uname);

                    paction += "<br />" + GameRender.RenderRollButton(g, uname);
                    break;

                case GameState.Mortgage:
                    paction = g.Text("Mortage.Cell", "земля заложена <br />", "land is mortgaged <br />");
                    break;

                case GameState.CanBuy:
                    if (IsCurrPlayer)
                    {
                        var tt = g.Text("pAction.CanBuy", "вы можете купить", "you can buy");
                        paction = string.Format("{0} {1}<br /> {2}", tt, g.CurrCell.Name,
                            UIParts("BuyOrAuc"));
                    }
                    break;

                case GameState.Auction:
                    paction = RenderAuction(g, uname);
                    break;

                case GameState.Trade:
                    paction = GameRender.RenderTradeProposal(g, uname);
                    break;

                case GameState.NeedPay:
                    if (IsCurrPlayer)
                    {
                        if (g.Curr.Police == 4)
                            paction = string.Format("{0} {1} {2}",
                                g.Text("pAction.MustPay", "вы должны заплатить", "you must pay"),
                                UIParts("ButtonPay"),
                                g.PayAmount.PrintMoney()
                                );
                        else
                            paction = string.Format("{0} {1}", UIParts("ButtonPay"), g.PayAmount.PrintMoney());
                    }
                    break;

                case GameState.CantPay:
                    if (IsCurrPlayer)
                    {
                        paction = g.Text("CannotPay",
                            "у вас нет денег, попробуйте заложить", "not enough money, try mortgage land");

                        if (g.CurrCell.Owner == null && g.CurrCell.IsLand)
                            paction += "<br />" + UIParts("BuyOrAuc");
                        else paction += "<br />" + UIParts("ButtonPay");
                    }
                    //g.State = GameState.Pay;
                    break;

                case GameState.MoveToCell:
                    if (IsCurrPlayer)
                    {
                        if (g.LastRandomCard != null && g.LastRandomCard.Pos != 10)
                            paction = string.Format("{0} {1} {2}",
                                 UIParts("ButtonRandomMove"),
                                g.Text("go.RanodmMove", " на клетку ", " to cell "),
                                g.LastRandomCard.Pos);
                        else
                            paction = string.Format("{0} {1}", UIParts("ButtonRandomMove"),
                       g.Text("go.RanodmMove.Police", "вас задержал интерпол", "go to Police"));

                    }
                    break;

                case GameState.RandomCell:
                    if (g.IsCurrPlayer(uname))
                    {
                        paction = string.Format("{0} {1}",
                            g.LastRandomCard.Text,
                             UIParts("ButtonOK"));
                    }
                    else paction = g.LastRandomCard.Text;

                    break;

                default:
                    paction = "Nothing";
                    break;
            }

            return string.Format("{0}", paction);

            //var lr = g.LastRoll != null ? g.LastRoll : new[] { 1, 1 };
            //var roll = string.Format("{0}<br /> {1} {2}",
            //    g.Text("Map.LastRoll", "последний бросок", "last roll"),
            //    //g.Curr.htmlName,
            //    ImageHelper.GetRollImage(lr[0]),
            //    ImageHelper.GetRollImage(lr[1]));

            //return string.Format("{0} <br /> {1}", roll, paction);
        }
Пример #4
0
        private static string RenderStartState(Game g, string uname)
        {
            var p = g.GetPlayer(uname);

            if (p != null && p.CaughtByPolice && p.Id == g.Curr.Id)
            {
                if (p.Police == 4)
                    return string.Format("you must pay {0}", UIParts("ButtonPay"));
                else
                {

                    if (p.FreePoliceKey > 0)
                    {
                        var tt = g.Text("Map.OutPoliceWithKey", "Хотите заплатить за выход {0} или ключ {1} ", "want pay to out from POLICE {0} or use key {1}");
                        return string.Format(tt, UIParts("ButtonPay"), UIParts("ButtonPoliceUseKey"));
                    }
                    else
                    {
                        var tt = g.Text("Map.OutPolice", "Хотите заплатить за выход {0}", "want pay to out from POLICE {0}");
                        return string.Format(tt, UIParts("ButtonPay"));
                    }

                }
            }
            else
            {
                var tt = "last roll " + RenderLastRoll(g)+"<br />";
                tt += g.Text("Map.StepOf", "ходит... ", "step of... ") + g.Curr.htmlName;
                return tt;
            }
        }
Пример #5
0
        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;
        }