Exemplo n.º 1
0
        public PlayersSyncResult(
            IEnumerable <PlayerRow> playerRows,
            IEnumerable <Player> players)
        {
            var playerRowsByID = playerRows.ToDictionary(r => r.ID);
            var playersByID    = players.ToDictionary(p => p.ID);

            DefunctPlayerRows = playerRowsByID.Values
                                .Where(r => !playersByID.ContainsKey(r.ID))
                                .ToArray();
            NewPlayerRows = PlayerRow.CreateRows(playersByID.Values
                                                 .Where(p => !playerRowsByID.ContainsKey(p.ID)))
                            .ToArray();

            var updatedPlayerRows = new List <PlayerRow>();

            foreach (var player in playersByID.Values)
            {
                if (playerRowsByID.TryGetValue(player.ID, out PlayerRow playerRow) &&
                    !player.Matches(playerRow))
                {
                    player.CopyTo(playerRow);
                    updatedPlayerRows.Add(playerRow);
                }
            }
            UpdatedPlayerRows = updatedPlayerRows;
        }
Exemplo n.º 2
0
    List <PlayerMeta> ValidatePlayers()
    {
        List <PlayerMeta> playersToActivate = new List <PlayerMeta>();

        for (int i = 0; i < playersRow.Length; i++)
        {
            PlayerRow currPlayerRow      = playersRow[i];
            bool      isLeftKeyAssigned  = currPlayerRow.Left.text.Length > 0;
            bool      isRightKeyAssigned = currPlayerRow.Right.text.Length > 0;
            bool      oneKeyIsMissing    = (isLeftKeyAssigned && !isRightKeyAssigned) || (!isLeftKeyAssigned && isRightKeyAssigned);

            if (oneKeyIsMissing)
            {
                throw new System.Exception(currPlayerRow.PlayerName.text + " - please choose keys");
            }

            if (isLeftKeyAssigned && isRightKeyAssigned)
            {
                PlayerMeta pm = new PlayerMeta();
                pm.LeftKey     = currPlayerRow.Left.text;
                pm.RightKey    = currPlayerRow.Right.text;
                pm.playerColor = currPlayerRow.getPlayerColor();
                playersToActivate.Add(pm);
            }
        }

        if (playersToActivate.Count < 1)
        {
            throw new System.Exception("At least one player is required.");
        }

        return(playersToActivate);
    }
Exemplo n.º 3
0
        public void CreateRow()
        {
            var player = new Player
            {
                ID             = "jamesle01",
                FeedUrl        = "https://www.basketball-reference.com/players/j/",
                Name           = "LeBron James",
                FirstSeason    = 2004,
                LastSeason     = 2020,
                Position       = "F-G",
                HeightInInches = 81,
                WeightInPounds = 250,
                BirthDate      = new DateTime(1984, 12, 30).AsUtc(),
            };
            var playerRow = PlayerRow.CreateRow(player, DateTime.UtcNow);

            Assert.AreEqual("0", playerRow.PartitionKey);
            Assert.AreEqual("jamesle01", playerRow.ID);
            Assert.AreEqual("https://www.basketball-reference.com/players/j/", playerRow.FeedUrl);
            Assert.AreEqual("https://www.basketball-reference.com/players/j/jamesle01.html", playerRow.GetProfileUrl());
            Assert.AreEqual("LeBron James", playerRow.Name);
            Assert.AreEqual(2004, playerRow.FirstSeason);
            Assert.AreEqual(2020, playerRow.LastSeason);
            Assert.AreEqual("F-G", playerRow.Position);
            Assert.AreEqual(81, playerRow.HeightInInches);
            Assert.AreEqual(250, playerRow.WeightInPounds);
            Assert.AreEqual(new DateTime(1984, 12, 30).AsUtc(), playerRow.BirthDate);
        }
Exemplo n.º 4
0
    private void AddPlayerRowToContainer(Player player, Transform container)
    {
        GameObject rowObject = Instantiate(playerRowPrefab, container);
        PlayerRow  row       = rowObject.GetComponent <PlayerRow>();

        row.SetNickname(player.NickName);
    }
Exemplo n.º 5
0
 /**
  * make every player out of focus,
  * used when you want to focus new player.
  */
 public void BlurAllPlayers()
 {
     for (int i = 0; i < playersRow.Length; i++)
     {
         PlayerRow currP = playersRow[i];
         currP.turnOff();
     }
 }
Exemplo n.º 6
0
        public Task RequeuePlayerRow(PlayerRow playerRow, int syncSeason, bool syncFoundChanges)
        {
            var batchOperation = new TableBatchOperation();

            batchOperation.Delete(playerRow);
            batchOperation.Insert(playerRow.CreateRequeuedRow(DateTime.UtcNow, syncSeason, syncFoundChanges));

            return(_playersTable.ExecuteBatchAsync(batchOperation));
        }
Exemplo n.º 7
0
    void HandleOnPlayerAdded(Player player)
    {
        PlayerRow row = new PlayerRow(player);

        rowHolder.AddChild(row);
        rows.Add(row);

        UpdateRowPositions();
    }
Exemplo n.º 8
0
 /// <summary>
 /// Inits the references.
 /// </summary>
 public override void OnStartClient()
 {
     base.OnStartClient();
     DontDestroyOnLoad(gameObject);
     playerList  = FindObjectOfType <MenuPlayerList>();
     menuManager = FindObjectOfType <MenuManager>();
     SceneManager.activeSceneChanged += SceneChanged;
     playerRow        = Instantiate(playerRowPrefab, playerList.transform);
     playerRow.player = this;
 }
Exemplo n.º 9
0
    public static void SetupPlayerRowPositionOnBoard(PlayerRow playerRow, int row_index)
    {
        Vector3 position = playerRow.transform.position;

        // Have to deal with the row index
        // Only in the context of a player row
        position.z += row_index * 0.5f;

        playerRow.transform.position = position;
    }
Exemplo n.º 10
0
            public PlayerRow AddPlayerRow(string Name, int ReplayID)
            {
                PlayerRow rowPlayerRow = ((PlayerRow)(this.NewRow()));

                rowPlayerRow.ItemArray = new object[] {
                    null,
                    Name,
                    ReplayID
                };
                this.Rows.Add(rowPlayerRow);
                return(rowPlayerRow);
            }
Exemplo n.º 11
0
        public void CreateRows()
        {
            var players = Enumerable.Range(0, 50)
                          .Select(i => new Player {
                ID = i.ToString(), Name = $"player {i}"
            });
            var playerRows = PlayerRow.CreateRows(players).ToArray();

            Assert.AreEqual(50, playerRows.Length);
            CollectionAssert.AreEqual(
                players.Select(f => f.ID).ToArray(),
                playerRows.Select(r => r.ID).ToArray());
            Assert.IsTrue(playerRows.All(r => r.PartitionKey == "0"));
            Assert.AreEqual(playerRows.Length, playerRows.Select(r => r.RowKey).Distinct().Count());
        }
Exemplo n.º 12
0
    /**
     * Return if a color still has to be well placed or not
     */
    public bool IsColorFullyFound(BallManager.Color ball_color, PlayerRow current_player_row)
    {
        int         color_count  = this.CountColor(ball_color);
        List <Ball> player_balls = current_player_row.GetBalls();

        for (int x = 0, y = this.m_balls.Count - 1; x < this.m_balls.Count; x++, y--)
        {
            if (player_balls[x].GetColor() == ball_color && player_balls[x].Equals(this.m_balls[y]))
            {
                color_count--;
            }
        }

        return(color_count == 0);
    }
Exemplo n.º 13
0
        public async Task <Player> Save(Player player)
        {
            const string query = @"INSERT INTO dbo.Player (Name, ZoneId, ChampionId, GameId)
                                    VALUES
                                    (@Name, @ZoneId, @ChampionId, @GameId);
                                    SELECT SCOPE_IDENTITY();";

            PlayerRow row = PlayerRow.FromDomain(player);
            int       id  = row.Id;

            using (var conn = new SqlConnection(_connectionStr))
            {
                id = (await conn.QueryAsync <int>(query, row)).First();
            }
            return(await GetById(id));
        }
Exemplo n.º 14
0
        public Task <IList <PlayerRow> > GetNextPlayerRows(
            int rowLimit, TimeSpan minimumTimeSinceLastSync)
        {
            // Rows are always returned in ascending order by partition key, then row key. A row's row key
            // equals the ticks of the row's last sync time (or a later deprioritized time for players who
            // are probably retired), so this returns the rows most needing a sync.
            string rowKeyCutoff = PlayerRow.GetRowKey(DateTime.UtcNow.Subtract(minimumTimeSinceLastSync));
            var    query        = new TableQuery <PlayerRow>().Where(
                TableQuery.CombineFilters(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, "0"),
                    TableOperators.And,
                    TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.LessThanOrEqual, rowKeyCutoff)))
                                  .Take(rowLimit);

            return(_playersTable.ExecuteQueryAsync(query));
        }
Exemplo n.º 15
0
    private void UpdatePlayerList()
    {
        // Remove existing rows

        PlayerRow[] oldPlayerRows = FindObjectsOfType <PlayerRow>();

        foreach (PlayerRow oldPlayerRow in oldPlayerRows)
        {
            Destroy(oldPlayerRow.gameObject);
        }

        int i = 0;

        // Create list of players
        foreach (Player player in serverController.game.players)
        {
            GameObject playerRowInstance = Instantiate(playerRow, playerList.transform, false);

            // Put rows under eachother
            RectTransform playerRowRectTransform = playerRowInstance.GetComponent <RectTransform>();
            playerRowRectTransform.localPosition -= new Vector3(0, height * i, 0);

            PlayerRow playerRowComponent = playerRowInstance.GetComponent <PlayerRow>();
            playerRowComponent.playerName = player.name;
            playerRowComponent.ip         = player.ip;
            playerRowComponent.isHost     = player.isHost;
            if (serverController.playerName == player.name && serverController.playerIp == player.ip)
            {
                playerRowComponent.isPlayer = true;
            }

            if (serverController.isHost)
            {
                if (!player.isHost)
                {
                    playerRowComponent.canKick = true;
                }
            }

            i++;
        }
        playerListContentTransform.sizeDelta = new Vector2(playerListContentTransform.sizeDelta.x, height * i);
    }
Exemplo n.º 16
0
        public void GetNextSyncSeasonForRetiredPlayer()
        {
            var playerRow = new PlayerRow
            {
                ID          = "testte01",
                FeedUrl     = "https://www.basketball-reference.com/players/j/",
                Name        = "test test",
                FirstSeason = 2000,
                LastSeason  = 2010,
            };

            Assert.AreEqual(playerRow.FirstSeason, playerRow.GetNextSyncSeason());

            playerRow.LastSyncSeason = playerRow.FirstSeason;
            Assert.AreEqual(playerRow.FirstSeason + 1, playerRow.GetNextSyncSeason());

            playerRow.LastSyncSeason = playerRow.LastSeason;
            Assert.AreEqual(playerRow.FirstSeason, playerRow.GetNextSyncSeason());
        }
Exemplo n.º 17
0
        public void GetNextSyncSeasonForActivePlayer()
        {
            var utcNow    = DateTime.UtcNow;
            var playerRow = new PlayerRow
            {
                ID          = "testte01",
                FeedUrl     = "https://www.basketball-reference.com/players/j/",
                Name        = "test test",
                FirstSeason = utcNow.Year - 10,
                LastSeason  = utcNow.Year,
            };

            Assert.AreEqual(playerRow.FirstSeason, playerRow.GetNextSyncSeason());

            playerRow.LastSyncSeason = playerRow.FirstSeason;
            Assert.AreEqual(playerRow.FirstSeason + 1, playerRow.GetNextSyncSeason());

            playerRow.LastSyncSeason = playerRow.LastSeason;
            Assert.AreEqual(playerRow.LastSeason, playerRow.GetNextSyncSeason());
        }
Exemplo n.º 18
0
        public void CreateRequeuedRowForRetiredPlayer()
        {
            var utcNow = DateTime.UtcNow;
            var player = new Player
            {
                ID          = "testte01",
                FeedUrl     = "https://www.basketball-reference.com/players/j/",
                Name        = "test test",
                FirstSeason = 2000,
                LastSeason  = 2010,
            };
            var playerRow = PlayerRow.CreateRow(player, utcNow);

            Assert.AreEqual(playerRow.FirstSeason, playerRow.GetNextSyncSeason());
            Assert.AreEqual(null, playerRow.LastSyncSeason);
            Assert.AreEqual(null, playerRow.LastSyncTimeUtc);
            Assert.AreEqual(null, playerRow.LastSyncWithChangesTimeUtc);
            Assert.AreEqual(PlayerRow.GetRowKey(utcNow), playerRow.RowKey);

            for (int i = 0; i < 10; ++i)
            {
                playerRow = playerRow.CreateRequeuedRow(utcNow.AddTicks(i), playerRow.FirstSeason + i, syncFoundChanges: true);
                Assert.AreEqual(playerRow.FirstSeason + i + 1, playerRow.GetNextSyncSeason());
                Assert.AreEqual(playerRow.FirstSeason + i, playerRow.LastSyncSeason);
                Assert.AreEqual(utcNow.AddTicks(i), playerRow.LastSyncTimeUtc);
                Assert.AreEqual(utcNow.AddTicks(i), playerRow.LastSyncWithChangesTimeUtc);
                Assert.AreEqual(PlayerRow.GetRowKey(utcNow.AddTicks(i)), playerRow.RowKey);
            }

            playerRow = playerRow.CreateRequeuedRow(utcNow.AddTicks(10), playerRow.FirstSeason + 10, syncFoundChanges: true);
            Assert.AreEqual(playerRow.FirstSeason, playerRow.GetNextSyncSeason());
            Assert.AreEqual(playerRow.LastSeason, playerRow.LastSyncSeason);
            Assert.AreEqual(utcNow.AddTicks(10), playerRow.LastSyncTimeUtc);
            Assert.AreEqual(utcNow.AddTicks(10), playerRow.LastSyncWithChangesTimeUtc);
            // Deprioritized due to being retired.
            Assert.AreEqual(PlayerRow.GetRowKey(utcNow.AddTicks(10).AddDays(180)), playerRow.RowKey);
        }
Exemplo n.º 19
0
 public void AddPlayerRow(PlayerRow row) {
     this.Rows.Add(row);
 }
Exemplo n.º 20
0
 public PlayerRowChangeEvent(PlayerRow row, DataRowAction action) {
     this.eventRow = row;
     this.eventAction = action;
 }
        /// <summary>
        /// Updates the scaleform settings.
        /// </summary>
        /// <returns></returns>
        private async Task UpdateScale()
        {
            List <PlayerRow> rows = new List <PlayerRow>();

            for (var x = 0; x < 150; x++) // cleaning up in case of a reload, this frees up all ped headshot handles :)
            {
                UnregisterPedheadshot(x);
            }

            var amount = 0;

            foreach (Player p in new PlayerList())
            {
                if (IsRowSupposedToShow(amount))
                {
                    PlayerRow row = new PlayerRow(); // Set as a blank PlayerRow obj

                    if (playerConfigs.ContainsKey(p.ServerId))
                    {
                        row = new PlayerRow()
                        {
                            color                = 111,
                            crewLabelText        = playerConfigs[p.ServerId].crewName,
                            friendType           = ' ',
                            iconOverlayText      = "",
                            jobPointsDisplayType = playerConfigs[p.ServerId].showJobPointsIcon ? PlayerRow.DisplayType.ICON :
                                                   (playerConfigs[p.ServerId].jobPoints >= 0 ? PlayerRow.DisplayType.NUMBER_ONLY : PlayerRow.DisplayType.NONE),
                            jobPointsText = playerConfigs[p.ServerId].jobPoints >= 0 ? playerConfigs[p.ServerId].jobPoints.ToString() : "",
                            name          = p.Name.Replace("<", "").Replace(">", "").Replace("^", "").Replace("~", "").Trim(),
                            rightIcon     = (int)PlayerRow.RightIconType.RANK_FREEMODE,
                            rightText     = $"{p.ServerId}",
                            serverId      = p.ServerId,
                        };
                    }
                    else
                    {
                        row = new PlayerRow()
                        {
                            color                = 111,
                            crewLabelText        = "",
                            friendType           = ' ',
                            iconOverlayText      = "",
                            jobPointsDisplayType = PlayerRow.DisplayType.NUMBER_ONLY,
                            jobPointsText        = "",
                            name      = p.Name.Replace("<", "").Replace(">", "").Replace("^", "").Replace("~", "").Trim(),
                            rightIcon = (int)PlayerRow.RightIconType.RANK_FREEMODE,
                            rightText = $"{p.ServerId}",
                            serverId  = p.ServerId,
                        };
                    }

                    //Debug.WriteLine("Checking if {0} is in the Dic. Their SERVER ID {1}.", p.Name, p.ServerId);
                    if (textureCache.ContainsKey(p.ServerId))
                    {
                        row.textureString = textureCache[p.ServerId];
                    }
                    else
                    {
                        //Debug.WriteLine("Not in setting image to blank");
                        row.textureString = "";
                    }

                    rows.Add(row);
                }
                amount++;
            }
            rows.Sort((row1, row2) => row1.serverId.CompareTo(row2.serverId));
            for (var i = 0; i < maxClients * 2; i++)
            {
                scale.CallFunction("SET_DATA_SLOT_EMPTY", i);
            }
            var index = 0;

            foreach (PlayerRow row in rows)
            {
                if (row.crewLabelText != "")
                {
                    scale.CallFunction("SET_DATA_SLOT", index, row.rightText, row.name, row.color, row.rightIcon, row.iconOverlayText, row.jobPointsText,
                                       $"..+{row.crewLabelText}", (int)row.jobPointsDisplayType, row.textureString, row.textureString, row.friendType);
                }
                else
                {
                    scale.CallFunction("SET_DATA_SLOT", index, row.rightText, row.name, row.color, row.rightIcon, row.iconOverlayText, row.jobPointsText,
                                       "", (int)row.jobPointsDisplayType, row.textureString, row.textureString, row.friendType);
                }
                index++;
            }

            await Delay(0);
        }
Exemplo n.º 22
0
        public static void GetPlayerTeam(string teamAcronym, IEnumerable <string> nameAcronyms, PlayerRow playerRow)
        {
            if (playerRow.TeamAcronym == null)
            {
                playerRow.TeamAcronym = teamAcronym;
            }

            if (nameAcronyms.Contains("TOT"))
            {
                playerRow.TeamAcronym = null;
            }

            if (PreviousName == playerRow.Name)
            {
                playerRow.IsSubTotal = true;
            }

            PreviousName = playerRow.Name;
        }
Exemplo n.º 23
0
 public void AddPlayerRow(PlayerRow row)
 {
     this.Rows.Add(row);
 }
Exemplo n.º 24
0
 public void RemovePlayerRow(PlayerRow row)
 {
     this.Rows.Remove(row);
 }
Exemplo n.º 25
0
 public PlayerRowChangeEvent(PlayerRow row, DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
Exemplo n.º 26
0
 public PlayerRowChangeEvent(PlayerRow row, global::System.Data.DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }
Exemplo n.º 27
0
    void HandleOnPlayerAdded(Player player)
    {
        PlayerRow row = new PlayerRow(player);
        rowHolder.AddChild(row);
        rows.Add(row);

        UpdateRowPositions();
    }
Exemplo n.º 28
0
 public void RemovePlayerRow(PlayerRow row) {
     this.Rows.Remove(row);
 }