コード例 #1
0
 private void FetchGames()
 {
     var asyncDelegation = new AsyncDelegation(restService);
     asyncDelegation.Get<Hashes>("list", new { q = "list" })
         .WhenFinished(
             result =>
             {
             // Web games Section
             var tGroup = new TableItemGroup{ Name = "Active Games"};
             foreach(var hash in result)
             {
                 tGroup.Items.Add(hash["name"].ToString());
                 tGroup.ItemIds.Add(new Guid(hash["id"].ToString()));
             }
             _games.Clear();
             _games.Add(tGroup);
             InvokeOnMainThread(GamesTable.ReloadData);
         });
     asyncDelegation.Go();
 }
コード例 #2
0
        void UpdateView(Game game)
        {
            Title = game.Name;
            _game = game;
            _whiteCards.Clear ();

            if (game.IsStarted) {
                BlackCard.Text = game.CurrentBlackCard;
            } else {
                BlackCard.Text = "waiting on round to start";
                return;
            }

            WhiteCardTable.AllowsSelection = false;
            // Web games Section
            var tGroup = new TableItemGroup{ Name = "Select a card to play"};

            TableItemGroup status = null;
            if (game.Players.Any (p => p.Id == Application.PlayerId)) {

                var player = game.Players.First (p => p.Id == Application.PlayerId);

                if (string.IsNullOrWhiteSpace (player.SelectedWhiteCardId)) {
                    tGroup = new TableItemGroup{ Name = "Select a card to play"};
                    Title = tGroup.Name;
                    foreach (var whiteCard in player.Cards) {
                        tGroup.Items.Add (whiteCard);
                        tGroup.ItemIds.Add (whiteCard);

                        WhiteCardTable.AllowsSelection = true;
                    }
                } else {
                    tGroup = new TableItemGroup{ Name = "You're selection:"};
                    tGroup.Items.Add (player.SelectedWhiteCardId);
                    status = new TableItemGroup{ Name = "Waiting for the Czar to pick winner..."};
                }

                PointsLabel.Text = string.Format ("{0}", player.AwesomePoints);

                if (!string.IsNullOrWhiteSpace (game.WinningCardId)) {

                    if (game.WinningCardId == player.SelectedWhiteCardId) {
                        status = new TableItemGroup{ Name = "You're the winner!"};
                    } else {
                        status = new TableItemGroup{ Name = "Winner Selected"};
                        status.Items.Add (game.WinningCardId);
                    }

                    tGroup = new TableItemGroup{ Name = "Cards Played:"};
                    foreach (var oPlayer in game.Players) {
                        var card = oPlayer.SelectedWhiteCardId;
                        if (string.IsNullOrWhiteSpace (card))
                            continue;
                        tGroup.Items.Add (card);
                    }
                }

                if (game.IsReadyForReview && !player.IsReady) {
                    if(status == null)
                    {
                        status = new TableItemGroup{ Name = "You're the Czar!"};
                    }
                    shouldPool = false;
                    var alert = new UIAlertView(status.Name, "Next round will start when everyone is ready", null, "OK", null);
                    alert.Clicked += (sender, e) => {
                        ReadyForNextRound();
                    };
                    alert.Show();
                }
                _isCzar = player.IsCzar;

                if(player.IsCzar){
                    status = null;
                    Title = "You're the Czar!";
                    tGroup = new TableItemGroup{ Name = "Choices so far:"};
                    foreach (var oPlayer in game.Players) {
                        var card = oPlayer.SelectedWhiteCardId;
                        if (string.IsNullOrWhiteSpace (card))
                            continue;
                        tGroup.Items.Add (card);
                        tGroup.ItemIds.Add (card);
                    }
                    if(game.IsReadyForScoring)
                    {
                        WhiteCardTable.AllowsSelection = true;
                        Title = tGroup.Name = "Select a winner";
                    }

                    if(game.IsReadyForReview){
                        Title = "Round Ended";
                        tGroup = new TableItemGroup{ Name = "Next round will start when everyone is ready"};
                        status = null;
                    }
                }
            }
            if (status != null)
                _whiteCards.Add (status);
            _whiteCards.Add (tGroup);
            WhiteCardTable.ReloadData ();
        }