Пример #1
0
        private void BingoEvent(StatusMessage msg)
        {
            var rendered = msg.Render();

            if (rendered != null)
            {
                this.LogChat(rendered);
            }
            switch (msg.type)
            {
            case "connection" when msg.event_type == "disconnected":
                break;

            case "connection" when msg.event_type == "connected":
                this.Connected = true;
                break;

            case "connection":
                break;

            case "goal": {
                var i      = int.Parse(msg.square.slot.Substring(4)) - 1;
                var colors = msg.square.colors.Split(' ');
                this.Board[i].Colors = new List <BingoColors>(BingoEnumExtensions.ParseColors(msg.square.colors));
                break;
            }

            case "new-card":
                var settings = this.GetSettings();
                this.IsBoardHidden = settings.Item1;
                this.IsLockout     = settings.Item2;
                Thread.Sleep(500);
                this.RefreshBoard();
                break;

            case "color":
            case "chat":
            case "revealed":
                break;

            case "error":
                if (this.Connected)
                {
                    this.LogChat(Dialog.Clean("bingoclient_connect_retrying"));
                    this.Reconnect();
                }
                else
                {
                    this.LogChat(Dialog.Clean("bingoclient_connect_tryagain"));
                    this.Disconnect();
                }
                break;

            default:
                Logger.Log("BingoClient", $"Unknown message {msg.type}");
                break;
            }
        }
Пример #2
0
        private void RefreshBoard()
        {
            var board = this.GetBoard();

            this.Board = new List <BingoSquare>();
            for (int i = 0; i < 25; i++)
            {
                this.Board.Add(new BingoSquare {
                    Idx = i,
                });
            }

            foreach (var square in board)
            {
                int i = int.Parse(square.slot.Substring(4)) - 1;
                this.Board[i].Colors = new List <BingoColors>(BingoEnumExtensions.ParseColors(square.colors));
                this.Board[i].Text   = square.name;
            }

            this.RefreshObjectives();
        }