示例#1
0
        private async Task Encounter()
        {
            await using JsonHandler json = new JsonHandler(SaveJson);
            await StarterSavefileIntegrity();

            if (!File.Exists(SaveJson))
            {
                await File.CreateText(SaveJson).DisposeAsync();

                await File.WriteAllTextAsync(SaveJson, "{}");
            }
            if (await HasInitialized() == false)
            {
                await ReplyAsync("Please use the `.start` command first to initialize.");

                return;
            }
            await json.WriteEntry(PlayerData.InBattle, true);

            EmbedBuilder encounterMessage = new EmbedBuilder
            {
                Title       = "Enemy Encounter",
                Description = "Finding enemy to fight...",
                Color       = Color.Gold
            };
            IUserMessage message = await ReplyAsync(embed : encounterMessage.Build());

            //Dictionary<string, Enemy> enemyCollection = Collections.Enemies;
            //Enemy encounteredEnemy = GetRandomFromDictionary<Enemy>(enemyCollection);

            encounterMessage.EditEmbed("Enemy found!", "Get ready!", Color.DarkRed);

            await Task.Delay(Globals.Rnd.Next(350, 850));

            await message.ModifyAsync(msg => msg.Embed = encounterMessage.Build());

            await Task.Delay(Globals.Rnd.Next(350, 450));

            await json.WriteEntry(PlayerData.InBattle, false);
        }