public async Task PrayCommand() { Player player = Context.Player; if (player.IsEncounter("Combat")) { await ReplyAsync("It is not the time for this, my child."); } else { int index = -1; //jewelry index of a god's sigil for (int i = 0; i < player.equipment.jewelry.Length; i++) { Item jewel = player.equipment.jewelry[i]; if (jewel != null && jewel.isUnique && Faith.Sigils.ContainsKey(jewel.name)) { if (index > -1) { throw NeitsilliaError.ReplyError("A divided faith is a useless faith"); } index = i; } } if (index <= -1) { await ReplyAsync("You show no faith to pray to."); } else { await ReplyAsync(player.Faith.Pray(player, player.equipment.jewelry[index].name)); } } }
internal static async Task ViewSchems(Player player, ISocketMessageChannel chan, int displayPage = 1) { int count = player.schematics.Count; if (count == 0) { throw NeitsilliaError.ReplyError("No known schematics."); } const int itemPerPage = 15; int pages = NumbersM.CeilParse <int>(count / (double)itemPerPage); displayPage = Verify.MinMax(displayPage, pages, 1); int start = (displayPage - 1) * itemPerPage; string desc = string.Join(Environment.NewLine, player.schematics.GetRange( start, start + itemPerPage > count ? count - start : itemPerPage)); EmbedBuilder schems = DUtils.BuildEmbed($"{player.name}'s Schematics", desc, $"Page {displayPage}/{pages}", player.userSettings.Color); await player.NewUI(await chan.SendMessageAsync(embed: schems.Build()), MsgType.Schems, displayPage.ToString()); }
internal static async Task <bool> SpecialExceptions(NeitsilliaError error, IMessageChannel chan, Player player) { switch (error.ErrorType) { case NeitsilliaErrorType.ReplyError: await chan.SendMessageAsync(error.ExtraMessage); return(true); case NeitsilliaErrorType.ReplyUI: { await chan.SendMessageAsync(error.ExtraMessage); switch (error.uitype) { case MsgType.CardGame: { Type type = Neitsillia.Gambling.Games.GamblingGame.GetGameType(player.ui.data); Neitsillia.Gambling.Games.IGamblingGame game = Neitsillia.Gambling.Games.GamblingGame.CreateInstance(type, player); var embed = ((Neitsillia.Gambling.Games.GamblingGame)game).GetEmbed(player).Build(); await player.NewUI(null, embed, await player.DMChannel(), player.ui.type, player.ui.data); } break; } return(true); } case NeitsilliaErrorType.CharacterIsNotSetUp: if (player != null) { if (player.ui.type == MsgType.AutoNewCharacter) { await CharacterCommands.AutoCharacter(player, chan, true); } else if (player.ui.type == MsgType.SetSkill || player.ui.type == MsgType.ConfirmSkills) { string[] arrays = player.ui.data.Split(';'); await CharacterCommands.SetSkills(player, chan, 0, Utils.JSON <int[]>(arrays[0]), Utils.JSON <bool[]>(arrays[1])); } else if (!await CharacterCommands.Set_Race(chan, player)) { await CharacterCommands.StarterAbilities(player, chan, 1); } return(true); } return(false); case NeitsilliaErrorType.CharacterAdventuring: if (player != null) { await Areas.AdventureStat(player, chan); return(true); } return(false); case NeitsilliaErrorType.CharacterIsResting: if (player != null) { await Areas.RestStat(player, chan); return(true); } return(false); default: return(false); } }
internal static bool Is(Exception exception, NeitsilliaErrorType type, out NeitsilliaError error) { error = null; return(exception is NeitsilliaError e && (error = e).ErrorType == type); }