Changed GetMoves to extension method, used PascalCase,

This commit is contained in:
appelemac 2016-03-28 13:26:14 +02:00
parent ddbe51e33b
commit 671cc01306
23 changed files with 330 additions and 594 deletions

View File

@ -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<string, int> DefaultMovesList = new Dictionary<string, int>()
{
{"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}
};
}
}

View File

@ -8,5 +8,11 @@ namespace NadekoBot.Modules.Pokemon
{ {
class PokeStats 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<ulong> LastAttacked { get; set; } = new List<ulong>();
} }
} }

View File

@ -12,16 +12,18 @@ using NadekoBot.Classes._DataModels;
using NadekoBot.Classes.Permissions; using NadekoBot.Classes.Permissions;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using NadekoBot.Modules.Pokemon.PokeTypes; using NadekoBot.Modules.Pokemon.PokeTypes;
using NadekoBot.Modules.Pokemon.PokeTypes.Extensions;
namespace NadekoBot.Modules.Pokemon namespace NadekoBot.Modules.Pokemon
{ {
class PokemonGame : DiscordModule class PokemonGame : DiscordModule
{ {
public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Pokemon; public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Pokemon;
public readonly int BASEHEALTH = 500; public readonly int BaseHealth = 500;
//private Dictionary<ulong, Pokestats> stats = new Dictionary<ulong, Pokestats>(); //private Dictionary<ulong, Pokestats> stats = new Dictionary<ulong, Pokestats>();
private ConcurrentDictionary<ulong, Pokestats> stats = new ConcurrentDictionary<ulong, Pokestats>(); private ConcurrentDictionary<ulong, PokeStats> Stats = new ConcurrentDictionary<ulong, PokeStats>();
public PokemonGame() public PokemonGame()
@ -43,60 +45,50 @@ namespace NadekoBot.Modules.Pokemon
.Do(async e => .Do(async e =>
{ {
var move = e.GetArg("move"); var move = e.GetArg("move");
Discord.User target = null; var target = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault();
if (!string.IsNullOrWhiteSpace(e.GetArg("target"))) if (target == null)
{
target = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault();
if (target == null)
{
await e.Channel.SendMessage("No such person.");
return;
}
}
else
{ {
await e.Channel.SendMessage("No such person."); await e.Channel.SendMessage("No such person.");
return; return;
} }
// Checking stats first, then move // Checking stats first, then move
//Set up the userstats //Set up the userstats
Pokestats userstats; PokeStats userStats;
userstats = stats.GetOrAdd(e.User.Id, defaultStats()); userStats = Stats.GetOrAdd(e.User.Id, defaultStats());
//Check if able to move //Check if able to move
//User not able if HP < 0, has made more than 4 attacks //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!"); await e.Channel.SendMessage($"{e.User.Mention} has fainted and was not able to move!");
return; 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!"); await e.Channel.SendMessage($"{e.User.Mention} has used too many moves in a row and was not able to move!");
return; 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!"); await e.Channel.SendMessage($"{e.User.Mention} can't attack again without retaliation!");
return; return;
} }
//get target stats //get target stats
Pokestats targetstats; PokeStats targetStats;
targetstats = stats.GetOrAdd(target.Id, defaultStats()); targetStats = Stats.GetOrAdd(target.Id, defaultStats());
//If target's HP is below 0, no use attacking //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!"); await e.Channel.SendMessage($"{target.Mention} has already fainted!");
return; return;
} }
//Check whether move can be used //Check whether move can be used
IPokeType usertype = getPokeType(e.User.Id); IPokeType userType = getPokeType(e.User.Id);
var EnabledMoves = usertype.getMoves(); var enabledMoves = userType.GetMoves();
if (!EnabledMoves.Contains(move.ToLowerInvariant())) 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"); await e.Channel.SendMessage($"{e.User.Mention} was not able to use **{move}**, use {Prefix}listmoves to see moves you can use");
return; return;
@ -105,11 +97,11 @@ namespace NadekoBot.Modules.Pokemon
//get target type //get target type
IPokeType targetType = getPokeType(target.Id); IPokeType targetType = getPokeType(target.Id);
//generate damage //generate damage
int damage = getDamage(usertype, targetType); int damage = getDamage(userType, targetType);
//apply damage to target //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 //Damage type
if (damage < 40) if (damage < 40)
@ -127,28 +119,28 @@ namespace NadekoBot.Modules.Pokemon
//check fainted //check fainted
if (targetstats.HP <= 0) if (targetStats.HP <= 0)
{ {
response += $"\n**{target.Name}** has fainted!"; response += $"\n**{target.Name}** has fainted!";
} }
else else
{ {
response += $"\n**{target.Name}** has {targetstats.HP} HP remaining"; response += $"\n**{target.Name}** has {targetStats.HP} HP remaining";
} }
//update other stats //update other stats
userstats.lastAttacked.Add(target.Id); userStats.LastAttacked.Add(target.Id);
userstats.movesMade++; userStats.MovesMade++;
targetstats.movesMade = 0; targetStats.MovesMade = 0;
if (targetstats.lastAttacked.Contains(e.User.Id)) if (targetStats.LastAttacked.Contains(e.User.Id))
{ {
targetstats.lastAttacked.Remove(e.User.Id); targetStats.LastAttacked.Remove(e.User.Id);
} }
//update dictionary //update dictionary
//This can stay the same right? //This can stay the same right?
stats[e.User.Id] = userstats; Stats[e.User.Id] = userStats;
stats[target.Id] = targetstats; Stats[target.Id] = targetStats;
await e.Channel.SendMessage(response); await e.Channel.SendMessage(response);
}); });
@ -158,11 +150,11 @@ namespace NadekoBot.Modules.Pokemon
.Do(async e => .Do(async e =>
{ {
var userType = getPokeType(e.User.Id); var userType = getPokeType(e.User.Id);
List<string> movesList = userType.getMoves(); List<string> movesList = userType.GetMoves();
var str = "**Moves:**"; var str = "**Moves:**";
foreach (string m in movesList) foreach (string m in movesList)
{ {
str += $"\n{userType.getImage()}{m}"; str += $"\n{userType.GetImage()}{m}";
} }
await e.Channel.SendMessage(str); await e.Channel.SendMessage(str);
}); });
@ -176,7 +168,7 @@ namespace NadekoBot.Modules.Pokemon
//Implement NadekoFlowers???? //Implement NadekoFlowers????
string newMove = e.GetArg("movename").ToLowerInvariant(); string newMove = e.GetArg("movename").ToLowerInvariant();
var newType = PokemonTypesMain.stringToPokeType(e.GetArg("movetype").ToUpperInvariant()); var newType = PokemonTypesMain.stringToPokeType(e.GetArg("movetype").ToUpperInvariant());
int typeNum = newType.getNum(); int typeNum = newType.GetNum();
var db = DbHandler.Instance.GetAllRows<PokeMoves>().Select(x => x.move); var db = DbHandler.Instance.GetAllRows<PokeMoves>().Select(x => x.move);
if (db.Contains(newMove)) if (db.Contains(newMove))
{ {
@ -191,7 +183,7 @@ namespace NadekoBot.Modules.Pokemon
type = typeNum type = typeNum
}); });
}); });
await e.Channel.SendMessage($"Added {newType.getImage()}{newMove}"); await e.Channel.SendMessage($"Added {newType.GetImage()}{newMove}");
}); });
cgb.CreateCommand(Prefix + "heal") cgb.CreateCommand(Prefix + "heal")
@ -205,12 +197,12 @@ namespace NadekoBot.Modules.Pokemon
await e.Channel.SendMessage("No such person."); await e.Channel.SendMessage("No such person.");
return; 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; int HP = targetStats.HP;
if (targetStats.HP == BASEHEALTH) if (targetStats.HP == BaseHealth)
{ {
await e.Channel.SendMessage($"{usr.Name} already has full HP!"); await e.Channel.SendMessage($"{usr.Name} already has full HP!");
return; return;
@ -226,15 +218,15 @@ namespace NadekoBot.Modules.Pokemon
var up = (usr.Id == e.User.Id) ? "yourself" : usr.Name; var up = (usr.Id == e.User.Id) ? "yourself" : usr.Name;
await FlowersHandler.RemoveFlowersAsync(e.User, $"heal {up}", amount); await FlowersHandler.RemoveFlowersAsync(e.User, $"heal {up}", amount);
//healing //healing
targetStats.HP = BASEHEALTH; targetStats.HP = BaseHealth;
if (HP < 0) if (HP < 0)
{ {
//Could heal only for half HP? //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 🌸"); await e.Channel.SendMessage($"{e.User.Name} revived {usr.Name} for 🌸");
return; 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; return;
} }
else else
@ -255,12 +247,12 @@ namespace NadekoBot.Modules.Pokemon
return; return;
} }
var pType = getPokeType(usr.Id); 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") cgb.CreateCommand(Prefix + "setdefaultmoves")
.Description($"Sets the moves DB to the default state **OWNER ONLY**") .Description($"Sets the moves DB to the default state and returns them all **OWNER ONLY**")
.AddCheck(SimpleCheckers.OwnerOnly()) .AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e => .Do(async e =>
{ {
@ -270,81 +262,8 @@ namespace NadekoBot.Modules.Pokemon
{ {
DbHandler.Instance.Delete<PokeMoves>(p.Id); DbHandler.Instance.Delete<PokeMoves>(p.Id);
} }
Dictionary<string, int> defaultmoves = new Dictionary<string, int>() foreach (var entry in DefaultMoves.DefaultMovesList)
{
{"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<string, int> entry in defaultmoves)
{ {
DbHandler.Instance.InsertData(new Classes._DataModels.PokeMoves 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 //could sort, but meh
var dbMoves = DbHandler.Instance.GetAllRows<PokeMoves>(); var dbMoves = DbHandler.Instance.GetAllRows<PokeMoves>();
foreach (PokeMoves m in dbMoves) 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); await e.Channel.SendMessage(str);
@ -381,7 +300,7 @@ namespace NadekoBot.Modules.Pokemon
} }
if (targetType == getPokeType(e.User.Id)) 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; return;
} }
@ -406,12 +325,12 @@ namespace NadekoBot.Modules.Pokemon
DbHandler.Instance.InsertData(new Classes._DataModels.userPokeTypes DbHandler.Instance.InsertData(new Classes._DataModels.userPokeTypes
{ {
UserId = (long)e.User.Id, UserId = (long)e.User.Id,
type = targetType.getNum() type = targetType.GetNum()
}); });
//Now for the response //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(); Random rng = new Random();
int damage = rng.Next(40, 60); int damage = rng.Next(40, 60);
double multiplier = 1; double multiplier = 1;
multiplier = usertype.getMagnifier(targetType); multiplier = usertype.GetMagnifier(targetType);
damage = (int)(damage * multiplier); damage = (int)(damage * multiplier);
return damage; return damage;
} }
@ -436,39 +355,27 @@ namespace NadekoBot.Modules.Pokemon
Dictionary<long, int> setTypes = db.ToDictionary(x => x.UserId, y => y.type); Dictionary<long, int> setTypes = db.ToDictionary(x => x.UserId, y => y.type);
if (setTypes.ContainsKey((long)id)) if (setTypes.ContainsKey((long)id))
{ {
return PokemonTypesMain.intToPokeType(setTypes[(long)id]); return PokemonTypesMain.IntToPokeType(setTypes[(long)id]);
} }
int remainder = (int)id % 16; int remainder = (int)id % 16;
return PokemonTypesMain.intToPokeType(remainder); return PokemonTypesMain.IntToPokeType(remainder);
} }
private Pokestats defaultStats() private PokeStats defaultStats()
{ {
Pokestats s = new Pokestats(); PokeStats s = new PokeStats();
s.HP = BASEHEALTH; s.HP = BaseHealth;
return s; 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<ulong> lastAttacked { get; set; } = new List<ulong>();
}
} }
//Not sure this is what you wanted?

View File

@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "BUG"; static readonly string name = "BUG";
public static int numType = 11; 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; case "FIRE": return 0.5;
@ -33,39 +33,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
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 "🐛"; return "🐛";
} }
public int getNum() public int GetNum()
{ {
return numType; return numType;
} }

View File

@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "DARK"; static readonly string name = "DARK";
public static int numType = 15; 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; case "FIGHTING": return 0.5;
@ -29,39 +29,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
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 "🕶"; return "🕶";
} }
public int getNum() public int GetNum()
{ {
return numType; return numType;
} }

View File

@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "DRAGON"; static readonly string name = "DRAGON";
public static int numType = 14; 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; case "DRAGON": return 2;
@ -26,39 +26,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
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 "🐉"; return "🐉";
} }
public int getNum() public int GetNum()
{ {
return numType; return numType;
} }

View File

@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "ELECTRIC"; static readonly string name = "ELECTRIC";
public static int numType = 3; 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; case "WATER": return 2;
@ -30,38 +30,21 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{ public string GetImage()
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
foreach (PokeMoves p in db)
{
if (p.type == numType)
{
if (!moves.Contains(p.move))
{
moves.Add(p.move);
}
}
}
}
public string getImage()
{ {
return "⚡️"; return "⚡️";
} }
public int getNum() public int GetNum()
{ {
return numType; return numType;
} }

View File

@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "FIGHTING"; static readonly string name = "FIGHTING";
public static int numType = 6; 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; case "NORMAL": return 2;
@ -34,38 +34,21 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{ public string GetImage()
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
foreach (PokeMoves p in db)
{
if (p.type == numType)
{
if (!moves.Contains(p.move))
{
moves.Add(p.move);
}
}
}
}
public string getImage()
{ {
return "✊"; return "✊";
} }
public int getNum() public int GetNum()
{ {
return numType; return numType;
} }

View File

@ -16,9 +16,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "FIRE"; static readonly string name = "FIRE";
public static int numType = 1; 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; case "FIRE": return 0.5;
@ -34,39 +34,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
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 "🔥"; return "🔥";
} }
public int getNum() public int GetNum()
{ {
return numType; return numType;
} }

View File

@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "FLYING"; static readonly string name = "FLYING";
public static int numType = 9; 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; case "ELECTRIC": return 0.5;
@ -30,39 +30,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
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 "☁"; return "☁";
} }
public int getNum() public int GetNum()
{ {
return numType; return numType;
} }

View File

@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "GHOST"; static readonly string name = "GHOST";
public static int numType = 13; 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; case "NORMAL": return 0;
@ -29,39 +29,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
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 "👻"; return "👻";
} }
public int getNum() public int GetNum()
{ {
return numType; return numType;
} }

View File

@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "GRASS"; static readonly string name = "GRASS";
public static int numType = 4; 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; case "FIRE": return 0.5;
@ -32,38 +32,21 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{ public string GetImage()
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
foreach (PokeMoves p in db)
{
if (p.type == numType)
{
if (!moves.Contains(p.move))
{
moves.Add(p.move);
}
}
}
}
public string getImage()
{ {
return "🌿"; return "🌿";
} }
public int getNum() public int GetNum()
{ {
return numType; return numType;
} }

View File

@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "GROUND"; static readonly string name = "GROUND";
public static int numType = 8; 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; case "FIRE": return 2;
@ -32,39 +32,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
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 "🗻"; return "🗻";
} }
public int getNum() public int GetNum()
{ {
return numType; return numType;
} }

View File

@ -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<string> GetMoves(this IPokeType poketype)
{
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
List<string> moves = new List<string>();
foreach (PokeMoves p in db)
{
if (p.type == poketype.GetNum())
{
if (!moves.Contains(p.move))
{
moves.Add(p.move);
}
}
}
return moves;
}
}
}

View File

@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "ICE"; static readonly string name = "ICE";
public static int numType = 5; 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; case "FIRE": return 0.5;
@ -32,38 +32,21 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{ public string GetImage()
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
foreach (PokeMoves p in db)
{
if (p.type == numType)
{
if (!moves.Contains(p.move))
{
moves.Add(p.move);
}
}
}
}
public string getImage()
{ {
return "❄"; return "❄";
} }
public int getNum() public int GetNum()
{ {
return numType; return numType;
} }

View File

@ -16,9 +16,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "NORMAL"; static readonly string name = "NORMAL";
public static int type_num = 0; 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; case "ROCK": return 0.5;
@ -29,39 +29,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
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 "⭕️"; return "⭕️";
} }
public int getNum() public int GetNum()
{ {
return type_num; return type_num;
} }

View File

@ -15,9 +15,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "POISON"; static readonly string name = "POISON";
public static int numType = 7; 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; case "GRASS": return 2;
@ -31,38 +31,21 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{ public string GetImage()
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
foreach (PokeMoves p in db)
{
if (p.type == numType)
{
if (!moves.Contains(p.move))
{
moves.Add(p.move);
}
}
}
}
public string getImage()
{ {
return "☠"; return "☠";
} }
public int getNum() public int GetNum()
{ {
return numType; return numType;
} }

View File

@ -1,8 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Classes; using NadekoBot.Classes;
using NadekoBot.Classes._DataModels; using NadekoBot.Classes._DataModels;
using NadekoBot.Modules.Pokemon.PokemonTypes; using NadekoBot.Modules.Pokemon.PokemonTypes;
@ -12,12 +8,11 @@ namespace NadekoBot.Modules.Pokemon.PokeTypes
public interface IPokeType public interface IPokeType
{ {
string getImage();
string getName(); string GetImage();
int getNum(); string GetName();
List<string> getMoves(); int GetNum();
double getMagnifier(IPokeType target); double GetMagnifier(IPokeType target);
void updateMoves();
} }
public class PokemonTypesMain public class PokemonTypesMain
{ {
@ -25,9 +20,9 @@ namespace NadekoBot.Modules.Pokemon.PokeTypes
public static IPokeType stringToPokeType(string newType) 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; return t;
} }
@ -35,8 +30,26 @@ namespace NadekoBot.Modules.Pokemon.PokeTypes
return null; return null;
} }
//public static List<string> getMoves(int numType)
//{
// var db = DbHandler.Instance.GetAllRows<PokeMoves>();
// List<string> moves = new List<string>();
// 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) //These classes can use all methods (except getMoves)
public static List<IPokeType> typeList = new List<IPokeType>() public static List<IPokeType> TypeList = new List<IPokeType>()
{ {
new NormalType(), new NormalType(),
new FireType(), new FireType(),
@ -57,11 +70,11 @@ namespace NadekoBot.Modules.Pokemon.PokeTypes
new SteelType() 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; return t;
} }
@ -69,23 +82,5 @@ namespace NadekoBot.Modules.Pokemon.PokeTypes
return null; return null;
} }
} }
} }

View File

@ -5,7 +5,8 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon; using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes; 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 namespace NadekoBot.Modules.Pokemon.PokemonTypes
{ {
@ -14,9 +15,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "PSYCHIC"; static readonly string name = "PSYCHIC";
public static int numType = 10; 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; case "FIGHTING": return 2;
@ -29,39 +30,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
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 "💫"; return "💫";
} }
public int getNum() public int GetNum()
{ {
return numType; return numType;
} }

View File

@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "ROCK"; static readonly string name = "ROCK";
public static int numType = 12; 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; case "FIRE": return 2;
@ -31,39 +31,22 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
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 "💎"; return "💎";
} }
public int getNum() public int GetNum()
{ {
return numType; return numType;
} }

View File

@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "STEEL"; static readonly string name = "STEEL";
public static int numType = -1; 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; case "FIRE": return 0.5;
@ -30,38 +30,21 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{ public string GetImage()
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
foreach (PokeMoves p in db)
{
if (p.type == numType)
{
if (!moves.Contains(p.move))
{
moves.Add(p.move);
}
}
}
}
public string getImage()
{ {
return "🔩"; return "🔩";
} }
public int getNum() public int GetNum()
{ {
return numType; return numType;
} }

View File

@ -14,9 +14,9 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
static readonly string name = "WATER"; static readonly string name = "WATER";
public static int numType = 2; 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; case "FIRE": return 2;
@ -30,38 +30,21 @@ namespace NadekoBot.Modules.Pokemon.PokemonTypes
} }
List<string> moves = new List<string>(); List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName() public string GetName()
{ {
return name; return name;
} }
public void updateMoves()
{ public string GetImage()
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
foreach (PokeMoves p in db)
{
if (p.type == numType)
{
if (!moves.Contains(p.move))
{
moves.Add(p.move);
}
}
}
}
public string getImage()
{ {
return "💦"; return "💦";
} }
public int getNum() public int GetNum()
{ {
return numType; return numType;
} }

View File

@ -188,7 +188,9 @@
<Compile Include="Modules\NSFW.cs" /> <Compile Include="Modules\NSFW.cs" />
<Compile Include="Modules\Permissions.cs" /> <Compile Include="Modules\Permissions.cs" />
<Compile Include="Commands\RatelimitCommand.cs" /> <Compile Include="Commands\RatelimitCommand.cs" />
<Compile Include="Modules\Pokemon\DefaultMoves.cs" />
<Compile Include="Modules\Pokemon\PokemonModule.cs" /> <Compile Include="Modules\Pokemon\PokemonModule.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\IPokeTypeExtensions.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\PokeType.cs" /> <Compile Include="Modules\Pokemon\PokemonTypes\PokeType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\PsychicType.cs" /> <Compile Include="Modules\Pokemon\PokemonTypes\PsychicType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\BugType.cs" /> <Compile Include="Modules\Pokemon\PokemonTypes\BugType.cs" />