Here's some more minigames in C#. I'm not actually requesting these be added, just posting them here for some ideas. Naturally all of these would need to be adapted from IRC to TMI.
BOMB
{
class Bomb : Game
{
int time = 10;
int prize = 70;
string[] colors = { "red", "blue", "green", "yellow", "black" };
string player;
string host;
string solution;
public Bomb(Bot bot, Channel chan, IrcEventArgs e)
: base(bot, chan)
{
solution = colors[bot.Random.Next(0, colors.Length)];
player = e.Data.Nick;
host = bot.GetHost(player);
}
public override void Start()
{
string tmp = bot.Prefix;
foreach (string s in colors)
tmp += s + "/";
chan.StartTimer(time);
chan.SendMessage(player + " recieves the bomb. You have " + time + " seconds to defuse it using by cutting the right cable." +
" Choose you destiny: " + Msg.Bold(tmp));
}
public override void Update(IrcEventArgs e)
{
string[] msgArray = e.Data.MessageArray;
if (bot.GetHost(e.Data.Nick) == host)
{
if (msgArray[0].ToLower() == solution || msgArray[0].ToLower() + bot.Prefix == solution)
{
bot.UpdateMoney(host, prize);
chan.SendMessage(player + " defused the bomb. Seems like he was wise enough to buy a defuse kit. You win " + prize + "$");
}
else
{
chan.SendMessage("The bomb explodes in " + player + "'s hands. You lost your life and - even worse - $20." +
" The right color would have been " + Msg.Bold(solution));
bot.UpdateMoney(host, -20);
}
chan.DisposeGame();
}
}
public override void TimeOut()
{
chan.SendMessage("the bomb explodes in front of " + player + ". Seems like you did not even notice the big beeping suitcase. You loose $50");
bot.UpdateMoney(host, -50);
chan.DisposeGame();
}
}
}
DICE
{
class Dice : Game
{
string[] player = new string[2];
string[] host = new string[2];
int[] score = new int[2];
int[] round = new int[2];
GameState gameState = GameState.Waiting;
int turn = 0;
public Dice(Bot bot, Channel chan, IrcEventArgs e)
: base(bot, chan)
{
player[0] = e.Data.Nick;
host[0] = bot.GetHost(e.Data.Nick);
score[0] = 0;
score[1] = 0;
}
public override void Start()
{
chan.StartTimer(30);
chan.SendMessage(player[0] + " wants to play. Type " + bot.Prefix + "join to play against him :)");
}
public override void Update(IrcEventArgs e)
{
if (gameState == GameState.Waiting)
{
if (bot.isCommand(e, "join")) //&& !(string.Equals(bot.GetHost(e.Data.Nick), host[0])))
{
player[1] = e.Data.Nick;
host[1] = bot.GetHost(e.Data.Nick);
gameState = GameState.Running;
chan.StartTimer(15);
chan.SendMessage("The game starts now : " + player[0] + " vs. " + player[1] + ". You have up to three rolls (1-6), your last roll counts.");
chan.SendNotice(player[turn], "It's your turn! Use " + Msg.Bold(bot.Prefix + "roll") + " to roll the dice or "
+ Msg.Bold(bot.Prefix + "stop") + " to end your turn.");
}
}
//Game running
else if ((e.Data.Nick == player[0] && turn == 0) || (e.Data.Nick == player[1] && turn == 1))
{
if (bot.isCommand(e, "roll"))
{
score[turn] = bot.Random.Next(1, 7);
round[turn]++;
if (round[turn] == 3)
{
chan.SendNotice(player[turn], "You rolled a " + Msg.Bold(score[turn]) + ". This was your last roll.");
if (turn < 1)
Next();
else
Over();
}
else
{
chan.SendNotice(player[turn], "You rolled a " + Msg.Bold(score[turn]) +
". You have " + (3 - round[turn]) + " attempt(s) left -> " + bot.Prefix + "roll/stop");
chan.StartTimer(15);
}
}
else if (bot.isCommand(e, "stop"))
{
if (turn < 1)
Next();
else
Over();
}
}
}
public override void TimeOut()
{
if (gameState == GameState.Waiting)
chan.SendMessage("Sorry " + player[0] + " but nobody wanted to play with you." +
" Seems like you should get some friends ;)");
else
chan.SendMessage("Gameover - " + player[turn] + " was too slow.");
chan.DisposeGame();
}
private void Next()
{
turn++;
chan.SendNotice(player[turn], "It's your turn! Use " + Msg.Bold(bot.Prefix + "roll") + " to roll the dice or "
+ Msg.Bold(bot.Prefix + "stop") + " to end your turn.");
chan.StartTimer(15);
}
private void Over()
{
chan.SendMessage(player[0] + ": " + Msg.Bold(score[0]) + " vs. " + player[1] + ": " + Msg.Bold(score[1]));
if (score[0] > score[1])
Winner(0);
else if (score[0] < score[1])
Winner(1);
else if (score[0] <= 3)
{
chan.SendMessage("Both players lose 20$");
bot.UpdateMoney(host[0], -20);
bot.UpdateMoney(host[1], -20);
}
else
{
chan.SendMessage("Both players win 10$");
bot.UpdateMoney(host[0], 10);
bot.UpdateMoney(host[1], 10);
}
chan.DisposeGame();
}
private void Winner(int winner)
{
int loser = (winner + 1) % 2;
chan.SendMessage(player[winner] + " wins 35$ and " + player[loser] + " loses 20$.");
bot.UpdateMoney(host[winner], 35);
bot.UpdateMoney(host[loser], -20);
}
}
}
HANGMAN
{
class Hangman : Game
{
int lifes = 10;
int time = 60;
int prize = 30;
string solution;
bool[] correct;
char[] chars;
int count = 0;
public Hangman(Bot bot, Channel chan, IrcEventArgs e)
: base(bot, chan)
{
solution = bot.RandomWord;
chars = solution.ToCharArray();
correct = new bool[solution.Length];
}
public override void Start()
{
chan.StartTimer(time);
chan.SendMessage("You have " + time + " seconds to find the following word: " + Msg.Bold(GenerateWord()) +
" but don't forget, you have only " + lifes + " lifes.");
}
public override void Update(IrcEventArgs e)
{
if (e.Data.Message.Length == 1)
{
bool changed = false;
//check each letter of the solution
for (int i = 0; i < solution.Length; i++)
{
if (chars[i] == char.Parse(e.Data.Message) && correct[i] == false)
{
correct[i] = true;
changed = true;
count++;
}
}
if (changed) //correct letter
{
if (count == solution.Length) //final letter
Over(e.Data.Nick);
else //any letter
chan.SendMessage(Msg.Bold(e.Data.Message) + " is correct! " + Msg.Bold(GenerateWord()) + " Lifes left: " + lifes);
}
else
{
lifes--;
if (lifes == 0)
{
chan.SendMessage("Game over! " + Msg.Bold(solution) + " would have been the solution.");
chan.DisposeGame();
}
else
chan.SendMessage(Msg.Bold(e.Data.Message) + " is wrong or was already guessed. Lifes left: " + lifes);
}
}
else if (e.Data.Message == solution)
Over(e.Data.Nick);
}
public override void TimeOut()
{
chan.SendMessage("Time is over! The word we looked for was " + Msg.Bold(solution));
chan.DisposeGame();
}
private void Over(string nick)
{
int earned = bot.UpdateMoney(bot.GetHost(nick), prize + lifes + solution.Length, int.Parse(chan.CurrentTime), time);
chan.SendMessage(nick + " has found the solution: " + Msg.Bold(solution) + " and wins " + earned + "$");
chan.DisposeGame();
}
private string GenerateWord()
{
string word = "";
for (int i = 0; i < solution.Length; i++)
{
if (correct[i])
word += chars[i];
else
word += "_";
}
return word;
}
}
}
RNG LOTTO
{
class Luckylotto : Game
{
const int time = 15;
const int prize = 50;
int solution;
List<string> player;
List<string> host;
List<int> bet;
public Luckylotto(Bot bot, Channel chan, IrcEventArgs e)
: base(bot, chan)
{
solution = bot.Random.Next(0, 10);
player = new List<string>();
host= new List<string>();
bet = new List<int>();
}
public override void Start()
{
chan.StartTimer(time);
chan.SendMessage("Everybody in the channel has " + time + " seconds to choose a number between 0 and 9." +
" Each player who guessed the correct number wins. The more players joined, the higher the prize.");
}
public override void Update(IrcEventArgs e)
{
int tmp;
if (e.Data.Message.Length == 1 && !player.Contains(e.Data.Nick) && int.TryParse(e.Data.Message, out tmp))
{
player.Add(e.Data.Nick);
host.Add(e.Data.Host);
bet.Add(tmp);
}
}
public override void TimeOut()
{
if (player.Count == 0)
chan.SendMessage("Nobody entered the game in time - it would have been " + Msg.Bold(solution.ToString()));
else
{
string tmp = "";
int earned = prize + 25 * player.Count;
int lost = 10 + player.Count;
for (int i = 0; i < bet.Count; i++)
{
if (bet[i] == solution)
{
tmp += " " + player[i];
bot.UpdateMoney(host[i], earned);
}
else
bot.UpdateMoney(host[i], -lost);
}
if (tmp.Length == 0)
chan.SendMessage("Every player lost " + lost + "$ - the correct number would have been " + Msg.Bold(solution));
else
chan.SendMessage("The following players were lucky and win " + earned + "$:" +
Msg.Bold(tmp) + ". Everybody else lost " + lost + "$. Correct was: " + Msg.Bold(solution));
}
chan.DisposeGame();
}
}
}
WORD GAME
{
class Omgword : Game
{
const int time = 30;
const int prize = 20;
string solution;
public Omgword(Bot bot, Channel chan, IrcEventArgs e)
: base(bot, chan)
{
solution = bot.RandomWord;
}
public override void Start()
{
string word = "";
//randomize the order of the chars
for (int i = 0; i < solution.Length; i++)
{
if (bot.Random.Next(0, 2) == 0)
word = word + solution.Substring(i, 1);
else
word = solution.Substring(i, 1) + word;
}
chan.StartTimer(time);
chan.SendMessage("You have " + time + " seconds to solve this: " + Msg.Bold(word));
}
public override void Update(IrcEventArgs e)
{
if (e.Data.Message == solution)
{
int earned = bot.UpdateMoney(bot.GetHost(e.Data.Nick), prize + solution.Length, int.Parse(chan.CurrentTime), time);
chan.SendMessage(e.Data.Nick + " entered the solution in " + chan.CurrentTime +
" seconds and wins " + earned + "$. Correct was " + Msg.Bold(solution));
chan.DisposeGame();
}
}
public override void TimeOut()
{
chan.SendMessage("Time is over! The word we looked for was " + Msg.Bold(solution));
chan.DisposeGame();
}
}
}
SLOTS
{
class Slot : Game
{
int[] prizes = { -10, 30, 300, 1337 };
string[] words = { "Apple", "Pear", "Cherry", "Citron", "Orange", "Banana", "1337" };
string[] slots;
string player;
string host;
public Slot(Bot bot, Channel chan, IrcEventArgs e)
: base(bot, chan)
{
slots = new string[] { words[bot.Random.Next(0, words.Length)], words[bot.Random.Next(0, words.Length)],
words[bot.Random.Next(0, words.Length)] };
player = e.Data.Nick;
host = bot.GetHost(player);
}
public override void Start()
{
string temp = "(" + slots[0] + ") (" + slots[1] + ") (" + slots[2] + ")";
//3x "1337"
if ((slots[0] == slots[1]) && (slots[1] == slots[2]) && (slots[0] == "1337"))
{
temp += " C0nGr47ul47!0nz" + Msg.Bold(player) + " u won " + prizes[3] + "$ - go pwn some n00bs :>";
bot.UpdateMoney(host, prizes[3]);
}
//3 equal
else if ((slots[0] == slots[1]) && (slots[1] == slots[2]))
{
temp += " Congratulations " + Msg.Bold(player) + " you won " + prizes[2] + "$";
bot.UpdateMoney(host, prizes[2]);
}
//0 equal
else if ((slots[0] != slots[1]) && (slots[1] != slots[2]) && (slots[0] != slots[2]))
{
temp += " Sorry " + Msg.Bold(player) + " but you lost " + -prizes[0] + "$";
bot.UpdateMoney(host, prizes[0]);
}
//2 equal
else
{
temp += " Congratulations " + Msg.Bold(player) + " you won " + prizes[1] + "$";
bot.UpdateMoney(host, prizes[1]);
}
chan.SendMessage(temp);
chan.DisposeGame();
}
public override void Update(IrcEventArgs e)
{
}
public override void TimeOut()
{
}
}
}
REVERSE
{
class Reverse : Game
{
const int time = 20;
const int prize = 10;
string word;
string solution = "";
public Reverse(Bot bot, Channel chan, IrcEventArgs e)
: base(bot, chan)
{
word = bot.RandomWord;
}
public override void Start()
{
for (int i = 0; i < word.Length; i++)
solution += word.Substring((word.Length - i - 1), 1);
chan.StartTimer(time);
chan.SendMessage("You have " + time + " seconds to write this word in reverse order: " + Msg.Bold(word));
}
public override void Update(IrcEventArgs e)
{
if (e.Data.Message == solution)
{
int earned = bot.UpdateMoney(bot.GetHost(e.Data.Nick), prize + solution.Length, int.Parse(chan.CurrentTime), time);
chan.SendMessage(e.Data.Nick + " entered the solution in " + chan.CurrentTime +
" seconds and wins " + earned + "$. Correct was " + Msg.Bold(solution));
chan.DisposeGame();
}
}
public override void TimeOut()
{
chan.SendMessage("Time is over! The word we looked for was " + Msg.Bold(solution));
chan.DisposeGame();
}
}
}