From 5fb1a7fa31edfc295dbee1a1aee6b9e67acd5a58 Mon Sep 17 00:00:00 2001 From: Kwoth Date: Sun, 13 Dec 2015 02:07:29 +0100 Subject: [PATCH] Added stupid pokemon attacks. Also, every person now has an element depending on their user ID. Every element has anti-element. --- NadekoBot/Modules/Games.cs | 95 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/NadekoBot/Modules/Games.cs b/NadekoBot/Modules/Games.cs index cbe17bc2..92ff63f6 100644 --- a/NadekoBot/Modules/Games.cs +++ b/NadekoBot/Modules/Games.cs @@ -18,7 +18,102 @@ namespace NadekoBot.Modules manager.CreateCommands("", cgb => { commands.ForEach(cmd => cmd.Init(cgb)); + cgb.CreateCommand(">") + .Description("Attack a person. Supported attacks: 'splash', 'strike', 'burn', 'surge'.\n**Usage**: @BotName strike @User") + .Parameter("attack_type",Discord.Commands.ParameterType.Required) + .Parameter("target",Discord.Commands.ParameterType.Required) + .Do(async e => + { + + var usr = NadekoBot.client.FindUsers(e.Server,e.GetArg("target")).FirstOrDefault(); + var usrType = GetType(usr.Id); + string response = ""; + int dmg = GetDamage(usrType, e.GetArg("attack_type").ToLowerInvariant()); + response = e.GetArg("attack_type") + (e.GetArg("attack_type")=="splash"?"es ":"s ") + usr.Mention + " for " + dmg+".\n"; + if (dmg >= 65) + { + response += "It's super effective!"; + } + else if (dmg <= 35) { + response += "Ineffective!"; + } + await e.Send(NadekoBot.botMention + " " + response); + }); + + cgb.CreateCommand("poketype") + .Parameter("target", Discord.Commands.ParameterType.Required) + .Do(async e => + { + var usr = NadekoBot.client.FindUsers(e.Server, e.GetArg("target")).FirstOrDefault(); + if (usr == null) { + await e.Send("No such person."); + } + + await e.Send(usr.Name + "'s type is " + GetType(usr.Id)); + }); }); } + + private int GetDamage(PokeType targetType, string v) + { + var rng = new Random(); + switch (v) + { + case "splash": //water + if (targetType == PokeType.FIRE) + return rng.Next(65, 100); + else if (targetType == PokeType.ELECTRICAL) + return rng.Next(0, 35); + else + return rng.Next(40, 60); + case "strike": //grass + if (targetType == PokeType.ELECTRICAL) + return rng.Next(65, 100); + else if (targetType == PokeType.FIRE) + return rng.Next(0, 35); + else + return rng.Next(40, 60); + case "burn": //fire + case "flame": + if (targetType == PokeType.GRASS) + return rng.Next(65, 100); + else if (targetType == PokeType.WATER) + return rng.Next(0, 35); + else + return rng.Next(40, 60); + case "surge": //electrical + case "electrocute": + if (targetType == PokeType.WATER) + return rng.Next(65, 100); + else if (targetType == PokeType.GRASS) + return rng.Next(0, 35); + else + return rng.Next(40, 60); + default: + return 0; + } + } + + private PokeType GetType(long id) { + var remainder = id % 10; + if (remainder < 3) + return PokeType.WATER; + else if (remainder >= 3 && remainder < 5) + { + return PokeType.GRASS; + } + else if (remainder >= 5 && remainder < 8) + { + return PokeType.FIRE; + } + else { + return PokeType.ELECTRICAL; + } + } + + private enum PokeType + { + WATER, GRASS, FIRE, ELECTRICAL + } } }