public CombatInstance2(ContextIds loc, List <Team> teams) { Location = loc; Teams = new List <Team>(); Players = new List <UserAccount>(); Environment = new Environment(true); IsPvP = true; IsOneOnOne = true; CombatOver = false; CombatPhase = -1; var usercount = 0; foreach (Team t in teams) { Teams.Add(t); t.TeamNum = Teams.Count; foreach (ulong user in t.MemberIDs) { UserHandler.GetUser(user).Char.JoinPvPCombat(); usercount++; } } if (usercount == 2) { IsOneOnOne = true; } else { IsOneOnOne = false; } }
public async Task DataWipe() { var idList = new ContextIds(Context); await MessageHandler.SendMessage(idList, "User data cleared. Reboot bot to take effect."); UserHandler.ClearUserData(); }
public async Task Party() { var idList = new ContextIds(Context); var user = UserHandler.GetUser(idList.UserId); //Tests each case to make sure all circumstances for the execution of this command are valid (character exists, in correct location) try { await UserHandler.CharacterExists(idList); await UserHandler.ValidCharacterLocation(idList); } catch (InvalidCharacterStateException) { return; } var count = 6; foreach (BasicMon mon in user.Char.Party) { await MessageHandler.SendEmbedMessage(idList, "", MonEmbedBuilder.FieldMon(mon)); count--; } await MessageHandler.SendEmbedMessage(idList, "", MonEmbedBuilder.EmptyPartySpot(count)); }
public CombatInstance(ContextIds loc, ulong thisPlayer, ulong otherPlayer) { ThisPlayer = thisPlayer; OtherPlayer = otherPlayer; Location = loc; CombatPhase = -1; }
public async Task Attack() { var user = UserHandler.GetUser(Context.User.Id); ContextIds idList = new ContextIds(Context); //Tests each case to make sure all circumstances for the execution of this command are valid (character exists, in correct location) try { await UserHandler.CharacterExists(idList); await UserHandler.ValidCharacterLocation(idList); } catch (InvalidCharacterStateException) { return; } if (user.Char.Combat == null) { await MessageHandler.SendMessage(idList, $"{user.Mention} aren't in combat right now!"); } else { await CombatHandler.Attack(user.Char.Combat); } }
public async Task DebugInfo(SocketGuildUser target) { var idList = new ContextIds(Context); var user = UserHandler.GetUser(target?.Id ?? idList.UserId); await MessageHandler.SendMessage(idList, user.DebugString()); }
public static void ClearCombatData(ContextIds ids) { System.Console.WriteLine("Deleting all combat instances."); Dictionary <ulong, CombatInstance> emptyDic = new Dictionary <ulong, CombatInstance>(); emptyDic.Add(0, new CombatInstance(ids)); _jsonStorage.StoreObject(emptyDic, filepath); }
public static async Task OtherCharacterExists(ContextIds ids, UserAccount otherUser) { if (!otherUser.HasCharacter) { await MessageHandler.OtherCharacterMissing(ids); throw new InvalidCharacterStateException("other player's character doesn't exist"); } }
public static async Task OtherUserHasNoCards(ContextIds ids, UserAccount user, UserAccount otherUser) { if (otherUser.ActiveCards.Count <= 0) { await MessageHandler.OtherUserHasNoCards(ids, user); throw new InvalidUserStateException("other user has no card"); } }
public static async Task OtherCharacterLocation(ContextIds ids, UserAccount otherUser) { if (otherUser.Char.CurrentGuildId != ids.GuildId) { await MessageHandler.InvalidOtherCharacterLocation(ids, otherUser); throw new InvalidCharacterStateException("other player's character in a different location"); } }
public static async Task OtherUserNotInCombat(ContextIds ids, UserAccount otherUser) { var user = GetUser(ids.UserId); if (otherUser.CombatID == -1) { await MessageHandler.OtherUserNotInCombat(ids); throw new InvalidUserStateException("other user not in combat"); } }
public static async Task UserInCombat(ContextIds ids) { var user = GetUser(ids.UserId); if (user.CombatID != -1) { await MessageHandler.UserInCombat(ids); throw new InvalidUserStateException("user in combat"); } }
public static async Task CharacterExists(ContextIds ids) { var user = GetUser(ids.UserId); if (!user.HasCharacter) { await MessageHandler.CharacterMissing(ids); throw new InvalidCharacterStateException("character doesn't exist"); } }
public static async Task CharacterInCombat(ContextIds ids) { var user = GetUser(ids.UserId); if (!user.Char.InCombat) { await MessageHandler.NotInCombat(ids); throw new InvalidCharacterStateException("character not in combat"); } }
public async Task DebugResetCharacter() { var ids = new ContextIds(Context); var user = UserHandler.GetUser(ids.UserId); user.Char = null; user.HasCharacter = false; user.PromptState = -1; await MessageHandler.SendMessage(ids, $"{user.Mention}, your character has been deleted."); }
public static async Task ValidCharacterLocation(ContextIds ids) { var user = GetUser(ids.UserId); if (user.Char.CurrentGuildId != ids.GuildId) { await MessageHandler.InvalidCharacterLocation(ids); throw new InvalidCharacterStateException("character in incorrect location"); } }
public CombatInstance(ContextIds loc) { Location = loc; CombatId = -1; Teams = new List <Team>(); CardList = new List <BasicCard>(); Players = new List <UserAccount>(); RoundNumber = 0; TurnNumber = 0; IsDuel = true; CombatEnded = false; }
public async Task UpdateAllMenus(List <ulong> exclude, ContextIds idList, string info) { foreach (Team t in Teams) { foreach (ulong userid in t.MemberIDs) { if (!exclude.Contains(userid)) { await MessageHandler.UpdateMenu(UserHandler.GetUser(userid), idList.ChannelId, 12, info); } } } }
public static CombatInstance SearchForRaid(ContextIds idList) { CombatInstance inst = null; foreach (KeyValuePair <int, CombatInstance> entry in _dic) { if (!entry.Value.IsDuel && entry.Value.Location.ChannelId == idList.ChannelId) { inst = entry.Value; } } return(inst); }
public CombatInstance2(ContextIds loc, UserAccount one, UserAccount two) { Location = loc; Teams = new List <Team>(); Players = new List <UserAccount>(); CreateNewTeam().AddMember(one); CreateNewTeam().AddMember(two); Environment = new Environment(true); IsPvP = true; IsOneOnOne = true; CombatOver = false; CombatPhase = -1; one.Char.JoinPvPCombat(); two.Char.JoinPvPCombat(); }
public async Task StartAdventure() { var ids = new ContextIds(Context); var user = UserHandler.GetUser(ids.UserId); if ((user.PromptState == -1 || user.PromptState == 0) && !user.HasCharacter) { user.PromptState = 0; await MessageHandler.SendMessage(ids, $"{user.Mention}, are you sure you want to create a character here? You can only have one and it will be locked to this particular location. Moving to a new location will take time and money. Type the \"enter confirm\" comnmand again to confirm character creation or \"enter cancel\" to cancel."); } else if (user.HasCharacter) { await MessageHandler.SendMessage(ids, $"{user.Mention}, you already have a character!"); } else { await MessageHandler.SendMessage(ids, $"{user.Mention}, you are already in the process of creating a character!"); } }
public async Task MonStat([Remainder] int num) { var idList = new ContextIds(Context); var user = UserHandler.GetUser(idList.UserId); //Tests each case to make sure all circumstances for the execution of this command are valid (character exists, in correct location) try { await UserHandler.CharacterExists(idList); await UserHandler.ValidCharacterLocation(idList); } catch (InvalidCharacterStateException) { return; } await Context.Channel.SendMessageAsync( "", embed : MonEmbedBuilder.MonStats(user.Char.Party[num])) .ConfigureAwait(false); }
public async Task TypeTest() { ContextIds idList = new ContextIds(Context); var attack = new WaterType(true); List <BasicType> defense = new List <BasicType>() { new WaterType(true), new FireType(true) }; var effect = attack.ParseEffectiveness(defense); string defstr = $"{defense[0].Type}"; if (defense.Count > 1) { defstr += $"/{defense[1].Type}"; } await MessageHandler.SendMessage(idList, $"{attack.Type} is {effect}x effective against {defstr}"); }
public async Task Heal() { ContextIds idList = new ContextIds(Context); var user = UserHandler.GetUser(idList.UserId); //Tests each case to make sure all circumstances for the execution of this command are valid (character exists, in correct location) try { await UserHandler.CharacterExists(idList); await UserHandler.ValidCharacterLocation(idList); } catch (InvalidCharacterStateException) { return; } foreach (BasicMon mon in user.Char.Party) { mon.Heal(); } await MessageHandler.SendMessage(idList, $"{user.Mention}, your party has been healed!"); }
public async Task ExitCombat() { var user = UserHandler.GetUser(Context.User.Id); ContextIds idList = new ContextIds(Context); //Tests each case to make sure all circumstances for the execution of this command are valid (character exists, in correct location) try { await UserHandler.CharacterExists(idList); await UserHandler.ValidCharacterLocation(idList); } catch (InvalidCharacterStateException) { return; } if (user.Char.InPvpCombat) { var opponent = UserHandler.GetUser(user.Char.InCombatWith); user.Char.ExitCombat(); opponent.Char.ExitCombat(); await Context.Channel.SendMessageAsync($"{Context.User.Mention} has forfeited the match! {opponent.Char.Name} wins by default."); } else if (user.Char.InCombat) { await Context.Channel.SendMessageAsync($"{Context.User.Mention} blacked out!"); } else { await Context.Channel.SendMessageAsync($"{Context.User.Mention}, you cannot exit combat if you are not in combat."); } }
public async Task Enter([Remainder] string text) { var ids = new ContextIds(Context); var user = UserHandler.GetUser(ids.UserId); var originalText = text; text = text.ToLower(); /* PROMPT STATE MEANINGS- * -1- Has no character * 0- Awaiting confirmation or cancellation of character creation * 1- Character creation confirmed. Awaiting name. * 2- Name confirmed. Awaiting partner. */ switch (user.PromptState) { case 0: if (text.Equals("confirm")) { user.Char = new Character() { CurrentGuildId = ids.GuildId, CurrentGuildName = Context.Guild.Name }; user.PromptState = 1; await MessageHandler.SendMessage(ids, $"Beginning character creation for {user.Mention}.\nWhat is your name? (use the \"enter\" command to enter your name)"); } else if (text.Equals("cancel")) { user.PromptState = -1; await MessageHandler.SendMessage(ids, $"Character creation cancelled for {user.Mention}."); } else { await MessageHandler.SendMessage(ids, $"{user.Mention}, I'm sorry, but I don't recognize that. Please enter \"confirm\" or \"cancel\""); } break; case 1: if (text.Length <= 32 && text.Length > 0) { user.Char.Name = originalText; user.PromptState = 2; await MessageHandler.SendMessage(ids, $"{user.Mention}, your character's name is now {originalText}. Now you must choose your partner."); await Context.Channel.SendMessageAsync( "", embed : MonEmbedBuilder.MonDex(new Snoril(true))) .ConfigureAwait(false); await Context.Channel.SendMessageAsync( "", embed : MonEmbedBuilder.MonDex(new Suki(true))) .ConfigureAwait(false); } else { await MessageHandler.SendMessage(ids, $"{user.Mention}, your name must be 32 characters or less."); } break; case 2: if (text.Equals("snoril") || text.Equals("1")) { user.Char.Party.Add(new Snoril(true) { CatcherID = user.UserId, OwnerID = user.UserId }); user.HasCharacter = true; await MessageHandler.SendMessage(ids, $"{user.Mention}, you have chosen Snoril as your partner! Good luck on your adventure."); } else if (text.Equals("suki") || text.Equals("2")) { user.Char.Party.Add(new Suki(true) { CatcherID = user.UserId, OwnerID = user.UserId }); user.HasCharacter = true; await MessageHandler.SendMessage(ids, $"{user.Mention}, you have chosen Suki as your partner! Good luck on your adventure."); } else { await MessageHandler.SendMessage(ids, $"{user.Mention}, please enter either Snoril or Suki."); } break; } }
public static async Task DebugPrintMoveResult(UserAccount user, UserAccount otherUser, MoveResult result, ContextIds loc) { string summ = ""; summ += $"\nOwner/Mon: {user.Name}/{user.Char.ActiveMon.Nickname}"; summ += $"\nLevel: {user.Char.ActiveMon.Level}"; summ += $"\nSpeed: {user.Char.ActiveMon.CurStats[4]}"; summ += $"\nPower: {user.Char.ActiveMon.SelectedMove.Power}"; summ += $"\nAccuracy: {user.Char.ActiveMon.SelectedMove.Accuracy}"; summ += $"\nAttack: {user.Char.ActiveMon.CurStats[1]}"; (double mod, string mess) = user.Char.ActiveMon.ChangeAttStage(0); summ += $"\nAttack Stage Mod: {mod}"; summ += $"\nAttack Modified: {(int)(user.Char.ActiveMon.CurStats[1]*mod)}"; summ += $"\nAccuracy Stage: {user.Char.ActiveMon.GetAccStage()}"; summ += $"\nOpponent Speed: {otherUser.Char.ActiveMon.CurStats[4]}"; summ += $"\nDefense: {otherUser.Char.ActiveMon.CurStats[2]}"; (double mod2, string mess2) = otherUser.Char.ActiveMon.ChangeDefStage(0); summ += $"\nDefense Stage Mod: {mod2}"; summ += $"\nDefense Modified: {(int)(otherUser.Char.ActiveMon.CurStats[2]*mod2)}"; summ += $"\nEvasion Stage: {otherUser.Char.ActiveMon.GetEvaStage()}"; summ += $"\nChance To Hit: {result.ChanceToHit}"; summ += $"\nModifier: {result.Mod}"; summ += $"\nCrit: {result.ModCrit}"; summ += $"\nRandom: {result.ModRand}"; summ += $"\nType Eff: {result.ModType}"; summ += $"\nDamage: {result.EnemyDmg}"; summ += $"\nMiss: {result.Miss}"; summ += $"\nHit: {result.Hit}"; await MessageHandler.SendMessage(loc, $"**Move Summary:**{summ}"); }
public async Task EmojiTest() { ContextIds idList = new ContextIds(Context); await MessageHandler.EmojiTest(idList); }
public async Task Whisper() { ContextIds idList = new ContextIds(Context); await MessageHandler.MoveScreen(idList.UserId); }
public static UserAccount GetUser(ContextIds ids) { return(GetUser(ids.UserId)); }