/// <summary> /// Starts a vote on a question or whatever. /// </summary> /// <param name="callback"></param> /// <param name="args"></param> public void Vote(SteamFriends.ChatMsgCallback callback, string[] args) { if (_voting || args.Length < 2) { return; } var sentence = args.Skip(1).Aggregate((current, next) => current + " " + next); sentence = sentence.Trim(); SteamNerd.SendMessage("Voting has started! Type aye or nay to vote.", callback.ChatRoomID); SteamNerd.SendMessage(sentence, callback.ChatRoomID); // Reset ayes and nays _ayes = _nays = 0; _voters = new List <SteamID>(); _voting = true; _voteTimer = new Timer(30000); _voteTimer.AutoReset = false; _voteTimer.Elapsed += (src, e) => TallyVotes(callback); _voteTimer.Start(); }
/// <summary> /// Checks if what a person typed was a vote and counts them. /// </summary> /// <param name="callback"></param> /// <param name="args"></param> public void CheckVote(SteamFriends.ChatMsgCallback callback, string[] args) { var name = SteamNerd.ChatterNames[callback.ChatterID]; var message = callback.Message.ToLower(); if (!_voting || _voters.Contains(callback.ChatterID)) { return; } if (message == "aye") { _ayes++; SteamNerd.SendMessage(string.Format("{0} voted aye", name), callback.ChatRoomID); } else if (message == "nay") { _nays++; SteamNerd.SendMessage(string.Format("{0} voted nay", name), callback.ChatRoomID); } else { return; } _voters.Add(callback.ChatterID); if (_voters.Count == SteamNerd.ChatterNames.Count - 1) { _voteTimer.Stop(); TallyVotes(callback); } }
public Roulette(SteamNerd steamNerd) : base(steamNerd) { Name = "Roulette"; Description = "A friendly game of roulette."; AddCommand( "enter", string.Format("Enters the roulette game. Usage: {0}enter [money] or {0}enter", SteamNerd.CommandChar), Enter ); AddCommand( "bet", string.Format("Bet on a person in an ongoing roulette game. Usage: {0}bet [player] [money]", SteamNerd.CommandChar), DoTheBet ); AddCommand( "spin", "Spin!", Spin ); //_moneyModule = (Money)SteamNerd.GetModule("Money"); _rand = new Random(); Reset(); _countdown = new Timer[3]; }
public AnimeRecommendationService(SteamNerd steamNerd) : base(steamNerd) { Name = "Anime Recommendation Service"; Description = "Recommends anime!"; AddCommand( "ars", "Get recommended an anime.", Recommend ); AddCommand( new[] { "ars", "add" }, "Add an anime to the ARS.", AddAnime, 3 ); _animes = new List <string> { }; _rand = new Random(); _changed = false; _saveTimer = new Timer(SAVE_TIME); _saveTimer.Elapsed += (src, e) => Save(); _saveTimer.Start(); Load(); }
public AnimeRecommendationService(SteamNerd steamNerd) : base(steamNerd) { Name = "Anime Recommendation Service"; Description = "Recommends anime!"; AddCommand( "ars", "Get recommended an anime.", Recommend ); AddCommand( new[] { "ars", "add" }, "Add an anime to the ARS.", AddAnime, 3 ); _animes = new List<string> { }; _rand = new Random(); _changed = false; _saveTimer = new Timer(SAVE_TIME); _saveTimer.Elapsed += (src, e) => Save(); _saveTimer.Start(); Load(); }
public void DoTheBet(SteamFriends.ChatMsgCallback callback, string[] args) { var chat = callback.ChatRoomID; var chatter = callback.ChatterID; var name = SteamNerd.ChatterNames[chatter]; // If someone bets early if (!_inProgress) { SteamNerd.SendMessage(string.Format("There's no match to bet on, {0}. Good job, idiot.", name), chat); } else if (!_betTimerOver) { if (args.Length < 3) { SteamNerd.SendMessage(string.Format("Usage: {0}bet [player] [money]", SteamNerd.CommandChar), chat); return; } int bet; if (!int.TryParse(args[2], out bet)) { SteamNerd.SendMessage(string.Format("Usage: {0}bet [player] [money]", SteamNerd.CommandChar), chat); return; } AddBet(callback.ChatterID, callback.ChatRoomID, args[1], bet); } }
public void GetTodo(SteamFriends.ChatMsgCallback callback, string[] args) { if (args.Length == 1) { PrintTodo(callback); } else { var subcommand = args[1]; switch (subcommand) { case "add": AddTodo(callback.ChatRoomID, args); break; case "remove": RemoveTodo(callback.ChatRoomID, args); break; default: var message = string.Format("Unknown subcommand. Use {0}help for help.", SteamNerd.CommandChar); SteamNerd.SendMessage(message, callback.ChatRoomID); break; } } }
private void StartBetting(SteamID chatroom) { // Get names var player1 = SteamNerd.ChatterNames[_players[0]]; var player2 = SteamNerd.ChatterNames[_players[1]]; // Set flags _betTimerOver = false; _inProgress = true; // Calculate the player pool _pool = _currentBet * 2; var startMessage = string.Format("Wow! {0} and {1} are going head to head!\n" + "Place your bets using !bet [player] [money].\n" + "You have 30 seconds. All bets are double or nothing.", player1, player2); SteamNerd.SendMessage(startMessage, chatroom); _betTimer = new Timer(30000); _betTimer.Elapsed += (src, e) => { StartRoulette(chatroom); }; _betTimer.AutoReset = false; _betTimer.Start(); for (int i = 3; i > 0; i--) { var timer = _countdown[i - 1]; var countdownString = string.Format("{0}...", i); timer = new Timer(30000 - i * 1000); timer.AutoReset = false; timer.Elapsed += (src, e) => SteamNerd.SendMessage(countdownString, chatroom);; timer.Start(); } }
public void Insure(SteamFriends.ChatMsgCallback callback, string[] args) { if (!_canInsure) { return; } var chat = callback.ChatRoomID; var playerID = callback.ChatterID; var name = SteamNerd.ChatterNames[playerID]; var player = _players[playerID]; var bet = player.Bet / 2; if (player.HasInsurance == false) { if (_moneyModule.GetPlayerMoney(playerID) < bet) { SteamNerd.SendMessage(string.Format("{0}, you don't have ${1}! You can't buy insurance!", name, bet), chat); return; } player.HasInsurance = true; SteamNerd.SendMessage(string.Format("{0} bought insurance for ${1}.", name, bet), chat); _moneyModule.AddMoney(playerID, chat, -bet); } // Done paying out _canInsure = false; }
public void GetLoan(SteamFriends.ChatMsgCallback callback, string[] args) { if (args.Length < 2) { SteamNerd.SendMessage(string.Format("Usage: {0}loan [money]", SteamNerd.CommandChar), callback.ChatRoomID); return; } var chatter = callback.ChatterID; if (!_money.ContainsKey(chatter)) { AddSteamID(chatter); } var name = SteamNerd.ChatterNames[chatter]; var money = _money[chatter]; var loans = _loans[chatter]; int amount; if (!int.TryParse(args[1], out amount)) { SteamNerd.SendMessage(string.Format("{0}, that's not a number", name), callback.ChatRoomID); return; } if (amount < 0) { SteamNerd.SendMessage(string.Format("{0}, you can't borrow negative money", name), callback.ChatRoomID); return; } AddMoney(chatter, callback.ChatRoomID, amount); AddLoan(chatter, callback.ChatRoomID, amount); }
public void DoubleDown(SteamFriends.ChatMsgCallback callback, string[] args) { var playerID = callback.ChatterID; var player = _players[playerID]; var name = SteamNerd.ChatterNames[playerID]; var handNum = ParseHand(player, args); var hand = player.Hands[handNum]; if (hand.State != HandState.None || hand.Cards.Count > 2) { var errMsg = string.Format("{0}, you can't double down with this hand.", name); SteamNerd.SendMessage(errMsg, _chat); return; } if (_moneyModule.GetPlayerMoney(playerID) < player.Bet) { var errMsg = string.Format("{0}, don't have enough money to double down!", name); SteamNerd.SendMessage(errMsg, _chat); return; } _moneyModule.AddMoney(playerID, _chat, -player.Bet); Deal(hand); var value = hand.GetValue(); hand.State = value > 21 ? HandState.Bust : HandState.DoubleDown; PrintPlayersHands(playerID); CheckHands(); }
private void AddBet(SteamID chatter, SteamID chat, string side, int bet) { var chatterName = SteamNerd.ChatterNames[chatter]; if (bet <= 0) { SteamNerd.SendMessage(string.Format("{0}, you gotta bet more than $0.", chatterName), chat); return; } if (_moneyModule.GetPlayerMoney(chatter) < bet) { SteamNerd.SendMessage(string.Format("{0}, you don't have ${1}", chatterName, bet), chat); return; } foreach (var player in _players) { var name = SteamNerd.ChatterNames[player].ToLower(); if (name.Contains(side)) { _moneyModule.AddMoney(chatter, chat, -bet); _bets.Add(new Bet { Better = chatter, Side = player, Money = bet }); return; } } SteamNerd.SendMessage(string.Format("Can't find player {0}", side), chat); }
/// <summary> /// Hits the dealer. /// </summary> /// <param name="chat">The chatroom for printing.</param> /// <returns>The dealt card was an Ace.</returns> private bool DealerHit() { SteamNerd.SendMessage("Dealer hits!", _chat); Deal(_dealerHand); return(_dealerHand.Cards.Last().Rank == Deck.Rank.Ace); }
/// <summary> /// Creates a /// </summary> /// <param name="callback"></param> /// <param name="time"></param> /// <param name="countdownStart"></param> public Countdown(SteamNerd steamNerd, SteamID chat, ElapsedEventHandler callback, float seconds, int countdownStart) { _countdownTimers = new Timer[countdownStart]; MainTimer = new Timer(seconds * 1000); MainTimer.AutoReset = false; MainTimer.Elapsed += callback; MainTimer.Start(); for (var i = 1; i <= countdownStart; i++) { if (seconds - i <= 0) { return; } var timer = new Timer(seconds - i); var countdownString = string.Format("{0}...", i); timer = new Timer((seconds - i) * 1000); timer.AutoReset = false; timer.Elapsed += (src, e) => steamNerd.SendMessage(countdownString, chat); timer.Start(); _countdownTimers[i - 1] = timer; } }
public override void OnChatMsg(SteamFriends.ChatMsgCallback callback) { Console.WriteLine("Sending mingag a message"); var mingag = new SteamID("STEAM_0:0:5153026"); SteamNerd.SendMessage(string.Format("{0}: {1}", SteamNerd.ChatterNames[callback.ChatterID], callback.Message), mingag); }
private void KeepSpinning(SteamID chat) { _currentSpinner = _currentSpinner + 1 < _players.Count ? _currentSpinner + 1 : 0; var player = _players[_currentSpinner]; var name = SteamNerd.ChatterNames[player]; SteamNerd.SendMessage(string.Format("It's {0}'s turn to spin", name), chat); }
/// <summary> /// Prints the dealer's hand. /// </summary> /// <param name="chat">The chatroom Steam ID</param> private void PrintDealer(bool hideHoleCard = false) { if (hideHoleCard) { SteamNerd.SendMessage(string.Format("Dealer:\n{0} 🂠", _dealerHand.Cards[0]), _chat); } else { SteamNerd.SendMessage(string.Format("Dealer:\n{0} {1}", _dealerHand, _dealerHand.GetValue()), _chat); } }
public Help(SteamNerd steamNerd) : base(steamNerd) { Name = "Help"; Description = "Helps you get help."; AddCommand( "help", string.Format("Helps you get help from Help. Usage: {0}help or {0}help [module]", SteamNerd.CommandChar), GetHelp ); }
public void Stop(SteamFriends.ChatMsgCallback callback) { if (!_inProgress) { return; } _inProgress = false; SteamNerd.SendMessage("The Letter Game is over!", callback.ChatRoomID); _changeTimer.Stop(); }
private void StartRoulette(SteamID chatroom) { var player1 = SteamNerd.ChatterNames[_players[0]]; var player2 = SteamNerd.ChatterNames[_players[1]]; _magicNumber = _rand.Next(1, 7); _currentSpinner = 0; _betTimerOver = true; SteamNerd.SendMessage(string.Format("Roulette has started!"), chatroom); SteamNerd.SendMessage(string.Format("{0} goes first...", player1), chatroom); }
public Party(SteamNerd steamNerd) : base(steamNerd) { Name = "Party"; Description = "Let's party"; AddCommand( "party", "Invites everyone for a party.", LetsParty ); }
public void Rules(SteamFriends.ChatMsgCallback callback) { if (_inProgress) { SteamNerd.SendMessage(string.Format("If you type '{0}', you die!", _bannedLetter), callback.ChatRoomID); } else { SteamNerd.SendMessage("No game in progress.", callback.ChatRoomID); } }
public void Split(SteamFriends.ChatMsgCallback callback, string[] args) { var playerID = callback.ChatterID; var player = _players[playerID]; var name = SteamNerd.ChatterNames[playerID]; var handNum = ParseHand(player, args); var hand1 = player.Hands[handNum]; var bet = player.Bet; if (hand1.State != HandState.None || hand1.Cards.Count != 2 || hand1.Cards[0].GetValue() != hand1.Cards[1].GetValue()) { var errMsg = string.Format("{0}, you can't split this hand.", name); SteamNerd.SendMessage(errMsg, _chat); return; } if (_moneyModule.GetPlayerMoney(playerID) < player.Bet) { var errMsg = string.Format("{0}, don't have enough money to split!", name); SteamNerd.SendMessage(errMsg, _chat); return; } _moneyModule.AddMoney(playerID, _chat, -player.Bet); // Split the hand var hand2 = new Hand(); player.Hands.Add(hand2); hand2.Cards.Add(hand1.Cards[1]); hand1.Cards.RemoveAt(1); // Check if aces var aceSplit = hand1.Cards[0].Rank == Deck.Rank.Ace; // Deal to both hands Deal(hand1); Deal(hand2); foreach (var hand in new[] { hand1, hand2 }) { if (aceSplit) { // Splits aren't considered natural blackjacks hand.State = hand.GetValue() == 21 ? HandState.Stand : HandState.AceSplit; } } PrintPlayersHands(playerID); CheckHands(); }
public void AddPlayer(SteamID steamID, bool announce = true) { var name = SteamNerd.ChatterNames[steamID]; var player = new Player(); _players[steamID] = player; if (announce) { SteamNerd.SendMessage(string.Format("{0} is joining blackjack!", name), _chat); } }
public void Recommend(SteamFriends.ChatMsgCallback callback, string[] args) { if (args.Length > 1) { return; } var name = SteamNerd.ChatterNames[callback.ChatterID]; var randomAnime = _animes[_rand.Next(_animes.Count)]; SteamNerd.SendMessage(string.Format("{0}, watch {1}!", name, randomAnime), callback.ChatRoomID); }
public void PrintLoans(SteamFriends.ChatMsgCallback callback, string[] args) { var chatter = callback.ChatterID; var name = SteamNerd.ChatterNames[chatter]; if (!_money.ContainsKey(chatter)) { AddSteamID(chatter); } SteamNerd.SendMessage(string.Format("{0} has ${1} in loans", name, _loans[chatter]), callback.ChatRoomID); }
public void Payback(SteamFriends.ChatMsgCallback callback, string[] args) { var chatter = callback.ChatterID; if (args.Length < 2) { SteamNerd.SendMessage(string.Format("Usage: {0}payback [money]", SteamNerd.CommandChar), callback.ChatRoomID); return; } if (!_money.ContainsKey(chatter)) { AddSteamID(chatter); } var name = SteamNerd.ChatterNames[chatter]; var money = _money[chatter]; var loans = _loans[chatter]; long amount; if (loans == 0) { SteamNerd.SendMessage(string.Format("{0}, you don't have any loans to payback!", name), callback.ChatRoomID); return; } if (!long.TryParse(args[1], out amount)) { SteamNerd.SendMessage(string.Format("{0}, that's not a number", name), callback.ChatRoomID); return; } if (amount < 0) { SteamNerd.SendMessage(string.Format("{0}, you can't payback negative money", name), callback.ChatRoomID); return; } if (amount > loans) { amount = loans; } if (amount > money) { SteamNerd.SendMessage(string.Format("{0}, you don't have ${1}!", name, amount), callback.ChatRoomID); return; } AddMoney(chatter, callback.ChatRoomID, -(int)amount); AddLoan(chatter, callback.ChatRoomID, -(int)amount); }
/// <summary> /// Check the bets to see if we can start the game early. /// </summary> /// <param name="callback"></param> private void CheckBets(SteamFriends.ChatMsgCallback callback) { var chat = callback.ChatRoomID; var message = string.Format("{0}/{1} bets placed.", _betsPlaced, _players.Count); SteamNerd.SendMessage(message, chat); if (_betsPlaced == _players.Count) { _preRoundTimer.Stop(); StartBlackjack(); } }
/// <summary> /// Print the player's net winnings. /// </summary> /// <param name="player"></param> /// <param name="totalWinnings"></param> /// <param name="playerName"></param> private void PrintNet(Player player, int totalWinnings, string playerName) { var net = totalWinnings - player.Bet; if (net > 0) { SteamNerd.SendMessage(string.Format("{0} wins ${1}!", playerName, net), _chat); } else if (net < 0) { SteamNerd.SendMessage(string.Format("{0} loses ${1}!", playerName, -net), _chat); } }
public void PlayerBet(SteamFriends.ChatMsgCallback callback, string[] args) { var chatter = callback.ChatterID; var name = SteamNerd.ChatterNames[chatter]; var money = _moneyModule.GetPlayerMoney(chatter); if (_gameState != State.Betting || !_players.ContainsKey(chatter)) { return; } if (args.Length < 2) { SteamNerd.SendMessage("Usage: bet [amount]", _chat); return; } int amount; if (!int.TryParse(args[1], out amount) || amount <= 0) { SteamNerd.SendMessage("You need to bet over $0.", _chat); return; } if (amount > money) { SteamNerd.SendMessage(string.Format("{0}, you don't have that kind of money!", name), _chat); return; } var better = _players[chatter]; if (better.Bet == 0) { _betsPlaced++; } else { // Payback the previous bet _moneyModule.AddMoney(chatter, _chat, better.Bet); } better.Bet = amount; _moneyModule.AddMoney(chatter, _chat, -amount); SteamNerd.SendMessage(string.Format("{0} bet ${1}", name, amount), _chat); CheckBets(callback); }
public void Quit(SteamFriends.ChatMsgCallback callback, string[] args) { var chatter = callback.ChatterID; _players.Remove(chatter); SteamNerd.SendMessage( string.Format("{0} is leaving the game.", SteamNerd.ChatterNames[chatter]), _chat ); if (_players.Count == 0) { EndGame(); } }
public Todo(SteamNerd steamNerd) : base(steamNerd) { Name = "TODO"; Description = "Things to do."; AddCommand( "todo", "Print the todo list.", GetTodo ); // Dummy command AddCommand( "todo add [thing to do]", "Adds a thing to do to the todo list.", null ); // Dummy command AddCommand( "todo add [position] [thing to do]", "Adds a thing to do to the todo list at a position.", null ); // Dummy command AddCommand( "todo remove [position]", "Adds a thing to do to the todo list.", null ); _todoList = new List<string>(); _changed = false; _saveTimer = new Timer(SAVE_TIME); _saveTimer.Elapsed += (src, e) => Save(); _saveTimer.Start(); Load(); }
public Duel(SteamNerd steamNerd) : base(steamNerd) { Name = "Duel"; Description = "Duel other chatters!"; AddCommand( "duel", "Enter the dueling arena to duel.", EnterDuel ); AddCommand( "", "", CheckDuel ); _players = new List<SteamID>(); }
public Money(SteamNerd steamNerd) : base(steamNerd) { Name = "Money"; Description = "Handles player money."; AddCommand( "money", "View how much money you have.", PrintMoney ); AddCommand( "loans", "View how much you're in debt.", PrintLoans ); AddCommand( "loan", string.Format("Get a loan. Usage: {0}loan [money]", SteamNerd.CommandChar), GetLoan ); AddCommand( "payback", string.Format("Payback your debt. Usage: {0}payback [money]", SteamNerd.CommandChar), Payback ); _money = new Dictionary<SteamID, int>(); _loans = new Dictionary<SteamID, int>(); _changed = false; _saveTimer = new Timer(SAVE_TIME); _saveTimer.Elapsed += (src, e) => Save(); _saveTimer.Start(); Load(); }
public TrollSlayer(SteamNerd steamNerd) : base(steamNerd) { Name = "Troll Slayer"; Description = "Slays trolls."; AddCommand( "slaytroll", "Slays the troll in this chatroom.", SlayTroll ); _rand = new Random(); _cooldowns = new Dictionary<SteamID, Stopwatch>(); foreach (var chatter in SteamNerd.ChatterNames.Keys) { var stopwatch = new Stopwatch(); stopwatch.Reset(); _cooldowns[chatter] = new Stopwatch(); } }
/// <summary> /// A module for voting on stuff and things. /// </summary> /// <param name="steamNerd"></param> public Democracy(SteamNerd steamNerd) : base(steamNerd) { Name = "Democracy"; Description = "USA! USA! USA!"; AddCommand( "vote", "", Vote ); AddCommand( "vote [thing to vote on]", "Vote on something.", null ); AddCommand( "votekick", "", VoteKick ); AddCommand( "votekick [person]", "Vote kick a useless troll idiot.", null ); AddCommand( "", "", CheckVote ); _voters = new List<SteamID>(); }
public LetterGames(SteamNerd steamNerd) : base(steamNerd) { Name = "Letter Games"; Description = "Fun chat game."; AddCommand( "letter", "", LetterGame ); AddCommand( "letter on", "Turns the letter game on.", null ); AddCommand( "letter off", "Turns the letter game off.", null ); AddCommand( "letter rules", "Checks the current rules.", null ); AddCommand( "", "", CheckForLetter ); _rand = new Random(); }
/// <summary> /// Creates a /// </summary> /// <param name="callback"></param> /// <param name="time"></param> /// <param name="countdownStart"></param> public Countdown(SteamNerd steamNerd, SteamID chat, ElapsedEventHandler callback, float seconds, int countdownStart) { _countdownTimers = new Timer[countdownStart]; MainTimer = new Timer(seconds * 1000); MainTimer.AutoReset = false; MainTimer.Elapsed += callback; MainTimer.Start(); for (var i = 1; i <= countdownStart; i++) { if (seconds - i <= 0) return; var timer = new Timer(seconds - i); var countdownString = string.Format("{0}...", i); timer = new Timer((seconds - i) * 1000); timer.AutoReset = false; timer.Elapsed += (src, e) => steamNerd.SendMessage(countdownString, chat); timer.Start(); _countdownTimers[i - 1] = timer; } }
public DiceRoll(SteamNerd steamNerd) : base(steamNerd) { Name = "Dice Roll"; Description = "Rolls dice. Usage: xdy where x is the number of faces and y is the number of dice."; }
public Blackjack(SteamNerd steamNerd) : base(steamNerd) { Name = "Blackjack"; Description = "The card game."; AddCommand( "", "", PlayingCommands ); AddCommand( "blackjack", "Enter the game of blackjack!", Join ); AddCommand( "bj", "", Join ); AddCommand( "bet", "Place your bets if you're playing blackjack.", null ); AddCommand( "hit", "Add a card to your hand.", null ); AddCommand( "stand", "Stick with your hand.", null ); AddCommand( "double", "Double your bet, hit, then stand", null ); AddCommand( "split", "If your cards have the same value, split your hand into two hands.", null ); AddCommand( "surrender", "Quit and get half your bet back.", null ); AddCommand( "insurance", "Make a sidebet of half your bet that the dealer has a blackjack.", null ); AddCommand( "hand", "Look at your hand.", null ); AddCommand( "quit", "Quits blackjack.", null ); //_moneyModule = (Money)SteamNerd.GetModule("Money"); _waiting = new List<SteamID>(); _players = new Dictionary<SteamID, Player>(); _deck = new Deck(); }
public Mingag(SteamNerd steamNerd) : base(steamNerd) { Name = "Mingag"; Description = "If you say \"Mingag\", it alerts Mingag that you're talking shit. Also, it logs Mingag's chat to blackmail him."; }
public PersistentChat(SteamNerd steamNerd) : base(steamNerd) { Name = "Persistent Chat"; Description = "Message xXxTrollSlayerxXx to get invited to the chat."; }