Пример #1
0
        private void OnJoinSide(JoinSideEvent e)
        {
            Program.DebugLog("on join side");

            if (!ProposalExists(e.PostedChannel.Id)) //if there is already an active proposal
            {
                return;
            }

            var proposal    = _proposals[e.PostedChannel.Id];
            var desiredSide = proposal.GetSide(e.IsWhite);

            if (desiredSide == null)
            {
                Program.DebugLog($"{e.Author.Username} joined {(e.IsWhite ? "white" : "black")} side!");
                proposal.SetSide(e.IsWhite, e.Author);
                GameManagerRenderer.DrawProposal(proposal);
            }

            if (proposal.BothSidesNotNull())
            {
                Program.DebugLog($"new game created!");
                var game = new Game(proposal);
                game.SetupAndRender();
                _games.Add(e.PostedChannel.Id, game);
                _proposals.Remove(e.PostedChannel.Id);
            }
        }
Пример #2
0
        public void OnGameProposalProposal(ISocketMessageChannel channel, SocketUser creator)
        {
            if (_proposals.ContainsKey(channel.Id))
            {
                Program.WarningLog("Cannot create proposal when one already exists in same channel!");
                return;
            }

            if (_games.ContainsKey(channel.Id))
            {
                Program.WarningLog("Cannot create proposal when an active game already exists in same channel!");
                return;
            }

            Program.DebugLog($"New Game Proposal at {channel.Name}");
            var newProposal = new GameProposal(creator, channel, new EmbededDrawer(channel));

            _proposals.Add(channel.Id, newProposal);
            GameManagerRenderer.DrawProposal(newProposal);
        }