Beispiel #1
0
        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();
        }
Beispiel #2
0
        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);
        }