Skip to content

Commit

Permalink
- Move event callback to private scope
Browse files Browse the repository at this point in the history
  • Loading branch information
ParticleG committed Aug 12, 2024
1 parent 2368701 commit aa69d74
Showing 1 changed file with 25 additions and 12 deletions.
37 changes: 25 additions & 12 deletions ZZZTOJ.Botris/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit aa69d74

Please sign in to comment.