diff --git a/NadekoBot/Modules/Pokemon/DefaultMoves.cs b/NadekoBot/Modules/Pokemon/DefaultMoves.cs new file mode 100644 index 00000000..0072f6bf --- /dev/null +++ b/NadekoBot/Modules/Pokemon/DefaultMoves.cs @@ -0,0 +1,87 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NadekoBot.Modules.Pokemon +{ + class DefaultMoves + { + + public static Dictionary DefaultMovesList = new Dictionary() + { + {"sonic boom",0}, + {"quick attack",0}, + {"doubleslap",0}, + {"headbutt",0}, + {"incinerate",1}, + {"ember",1}, + {"fire punch",1}, + {"fiery dance",1}, + {"bubblebeam",2}, + {"dive",2}, + {"whirlpool",2}, + {"aqua tail",2}, + {"nuzzle",3}, + {"thunderbolt",3}, + {"thundershock",3}, + {"discharge",3}, + {"absorb",4}, + {"mega drain",4}, + {"vine whip",4}, + {"razor leaf",4}, + {"ice ball",5}, + {"powder snow",5}, + {"avalanche",5}, + {"icy wind",5}, + {"low kick",6}, + {"force palm",6}, + {"mach punch",6}, + {"double kick",6}, + {"acid",7}, + {"smog",7}, + {"sludge",7}, + {"poison jab",7}, + {"mud-slap",8}, + {"boomerang",8}, + {"bulldoze",8}, + {"dig",8}, + {"peck",9}, + {"pluck",9}, + {"gust",9}, + {"aerial ace",9}, + {"confusion",10}, + {"psybeam",10}, + {"psywave",10}, + {"heart stamp",10}, + {"bug bite",11}, + {"infestation",11}, + {"x-scissor",11}, + {"twineedle",11}, + {"rock throw",12}, + {"rollout",12}, + {"rock tomb",12}, + {"rock blast",12}, + {"astonish",13}, + {"night shade",13}, + {"lick",13}, + {"ominous wind",13}, + {"hex",13}, + {"dragon tail",14}, + {"dragon rage",14}, + {"dragonbreath",14}, + {"twister",14}, + {"pursuit",15}, + {"assurance",15}, + {"bite",15}, + {"faint attack",15}, + {"bullet punch",16}, + {"metal burst",16}, + {"gear grind",16}, + {"magnet bomb",16} + }; + + + } +} diff --git a/NadekoBot/Modules/Pokemon/PokeStats.cs b/NadekoBot/Modules/Pokemon/PokeStats.cs index dca9d31f..0d9c9d34 100644 --- a/NadekoBot/Modules/Pokemon/PokeStats.cs +++ b/NadekoBot/Modules/Pokemon/PokeStats.cs @@ -8,5 +8,11 @@ namespace NadekoBot.Modules.Pokemon { class PokeStats { + //Health left + public int HP { get; set; } = 500; + //Amount of moves made since last time attacked + public int MovesMade { get; set; } = 0; + //Last people attacked + public List LastAttacked { get; set; } = new List(); } } diff --git a/NadekoBot/Modules/Pokemon/PokemonModule.cs b/NadekoBot/Modules/Pokemon/PokemonModule.cs index 9d8973ce..ac29c79c 100644 --- a/NadekoBot/Modules/Pokemon/PokemonModule.cs +++ b/NadekoBot/Modules/Pokemon/PokemonModule.cs @@ -12,16 +12,18 @@ using NadekoBot.Classes._DataModels; using NadekoBot.Classes.Permissions; using System.Collections.Concurrent; using NadekoBot.Modules.Pokemon.PokeTypes; +using NadekoBot.Modules.Pokemon.PokeTypes.Extensions; + namespace NadekoBot.Modules.Pokemon { - + class PokemonGame : DiscordModule { public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Pokemon; - public readonly int BASEHEALTH = 500; + public readonly int BaseHealth = 500; //private Dictionary stats = new Dictionary(); - private ConcurrentDictionary stats = new ConcurrentDictionary(); + private ConcurrentDictionary Stats = new ConcurrentDictionary(); public PokemonGame() @@ -43,60 +45,50 @@ namespace NadekoBot.Modules.Pokemon .Do(async e => { var move = e.GetArg("move"); - Discord.User target = null; - if (!string.IsNullOrWhiteSpace(e.GetArg("target"))) - { - - target = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault(); - if (target == null) - { - await e.Channel.SendMessage("No such person."); - return; - } - } - else + var target = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault(); + if (target == null) { await e.Channel.SendMessage("No such person."); return; } // Checking stats first, then move //Set up the userstats - Pokestats userstats; - userstats = stats.GetOrAdd(e.User.Id, defaultStats()); + PokeStats userStats; + userStats = Stats.GetOrAdd(e.User.Id, defaultStats()); //Check if able to move //User not able if HP < 0, has made more than 4 attacks - if (userstats.HP < 0) + if (userStats.HP < 0) { await e.Channel.SendMessage($"{e.User.Mention} has fainted and was not able to move!"); return; } - if (userstats.movesMade >= 5) + if (userStats.MovesMade >= 5) { await e.Channel.SendMessage($"{e.User.Mention} has used too many moves in a row and was not able to move!"); return; } - if (userstats.lastAttacked.Contains(target.Id)) + if (userStats.LastAttacked.Contains(target.Id)) { await e.Channel.SendMessage($"{e.User.Mention} can't attack again without retaliation!"); return; } //get target stats - Pokestats targetstats; - targetstats = stats.GetOrAdd(target.Id, defaultStats()); + PokeStats targetStats; + targetStats = Stats.GetOrAdd(target.Id, defaultStats()); //If target's HP is below 0, no use attacking - if (targetstats.HP <= 0) + if (targetStats.HP <= 0) { await e.Channel.SendMessage($"{target.Mention} has already fainted!"); return; } //Check whether move can be used - IPokeType usertype = getPokeType(e.User.Id); + IPokeType userType = getPokeType(e.User.Id); - var EnabledMoves = usertype.getMoves(); - if (!EnabledMoves.Contains(move.ToLowerInvariant())) + var enabledMoves = userType.GetMoves(); + if (!enabledMoves.Contains(move.ToLowerInvariant())) { await e.Channel.SendMessage($"{e.User.Mention} was not able to use **{move}**, use {Prefix}listmoves to see moves you can use"); return; @@ -105,11 +97,11 @@ namespace NadekoBot.Modules.Pokemon //get target type IPokeType targetType = getPokeType(target.Id); //generate damage - int damage = getDamage(usertype, targetType); + int damage = getDamage(userType, targetType); //apply damage to target - targetstats.HP -= damage; + targetStats.HP -= damage; - var response = $"{e.User.Mention} used **{move}**{usertype.getImage()} on {target.Mention}{targetType.getImage()} for **{damage}** damage"; + var response = $"{e.User.Mention} used **{move}**{userType.GetImage()} on {target.Mention}{targetType.GetImage()} for **{damage}** damage"; //Damage type if (damage < 40) @@ -127,28 +119,28 @@ namespace NadekoBot.Modules.Pokemon //check fainted - if (targetstats.HP <= 0) + if (targetStats.HP <= 0) { response += $"\n**{target.Name}** has fainted!"; } else { - response += $"\n**{target.Name}** has {targetstats.HP} HP remaining"; + response += $"\n**{target.Name}** has {targetStats.HP} HP remaining"; } //update other stats - userstats.lastAttacked.Add(target.Id); - userstats.movesMade++; - targetstats.movesMade = 0; - if (targetstats.lastAttacked.Contains(e.User.Id)) + userStats.LastAttacked.Add(target.Id); + userStats.MovesMade++; + targetStats.MovesMade = 0; + if (targetStats.LastAttacked.Contains(e.User.Id)) { - targetstats.lastAttacked.Remove(e.User.Id); + targetStats.LastAttacked.Remove(e.User.Id); } //update dictionary //This can stay the same right? - stats[e.User.Id] = userstats; - stats[target.Id] = targetstats; + Stats[e.User.Id] = userStats; + Stats[target.Id] = targetStats; await e.Channel.SendMessage(response); }); @@ -158,11 +150,11 @@ namespace NadekoBot.Modules.Pokemon .Do(async e => { var userType = getPokeType(e.User.Id); - List movesList = userType.getMoves(); + List movesList = userType.GetMoves(); var str = "**Moves:**"; foreach (string m in movesList) { - str += $"\n{userType.getImage()}{m}"; + str += $"\n{userType.GetImage()}{m}"; } await e.Channel.SendMessage(str); }); @@ -176,7 +168,7 @@ namespace NadekoBot.Modules.Pokemon //Implement NadekoFlowers???? string newMove = e.GetArg("movename").ToLowerInvariant(); var newType = PokemonTypesMain.stringToPokeType(e.GetArg("movetype").ToUpperInvariant()); - int typeNum = newType.getNum(); + int typeNum = newType.GetNum(); var db = DbHandler.Instance.GetAllRows().Select(x => x.move); if (db.Contains(newMove)) { @@ -191,7 +183,7 @@ namespace NadekoBot.Modules.Pokemon type = typeNum }); }); - await e.Channel.SendMessage($"Added {newType.getImage()}{newMove}"); + await e.Channel.SendMessage($"Added {newType.GetImage()}{newMove}"); }); cgb.CreateCommand(Prefix + "heal") @@ -205,12 +197,12 @@ namespace NadekoBot.Modules.Pokemon await e.Channel.SendMessage("No such person."); return; } - if (stats.ContainsKey(usr.Id)) + if (Stats.ContainsKey(usr.Id)) { - var targetStats = stats[usr.Id]; + var targetStats = Stats[usr.Id]; int HP = targetStats.HP; - if (targetStats.HP == BASEHEALTH) + if (targetStats.HP == BaseHealth) { await e.Channel.SendMessage($"{usr.Name} already has full HP!"); return; @@ -226,15 +218,15 @@ namespace NadekoBot.Modules.Pokemon var up = (usr.Id == e.User.Id) ? "yourself" : usr.Name; await FlowersHandler.RemoveFlowersAsync(e.User, $"heal {up}", amount); //healing - targetStats.HP = BASEHEALTH; + targetStats.HP = BaseHealth; if (HP < 0) { //Could heal only for half HP? - stats[usr.Id].HP = (BASEHEALTH / 2); + Stats[usr.Id].HP = (BaseHealth / 2); await e.Channel.SendMessage($"{e.User.Name} revived {usr.Name} for 🌸"); return; } - await e.Channel.SendMessage($"{e.User.Name} healed {usr.Name} for {BASEHEALTH - HP} HP with a 🌸"); + await e.Channel.SendMessage($"{e.User.Name} healed {usr.Name} for {BaseHealth - HP} HP with a 🌸"); return; } else @@ -255,12 +247,12 @@ namespace NadekoBot.Modules.Pokemon return; } var pType = getPokeType(usr.Id); - await e.Channel.SendMessage($"Type of {usr.Name} is **{pType.getName().ToLowerInvariant()}**{pType.getImage()}"); + await e.Channel.SendMessage($"Type of {usr.Name} is **{pType.GetName().ToLowerInvariant()}**{pType.GetImage()}"); }); - cgb.CreateCommand(Prefix + "defaultmoves") - .Description($"Sets the moves DB to the default state **OWNER ONLY**") + cgb.CreateCommand(Prefix + "setdefaultmoves") + .Description($"Sets the moves DB to the default state and returns them all **OWNER ONLY**") .AddCheck(SimpleCheckers.OwnerOnly()) .Do(async e => { @@ -270,81 +262,8 @@ namespace NadekoBot.Modules.Pokemon { DbHandler.Instance.Delete(p.Id); } - - Dictionary defaultmoves = new Dictionary() - { - {"sonic boom",0}, - {"quick attack",0}, - {"doubleslap",0}, - {"headbutt",0}, - {"incinerate",1}, - {"ember",1}, - {"fire punch",1}, - {"fiery dance",1}, - {"bubblebeam",2}, - {"dive",2}, - {"whirlpool",2}, - {"aqua tail",2}, - {"nuzzle",3}, - {"thunderbolt",3}, - {"thundershock",3}, - {"discharge",3}, - {"absorb",4}, - {"mega drain",4}, - {"vine whip",4}, - {"razor leaf",4}, - {"ice ball",5}, - {"powder snow",5}, - {"avalanche",5}, - {"icy wind",5}, - {"low kick",6}, - {"force palm",6}, - {"mach punch",6}, - {"double kick",6}, - {"acid",7}, - {"smog",7}, - {"sludge",7}, - {"poison jab",7}, - {"mud-slap",8}, - {"boomerang",8}, - {"bulldoze",8}, - {"dig",8}, - {"peck",9}, - {"pluck",9}, - {"gust",9}, - {"aerial ace",9}, - {"confusion",10}, - {"psybeam",10}, - {"psywave",10}, - {"heart stamp",10}, - {"bug bite",11}, - {"infestation",11}, - {"x-scissor",11}, - {"twineedle",11}, - {"rock throw",12}, - {"rollout",12}, - {"rock tomb",12}, - {"rock blast",12}, - {"astonish",13}, - {"night shade",13}, - {"lick",13}, - {"ominous wind",13}, - {"hex",13}, - {"dragon tail",14}, - {"dragon rage",14}, - {"dragonbreath",14}, - {"twister",14}, - {"pursuit",15}, - {"assurance",15}, - {"bite",15}, - {"faint attack",15}, - {"bullet punch",16}, - {"metal burst",16}, - {"gear grind",16}, - {"magnet bomb",16} - }; - - foreach (KeyValuePair entry in defaultmoves) + + foreach (var entry in DefaultMoves.DefaultMovesList) { DbHandler.Instance.InsertData(new Classes._DataModels.PokeMoves { @@ -353,14 +272,14 @@ namespace NadekoBot.Modules.Pokemon }); } - var str = "Reset moves.\n**Moves:**"; + var str = "**Reset moves to default**.\n**Moves:**"; //could sort, but meh var dbMoves = DbHandler.Instance.GetAllRows(); foreach (PokeMoves m in dbMoves) { - var t = PokemonTypesMain.intToPokeType(m.type); + var t = PokemonTypesMain.IntToPokeType(m.type); - str += $"\n{t.getImage()}{m.move}"; + str += $"\n{t.GetImage()}{m.move}"; } await e.Channel.SendMessage(str); @@ -381,7 +300,7 @@ namespace NadekoBot.Modules.Pokemon } if (targetType == getPokeType(e.User.Id)) { - await e.Channel.SendMessage($"Your type is already {targetType.getName().ToLowerInvariant()}{targetType.getImage()}"); + await e.Channel.SendMessage($"Your type is already {targetType.GetName().ToLowerInvariant()}{targetType.GetImage()}"); return; } @@ -406,12 +325,12 @@ namespace NadekoBot.Modules.Pokemon DbHandler.Instance.InsertData(new Classes._DataModels.userPokeTypes { UserId = (long)e.User.Id, - type = targetType.getNum() + type = targetType.GetNum() }); //Now for the response - await e.Channel.SendMessage($"Set type of {e.User.Mention} to {targetTypeString}{targetType.getImage()} for a 🌸"); + await e.Channel.SendMessage($"Set type of {e.User.Mention} to {targetTypeString}{targetType.GetImage()} for a 🌸"); }); }); } @@ -424,7 +343,7 @@ namespace NadekoBot.Modules.Pokemon Random rng = new Random(); int damage = rng.Next(40, 60); double multiplier = 1; - multiplier = usertype.getMagnifier(targetType); + multiplier = usertype.GetMagnifier(targetType); damage = (int)(damage * multiplier); return damage; } @@ -436,39 +355,27 @@ namespace NadekoBot.Modules.Pokemon Dictionary setTypes = db.ToDictionary(x => x.UserId, y => y.type); if (setTypes.ContainsKey((long)id)) { - return PokemonTypesMain.intToPokeType(setTypes[(long)id]); + return PokemonTypesMain.IntToPokeType(setTypes[(long)id]); } int remainder = (int)id % 16; - return PokemonTypesMain.intToPokeType(remainder); + return PokemonTypesMain.IntToPokeType(remainder); } - private Pokestats defaultStats() + private PokeStats defaultStats() { - Pokestats s = new Pokestats(); - s.HP = BASEHEALTH; + PokeStats s = new PokeStats(); + s.HP = BaseHealth; return s; } } - class Pokestats - { - //Health left - public int HP { get; set; } = 500; - //Amount of moves made since last time attacked - public int movesMade { get; set; } = 0; - //Last people attacked - public List lastAttacked { get; set; } = new List(); - } } -//Not sure this is what you wanted? - - diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/BugType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/BugType.cs index d7d6014a..2df84631 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/BugType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/BugType.cs @@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "BUG"; public static int numType = 11; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "FIRE": return 0.5; @@ -33,39 +33,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == numType) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } + - public string getImage() + public string GetImage() { return "🐛"; } - public int getNum() + public int GetNum() { return numType; } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/DarkType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/DarkType.cs index 98ba6a68..54f69e2d 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/DarkType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/DarkType.cs @@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "DARK"; public static int numType = 15; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "FIGHTING": return 0.5; @@ -29,39 +29,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == numType) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } + - public string getImage() + public string GetImage() { return "🕶"; } - public int getNum() + public int GetNum() { return numType; } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/Dragontype.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/Dragontype.cs index 435675b7..e7168ffc 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/Dragontype.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/Dragontype.cs @@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "DRAGON"; public static int numType = 14; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "DRAGON": return 2; @@ -26,39 +26,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == numType) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } + - public string getImage() + public string GetImage() { return "🐉"; } - public int getNum() + public int GetNum() { return numType; } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/ElectricType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/ElectricType.cs index 25aaa15e..3cb77723 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/ElectricType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/ElectricType.cs @@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "ELECTRIC"; public static int numType = 3; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "WATER": return 2; @@ -30,38 +30,21 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == numType) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } - public string getImage() + + public string GetImage() { return "⚡️"; } - public int getNum() + public int GetNum() { return numType; } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/FightingType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/FightingType.cs index 3f22ec33..3d4603ed 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/FightingType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/FightingType.cs @@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "FIGHTING"; public static int numType = 6; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "NORMAL": return 2; @@ -34,38 +34,21 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == numType) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } - public string getImage() + + public string GetImage() { return "✊"; } - public int getNum() + public int GetNum() { return numType; } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/FireType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/FireType.cs index bf6f8eb0..6995799a 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/FireType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/FireType.cs @@ -16,9 +16,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "FIRE"; public static int numType = 1; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "FIRE": return 0.5; @@ -34,39 +34,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == numType) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } + - public string getImage() + public string GetImage() { return "🔥"; } - public int getNum() + public int GetNum() { return numType; } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/FlyingType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/FlyingType.cs index 7d7c1d54..8f26875b 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/FlyingType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/FlyingType.cs @@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "FLYING"; public static int numType = 9; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "ELECTRIC": return 0.5; @@ -30,39 +30,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == numType) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } + - public string getImage() + public string GetImage() { return "☁"; } - public int getNum() + public int GetNum() { return numType; } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/GhostType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/GhostType.cs index 8db5b678..83c35504 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/GhostType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/GhostType.cs @@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "GHOST"; public static int numType = 13; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "NORMAL": return 0; @@ -29,39 +29,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == numType) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } + - public string getImage() + public string GetImage() { return "👻"; } - public int getNum() + public int GetNum() { return numType; } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/GrassType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/GrassType.cs index cab50981..1fc34dd6 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/GrassType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/GrassType.cs @@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "GRASS"; public static int numType = 4; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "FIRE": return 0.5; @@ -32,38 +32,21 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == numType) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } - public string getImage() + + public string GetImage() { return "🌿"; } - public int getNum() + public int GetNum() { return numType; } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/GroundType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/GroundType.cs index b1eb5ec4..9795aa77 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/GroundType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/GroundType.cs @@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "GROUND"; public static int numType = 8; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "FIRE": return 2; @@ -32,39 +32,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == numType) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } + - public string getImage() + public string GetImage() { return "🗻"; } - public int getNum() + public int GetNum() { return numType; } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/IPokeTypeExtensions.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/IPokeTypeExtensions.cs new file mode 100644 index 00000000..08d354cf --- /dev/null +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/IPokeTypeExtensions.cs @@ -0,0 +1,27 @@ +using NadekoBot.Classes; +using NadekoBot.Classes._DataModels; +using System.Collections.Generic; + +namespace NadekoBot.Modules.Pokemon.PokeTypes.Extensions +{ + public static class IPokeTypeExtensions + { + public static List GetMoves(this IPokeType poketype) + { + var db = DbHandler.Instance.GetAllRows(); + List moves = new List(); + foreach (PokeMoves p in db) + { + if (p.type == poketype.GetNum()) + { + if (!moves.Contains(p.move)) + { + moves.Add(p.move); + } + } + } + return moves; + } + } + + } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/IceType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/IceType.cs index 36cffe65..1d1156ad 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/IceType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/IceType.cs @@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "ICE"; public static int numType = 5; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "FIRE": return 0.5; @@ -32,38 +32,21 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == numType) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } - public string getImage() + + public string GetImage() { return "❄"; } - public int getNum() + public int GetNum() { return numType; } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/NormalType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/NormalType.cs index a6127865..3052b4e1 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/NormalType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/NormalType.cs @@ -16,9 +16,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "NORMAL"; public static int type_num = 0; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "ROCK": return 0.5; @@ -29,39 +29,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == type_num) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } + - public string getImage() + public string GetImage() { return "⭕️"; } - public int getNum() + public int GetNum() { return type_num; } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/PoisonType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/PoisonType.cs index f0cf19d1..9c30dfae 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/PoisonType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/PoisonType.cs @@ -15,9 +15,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "POISON"; public static int numType = 7; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "GRASS": return 2; @@ -31,38 +31,21 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == numType) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } - public string getImage() + + public string GetImage() { return "☠"; } - public int getNum() + public int GetNum() { return numType; } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/PokeType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/PokeType.cs index 75e265ea..6c47e466 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/PokeType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/PokeType.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; using NadekoBot.Classes; using NadekoBot.Classes._DataModels; using NadekoBot.Modules.Pokemon.PokemonTypes; @@ -12,12 +8,11 @@ namespace NadekoBot.Modules.Pokemon.PokeTypes public interface IPokeType { - string getImage(); - string getName(); - int getNum(); - List getMoves(); - double getMagnifier(IPokeType target); - void updateMoves(); + + string GetImage(); + string GetName(); + int GetNum(); + double GetMagnifier(IPokeType target); } public class PokemonTypesMain { @@ -25,9 +20,9 @@ namespace NadekoBot.Modules.Pokemon.PokeTypes public static IPokeType stringToPokeType(string newType) { - foreach (IPokeType t in typeList) + foreach (IPokeType t in TypeList) { - if (t.getName() == newType) + if (t.GetName() == newType) { return t; } @@ -35,8 +30,26 @@ namespace NadekoBot.Modules.Pokemon.PokeTypes return null; } + //public static List getMoves(int numType) + //{ + // var db = DbHandler.Instance.GetAllRows(); + // List moves = new List(); + // foreach (PokeMoves p in db) + // { + // if (p.type == numType) + // { + // if (!moves.Contains(p.move)) + // { + // moves.Add(p.move); + // } + // } + // } + // return moves; + //} + + //These classes can use all methods (except getMoves) - public static List typeList = new List() + public static List TypeList = new List() { new NormalType(), new FireType(), @@ -57,11 +70,11 @@ namespace NadekoBot.Modules.Pokemon.PokeTypes new SteelType() }; - public static IPokeType intToPokeType(int id) + public static IPokeType IntToPokeType(int id) { - foreach (IPokeType t in typeList) + foreach (IPokeType t in TypeList) { - if (t.getNum() == id) + if (t.GetNum() == id) { return t; } @@ -69,23 +82,5 @@ namespace NadekoBot.Modules.Pokemon.PokeTypes return null; } - - - - - - - - - - - - - - - - - - } } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/PsychicType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/PsychicType.cs index 1f1603ad..1972c197 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/PsychicType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/PsychicType.cs @@ -5,7 +5,8 @@ using System.Text; using System.Threading.Tasks; using NadekoBot.Modules.Pokemon; using NadekoBot.Classes; -using NadekoBot.Classes._DataModels; using NadekoBot.Modules.Pokemon.PokeTypes; +using NadekoBot.Classes._DataModels; +using NadekoBot.Modules.Pokemon.PokeTypes; namespace NadekoBot.Modules.Pokemon.PokemonTypes { @@ -14,9 +15,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "PSYCHIC"; public static int numType = 10; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "FIGHTING": return 2; @@ -29,39 +30,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == numType) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } + - public string getImage() + public string GetImage() { return "💫"; } - public int getNum() + public int GetNum() { return numType; } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/RockType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/RockType.cs index 4a48b9a7..76b7ae44 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/RockType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/RockType.cs @@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "ROCK"; public static int numType = 12; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "FIRE": return 2; @@ -31,39 +31,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == numType) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } + - public string getImage() + public string GetImage() { return "💎"; } - public int getNum() + public int GetNum() { return numType; } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/SteelType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/SteelType.cs index f34e1ff2..ff8b554b 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/SteelType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/SteelType.cs @@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "STEEL"; public static int numType = -1; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "FIRE": return 0.5; @@ -30,38 +30,21 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == numType) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } - public string getImage() + + public string GetImage() { return "🔩"; } - public int getNum() + public int GetNum() { return numType; } diff --git a/NadekoBot/Modules/Pokemon/PokemonTypes/WaterType.cs b/NadekoBot/Modules/Pokemon/PokemonTypes/WaterType.cs index 9ee96880..e5cfeaaa 100644 --- a/NadekoBot/Modules/Pokemon/PokemonTypes/WaterType.cs +++ b/NadekoBot/Modules/Pokemon/PokemonTypes/WaterType.cs @@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes static readonly string name = "WATER"; public static int numType = 2; - public double getMagnifier(IPokeType target) + public double GetMagnifier(IPokeType target) { - switch (target.getName()) + switch (target.GetName()) { case "FIRE": return 2; @@ -30,38 +30,21 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes } List moves = new List(); - public List getMoves() - { - updateMoves(); - return moves; - } + - public string getName() + public string GetName() { return name; } - public void updateMoves() - { - var db = DbHandler.Instance.GetAllRows(); - foreach (PokeMoves p in db) - { - if (p.type == numType) - { - if (!moves.Contains(p.move)) - { - moves.Add(p.move); - } - } - } - } - public string getImage() + + public string GetImage() { return "💦"; } - public int getNum() + public int GetNum() { return numType; } diff --git a/NadekoBot/NadekoBot.csproj b/NadekoBot/NadekoBot.csproj index c1e5e3ea..858557ba 100644 --- a/NadekoBot/NadekoBot.csproj +++ b/NadekoBot/NadekoBot.csproj @@ -188,7 +188,9 @@ + +