betray game started, commandlist updated

This commit is contained in:
Master Kwoth 2016-03-12 11:50:18 +01:00
parent fc19ec1f0b
commit f6bc247862
6 changed files with 139 additions and 21 deletions

View 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.");
}
}
}

View File

@ -16,7 +16,7 @@ namespace NadekoBot.Modules {
commands.Add(new Trivia(this)); commands.Add(new Trivia(this));
commands.Add(new SpeedTyping(this)); commands.Add(new SpeedTyping(this));
commands.Add(new PollCommand(this)); commands.Add(new PollCommand(this));
commands.Add(new BetrayGame(this));
_8BallAnswers = JArray.Parse(File.ReadAllText("data/8ball.json")).Select(t => t.ToString()).ToArray(); _8BallAnswers = JArray.Parse(File.ReadAllText("data/8ball.json")).Select(t => t.ToString()).ToArray();
} }

View File

@ -22,7 +22,7 @@ namespace NadekoBot.Modules {
TrelloConfiguration.Deserializer = serializer; TrelloConfiguration.Deserializer = serializer;
TrelloConfiguration.JsonFactory = new ManateeFactory(); TrelloConfiguration.JsonFactory = new ManateeFactory();
TrelloConfiguration.RestClientProvider = new Manatee.Trello.WebApi.WebApiClientProvider(); 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]"; //TrelloAuthorization.Default.UserToken = "[your user token]";
Discord.Channel bound = null; Discord.Channel bound = null;
@ -71,7 +71,9 @@ namespace NadekoBot.Modules {
}); });
cgb.CreateCommand("bind") 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) .Parameter("board_id", Discord.Commands.ParameterType.Required)
.Do(async e => { .Do(async e => {
if (!NadekoBot.IsOwner(e.User.Id)) return; if (!NadekoBot.IsOwner(e.User.Id)) return;

View File

@ -123,7 +123,7 @@ namespace NadekoBot {
modules.Add(new Searches(), "Searches", ModuleFilter.None); modules.Add(new Searches(), "Searches", ModuleFilter.None);
modules.Add(new NSFW(), "NSFW", ModuleFilter.None); modules.Add(new NSFW(), "NSFW", ModuleFilter.None);
modules.Add(new ClashOfClans(), "ClashOfClans", 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); modules.Add(new Trello(), "Trello", ModuleFilter.None);
//run the bot //run the bot

View File

@ -143,6 +143,7 @@
<Compile Include="Classes\_DataModels\StatsModel.cs" /> <Compile Include="Classes\_DataModels\StatsModel.cs" />
<Compile Include="Classes\_DataModels\TypingArticleModel.cs" /> <Compile Include="Classes\_DataModels\TypingArticleModel.cs" />
<Compile Include="Classes\_DataModels\UserQuoteModel.cs" /> <Compile Include="Classes\_DataModels\UserQuoteModel.cs" />
<Compile Include="Commands\BetrayGame.cs" />
<Compile Include="Modules\ClashOfClans.cs" /> <Compile Include="Modules\ClashOfClans.cs" />
<Compile Include="Commands\FilterWordsCommand.cs" /> <Compile Include="Commands\FilterWordsCommand.cs" />
<Compile Include="Commands\FilterInvitesCommand.cs" /> <Compile Include="Commands\FilterInvitesCommand.cs" />

View File

@ -2,7 +2,7 @@
######You can donate on paypal: `nadekodiscordbot@gmail.com` or Bitcoin `17MZz1JAqME39akMLrVT4XBPffQJ2n1EPa` ######You can donate on paypal: `nadekodiscordbot@gmail.com` or Bitcoin `17MZz1JAqME39akMLrVT4XBPffQJ2n1EPa`
#NadekoBot List Of Commands #NadekoBot List Of Commands
Version: `NadekoBot v0.9.5912.19900` Version: `NadekoBot v0.9.5915.21073`
### Administration ### Administration
Command and aliases | Description | Usage Command and aliases | Description | Usage
----------------|--------------|------- ----------------|--------------|-------
@ -21,6 +21,7 @@ Command and aliases | Description | Usage
`.listplaying`, `.lipl` | Lists all playing statuses with their corresponding number. `.listplaying`, `.lipl` | Lists all playing statuses with their corresponding number.
`.removeplaying`, `.repl`, `.rmpl` | Removes a playing string on a given number. `.removeplaying`, `.repl`, `.rmpl` | Removes a playing string on a given number.
`.slowmode` | Toggles slow mode. When ON, users will be able to send only 1 message every 5 seconds. `.slowmode` | Toggles slow mode. When ON, users will be able to send only 1 message every 5 seconds.
`.v+t`, `.voice+text` | Creates a text channel for each voice channel only users in that voice channel can see.If you are server owner, keep in mind you will see them all the time regardless.
`.sr`, `.setrole` | Sets a role for a given user. | .sr @User Guest `.sr`, `.setrole` | Sets a role for a given user. | .sr @User Guest
`.rr`, `.removerole` | Removes a role from a given user. | .rr @User Admin `.rr`, `.removerole` | Removes a role from a given user. | .rr @User Admin
`.r`, `.role`, `.cr` | Creates a role with a given name. | .r Awesome Role `.r`, `.role`, `.cr` | Creates a role with a given name. | .r Awesome Role
@ -69,12 +70,14 @@ Command and aliases | Description | Usage
`-hgit` | OWNER ONLY commandlist.md file generation. `-hgit` | OWNER ONLY commandlist.md file generation.
`-readme`, `-guide` | Sends a readme and a guide links to the channel. `-readme`, `-guide` | Sends a readme and a guide links to the channel.
`-donate`, `~donate` | Instructions for helping the project! `-donate`, `~donate` | Instructions for helping the project!
`.modules`, `-modules` | List all bot modules. `-modules`, `.modules` | List all bot modules.
`.commands`, `-commands` | List all of the bot's commands from a certain module. `-commands`, `.commands` | List all of the bot's commands from a certain module.
### Permissions ### Permissions
Command and aliases | Description | Usage Command and aliases | Description | Usage
----------------|--------------|------- ----------------|--------------|-------
`;cfi`, `;channelfilterinvites` | Enables or disables automatic deleting of invites on the channel.If no channel supplied, it will default to current one. Use ALL to apply to all existing channels at once. | ;cfi enable #general-chat
`;sfi`, `;serverfilterinvites` | Enables or disables automatic deleting of invites on the server. | ;sfi disable
`;permrole`, `;pr` | Sets a role which can change permissions. Or supply no parameters to find out the current one. Default one is 'Nadeko'. `;permrole`, `;pr` | Sets a role which can change permissions. Or supply no parameters to find out the current one. Default one is 'Nadeko'.
`;verbose`, `;v` | Sets whether to show when a command/module is blocked. | ;verbose true `;verbose`, `;v` | Sets whether to show when a command/module is blocked. | ;verbose true
`;serverperms`, `;sp` | Shows banned permissions for this server. `;serverperms`, `;sp` | Shows banned permissions for this server.
@ -140,7 +143,7 @@ Command and aliases | Description | Usage
Command and aliases | Description | Usage Command and aliases | Description | Usage
----------------|--------------|------- ----------------|--------------|-------
`$draw` | Draws a card from the deck.If you supply number [x], she draws up to 5 cards from the deck. | $draw [x] `$draw` | Draws a card from the deck.If you supply number [x], she draws up to 5 cards from the deck. | $draw [x]
`$shuffle`, `$reshuffle` | Reshuffles all cards back into the deck. `$shuffle`, `$sh` | Reshuffles all cards back into the deck.
`$flip` | Flips coin(s) - heads or tails, and shows an image. | `$flip` or `$flip 3` `$flip` | Flips coin(s) - heads or tails, and shows an image. | `$flip` or `$flip 3`
`$roll` | Rolls 2 dice from 0-10. If you supply a number [x] it rolls up to 30 normal dice. | $roll [x] `$roll` | Rolls 2 dice from 0-10. If you supply a number [x] it rolls up to 30 normal dice. | $roll [x]
`$nroll` | Rolls in a given range. | `$nroll 5` (rolls 0-5) or `$nroll 5-15` `$nroll` | Rolls in a given range. | `$nroll 5` (rolls 0-5) or `$nroll 5-15`
@ -150,21 +153,16 @@ Command and aliases | Description | Usage
### Games ### Games
Command and aliases | Description | Usage Command and aliases | Description | Usage
----------------|--------------|------- ----------------|--------------|-------
`t`, `-t` | Starts a game of trivia. `>t` | Starts a game of trivia.
`tl`, `-tl`, `tlb`, `-tlb` | Shows a current trivia leaderboard. `>tl` | Shows a current trivia leaderboard.
`tq`, `-tq` | Quits current trivia after current question. `>tq` | Quits current trivia after current question.
`typestart` | Starts a typing contest. `>typestart` | Starts a typing contest.
`typestop` | Stops a typing contest on the current channel. `>typestop` | Stops a typing contest on the current channel.
`typeadd` | Adds a new article to the typing contest. Owner only. `>typeadd` | Adds a new article to the typing contest. Owner only.
`>poll` | Creates a poll, only person who has manage server permission can do it. | >poll Question?;Answer1;Answ 2;A_3 `>poll` | Creates a poll, only person who has manage server permission can do it. | >poll Question?;Answer1;Answ 2;A_3
`>pollend` | Stops active poll on this server and prints the results in this channel. `>pollend` | Stops active poll on this server and prints the results in this channel.
`,createwar`, `,cw` | Creates a new war by specifying a size (>10 and multiple of 5) and enemy clan name. | ,cw 15 The Enemy Clan `>betray` | 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.
`,sw`, `,startwar` | Starts a war with a given number. `>cooperate` | 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.
`,listwar`, `,lw` | Shows the active war claims by a number. Shows all wars in a short way if no number is specified. | ,lw [war_number] or ,lw
`,claim`, `,call`, `,c` | Claims a certain base from a certain war. You can supply a name in the third optional argument to claim in someone else's place. | ,call [war_number] [base_number] (optional_otheruser)
`,cf`, `,claimfinish` | Finish your claim if you destroyed a base. Optional second argument finishes for someone else. | ,cf [war_number] (optional_other_name)
`,unclaim`, `,uncall`, `,uc` | Removes your claim from a certain war. Optional second argument denotes a person in whos place to unclaim | ,uc [war_number] (optional_other_name)
`,endwar`, `,ew` | Ends the war with a given index. | ,ew [war_number]
`>choose` | Chooses a thing from a list of things | >choose Get up;Sleep;Sleep more `>choose` | Chooses a thing from a list of things | >choose Get up;Sleep;Sleep more
`>8ball` | Ask the 8ball a yes/no question. `>8ball` | Ask the 8ball a yes/no question.
`>attack` | Attack a person. Supported attacks: 'splash', 'strike', 'burn', 'surge'. | > strike @User `>attack` | Attack a person. Supported attacks: 'splash', 'strike', 'burn', 'surge'. | > strike @User
@ -223,3 +221,23 @@ Command and aliases | Description | Usage
`~cp` | We all know where this will lead you to. `~cp` | We all know where this will lead you to.
`~boobs` | Real adult content. `~boobs` | Real adult content.
`~butts`, `~ass`, `~butt` | Real adult content. `~butts`, `~ass`, `~butt` | Real adult content.
### ClashOfClans
Command and aliases | Description | Usage
----------------|--------------|-------
`,createwar`, `,cw` | Creates a new war by specifying a size (>10 and multiple of 5) and enemy clan name. | ,cw 15 The Enemy Clan
`,sw`, `,startwar` | Starts a war with a given number.
`,listwar`, `,lw` | Shows the active war claims by a number. Shows all wars in a short way if no number is specified. | ,lw [war_number] or ,lw
`,claim`, `,call`, `,c` | Claims a certain base from a certain war. You can supply a name in the third optional argument to claim in someone else's place. | ,call [war_number] [base_number] (optional_otheruser)
`,cf`, `,claimfinish` | Finish your claim if you destroyed a base. Optional second argument finishes for someone else. | ,cf [war_number] (optional_other_name)
`,unclaim`, `,uncall`, `,uc` | Removes your claim from a certain war. Optional second argument denotes a person in whos place to unclaim | ,uc [war_number] (optional_other_name)
`,endwar`, `,ew` | Ends the war with a given index. | ,ew [war_number]
### Trello
Command and aliases | Description | Usage
----------------|--------------|-------
`trello join`, `trello j` | Joins a server
`trello bind` | Bind a trello bot to a single channel. You will receive notifications from your board when something is added or edited. | bind [board_id]
`trello unbind` | Unbinds a bot from the channel and board.
`trello lists`, `trello list` | Lists all lists yo ;)
`trello cards` | Lists all cards from the supplied list. You can supply either a name or an index.