From aa69d74d5460160e940f7d3a02cd996716cec12b Mon Sep 17 00:00:00 2001 From: ParticleG Date: Mon, 12 Aug 2024 12:47:52 +0800 Subject: [PATCH] - Move event callback to private scope --- ZZZTOJ.Botris/Program.cs | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/ZZZTOJ.Botris/Program.cs b/ZZZTOJ.Botris/Program.cs index 9b2f219..e7878ca 100644 --- a/ZZZTOJ.Botris/Program.cs +++ b/ZZZTOJ.Botris/Program.cs @@ -37,10 +37,22 @@ BotrisBot bot = new(botSetting.Token); ZZZBot bot1 = new() { BotSetting = botSetting }; -bot.RequestMove += Bot_RequestMove; -async void Bot_RequestMove(RequestMovePayload obj) + +bot.RequestMove += BotRequestMove; +bot.UpdateConfig += BotUpdateConfig; + +bot.Connect(botSetting.RoomKey, CancellationToken.None); + +while (true) { + var input = Console.ReadLine(); + if (input == "q") break; +} + +return; +void BotRequestMove(RequestMovePayload obj) +{ //await Task.Delay(1); //Console.Clear(); try @@ -53,25 +65,26 @@ async void Bot_RequestMove(RequestMovePayload obj) Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } - - } -bot.Connect(botSetting.RoomKey, CancellationToken.None); - -while (true) +void BotUpdateConfig(UpdateConfigPayload payload) { - var input = Console.ReadLine(); - if (input == "q") break; + try + { + bot1.BotSetting.Duration = payload.Duration; + } + catch (Exception e) + { + Console.WriteLine(e); + throw; + } } public class BotSetting { public int NextCnt { get; set; } = 6; - public int Level { get; set; } = 8; - public int BPM { get; set; } = 200; - + public int Duration { get; set; } = 100; public string Token { get; set; } = string.Empty; public string RoomKey { get; set; } = string.Empty; public bool Quiet {get;set;} = false;