betray game started, commandlist updated
This commit is contained in:
97
NadekoBot/Commands/BetrayGame.cs
Normal file
97
NadekoBot/Commands/BetrayGame.cs
Normal file
@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using NadekoBot.Modules;
|
||||
|
||||
namespace NadekoBot.Commands {
|
||||
class BetrayGame : DiscordCommand {
|
||||
public BetrayGame(DiscordModule module) : base(module) { }
|
||||
|
||||
private enum Answers {
|
||||
Cooperate,
|
||||
Betray
|
||||
}
|
||||
internal override void Init(CommandGroupBuilder cgb) {
|
||||
cgb.CreateCommand(Module.Prefix + "betray")
|
||||
.Description("BETRAY GAME. Betray nadeko next turn." +
|
||||
"If Nadeko cooperates - you get extra points, nadeko loses a LOT." +
|
||||
"If Nadeko betrays - you both lose some points.")
|
||||
.Do(async e => {
|
||||
await ReceiveAnswer(e, Answers.Betray);
|
||||
});
|
||||
|
||||
cgb.CreateCommand(Module.Prefix + "cooperate")
|
||||
.Description("BETRAY GAME. Cooperate with nadeko next turn." +
|
||||
"If Nadeko cooperates - you both get bonus points." +
|
||||
"If Nadeko betrays - you lose A LOT, nadeko gets extra.")
|
||||
.Do(async e => {
|
||||
|
||||
await ReceiveAnswer(e, Answers.Cooperate);
|
||||
});
|
||||
}
|
||||
|
||||
private int userPoints = 0;
|
||||
|
||||
private int UserPoints {
|
||||
get { return userPoints; }
|
||||
set {
|
||||
if (value < 0)
|
||||
userPoints = 0;
|
||||
userPoints = value;
|
||||
}
|
||||
}
|
||||
private int nadekoPoints = 0;
|
||||
private int NadekoPoints {
|
||||
get { return nadekoPoints; }
|
||||
set {
|
||||
if (value < 0)
|
||||
nadekoPoints = 0;
|
||||
nadekoPoints = value;
|
||||
}
|
||||
}
|
||||
|
||||
private int round = 0;
|
||||
private Answers NextAnswer = Answers.Cooperate;
|
||||
private async Task ReceiveAnswer(CommandEventArgs e, Answers userAnswer) {
|
||||
var response = userAnswer == Answers.Betray
|
||||
? ":no_entry: `You betrayed nadeko` - you monster."
|
||||
: ":ok: `You cooperated with nadeko.` ";
|
||||
var currentAnswer = NextAnswer;
|
||||
var nadekoResponse = currentAnswer == Answers.Betray
|
||||
? ":no_entry: `aww Nadeko betrayed you` - she is so cute"
|
||||
: ":ok: `Nadeko cooperated.`";
|
||||
NextAnswer = userAnswer;
|
||||
if (userAnswer == Answers.Betray && currentAnswer == Answers.Betray) {
|
||||
NadekoPoints--;
|
||||
UserPoints--;
|
||||
} else if (userAnswer == Answers.Cooperate && currentAnswer == Answers.Cooperate) {
|
||||
NadekoPoints += 2;
|
||||
UserPoints += 2;
|
||||
} else if (userAnswer == Answers.Betray && currentAnswer == Answers.Cooperate) {
|
||||
NadekoPoints -= 3;
|
||||
UserPoints += 3;
|
||||
} else if (userAnswer == Answers.Cooperate && currentAnswer == Answers.Betray) {
|
||||
NadekoPoints += 3;
|
||||
UserPoints -= 3;
|
||||
}
|
||||
|
||||
await e.Channel.SendMessage($"**ROUND {++round}**" +
|
||||
$"{response}\n" +
|
||||
$"{nadekoResponse}\n" +
|
||||
$"--------------------------------" +
|
||||
$"Nadeko has {NadekoPoints} points." +
|
||||
$"You have {UserPoints} points." +
|
||||
$"--------------------------------");
|
||||
if (round < 10) return;
|
||||
if (nadekoPoints == userPoints)
|
||||
await e.Channel.SendMessage("Its a draw");
|
||||
else if (nadekoPoints > userPoints)
|
||||
await e.Channel.SendMessage("Nadeko won.");
|
||||
else
|
||||
await e.Channel.SendMessage("You won.");
|
||||
}
|
||||
}
|
||||
}
|
@ -16,7 +16,7 @@ namespace NadekoBot.Modules {
|
||||
commands.Add(new Trivia(this));
|
||||
commands.Add(new SpeedTyping(this));
|
||||
commands.Add(new PollCommand(this));
|
||||
|
||||
commands.Add(new BetrayGame(this));
|
||||
_8BallAnswers = JArray.Parse(File.ReadAllText("data/8ball.json")).Select(t => t.ToString()).ToArray();
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ namespace NadekoBot.Modules {
|
||||
TrelloConfiguration.Deserializer = serializer;
|
||||
TrelloConfiguration.JsonFactory = new ManateeFactory();
|
||||
TrelloConfiguration.RestClientProvider = new Manatee.Trello.WebApi.WebApiClientProvider();
|
||||
TrelloAuthorization.Default.AppKey = NadekoBot.Creds.TrelloAppKey;
|
||||
//TrelloAuthorization.Default.AppKey = NadekoBot.Creds.TrelloAppKey ?? "123";
|
||||
//TrelloAuthorization.Default.UserToken = "[your user token]";
|
||||
|
||||
Discord.Channel bound = null;
|
||||
@ -71,7 +71,9 @@ namespace NadekoBot.Modules {
|
||||
});
|
||||
|
||||
cgb.CreateCommand("bind")
|
||||
.Description("Bind a trello bot to a single channel. You will receive notifications from your board when something is added or edited.")
|
||||
.Description("Bind a trello bot to a single channel. " +
|
||||
"You will receive notifications from your board when something is added or edited." +
|
||||
"\n**Usage**: bind [board_id]")
|
||||
.Parameter("board_id", Discord.Commands.ParameterType.Required)
|
||||
.Do(async e => {
|
||||
if (!NadekoBot.IsOwner(e.User.Id)) return;
|
||||
|
@ -123,7 +123,7 @@ namespace NadekoBot {
|
||||
modules.Add(new Searches(), "Searches", ModuleFilter.None);
|
||||
modules.Add(new NSFW(), "NSFW", ModuleFilter.None);
|
||||
modules.Add(new ClashOfClans(), "ClashOfClans", ModuleFilter.None);
|
||||
if (!string.IsNullOrWhiteSpace(Creds.TrelloAppKey))
|
||||
//if (!string.IsNullOrWhiteSpace(Creds.TrelloAppKey))
|
||||
modules.Add(new Trello(), "Trello", ModuleFilter.None);
|
||||
|
||||
//run the bot
|
||||
|
@ -143,6 +143,7 @@
|
||||
<Compile Include="Classes\_DataModels\StatsModel.cs" />
|
||||
<Compile Include="Classes\_DataModels\TypingArticleModel.cs" />
|
||||
<Compile Include="Classes\_DataModels\UserQuoteModel.cs" />
|
||||
<Compile Include="Commands\BetrayGame.cs" />
|
||||
<Compile Include="Modules\ClashOfClans.cs" />
|
||||
<Compile Include="Commands\FilterWordsCommand.cs" />
|
||||
<Compile Include="Commands\FilterInvitesCommand.cs" />
|
||||
|
Reference in New Issue
Block a user