public void Config() { var stringBuilder = new StringBuilder(); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("settings")); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("open"), Module.Config.Open)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("max"), Module.Config.MaxNumber)); stringBuilder.AppendLine(""); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("ticket")); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("prix"), Module.Config.TicketPrix)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("multiple"), Module.Config.TicketMultiple)); stringBuilder.AppendLine(""); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("gain")); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("gainTotal"), Module.Config.GainTotal)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("gain"), Module.Config.Gain)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("maxi"), Module.Config.GainMax)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("cumulate"), Module.Config.GainCumulate)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("partage"), Module.Config.GainPartage)); stringBuilder.AppendLine(""); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("draw")); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("auto"), Module.Config.DrawAuto)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("days"), (Module.Config.DrawDays.Sunday ? ", " + TranslatesUtils.GetGeneralId("sunday") : ""), (Module.Config.DrawDays.Monday ? ", " + TranslatesUtils.GetGeneralId("monday") : ""), (Module.Config.DrawDays.Tuesday ? ", " + TranslatesUtils.GetGeneralId("tuesday") : ""), (Module.Config.DrawDays.Wednesday ? ", " + TranslatesUtils.GetGeneralId("wednesday") : ""), (Module.Config.DrawDays.Thursday ? ", " + TranslatesUtils.GetGeneralId("thursday") : ""), (Module.Config.DrawDays.Friday ? ", " + TranslatesUtils.GetGeneralId("friday") : ""), (Module.Config.DrawDays.Saturday ? ", " + TranslatesUtils.GetGeneralId("saturday") : ""))); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("hout"), Module.Config.DrawHours)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetConfigId("next"), Module.Config.NextDraw)); DialogMessage dialogMessage = new DialogMessage(TranslatesUtils.GetConfigId("title"), TranslatesUtils.GetGeneralId("lotto"), stringBuilder.ToString()); ModCommunication.SendMessageTo(dialogMessage, base.Context.Player.SteamUserId); }
public void Play(int number) { if (!Module.Config.Open) { base.Context.Respond(TranslatesUtils.GetRespondId("dontPlay"), TranslatesUtils.GetGeneralId("lotto"), null); return; } base.Context.Player.TryGetBalanceInfo(out long money); if (money < Module.Config.TicketPrix) { base.Context.Respond(TranslatesUtils.GetRespondId("money"), TranslatesUtils.GetGeneralId("lotto"), null); return; } List <int> listPlayerNumbers = PlayersUtils.PlayerNumbers(base.Context.Player.IdentityId); if (listPlayerNumbers.Count > 0 && !Module.Config.TicketMultiple) { foreach (var item in listPlayerNumbers) { base.Context.Respond(String.Format(TranslatesUtils.GetInfoId("play"), item), TranslatesUtils.GetGeneralId("lotto"), null); } return; } Module.PlayersPlay.ListPlayersPlay.Add(new PlayersPlayStruct(base.Context.Player.DisplayName, base.Context.Player.IdentityId, number, DateTime.UtcNow)); base.Context.Player.RequestChangeBalance(-Module.Config.TicketPrix); base.Context.Respond(TranslatesUtils.GetRespondId("thank"), TranslatesUtils.GetGeneralId("lotto"), null); Module.SavePlayersPlay(); }
public void Save() { Module.SaveConfig(); Module.SavePlayersPlay(); Module.SavePlayersWin(); Module.SaveTranslates(); base.Context.Respond(TranslatesUtils.GetRespondId("save"), TranslatesUtils.GetGeneralId("lotto"), null); }
public void ReLoad() { Module.LoadConfig(); Module.LoadPlayersPlay(); Module.LoadPlayersWin(); Module.LoadTranslates(); base.Context.Respond(TranslatesUtils.GetRespondId("reload"), TranslatesUtils.GetGeneralId("lotto"), null); }
public void Info() { var stringBuilder = new StringBuilder(); stringBuilder.AppendLine(Module.Config.Open ? TranslatesUtils.GetInfoId("open") : TranslatesUtils.GetInfoId("close")); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetInfoId("next"), Module.Config.NextDraw)); stringBuilder.AppendLine(""); List <int> listPlayerNumbers = PlayersUtils.PlayerNumbers(base.Context.Player.IdentityId); if (listPlayerNumbers.Count != 0) { foreach (var item in listPlayerNumbers) { stringBuilder.AppendLine(String.Format(TranslatesUtils.GetInfoId("play"), item)); } } else { stringBuilder.AppendLine(TranslatesUtils.GetInfoId("dont")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("play")); } stringBuilder.AppendLine(""); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetInfoId("prix"), Module.Config.TicketPrix)); stringBuilder.AppendLine(Module.Config.TicketMultiple ? TranslatesUtils.GetInfoId("multiple") : TranslatesUtils.GetInfoId("dontMultiple")); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetInfoId("number"), Module.Config.MaxNumber)); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetInfoId("gain"), Module.Config.GainTotal)); stringBuilder.AppendLine(""); var win = PlayersUtils.PlayerWinLotto(base.Context.Player.IdentityId); if (win == null) { stringBuilder.AppendLine(TranslatesUtils.GetInfoId("dontRecove")); } else { long allGain = 0L; foreach (var item in win) { allGain += item.gain; } stringBuilder.AppendLine(String.Format(TranslatesUtils.GetInfoId("recove"), win.Count, allGain)); } stringBuilder.AppendLine(""); stringBuilder.AppendLine(""); stringBuilder.AppendLine(""); stringBuilder.AppendLine(String.Format(TranslatesUtils.GetGeneralId("stats"), Module.Config.NumberTotalDraw, Module.Config.NumberTotalPlayersWin)); DialogMessage dialogMessage = new DialogMessage(TranslatesUtils.GetInfoId("title"), TranslatesUtils.GetGeneralId("lotto"), stringBuilder.ToString()); ModCommunication.SendMessageTo(dialogMessage, base.Context.Player.SteamUserId); }
public void GainAdd(int add) { if ((Module.Config.GainTotal + add) > Module.Config.GainMax) { base.Context.Respond(TranslatesUtils.GetRespondId("add"), TranslatesUtils.GetGeneralId("lotto"), null); return; } Module.Config.GainTotal += add; base.Context.Respond(TranslatesUtils.GetGeneralId("changed"), TranslatesUtils.GetGeneralId("lotto"), null); Module.SaveConfig(); }
public void GainRemove(int remove) { if ((Module.Config.GainTotal - remove) < 0) { base.Context.Respond(TranslatesUtils.GetRespondId("remove"), TranslatesUtils.GetGeneralId("lotto"), null); return; } Module.Config.GainTotal -= remove; base.Context.Respond(TranslatesUtils.GetGeneralId("changed"), TranslatesUtils.GetGeneralId("lotto"), null); Module.SaveConfig(); }
public static void Draw(int number = -1) { Module.Config.NumberTotalDraw++; var random = new Random(); var randomNumber = number == -1 ? random.Next(0, Module.Config.MaxNumber) : number; MyVisualScriptLogicProvider.SendChatMessageColored(String.Format(TranslatesUtils.GetGeneralId("draw"), randomNumber), Color.Red, TranslatesUtils.GetGeneralId("lotto")); var listPlayersWin = ListPlayersWin(randomNumber); if (listPlayersWin.Count == 0) { MyVisualScriptLogicProvider.SendChatMessageColored(TranslatesUtils.GetGeneralId("dontWin"), Color.Red, TranslatesUtils.GetGeneralId("lotto")); } else { Module.Config.NumberTotalPlayersWin++; var gain = Module.Config.GainPartage ? Module.Config.GainTotal / listPlayersWin.Count : Module.Config.GainTotal; foreach (var item in listPlayersWin) { MyVisualScriptLogicProvider.SendChatMessageColored(String.Format(TranslatesUtils.GetGeneralId("win"), PlayersUtils.GetPlayerNameById(item.playerId)), Color.Red, TranslatesUtils.GetGeneralId("lotto")); Module.PlayersWin.ListPlayersWin.Add(new Models.PlayersWinStruct(item.playerName, item.playerId, randomNumber, gain, DateTime.Now)); } Module.Config.GainTotal = 0; } if (Module.Config.GainTotal + Module.Config.Gain > Module.Config.GainMax) { Module.Config.GainTotal = Module.Config.GainMax; } else { Module.Config.GainTotal += Module.Config.Gain; } var next = ConfigUtils.NextDraw(); Module.Config.NextDraw = next; MyVisualScriptLogicProvider.SendChatMessageColored(String.Format(TranslatesUtils.GetGeneralId("next"), next, Module.Config.GainTotal), Color.Red, TranslatesUtils.GetGeneralId("lotto")); Module.PlayersPlay.ListPlayersPlay.Clear(); Module.SaveConfig(); Module.SavePlayersPlay(); Module.SavePlayersWin(); }
public void Recove() { var win = PlayersUtils.PlayerWinLotto(base.Context.Player.IdentityId); if (win == null) { base.Context.Respond(TranslatesUtils.GetInfoId("dontRecove"), TranslatesUtils.GetGeneralId("lotto"), null); return; } foreach (var item in win) { base.Context.Respond(String.Format(TranslatesUtils.GetRespondId("recove"), item.gain), TranslatesUtils.GetGeneralId("lotto"), null); base.Context.Player.RequestChangeBalance(item.gain); } }
public void DrawDays(bool sun, bool mon, bool tue, bool wed, bool thu, bool fri, bool sat) { if (!sun && !mon && !tue && !wed && !thu && !fri && !sat) { base.Context.Respond(TranslatesUtils.GetRespondId("days"), TranslatesUtils.GetGeneralId("lotto"), null); return; } Module.Config.DrawDays = new DayOfWeekStruct(sun, mon, tue, wed, thu, fri, sat); Module.Config.NextDraw = ConfigUtils.NextDraw(); base.Context.Respond(TranslatesUtils.GetGeneralId("changed"), TranslatesUtils.GetGeneralId("lotto"), null); if (!Module.Config.DrawAuto) { base.Context.Respond(TranslatesUtils.GetRespondId("auto"), TranslatesUtils.GetGeneralId("lotto"), null); } Module.SaveConfig(); }
public void DrawHours(string hours) { if (!ConfigUtils.IsValidTimeFormat(hours)) { base.Context.Respond(TranslatesUtils.GetRespondId("hour"), TranslatesUtils.GetGeneralId("lotto"), null); return; } Module.Config.DrawHours = hours; Module.Config.NextDraw = ConfigUtils.NextDraw(); base.Context.Respond(TranslatesUtils.GetGeneralId("changed"), TranslatesUtils.GetGeneralId("lotto"), null); if (!Module.Config.DrawAuto) { base.Context.Respond(TranslatesUtils.GetRespondId("auto"), TranslatesUtils.GetGeneralId("lotto"), null); } Module.SaveConfig(); }
public void Help() { var stringBuilder = new StringBuilder(); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("info")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("play")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("recove")); if (base.Context.Player.PromoteLevel == MyPromoteLevel.Admin) { stringBuilder.AppendLine(""); stringBuilder.AppendLine("########## ADMIN ##########"); stringBuilder.AppendLine(""); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("settings")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("config")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("open")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("number")); stringBuilder.AppendLine(""); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("ticket")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("prix")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("multiple")); stringBuilder.AppendLine(""); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("gain")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("gainNumber")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("max")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("cumulate")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("add")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("remove")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("partage")); stringBuilder.AppendLine(""); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("draw")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("start")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("startNumber")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("auto")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("days")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("hour")); stringBuilder.AppendLine(""); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("save")); stringBuilder.AppendLine(TranslatesUtils.GetHelpId("reload")); } DialogMessage dialogMessage = new DialogMessage(TranslatesUtils.GetHelpId("title"), "Montmorency Lotto", stringBuilder.ToString()); ModCommunication.SendMessageTo(dialogMessage, base.Context.Player.SteamUserId); }
public void GainCumulate(bool cumulate) { Module.Config.GainCumulate = cumulate; base.Context.Respond(TranslatesUtils.GetGeneralId("changed"), TranslatesUtils.GetGeneralId("lotto"), null); Module.SaveConfig(); }
public void Open(bool open) { Module.Config.Open = open; base.Context.Respond(TranslatesUtils.GetGeneralId("changed"), TranslatesUtils.GetGeneralId("lotto"), null); Module.SaveConfig(); }
public void DrawAuto(bool auto) { Module.Config.DrawAuto = auto; base.Context.Respond(TranslatesUtils.GetGeneralId("changed"), TranslatesUtils.GetGeneralId("lotto"), null); Module.SaveConfig(); }
public void GainPartage(bool partage) { Module.Config.GainPartage = partage; base.Context.Respond(TranslatesUtils.GetGeneralId("changed"), TranslatesUtils.GetGeneralId("lotto"), null); Module.SaveConfig(); }
public void MaxNumber(int number) { Module.Config.MaxNumber = number; base.Context.Respond(TranslatesUtils.GetGeneralId("changed"), TranslatesUtils.GetGeneralId("lotto"), null); Module.SaveConfig(); }
public void TicketPrix(int prix) { Module.Config.TicketPrix = prix; base.Context.Respond(TranslatesUtils.GetGeneralId("changed"), TranslatesUtils.GetGeneralId("lotto"), null); Module.SaveConfig(); }
public void GainMax(int gainMax) { Module.Config.GainMax = gainMax; base.Context.Respond(TranslatesUtils.GetGeneralId("changed"), TranslatesUtils.GetGeneralId("lotto"), null); Module.SaveConfig(); }
public void TicketMultiple(bool multiple) { Module.Config.TicketMultiple = multiple; base.Context.Respond(TranslatesUtils.GetGeneralId("changed"), TranslatesUtils.GetGeneralId("lotto"), null); Module.SaveConfig(); }