コード例 #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();
        }
コード例 #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);
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
0
ファイル: LottoPlugin.cs プロジェクト: Montmo90/LottoPlugin
        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();
        }