LOTS OF WORK, THIS WAS
This commit is contained in:
appelemac 2016-03-27 14:55:49 +02:00
parent 5496531bf2
commit 6eca7745d3
25 changed files with 1756 additions and 1486 deletions

View File

@ -23,7 +23,7 @@ namespace NadekoBot.Classes {
conn.CreateTable<CurrencyTransaction>();
conn.CreateTable<Donator>();
conn.CreateTable<PokeMoves>();
conn.CreateTable<PokeTypes>();
conn.CreateTable<userPokeTypes>();
conn.CreateTable<UserQuote>();
conn.Execute(Queries.TransactionTriggerQuery);
}

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace NadekoBot.Classes._DataModels
{
class PokeTypes : IDataModel
class userPokeTypes : IDataModel
{
public long UserId { get; set; }
public int type { get; set; }

View File

@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NadekoBot.Modules.Pokemon
{
class PokeStats
{
}
}

View File

@ -0,0 +1,435 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Discord.Modules;
using Discord.Commands;
using NadekoBot.Commands;
using NadekoBot.Classes;
using NadekoBot.Extensions;
using NadekoBot.Classes._DataModels;
using NadekoBot.Classes.Permissions;
using System.Collections.Concurrent;
using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon
{
class PokemonGame : DiscordModule
{
public override string Prefix { get; } = NadekoBot.Config.CommandPrefixes.Pokemon;
public readonly int BASEHEALTH = 500;
//private Dictionary<ulong, Pokestats> stats = new Dictionary<ulong, Pokestats>();
private ConcurrentDictionary<ulong, Pokestats> stats = new ConcurrentDictionary<ulong, Pokestats>();
public PokemonGame()
{
//Something?
}
public override void Install(ModuleManager manager)
{
manager.CreateCommands("", cgb =>
{
cgb.AddCheck(Classes.Permissions.PermissionChecker.Instance);
commands.ForEach(cmd => cmd.Init(cgb));
cgb.CreateCommand(Prefix + "attack")
.Description("Attacks a target with the given move")
.Parameter("move", ParameterType.Required)
.Parameter("target", ParameterType.Unparsed)
.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
{
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());
//Check if able to move
//User not able if HP < 0, has made more than 4 attacks
if (userstats.HP < 0)
{
await e.Channel.SendMessage($"{e.User.Mention} has fainted and was not able to move!");
return;
}
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))
{
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());
//If target's HP is below 0, no use attacking
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);
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;
}
//get target type
IPokeType targetType = getPokeType(target.Id);
//generate damage
int damage = getDamage(usertype, targetType);
//apply damage to target
targetstats.HP -= damage;
var response = $"{e.User.Mention} used **{move}**{usertype.getImage()} on {target.Mention}{targetType.getImage()} for **{damage}** damage";
//Damage type
if (damage < 40)
{
response += "\nIt's not effective..";
}
else if (damage > 60)
{
response += "\nIt's super effective!";
}
else
{
response += "\nIt's somewhat effective";
}
//check fainted
if (targetstats.HP <= 0)
{
response += $"\n**{target.Name}** has fainted!";
}
else
{
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))
{
targetstats.lastAttacked.Remove(e.User.Id);
}
//update dictionary
//This can stay the same right?
stats[e.User.Id] = userstats;
stats[target.Id] = targetstats;
await e.Channel.SendMessage(response);
});
cgb.CreateCommand(Prefix + "listmoves")
.Description("Lists the moves you are able to use")
.Do(async e =>
{
var userType = getPokeType(e.User.Id);
List<string> movesList = userType.getMoves();
var str = "**Moves:**";
foreach (string m in movesList)
{
str += $"\n{userType.getImage()}{m}";
}
await e.Channel.SendMessage(str);
});
cgb.CreateCommand(Prefix + "addmove")
.Description($"Adds move given to database.\n**Usage**: {Prefix}addmove flame fire")
.Parameter("movename", ParameterType.Required)
.Parameter("movetype", ParameterType.Required)
.Do(async e =>
{
//Implement NadekoFlowers????
string newMove = e.GetArg("movename").ToLowerInvariant();
var newType = PokemonTypesMain.stringToPokeType(e.GetArg("movetype").ToUpperInvariant());
int typeNum = newType.getNum();
var db = DbHandler.Instance.GetAllRows<PokeMoves>().Select(x => x.move);
if (db.Contains(newMove))
{
await e.Channel.SendMessage($"{newMove} already exists");
return;
}
await Task.Run(() =>
{
DbHandler.Instance.InsertData(new Classes._DataModels.PokeMoves
{
move = newMove,
type = typeNum
});
});
await e.Channel.SendMessage($"Added {newType.getImage()}{newMove}");
});
cgb.CreateCommand(Prefix + "heal")
.Description($"Heals someone. Revives those that fainted. Costs a NadekoFlower \n**Usage**:{Prefix}revive @someone")
.Parameter("target", ParameterType.Required)
.Do(async e =>
{
var usr = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault();
if (usr == null)
{
await e.Channel.SendMessage("No such person.");
return;
}
if (stats.ContainsKey(usr.Id))
{
var targetStats = stats[usr.Id];
int HP = targetStats.HP;
if (targetStats.HP == BASEHEALTH)
{
await e.Channel.SendMessage($"{usr.Name} already has full HP!");
return;
}
//Payment~
var amount = 1;
var pts = Classes.DbHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0;
if (pts < amount)
{
await e.Channel.SendMessage($"{e.User.Mention} you don't have enough NadekoFlowers! \nYou still need {amount - pts} to be able to do this!");
return;
}
var up = (usr.Id == e.User.Id) ? "yourself" : usr.Name;
await FlowersHandler.RemoveFlowersAsync(e.User, $"heal {up}", amount);
//healing
targetStats.HP = BASEHEALTH;
if (HP < 0)
{
//Could heal only for half HP?
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 🌸");
return;
}
else
{
await e.Channel.SendMessage($"{usr.Name} already has full HP!");
}
});
cgb.CreateCommand(Prefix + "type")
.Description($"Get the poketype of the target.\n**Usage**: {Prefix}type @someone")
.Parameter("target", ParameterType.Required)
.Do(async e =>
{
var usr = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault();
if (usr == null)
{
await e.Channel.SendMessage("No such person.");
return;
}
var pType = getPokeType(usr.Id);
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**")
.AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e =>
{
//clear DB
var db = DbHandler.Instance.GetAllRows<PokeMoves>();
foreach (PokeMoves p in db)
{
DbHandler.Instance.Delete<PokeMoves>(p.Id);
}
Dictionary<string, int> defaultmoves = new Dictionary<string, int>()
{
{"flame",1},
{"hack",3},
{"scare",13},
{"splash",2},
{"freeze",5},
{"strike",4},
{"surge",3},
{"electrocute",3},
{"surf",2},
{"mellow",4},
{"flamethrower",1},
{"thundershock",3},
{"lava",12},
{"fly",9},
{"control",10},
{"sting",11},
{"poison",7},
{"confusion",10},
{"breathe",14},
{"ultrabash",6},
{"punch",6},
{"blind",15},
{"earthquake",8},
{"rocksmash",12},
{"transform",0},
{"bulldoze",8},
{"frustate",0},
{"confide",0},
{"metronome",0},
{"dracometeor",14},
{"outrage",14}
};
foreach (KeyValuePair<string, int> entry in defaultmoves)
{
DbHandler.Instance.InsertData(new Classes._DataModels.PokeMoves
{
move = entry.Key,
type = entry.Value
});
}
var str = "Reset moves.\n**Moves:**";
//could sort, but meh
var dbMoves = DbHandler.Instance.GetAllRows<PokeMoves>();
foreach (PokeMoves m in dbMoves)
{
var t = PokemonTypesMain.intToPokeType(m.type);
str += $"\n{t.getImage()}{m.move}";
}
await e.Channel.SendMessage(str);
});
cgb.CreateCommand(Prefix + "settype")
.Description($"Set your poketype. Costs a NadekoFlower.\n**Usage**: {Prefix}settype fire")
.Parameter("targetType", ParameterType.Required)
.Do(async e =>
{
var targetTypeString = e.GetArg("targetType");
var targetType = PokemonTypesMain.stringToPokeType(targetTypeString.ToUpperInvariant());
if (targetType == null)
{
await e.Channel.SendMessage("Invalid type specified. Type must be one of:\nNORMAL, FIRE, WATER, ELECTRIC, GRASS, ICE, FIGHTING, POISON, GROUND, FLYING, PSYCHIC, BUG, ROCK, GHOST, DRAGON, DARK, STEEL");
return;
}
if (targetType == getPokeType(e.User.Id))
{
await e.Channel.SendMessage($"Your type is already {targetType.getName().ToLowerInvariant()}{targetType.getImage()}");
return;
}
//Payment~
var amount = 1;
var pts = Classes.DbHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0;
if (pts < amount)
{
await e.Channel.SendMessage($"{e.User.Mention} you don't have enough NadekoFlowers! \nYou still need {amount - pts} to be able to do this!");
return;
}
await FlowersHandler.RemoveFlowersAsync(e.User, $"set usertype to {targetTypeString}", amount);
//Actually changing the type here
var preTypes = DbHandler.Instance.GetAllRows<userPokeTypes>();
Dictionary<long, int> Dict = preTypes.ToDictionary(x => x.UserId, y => y.Id);
if (Dict.ContainsKey((long)e.User.Id))
{
//delete previous type
DbHandler.Instance.Delete<userPokeTypes>(Dict[(long)e.User.Id]);
}
DbHandler.Instance.InsertData(new Classes._DataModels.userPokeTypes
{
UserId = (long)e.User.Id,
type = targetType.getNum()
});
//Now for the response
await e.Channel.SendMessage($"Set type of {e.User.Mention} to {targetTypeString}{targetType.getImage()} for a 🌸");
});
});
}
private int getDamage(IPokeType usertype, IPokeType targetType)
{
Random rng = new Random();
int damage = rng.Next(40, 60);
double multiplier = 1;
multiplier = usertype.getMagnifier(targetType);
damage = (int)(damage * multiplier);
return damage;
}
private IPokeType getPokeType(ulong id)
{
var db = DbHandler.Instance.GetAllRows<userPokeTypes>();
Dictionary<long, int> setTypes = db.ToDictionary(x => x.UserId, y => y.type);
if (setTypes.ContainsKey((long)id))
{
return PokemonTypesMain.intToPokeType(setTypes[(long)id]);
}
int remainder = (int)id % 16;
return PokemonTypesMain.intToPokeType(remainder);
}
private Pokestats defaultStats()
{
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

@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels; using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class BugType : IPokeType
{
static readonly string name = "BUG";
public static int numType = 11;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "FIRE": return 0.5;
case "GRASS": return 2;
case "FIGHTING": return 0.5;
case "POISON": return 0.5;
case "FLYING": return 0.5;
case "PSYCHIC": return 2;
case "ROCK": return 0.5;
case "DARK": return 2;
case "STEEL": return 0.5;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "🐛";
}
public int getNum()
{
return numType;
}
}
}

View File

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels; using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class DarkType : IPokeType
{
static readonly string name = "DARK";
public static int numType = 15;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "FIGHTING": return 0.5;
case "PSYCHIC": return 2;
case "GHOST": return 2;
case "DARK": return 0.5;
case "STEEL": return 0.5;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "🕶";
}
public int getNum()
{
return numType;
}
}
}

View File

@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels; using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class DragonType : IPokeType
{
static readonly string name = "DRAGON";
public static int numType = 14;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "DRAGON": return 2;
case "STEEL": return 0.5;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "🐉";
}
public int getNum()
{
return numType;
}
}
}

View File

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels; using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class ElectricType : IPokeType
{
static readonly string name = "ELECTRIC";
public static int numType = 3;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "WATER": return 2;
case "ELECTRIC": return 0.5;
case "GRASS": return 2;
case "GROUND": return 0;
case "FLYING": return 2;
case "DRAGON": return 0.5;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "⚡️";
}
public int getNum()
{
return numType;
}
}
}

View File

@ -0,0 +1,73 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels; using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class FightingType : IPokeType
{
static readonly string name = "FIGHTING";
public static int numType = 6;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "NORMAL": return 2;
case "ICE": return 2;
case "POISON": return 0.5;
case "FLYING": return 0.5;
case "PSYCHIC": return 0.5;
case "BUG": return 0.5;
case "ROCK": return 2;
case "GHOST": return 0;
case "DARK": return 2;
case "STEEL": return 2;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "✊";
}
public int getNum()
{
return numType;
}
}
}

View File

@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels; using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class FireType : IPokeType
{
static readonly string name = "FIRE";
public static int numType = 1;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "FIRE": return 0.5;
case "WATER": return 0.5;
case "GRASS": return 2;
case "ICE": return 2;
case "BUG": return 2;
case "ROCK": return 0.5;
case "DRAGON": return 0.5;
case "STEEL": return 2;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "🔥";
}
public int getNum()
{
return numType;
}
}
}

View File

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels; using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class FlyingType : IPokeType
{
static readonly string name = "FLYING";
public static int numType = 9;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "ELECTRIC": return 0.5;
case "GRASS": return 2;
case "FIGHTING": return 2;
case "BUG": return 2;
case "ROCK": return 0.5;
case "STEEL": return 0.5;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "☁";
}
public int getNum()
{
return numType;
}
}
}

View File

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels; using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class GhostType : IPokeType
{
static readonly string name = "GHOST";
public static int numType = 13;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "NORMAL": return 0;
case "PSYCHIC": return 2;
case "GHOST": return 2;
case "DARK": return 0.5;
case "STEEL": return 0.5;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "👻";
}
public int getNum()
{
return numType;
}
}
}

View File

@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels; using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class GrassType : IPokeType
{
static readonly string name = "GRASS";
public static int numType = 4;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "FIRE": return 0.5;
case "WATER": return 0.5;
case "GRASS": return 2;
case "ICE": return 2;
case "BUG": return 2;
case "ROCK": return 0.5;
case "DRAGON": return 0.5;
case "STEEL": return 2;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "🌿";
}
public int getNum()
{
return numType;
}
}
}

View File

@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels; using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class GroundType : IPokeType
{
static readonly string name = "GROUND";
public static int numType = 8;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "FIRE": return 2;
case "ELECTRIC": return 2;
case "GRASS": return 0.5;
case "POISON": return 0.5;
case "FLYING": return 0;
case "BUG": return 0.5;
case "ROCK": return 2;
case "STEEL": return 2;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "🗻";
}
public int getNum()
{
return numType;
}
}
}

View File

@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels; using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class IceType : IPokeType
{
static readonly string name = "ICE";
public static int numType = 5;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "FIRE": return 0.5;
case "WATER": return 0.5;
case "GRASS": return 2;
case "ICE": return 0.5;
case "GROUND": return 2;
case "FLYING": return 2;
case "DRAGON": return 2;
case "STEEL": return 0.5;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "❄";
}
public int getNum()
{
return numType;
}
}
}

View File

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels;
using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class NormalType : IPokeType
{
static readonly string name = "NORMAL";
public static int type_num = 0;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "ROCK": return 0.5;
case "GHOST": return 0;
case "STEEL": return 0.5;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "⭕️";
}
public int getNum()
{
return type_num;
}
}
}

View File

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels;
using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class PoisonType : IPokeType
{
static readonly string name = "POISON";
public static int numType = 7;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "GRASS": return 2;
case "POISON": return 0.5;
case "GROUND": return 0.5;
case "ROCK": return 0.5;
case "GHOST": return 0.5;
case "STEEL": return 0;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "☠";
}
public int getNum()
{
return numType;
}
}
}

View File

@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels;
using NadekoBot.Modules.Pokemon.PokemonTypes;
namespace NadekoBot.Modules.Pokemon.PokeTypes
{
public interface IPokeType
{
string getImage();
string getName();
int getNum();
List<string> getMoves();
double getMagnifier(IPokeType target);
void updateMoves();
}
public class PokemonTypesMain
{
public static IPokeType stringToPokeType(string newType)
{
foreach (IPokeType t in typeList)
{
if (t.getName() == newType)
{
return t;
}
}
return null;
}
//These classes can use all methods (except getMoves)
public static List<IPokeType> typeList = new List<IPokeType>()
{
new NormalType(),
new FireType(),
new WaterType(),
new ElectricType(),
new GrassType(),
new IceType(),
new FightingType(),
new PoisonType(),
new GroundType(),
new FlyingType(),
new PsychicType(),
new BugType(),
new RockType(),
new GhostType(),
new DragonType(),
new DarkType(),
new SteelType()
};
public static IPokeType intToPokeType(int id)
{
foreach (IPokeType t in typeList)
{
if (t.getNum() == id)
{
return t;
}
}
return null;
}
}
}

View File

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels; using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class PsychicType : IPokeType
{
static readonly string name = "PSYCHIC";
public static int numType = 10;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "FIGHTING": return 2;
case "POISON": return 2;
case "PSYCHIC": return 0.5;
case "DARK": return 0;
case "STEEL": return 0.5;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "💫";
}
public int getNum()
{
return numType;
}
}
}

View File

@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels; using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class RockType : IPokeType
{
static readonly string name = "ROCK";
public static int numType = 12;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "FIRE": return 2;
case "ICE": return 2;
case "FIGHTING": return 0.5;
case "GROUND": return 0.5;
case "FLYING": return 2;
case "BUG": return 2;
case "STEEL": return 0.5;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "💎";
}
public int getNum()
{
return numType;
}
}
}

View File

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NadekoBot.Modules.Pokemon;
using NadekoBot.Classes;
using NadekoBot.Classes._DataModels; using NadekoBot.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class SteelType : IPokeType
{
static readonly string name = "STEEL";
public static int numType = -1;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "FIRE": return 0.5;
case "WATER": return 0.5;
case "ELECTRIC": return 0.5;
case "ICE": return 2;
case "ROCK": return 2;
case "STEEL": return 0.5;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "🔩";
}
public int getNum()
{
return numType;
}
}
}

View File

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
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.Modules.Pokemon.PokeTypes;
namespace NadekoBot.Modules.Pokemon.PokemonTypes
{
class WaterType : IPokeType
{
static readonly string name = "WATER";
public static int numType = 2;
public double getMagnifier(IPokeType target)
{
switch (target.getName())
{
case "FIRE": return 2;
case "WATER": return 0.5;
case "GRASS": return 0.5;
case "GROUND": return 2;
case "ROCK": return 2;
case "DRAGON": return 0.5;
default: return 1;
}
}
List<string> moves = new List<string>();
public List<string> getMoves()
{
updateMoves();
return moves;
}
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()
{
return "💦";
}
public int getNum()
{
return numType;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ using NadekoBot.Classes.JSONModels;
using NadekoBot.Commands;
using NadekoBot.Modules;
using NadekoBot.Modules.Gambling;
using NadekoBot.Modules.pokegame;
using NadekoBot.Modules.Pokemon;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@ -166,7 +166,7 @@ namespace NadekoBot
modules.Add(new Searches(), "Searches", ModuleFilter.None);
modules.Add(new NSFW(), "NSFW", ModuleFilter.None);
modules.Add(new ClashOfClans(), "ClashOfClans", ModuleFilter.None);
modules.Add(new Pokegame(), "Pokegame", ModuleFilter.None);
modules.Add(new PokemonGame(), "Pokegame", ModuleFilter.None);
if (!string.IsNullOrWhiteSpace(Creds.TrelloAppKey))
modules.Add(new Trello(), "Trello", ModuleFilter.None);

View File

@ -188,7 +188,26 @@
<Compile Include="Modules\NSFW.cs" />
<Compile Include="Modules\Permissions.cs" />
<Compile Include="Commands\RatelimitCommand.cs" />
<Compile Include="Modules\PokemonModule.cs" />
<Compile Include="Modules\Pokemon\PokemonModule.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\PokeType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\PsychicType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\BugType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\RockType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\GhostType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\Dragontype.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\DarkType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\SteelType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\WaterType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\ElectricType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\GrassType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\IceType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\FightingType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\PoisonType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\GroundType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\FlyingType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\FireType.cs" />
<Compile Include="Modules\Pokemon\PokemonTypes\NormalType.cs" />
<Compile Include="Modules\Pokemon\PokeStats.cs" />
<Compile Include="Modules\Searches.cs" />
<Compile Include="Modules\Translator\Helpers\GoogleTranslator.cs" />
<Compile Include="Modules\Translator\TranslateCommand.cs" />