Exemplo n.º 1
0
        public GameCore(IRandomNumberGenerator randomNumberGenerator, ILeaderBoard leaderBoard)
        {
            _randomNumberGenerator =
                randomNumberGenerator ?? throw new ArgumentNullException(nameof(randomNumberGenerator));

            _leaderBoard = leaderBoard ?? throw new ArgumentNullException(nameof(leaderBoard));
        }
Exemplo n.º 2
0
        public leaderboarddata GetLeaderBoardData(int id, ILeaderBoard lb)
        {
            leaderboarddata lbd = null;

            leaderboard dbLb = this.GetLeaderBoard(lb);

            if (!this.idToLeaderBoardData.TryGetValue(this.GetLookupKey(id, lb.LeaderBoardKey), out lbd))
            {
                lbd = new leaderboarddata {
                    isPlayer = lb.IsPlayerBoard, leaderboard = dbLb, year = this.year
                };

                if (lb.IsPlayerBoard)
                {
                    lbd.playerId = id;
                }
                else
                {
                    lbd.teamId = id;
                }

                dbLb.leaderboarddatas.Add(lbd);
                this.boardToData[dbLb.key].Add(lbd);
            }

            return(lbd);
        }
        /// <summary>
        /// Cleans up board datas
        /// </summary>
        private void CleanUpLeaderBoardDatas <T>(IEnumerable <int> ids, ILeaderBoard board)
        {
            var lookup = new HashSet <int>(ids);

            var datas = new List <leaderboarddata>(this.lbc.GetBoardData(board.LeaderBoardKey));

            foreach (var d in datas)
            {
                int id = board.IsPlayerBoard ? d.playerId.Value : d.teamId.Value;

                if (!lookup.Contains(id))
                {
                    this.lbc.DeleteLeaderBoardData(id, board.LeaderBoardKey);
                }
            }
        }
Exemplo n.º 4
0
        public leaderboard GetLeaderBoard(ILeaderBoard lb)
        {
            leaderboard dbLb = null;

            if (!keyToLeaderBoard.TryGetValue(lb.LeaderBoardKey, out dbLb))
            {
                dbLb = new leaderboard
                {
                    key           = lb.LeaderBoardKey,
                    isPlayerBoard = lb.IsPlayerBoard,
                };

                dbLb = this.db.leaderboards.Add(dbLb);
                this.boardToData[dbLb.key] = new HashSet <leaderboarddata>();

                keyToLeaderBoard[lb.LeaderBoardKey] = dbLb;
            }

            dbLb.name       = lb.LeaderBoardName;
            dbLb.formatType = lb.Format.PersistedKey;
            dbLb.priority   = lb.Priority;

            return(dbLb);
        }
Exemplo n.º 5
0
 public GameFactory()
 {
     leaderBoard = new LeaderBoard();
     cachedSaves = new Dictionary <Guid, IGame>();
 }
Exemplo n.º 6
0
 public async Task JoinGame(Ulid leaderBoardId)
 {
     _leaderBoardGrain       = GrainFactory.GetGrain <ILeaderBoard>(leaderBoardId.ToGuid());
     State.CurrentJoinedGame = leaderBoardId;
     await WriteStateAsync();
 }
Exemplo n.º 7
0
 public LbServiceController(ILeaderBoard leaderBoard)
 {
     _leaderBoard = leaderBoard;
 }