// Update is called once per frame void Update() { // Check chat service { _inputUI.defaultText = Localization.instance.Get("IDS_TAP_TO_CHAT"); _inputBoxCollider.enabled = true; } IChatChannel chatChannel = ChatManager.Instance.GetChatChannel(IChatChannel.ENUM_CHAT_CHANNEL.CHANNEL_GUILD); if ((chatChannel != null) && chatChannel.HasNewMessage()) { _textListUI.Clear(); chatChannel.SortMessagesByStamptime(); List <ChatMessage> msgList = chatChannel.GetMessages(); for (int i = 0; i < msgList.Count; i++) { ChatMessage chatMessage = msgList[i]; string message = chatMessage.messageText; if (NetworkUtils.IsSystemMessage(message)) { string nickName = Localization.instance.Get("IDS_MESSAGE_TYPE_SYSTEM"); _textListUI.Add(nickName + ": " + message); } else { _textListUI.Add("[00FF00]" + chatMessage.fromPlayerInfo.nickName + "[-]" + ": " + message); } } chatChannel.SetNewMessageFlag(false); _uiScrollbar.scrollValue = 1f; } }
public void OnChannelResourceDataCached(IChatChannel channel, Dictionary <string, IChatResourceData> resources) { MainThreadInvoker.Invoke(() => { int count = 0; if (_chatConfig.PreCacheAnimatedEmotes) { foreach (var emote in resources) { if (emote.Value.IsAnimated) { StartCoroutine(ChatImageProvider.instance.PrecacheAnimatedImage(emote.Value.Uri, emote.Key, 110)); count++; } } Logger.log.Info($"Pre-cached {count} animated emotes."); } else { Logger.log.Warn("Pre-caching of animated emotes disabled by the user. If you're experiencing lag, re-enable emote precaching."); } }); }
private void btnLogin_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtUserName.Text.Trim())) { try { NewJoin += new UserJoined(ChatClient_NewJoin); MessageSent += new UserSendMessage(ChatClient_MessageSent); RemoveUser += new UserLeft(ChatClient_RemoveUser); channel = null; this.userName = txtUserName.Text.Trim(); InstanceContext context = new InstanceContext( new ChatClient(txtUserName.Text.Trim())); factory = new DuplexChannelFactory<IChatChannel>(context, "ChatEndPoint"); channel = factory.CreateChannel(); IOnlineStatus status = channel.GetProperty<IOnlineStatus>(); status.Offline += new EventHandler(Offline); status.Online += new EventHandler(Online); channel.Open(); channel.Join(this.userName); grpMessageWindow.Enabled = true; grpUserList.Enabled = true; grpUserCredentials.Enabled = false; this.AcceptButton = btnSend; rtbMessages.AppendText("*****************************WEL-COME to Chat Application*****************************\r\n"); txtSendMessage.Select(); txtSendMessage.Focus(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
public static void DisplayLatestMessageInInputbox(IChatChannel room, UIInput inputbox) { ChatMessage message = room.GetLatestMessage(); if (message == null) { return; } string lastetMsg = ""; string nickName = ""; if (NetworkUtils.IsSystemMessage(message.messageText)) { nickName = Localization.instance.Get("IDS_MESSAGE_TYPE_SYSTEM"); } else { nickName = message.fromPlayerInfo.nickName; lastetMsg = message.messageText; } inputbox.defaultText = nickName + ": " + lastetMsg; }
private void btnLogin_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtUserName.Text.Trim())) { try { NewJoin += new UserJoined(ChatClient_NewJoin); MessageSent += new UserSendMessage(ChatClient_MessageSent); RemoveUser += new UserLeft(ChatClient_RemoveUser); channel = null; this.userName = txtUserName.Text.Trim(); InstanceContext context = new InstanceContext( new ChatClient(txtUserName.Text.Trim())); factory = new DuplexChannelFactory <IChatChannel>(context, "ChatEndPoint"); channel = factory.CreateChannel(); IOnlineStatus status = channel.GetProperty <IOnlineStatus>(); status.Offline += new EventHandler(Offline); status.Online += new EventHandler(Online); channel.Open(); channel.Join(this.userName); grpMessageWindow.Enabled = true; grpUserList.Enabled = true; grpUserCredentials.Enabled = false; this.AcceptButton = btnSend; rtbMessages.AppendText("*****************************WEL-COME to Chat Application*****************************\r\n"); txtSendMessage.Select(); txtSendMessage.Focus(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
public override void ExecuteCommand(IChatChannel channel, StreamCommand command) { string pollkey; if (command.Arguments.Length == 0) { Logger.Info(this, $"Starting heuristic poll result estimation for '{command.User}'"); ActivePoll leadingpoll = module.GetMostActivePoll(); if (leadingpoll == null) { SendMessage(channel, command.User, "Since no one voted for anything i can't show you any poll."); return; } SendMessage(channel, command.User, $"You seem to be too lazy to tell me which poll you want to know something about. I just guess you want to see poll '{leadingpoll.Name}' since it is the most active poll."); pollkey = leadingpoll.Name; } else { pollkey = command.Arguments[0]; } Poll poll = module.GetPoll(pollkey); if (poll == null) { SendMessage(channel, command.User, $"There is no poll named '{pollkey}'"); return; } PollDiagramData data = new PollDiagramData(module.GetWeightedVotes(pollkey)); string message = $"Results for {pollkey}: {string.Join(", ", data.GetItems(100).Where(r => r.Count > 0).Select(r => $"{r.Item} [{r.Count}]"))}"; SendMessage(channel, command.User, message); }
private void StreamServiceProvider_OnLeaveChannel(IChatService svc, IChatChannel channel) { }
private void StreamServiceProvider_OnChannelStateUpdated(IChatService svc, IChatChannel channel) { }
public override void ExecuteCommand(IChatChannel channel, StreamCommand command) { BlackJackGame game = blackjack.GetGame(command.Service, command.User); if (game == null) { SendMessage(channel, command.User, "There is no active black jack game. Start another one with !bj <bet>"); return; } if (!logic.IsSplitPossible(game.PlayerBoards[game.ActiveBoard].Board)) { SendMessage(channel, command.User, "A split is not possible on the current hand."); return; } int bet = game.PlayerBoards[game.ActiveBoard].Bet; if (bet > playermodule.GetPlayerGold(game.PlayerID)) { SendMessage(channel, command.User, "You don't have enough gold to split the hand."); return; } playermodule.UpdateGold(game.PlayerID, -bet); game.PlayerBoards.Add(new BlackJackBoard { Bet = bet, Board = new Board(game.PlayerBoards[game.ActiveBoard].Board[1]) }); game.PlayerBoards[game.ActiveBoard].Board = game.PlayerBoards[game.ActiveBoard].Board.ChangeCard(1, game.Stack.Pop()); RPGMessageBuilder message = messages.Create(); message.User(game.PlayerID).Text(" current hand is "); foreach (Card card in game.PlayerBoards[game.ActiveBoard].Board) { message.Image(images.GetCardUrl(card), $"{card} "); } int value = logic.Evaluate(game.PlayerBoards[game.ActiveBoard].Board); message.Text($"({value}). "); while (value == 21 || (game.ActiveBoard < game.PlayerBoards.Count && game.PlayerBoards[game.ActiveBoard].Board[0].Rank == CardRank.Ace)) { ++game.ActiveBoard; if (game.ActiveBoard >= game.PlayerBoards.Count) { message.Text(" All hands are played."); logic.PlayoutDealer(game, message, playermodule, images); value = 0; } else { if (game.PlayerBoards[game.ActiveBoard].Board.Count == 0) { game.PlayerBoards[game.ActiveBoard].Board += game.Stack.Pop(); } message.User(game.PlayerID).Text(" next hand is "); foreach (Card card in game.PlayerBoards[0].Board) { message.Image(images.GetCardUrl(card), $"{card} "); } value = logic.Evaluate(game.PlayerBoards[game.ActiveBoard].Board); message.Text($"({value}). "); } } if (value > 0) { logic.CheckSplit(game.PlayerBoards[game.ActiveBoard].Board, message); } message.Send(); }
public override void ProvideHelp(IChatChannel channel, string user) { SendMessage(channel, user, "Removes a personal item from a collection. Syntax: !remove <collection> <item>"); }
public override void ProvideHelp(IChatChannel channel, string user) { SendMessage(channel, user, "Starts a new Casino Holdem game"); }
public override void ProvideHelp(IChatChannel channel, string user) { SendMessage(channel, user, "Displays the request queue in chat"); }
private void StreamServiceProvider_OnChannelJoined(IChatService svc, IChatChannel channel) { Console.WriteLine($"Joined channel {channel.Id}"); }
public override void ProvideHelp(IChatChannel channel, string user) { SendMessage(channel, user, "Buys an item from the shop. Syntax: !buy <item> [amount]. If no amount is specified 1 is considered to be the quantity to buy."); }
// Host the chat instance within this EXE console application. public static void Main() { Console.WriteLine("Enter your nickname [default=DefaultName]: "); string member = Console.ReadLine(); if (member == "") { member = "DefaultName"; } // Construct InstanceContext to handle messages on callback interface. // An instance of ChatApp is created and passed to the InstanceContext. InstanceContext instanceContext = new InstanceContext(new ChatApp(member)); // Create the participant with the given endpoint configuration // Each participant opens a duplex channel to the mesh // participant is an instance of the chat application that has opened a channel to the mesh DuplexChannelFactory <IChatChannel> factory = new DuplexChannelFactory <IChatChannel>(instanceContext, "ChatEndpoint"); IChatChannel participant = factory.CreateChannel(); // Retrieve the PeerNode associated with the participant and register for online/offline events // PeerNode represents a node in the mesh. Mesh is the named collection of connected nodes. IOnlineStatus ostat = participant.GetProperty <IOnlineStatus>(); ostat.Online += new EventHandler(OnOnline); ostat.Offline += new EventHandler(OnOffline); try { participant.Open(); } catch (CommunicationException) { Console.WriteLine("Could not find resolver. If you are using a custom resolver, please ensure"); Console.WriteLine("that the service is running before executing this sample. Refer to the readme"); Console.WriteLine("for more details."); return; } Console.WriteLine("{0} is ready", member); Console.WriteLine("Type chat messages after going Online"); Console.WriteLine("Press q<ENTER> to terminate this instance."); // Announce self to other participants participant.Join(member); // loop until the user quits while (true) { string line = Console.ReadLine(); if (line == "q") { break; } participant.Chat(member, line); } // Leave the mesh participant.Leave(member); participant.Close(); factory.Close(); }
public override void ExecuteCommand(IChatChannel channel, StreamCommand command) { module.Buy(command.Service, command.Channel, command.User, command.Arguments); }
public override void ProvideHelp(IChatChannel channel, string user) { SendMessage(channel, user, "Draw another card to increase value of your hand."); }
public override void ExecuteCommand(IChatChannel channel, StreamCommand command) { long userid = playermodule.GetPlayer(command.Service, command.User).UserID; HoldemGame game = casino.GetGame(userid); if (game != null) { SendMessage(channel, command.User, "You are already active in a holdem game. Use !fold to fold your hand or !call to stay active in the game."); return; } int bet; if (command.Arguments.Length == 0) { bet = 1; } else { int.TryParse(command.Arguments[0], out bet); } if (bet <= 0) { SendMessage(channel, command.User, $"{command.Arguments[0]} is no valid bet"); return; } int gold = playermodule.GetPlayerGold(userid); if (bet > 1 && bet > gold) { SendMessage(channel, command.User, "You can't bet more than you have."); return; } int maxbet = playermodule.GetLevel(userid) * 10; if (bet > maxbet) { SendMessage(channel, command.User, $"On your level you're only allowed to bet up to {maxbet} gold."); return; } // allow the player to play for one gold even if he has no gold if (gold > 0) { playermodule.UpdateGold(userid, -bet); } game = casino.CreateGame(userid, bet); game.Deck.Shuffle(); game.PlayerHand += game.Deck.Pop(); game.DealerHand += game.Deck.Pop(); game.PlayerHand += game.Deck.Pop(); game.DealerHand += game.Deck.Pop(); game.Muck.Push(game.Deck.Pop()); for (int i = 0; i < 3; ++i) { game.Board += game.Deck.Pop(); } RPGMessageBuilder message = messagemodule.Create(); message.Text("You have "); foreach (Card card in game.PlayerHand) { message.Image(imagemodule.GetCardUrl(card), $"{card} "); } message.Text(". The board shows "); foreach (Card card in game.Board) { message.Image(imagemodule.GetCardUrl(card), $"{card} "); } HandEvaluation evaluation = HandEvaluator.Evaluate(game.Board + game.PlayerHand); message.Text($" ({evaluation})").Send(); }
private void StreamServiceProvider_OnChannelJoined(IChatService svc, IChatChannel channel) { }
void SetupClient(string serviceNamespace, string issuerName, string issuerSecret) { // create the channel factory loading the configuration channelFactory = new ChannelFactory<IChatChannel>("ChatEndpoint", new EndpointAddress(serviceUri)); // apply the Service Bus credentials channelFactory.Endpoint.Behaviors.Add(sharedSecretServiceBusCredential); // create and open the client channel channel = channelFactory.CreateChannel(); channel.Open(); }
private void StreamServiceProvider_OnLeaveChannel(IChatService svc, IChatChannel channel) { Console.WriteLine($"Left channel {channel.Id}"); }
/// <summary> /// provides help for the /// </summary> /// <param name="channel">channel from which help request was received</param> /// <param name="user">use which requested help</param> public abstract void ProvideHelp(IChatChannel channel, string user);
public override void ExecuteCommand(IChatChannel channel, StreamCommand command) { module.RemoveItem(command.User, command.Arguments[0].ToLower(), command.Arguments[1].ToLower()); }
public override void ProvideHelp(IChatChannel channel, string user) { channel.SendMessage("Starts a game of video poker. Type !draw <bet> to start a game and when you get your first cards type !draw <slot> <slot> to redraw cards of the specified slot. Just type !draw to accept your hand."); }
public override void ProvideHelp(IChatChannel channel, string user) { SendMessage(channel, user, "Play a round of roulette in this channel. Just type '!roulette <field> <bet>' to place a bet. For instance '!roulette red 5' places 5 gold coins on red. '!roulette 8 10' places 10 gold on field 8. '!roulette odd' places 1 gold on odd numbers"); }
private void OnJoinChannel(IChatService svc, IChatChannel channel) { _chatDisplay.OnJoinChannel(svc, channel); }
/// <summary> /// executes a <see cref="StreamCommand"/> /// </summary> /// <param name="channel">channel from which command was received</param> /// <param name="command">command to execute</param> public abstract void ExecuteCommand(IChatChannel channel, StreamCommand command);
public override void ExecuteCommand(IChatChannel channel, StreamCommand command) { if (command.Arguments.Length == 0) { ProvideHelp(channel, command.User); return; } int gold; try { gold = command.Arguments.Length < 2 ? 1 : int.Parse(command.Arguments[1]); } catch (Exception e) { Logger.Error(this, $"{command.Arguments[1]} is no valid bet amount", e); SendMessage(channel, command.User, $"{command.Arguments[1]} is no valid bet amount"); return; } if (gold <= 0) { gold = 1; } if (playermodule.GetPlayerGold(playermodule.GetExistingPlayer(command.Service, command.User).UserID) < gold) { SendMessage(channel, command.User, $"You don't have {gold} gold"); return; } if (command.Arguments[0].All(c => char.IsDigit(c))) { int field = int.Parse(command.Arguments[0]); if (field < 0 || field > 36) { SendMessage(channel, command.User, $"Field {field} is not part of the board."); return; } module.Bet(command.Service, command.User, gold, BetType.Plein, field); return; } switch (command.Arguments[0].ToLower()) { case "r": case "red": case "rouge": module.Bet(command.Service, command.User, gold, BetType.Color, 0); SendMessage(channel, command.User, $"You bet {gold} on red for the next roulette round"); break; case "b": case "black": case "noir": module.Bet(command.Service, command.User, gold, BetType.Color, 1); SendMessage(channel, command.User, $"You bet {gold} on black for the next roulette round"); break; case "o": case "odd": module.Bet(command.Service, command.User, gold, BetType.OddEven, 1); SendMessage(channel, command.User, $"You bet {gold} on odds for the next roulette round"); break; case "e": case "even": module.Bet(command.Service, command.User, gold, BetType.OddEven, 0); SendMessage(channel, command.User, $"You bet {gold} on evens for the next roulette round"); break; case "dozen1": module.Bet(command.Service, command.User, gold, BetType.Douzaines, 0); SendMessage(channel, command.User, $"You bet {gold} on the first dozen for the next roulette round"); break; case "row1": module.Bet(command.Service, command.User, gold, BetType.Colonnes, 0); SendMessage(channel, command.User, $"You bet {gold} on the first row for the next roulette round"); break; case "dozen2": module.Bet(command.Service, command.User, gold, BetType.Douzaines, 1); SendMessage(channel, command.User, $"You bet {gold} on the second dozen for the next roulette round"); break; case "row2": module.Bet(command.Service, command.User, gold, BetType.Colonnes, 1); SendMessage(channel, command.User, $"You bet {gold} on the second row for the next roulette round"); break; case "dozen3": module.Bet(command.Service, command.User, gold, BetType.Douzaines, 2); SendMessage(channel, command.User, $"You bet {gold} on the third dozen for the next roulette round"); break; case "row3": module.Bet(command.Service, command.User, gold, BetType.Colonnes, 2); SendMessage(channel, command.User, $"You bet {gold} on the third row for the next roulette round"); break; case "half1": module.Bet(command.Service, command.User, gold, BetType.HalfBoard, 0); SendMessage(channel, command.User, $"You bet {gold} on 1-18 for the next roulette round"); break; case "half2": module.Bet(command.Service, command.User, gold, BetType.HalfBoard, 1); SendMessage(channel, command.User, $"You bet {gold} on 19-36 for the next roulette round"); break; case "history": SendMessage(channel, command.User, $"History of roulette fields: {string.Join(",", module.History)}"); break; } }
/// <summary> /// sends a message to a user in a channel (in public chat) /// </summary> /// <param name="channel">channel to which to send message</param> /// <param name="user">name of user</param> /// <param name="message">message to send</param> protected void SendMessage(IChatChannel channel, string user, string message) { channel.SendMessage($"@{user}: {message}"); }
public static TwitchChannel?AsTwitchChannel(this IChatChannel channel) { return(channel as TwitchChannel); }
public override void ExecuteCommand(IChatChannel channel, StreamCommand command) { VideoPokerGame game = pokermodule.GetGame(command.Service, command.User); long userid = playermodule.GetPlayer(command.Service, command.User).UserID; HandEvaluation evaluation; if (game == null) { if(command.Arguments.Length == 0) { SendMessage(channel, command.User, "You have to specify a bet amount"); return; } int bet; int.TryParse(command.Arguments[0], out bet); if(bet <= 0) { SendMessage(channel, command.User, $"{command.Arguments[0]} is no valid bet"); return; } if (bet > playermodule.GetPlayerGold(userid)) { SendMessage(channel, command.User, "You can't bet more than you have."); return; } int maxbet = playermodule.GetLevel(userid) * 10; if (bet > maxbet) { SendMessage(channel, command.User, $"On your level you're only allowed to bet up to {maxbet} gold."); return; } game = pokermodule.CreateGame(command.Service, command.User, bet); game.IsMaxBet = bet == maxbet; game.Deck.Shuffle(); for(int i = 0; i < 5; ++i) game.Hand += game.Deck.Pop(); RPGMessageBuilder message = messagemodule.Create(); message.User(userid).Text(" has "); foreach(Card card in game.Hand) message.Image(imagemodule.GetCardUrl(card), $"{card} "); evaluation = HandEvaluator.Evaluate(game.Hand); message.Text($"({evaluation})").Send(); } else { RPGMessageBuilder message = messagemodule.Create(); if(command.Arguments.Length > 0) { int redraw = 0; foreach(string argument in command.Arguments) { if(argument.All(c => char.IsDigit(c))) { int index = int.Parse(argument); if(index < 1 || index > 5) { SendMessage(channel, command.User, $"{index} is not a valid slot to redraw"); return; } redraw |= 1 << (index - 1); } else if(argument.ToLower() == "all") { redraw |= 31; } else { int index = game.Hand.IndexOf(c => c.ToString().ToLower() == argument.ToLower()); if(index == -1) { SendMessage(channel, command.User, $"{argument} points not to a card in your hand"); return; } redraw |= 1 << index; } } int cards = 0; for(int i = 0; i < 5; ++i) { if((redraw & (1 << i)) != 0) { game.Hand = game.Hand.ChangeCard(i, game.Deck.Pop()); ++cards; } } message.User(userid).Text($" is redrawing {cards} cards. "); foreach (Card card in game.Hand) message.Image(imagemodule.GetCardUrl(card), $"{card} "); evaluation = HandEvaluator.Evaluate(game.Hand); message.Text($"({evaluation})."); } else { evaluation = HandEvaluator.Evaluate(game.Hand); message.User(userid).Text(" is satisfied with the hand."); } int multiplicator = GetMultiplicator(evaluation, game.IsMaxBet); if(multiplicator == 0) message.Text(" ").ShopKeeper().Text(" laughs about that shitty hand."); else { int payout = game.Bet * multiplicator; playermodule.UpdateGold(userid, payout); message.Text(" Payout is ").Gold(payout); } message.Send(); pokermodule.RemoveGame(command.Service, command.User); } }
public override void ProvideHelp(IChatChannel channel, string user) { SendMessage(channel, user, "Splits the current hand of a black jack game."); }