Esempio n. 1
0
 private static void AfterStartIncident(int chatId, string msg, ModelStatus stat)
 {
     Loger.Log("IncidentLod ChatController.AfterStartIncident 1 msg:" + msg);
     if (stat.Status == 0)
     {
         string error;
         var    result = OCIncident.GetCostOnGameByCommand(msg, false, out error);
         //Find.WindowStack.Add(new Dialog_Input("Вызов инциндента", error ?? result, true));
         Find.WindowStack.Add(new Dialog_MessageBox(error ?? result));
     }
     else
     {
         //выводим сообщение с ошибкой
         var errorMessage = string.IsNullOrEmpty(stat.Message) ? "Error call" : stat.Message.Translate().ToString();
         Loger.Log("IncidentLod ChatController.AfterStartIncident errorMessage:" + errorMessage);
         Find.WindowStack.Add(new Dialog_MessageBox(errorMessage));
     }
 }
Esempio n. 2
0
        private static ModelStatus BeforeStartIncident(int chatId, string msg)
        {
            Loger.Log("IncidentLod ChatController.BeforeStartIncident 1 msg:" + msg);
            string error;

            OCIncident.GetCostOnGameByCommand(msg, true, out error);

            if (error != null)
            {
                Loger.Log("IncidentLod ChatController.BeforeStartIncident errorMessage:" + error);
                Find.WindowStack.Add(new Dialog_MessageBox(error));

                return(new ModelStatus()
                {
                    Status = 1
                });
            }
            else
            {
                Loger.Log("IncidentLod ChatController.BeforeStartIncident ok");
                return(null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Расчитывает стоимость инциндента, и изымает её.
        /// </summary>
        /// <param name="command">Текстовая команда для чата</param>
        /// <param name="onliCheck">Только рассчитать, не изымая.</param>
        /// <error>Ошибка, или результат при onliCheck</error>
        /// <returns>Строка с количество требуемой стоимости</returns>
        public static string GetCostOnGameByCommand(string command, bool onliCheck, out string error)
        {
            Loger.Log("IncidentLod OCIncident.GetCostOnGameByCommand 1 command:" + command);
            //разбираем аргументы в кавычках '. Удвоенная кавычка указывает на её символ.
            string        cmd;
            List <string> args;

            ChatUtils.ParceCommand(command, out cmd, out args);

            if (args.Count < 3)
            {
                error = "OC_Incidents_OCIncident_WrongArg".Translate().ToString();
                Loger.Log("IncidentLod OCIncident.GetCostOnGameByCommand error:" + error);
                return(null);
            }

            // /call raid '111' 1 10 air tribe

            //проверка, что денег хватает
            int cost = OCIncident.CalculateRaidCost(args[0].ToLower(), Int64.Parse(args[2])
                                                    , args.Count > 3 ? Int32.Parse(args[3]) : 1
                                                    , args.Count > 4 ? args[4].ToLower() : null
                                                    , args.Count > 5 ? args[5].ToLower() : null);
            int gold = -1;

            Map map = null;

            if (cost > 0)
            {
                gold = GameUtils.FindThings(ThingDefOf.Gold, 0, false);
            }

            if (cost < 0 || gold < 0 || gold < cost)
            {
                error = cost < 0 || gold < 0
                    ? "OC_Incidents_OCIncident_WealthErr".Translate().ToString() + $" cost={cost} gold={gold}"
                    : "OC_Incidents_OCIncident_GoldErr".Translate(gold, cost, cost - gold).ToString();
                Loger.Log("IncidentLod OCIncident.GetCostOnGameByCommand error:" + error);
                return(null);
            }

            if (onliCheck)
            {
                error = null;
                return("OC_Incidents_OCIncident_NotEnoughGold".Translate(cost));
            }

            Loger.Log("IncidentLod OCIncident.GetCostOnGameByCommand 2");

            //отнимаем нужное кол-во денег(золото или серебро... или что-нибудь ещё)
            GameUtils.FindThings(ThingDefOf.Gold, cost, false);

            Loger.Log("IncidentLod OCIncident.GetCostOnGameByCommand 3");
            //принудительное сохранение
            if (!SessionClientController.Data.BackgroundSaveGameOff)
            {
                SessionClientController.SaveGameNow(true);
            }
            Loger.Log("IncidentLod ChatController.AfterStartIncident 4");

            error = null;
            return("OC_Incidents_OCIncident_GoldPay".Translate(cost));
        }