Example #1
0
        private void Setup()
        {
            var map = GetMap(mapName);

            LogMapToFile(map, session.PlayersCount);
            scorer.Init(Converter.Convert(map));
            foreach (var x in session.Clients)
            {
                var setupMessage = new SetupMessage
                {
                    punter  = x.Id,
                    punters = session.PlayersCount,
                    map     = map
                };
                Log($"Sending setup message to punter {x.Name}");
                var reply = x.Client.WriteAndGetReply(serializer.Serialize(setupMessage),
                                                      TimeSpan.FromSeconds(10));
                if (reply == null)
                {
                    throw new Exception($"Client {x.Name} doesn't respond to setup");
                }
                var setupCommand = serializer.Deserialize <SetupCommand>(reply.MessageString);
                Log($"Punter {x.Id} is ready!");
                if (setupCommand.ready != x.Id)
                {
                    throw new Exception("ready must be equal to player id");
                }
            }

            var who = session.Clients.Select(x => new { x.Id, x.Name });

            File.WriteAllText("who.txt", JsonConvert.SerializeObject(who));

            Game(map);
        }
Example #2
0
        protected override void OnStarted()
        {
            _log?.Put(OutputLevel.Info, Name, "Start send message.");

            Response         = null;
            RequestException = null;
            SetupMessage?.Invoke(Message);
            SendMessage(Context.Resolve <HttpClient>());
        }
Example #3
0
        public static SetupMessage CreateSetupMessage(GuildEngine guild, ulong messageId, ulong ticketId, ulong channelId)
        {
            if (guild.SetupMessages.ContainsKey(messageId))
            {
                SetupMessage m_message;
                guild.SetupMessages.TryGetValue(messageId, out m_message);
                return(m_message);
            }
            SetupMessage message = new SetupMessage {
                MessageId = messageId, TicketId = ticketId, ChannelId = channelId
            };

            guild.SetupMessages.Add(messageId, message);
            return(message);
        }
Example #4
0
        public void HandleSetupMessage(GuildEngine guildE, SetupMessage setupMessage, SocketReaction reaction, Discord.Rest.RestUserMessage message)
        {
            var user   = reaction.User.Value as SocketGuildUser;
            var ticket = GetTicket(guildE.Id, setupMessage.TicketId);

            if (ticket == null)
            {
                return;
            }

            message.RemoveReactionAsync(reaction.Emote, user);

            if (ticket.ActiveChildChannels.Values.Any(x => x.UserId == user.Id))
            {
                return;
            }

            TicketManager.CreateNewChild(DiscordClient, user, ticket);
        }