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
{
//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 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<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()
@ -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<string> movesList = userType.getMoves();
List<string> 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<PokeMoves>().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<PokeMoves>(p.Id);
}
Dictionary<string, int> defaultmoves = 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}
};
foreach (KeyValuePair<string, int> 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<PokeMoves>();
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<long, int> 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<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";
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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "🐛";
}
public int getNum()
public int GetNum()
{
return numType;
}

View File

@ -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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "🕶";
}
public int getNum()
public int GetNum()
{
return numType;
}

View File

@ -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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "🐉";
}
public int getNum()
public int GetNum()
{
return numType;
}

View File

@ -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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "⚡️";
}
public int getNum()
public int GetNum()
{
return numType;
}

View File

@ -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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "✊";
}
public int getNum()
public int GetNum()
{
return numType;
}

View File

@ -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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "🔥";
}
public int getNum()
public int GetNum()
{
return numType;
}

View File

@ -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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "☁";
}
public int getNum()
public int GetNum()
{
return numType;
}

View File

@ -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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "👻";
}
public int getNum()
public int GetNum()
{
return numType;
}

View File

@ -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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "🌿";
}
public int getNum()
public int GetNum()
{
return numType;
}

View File

@ -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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "🗻";
}
public int getNum()
public int GetNum()
{
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";
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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "❄";
}
public int getNum()
public int GetNum()
{
return numType;
}

View File

@ -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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "⭕️";
}
public int getNum()
public int GetNum()
{
return type_num;
}

View File

@ -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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "☠";
}
public int getNum()
public int GetNum()
{
return numType;
}

View File

@ -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<string> 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<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)
public static List<IPokeType> typeList = new List<IPokeType>()
public static List<IPokeType> TypeList = new List<IPokeType>()
{
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;
}
}
}

View File

@ -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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "💫";
}
public int getNum()
public int GetNum()
{
return numType;
}

View File

@ -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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "💎";
}
public int getNum()
public int GetNum()
{
return numType;
}

View File

@ -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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "🔩";
}
public int getNum()
public int GetNum()
{
return numType;
}

View File

@ -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<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
public string getName()
public string GetName()
{
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 "💦";
}
public int getNum()
public int GetNum()
{
return numType;
}

View File

@ -188,7 +188,9 @@
<Compile Include="Modules\NSFW.cs" />
<Compile Include="Modules\Permissions.cs" />
<Compile Include="Commands\RatelimitCommand.cs" />
<Compile Include="Modules\Pokemon\DefaultMoves.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\PsychicType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\BugType.cs" />