woopsy, commented out unneeded stuff

This commit is contained in:
Master Kwoth 2016-03-28 17:05:56 +02:00
parent d5ea8f69c8
commit 4ff0c0cf34
3 changed files with 294 additions and 285 deletions

View File

@ -27,6 +27,7 @@ namespace NadekoBot.Classes
conn.CreateTable<CurrencyTransaction>(); conn.CreateTable<CurrencyTransaction>();
conn.CreateTable<Donator>(); conn.CreateTable<Donator>();
conn.CreateTable<PokeMoves>(); conn.CreateTable<PokeMoves>();
conn.CreateTable<UserPokeTypes>();
conn.CreateTable<UserQuote>(); conn.CreateTable<UserQuote>();
conn.Execute(Queries.TransactionTriggerQuery); conn.Execute(Queries.TransactionTriggerQuery);
} }

View File

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

View File

@ -10,7 +10,6 @@ using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks;
namespace NadekoBot.Modules.Pokemon namespace NadekoBot.Modules.Pokemon
{ {
@ -34,7 +33,7 @@ namespace NadekoBot.Modules.Pokemon
private PokeType GetPokeType(ulong id) private PokeType GetPokeType(ulong id)
{ {
var db = DbHandler.Instance.GetAllRows<userPokeTypes>(); var db = DbHandler.Instance.GetAllRows<UserPokeTypes>();
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))
{ {
@ -161,7 +160,8 @@ namespace NadekoBot.Modules.Pokemon
await e.Channel.SendMessage(response); await e.Channel.SendMessage(response);
}); });
cgb.CreateCommand(Prefix + "listmoves") cgb.CreateCommand(Prefix + "ml")
.Alias("movelist")
.Description("Lists the moves you are able to use") .Description("Lists the moves you are able to use")
.Do(async e => .Do(async e =>
{ {
@ -175,39 +175,15 @@ namespace NadekoBot.Modules.Pokemon
await e.Channel.SendMessage(str); 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.Num;
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.Image}{newMove}");
});
cgb.CreateCommand(Prefix + "heal") cgb.CreateCommand(Prefix + "heal")
.Description($"Heals someone. Revives those that fainted. Costs a NadekoFlower \n**Usage**:{Prefix}revive @someone") .Description($"Heals someone. Revives those that fainted. Costs a NadekoFlower \n**Usage**:{Prefix}revive @someone")
.Parameter("target", ParameterType.Required) .Parameter("target", ParameterType.Unparsed)
.Do(async e => .Do(async e =>
{ {
var usr = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault(); var targetStr = e.GetArg("target");
if (string.IsNullOrWhiteSpace(targetStr))
return;
var usr = e.Server.FindUsers(targetStr).FirstOrDefault();
if (usr == null) if (usr == null)
{ {
await e.Channel.SendMessage("No such person."); await e.Channel.SendMessage("No such person.");
@ -253,10 +229,13 @@ namespace NadekoBot.Modules.Pokemon
cgb.CreateCommand(Prefix + "type") cgb.CreateCommand(Prefix + "type")
.Description($"Get the poketype of the target.\n**Usage**: {Prefix}type @someone") .Description($"Get the poketype of the target.\n**Usage**: {Prefix}type @someone")
.Parameter("target", ParameterType.Required) .Parameter("target", ParameterType.Unparsed)
.Do(async e => .Do(async e =>
{ {
var usr = e.Server.FindUsers(e.GetArg("target")).FirstOrDefault(); var usrStr = e.GetArg("target");
if (string.IsNullOrWhiteSpace(usrStr))
return;
var usr = e.Server.FindUsers(usrStr).FirstOrDefault();
if (usr == null) if (usr == null)
{ {
await e.Channel.SendMessage("No such person."); await e.Channel.SendMessage("No such person.");
@ -267,87 +246,116 @@ namespace NadekoBot.Modules.Pokemon
}); });
cgb.CreateCommand(Prefix + "setdefaultmoves") //cgb.CreateCommand(Prefix + "settype")
.Description($"Sets the moves DB to the default state and returns them all **OWNER ONLY**") // .Description($"Set your poketype. Costs a NadekoFlower.\n**Usage**: {Prefix}settype fire")
.AddCheck(SimpleCheckers.OwnerOnly()) // .Parameter("targetType", ParameterType.Unparsed)
.Do(async e => // .Do(async e =>
{ // {
//clear DB // var targetTypeStr = e.GetArg("targetType")?.ToUpperInvariant();
var db = DbHandler.Instance.GetAllRows<PokeMoves>(); // if (string.IsNullOrWhiteSpace(targetTypeStr))
foreach (PokeMoves p in db) // return;
{ // var targetType = PokemonTypesMain.stringToPokeType(targetTypeStr);
DbHandler.Instance.Delete<PokeMoves>(p.Id); // 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.Name.ToLowerInvariant()}{targetType.Image}");
// return;
// }
foreach (var entry in DefaultMoves.DefaultMovesList) // //Payment~
{ // var amount = 1;
DbHandler.Instance.InsertData(new Classes._DataModels.PokeMoves // var pts = Classes.DbHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0;
{ // if (pts < amount)
move = entry.Key, // {
type = entry.Value // 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 {targetTypeStr}", 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]);
// }
var str = "**Reset moves to default**.\n**Moves:**"; // DbHandler.Instance.InsertData(new Classes._DataModels.UserPokeTypes
//could sort, but meh // {
var dbMoves = DbHandler.Instance.GetAllRows<PokeMoves>(); // UserId = (long)e.User.Id,
foreach (PokeMoves m in dbMoves) // type = targetType.Num
{ // });
var t = PokemonTypesMain.IntToPokeType(m.type);
str += $"\n{t.Image}{m.move}"; // //Now for the response
}
await e.Channel.SendMessage(str); // await e.Channel.SendMessage($"Set type of {e.User.Mention} to {targetTypeStr}{targetType.Image} for a 🌸");
// });
}); //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.Num;
// 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.Image}{newMove}");
// });
cgb.CreateCommand(Prefix + "settype") //cgb.CreateCommand(Prefix + "setdefaultmoves")
.Description($"Set your poketype. Costs a NadekoFlower.\n**Usage**: {Prefix}settype fire") // .Description($"Sets the moves DB to the default state and returns them all **OWNER ONLY**")
.Parameter("targetType", ParameterType.Required) // .AddCheck(SimpleCheckers.OwnerOnly())
.Do(async e => // .Do(async e =>
{ // {
var targetTypeString = e.GetArg("targetType"); // //clear DB
var targetType = PokemonTypesMain.stringToPokeType(targetTypeString.ToUpperInvariant()); // var db = DbHandler.Instance.GetAllRows<PokeMoves>();
if (targetType == null) // foreach (PokeMoves p in db)
{ // {
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"); // DbHandler.Instance.Delete<PokeMoves>(p.Id);
return; // }
}
if (targetType == GetPokeType(e.User.Id))
{
await e.Channel.SendMessage($"Your type is already {targetType.Name.ToLowerInvariant()}{targetType.Image}");
return;
}
//Payment~ // foreach (var entry in DefaultMoves.DefaultMovesList)
var amount = 1; // {
var pts = Classes.DbHandler.Instance.GetStateByUserId((long)e.User.Id)?.Value ?? 0; // DbHandler.Instance.InsertData(new Classes._DataModels.PokeMoves
if (pts < amount) // {
{ // move = entry.Key,
await e.Channel.SendMessage($"{e.User.Mention} you don't have enough NadekoFlowers! \nYou still need {amount - pts} to be able to do this!"); // type = entry.Value
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 // var str = "**Reset moves to default**.\n**Moves:**";
{ // //could sort, but meh
UserId = (long)e.User.Id, // var dbMoves = DbHandler.Instance.GetAllRows<PokeMoves>();
type = targetType.Num // foreach (PokeMoves m in dbMoves)
}); // {
// var t = PokemonTypesMain.IntToPokeType(m.type);
//Now for the response // str += $"\n{t.Image}{m.move}";
// }
await e.Channel.SendMessage($"Set type of {e.User.Mention} to {targetTypeString}{targetType.Image} for a 🌸"); // await e.Channel.SendMessage(str);
});
// });
}); });
} }
} }