Example #1
0
    public static void _Store_258(object val, GameStore gs)
    {
        MethodBase base2 = val as MethodBase;

        StoreExtendPlugin._Store_21(base2.DeclaringType, gs);
        gs.WriteString(base2.Name);
    }
Example #2
0
        public async Task <Player> Register(NewPlayer model, bool sudo = false)
        {
            var game = await GameStore.Retrieve(model.GameId);

            if (!sudo && !game.RegistrationActive)
            {
                throw new RegistrationIsClosed();
            }

            var user = await Store.GetUserEnrollments(model.UserId);

            if (user.Enrollments.Any(p => p.GameId == model.GameId))
            {
                throw new AlreadyRegistered();
            }

            var entity = Mapper.Map <Data.Player>(model);

            entity.TeamId         = Guid.NewGuid().ToString("n");
            entity.Role           = PlayerRole.Manager;
            entity.ApprovedName   = user.ApprovedName;
            entity.Name           = user.ApprovedName;
            entity.Sponsor        = user.Sponsor;
            entity.SessionMinutes = game.SessionMinutes;

            await Store.Create(entity);

            return(Mapper.Map <Player>(entity));
        }
Example #3
0
    public static void _Store_247(object val, GameStore gs)
    {
        FieldInfo info = val as FieldInfo;

        StoreExtendPlugin._Store_21(info.DeclaringType, gs);
        gs.WriteString(info.Name);
    }
Example #4
0
 public ViewModel()
 {
     this.genres    = new ObservableCollection <Genre>();
     this.companies = new ObservableCollection <GameCompany>();
     this.games     = new ObservableCollection <Game>();
     store          = new GameStore();
 }
Example #5
0
        public async Task LeaveGame(string gameCode)
        {
            await Groups.RemoveFromGroupAsync(Context.ConnectionId, gameCode);

            Game game   = GameStore.GetGame(gameCode);
            var  player = game.Players.FirstOrDefault(e => e.ConnectionId == Context.ConnectionId);

            if (player == null || game.Status == GameStatus.Completed)
            {
                return;
            }
            if (game.Status == GameStatus.NotStarted)
            {
                game.Players.Remove(player);
                if (game.Players.Count == 0)
                {
                    GameStore.RemoveGame(gameCode);
                    await Clients.Group(GameList).GameListUpdated(GameStore.GetGames());
                }

                return;
            }

            player.ChallengesRemaining = 0;
            if (game.Players.Count == 1)
            {
                game.Status = GameStatus.Completed;
            }
        }
Example #6
0
        //[Command("balance")]
        public Task balance()
        {
            var       guild = Context.Guild.Id;
            var       user  = Context.User.Id;
            GameStore myStore;

            if (System.IO.File.Exists(Environment.CurrentDirectory + "\\cache\\" + guild + "\\game.json"))
            {
                myStore = JsonConvert.DeserializeObject <GameStore>(
                    System.IO.File.ReadAllText(Environment.CurrentDirectory + "\\cache\\" + guild + "\\game.json"));
            }
            else
            {
                myStore          = new GameStore();
                myStore.profiles = new Dictionary <ulong, UserProfile>();
            }

            UserProfile u = null;

            if (myStore.profiles.ContainsKey(user))
            {
                u = myStore.profiles[user];
            }
            else
            {
                u = new UserProfile();
                myStore.profiles.Add(user, u);
            }

            myStore.profiles[user] = u;
            System.IO.File.WriteAllText(Environment.CurrentDirectory + "\\cache\\" + guild + "\\game.json",
                                        JsonConvert.SerializeObject(myStore));
            return(ReplyAsync("Balance for " + Context.User.Mention + " is " +
                              u.credits + " credits."));
        }
Example #7
0
 public static void _Store_4125(Rect val, GameStore gs)
 {
     gs.WriteSingle(val.x);
     gs.WriteSingle(val.y);
     gs.WriteSingle(val.width);
     gs.WriteSingle(val.height);
 }
Example #8
0
 public static void _Store_221(Color val, GameStore gs)
 {
     gs.WriteSingle(val.r);
     gs.WriteSingle(val.g);
     gs.WriteSingle(val.b);
     gs.WriteSingle(val.a);
 }
Example #9
0
 public static void _Store_34(Quaternion val, GameStore gs)
 {
     gs.WriteSingle(val.x);
     gs.WriteSingle(val.y);
     gs.WriteSingle(val.z);
     gs.WriteSingle(val.w);
 }
Example #10
0
    private void Build()
    {
        if (!canBuild || manageDialog.IsPointerOverBuildingDialog())
        {
            return;
        }
        if (!Economy.CanBuy(selectedBuildingUnit.price))
        {
            return;
        }

        GameObject newBuildingObject = Instantiate(
            buildingPrefab,
            createdBuildings.transform,
            true
            );

        buildingsTileMap.SetTile(currentCell, currentBuildingTile);
        // GameStore.SetBuildingPosition(currentArea);
        newBuildingObject.GetComponent <Building>()
        .SetInitialValues(currentArea, resourcesMap, selectedBuildingUnit);

        foreach (var boundCell in currentArea.allPositionsWithin)
        {
            // Add building position/bound to list
            GameStore.SetBuildingPosition(boundCell);
        }
    }
Example #11
0
        public ActionResult Join(string id)
        {
            Guid guidId = Guid.Empty;

            if (!Guid.TryParse(id, out guidId))
            {
                return(StatusCode((int)System.Net.HttpStatusCode.NotFound));
            }

            var selected      = this.GameStore.LoadById(guidId);
            var joiningPlayer = this.PlayerStore.GetPlayer(this.User);

            if (selected == null)
            {
                return(StatusCode((int)System.Net.HttpStatusCode.NotFound));
            }

            if (!selected.CanJoin(joiningPlayer))
            {
                return(StatusCode((int)System.Net.HttpStatusCode.NotAcceptable));
            }

            selected.AddPlayer(joiningPlayer);
            GameStore.Save(selected);

            return(selected.State == GameStatus.ReadyToStart ?
                   StatusCode((int)System.Net.HttpStatusCode.Created) :
                   StatusCode((int)System.Net.HttpStatusCode.OK));
        }
Example #12
0
        public static IReadOnlyList <SystemTrayAction> FindAllActions()
        {
            var actions = new List <SystemTrayAction>
            {
                new SystemTrayAction {
                    Name = "Profile", Action = () => { Process.Start(OpenProfile); }
                },
                new SystemTrayAction {
                    Name = "Control Panel", Action = () => { Process.Start(OpenControlPanel); }
                },
                new SystemTrayAction {
                    Name = "Refresh Games", Action = () => { GameStore.ReloadGamesFromCentralRepository(); }
                },
                new SystemTrayAction {
                    Name = "Rematch Process Sessions", Action = () => { new UserActivityBackfiller().Backfill(); }
                },
            };

            if (!AddToStartupAction.ShortcutExists())
            {
                actions.Add(new SystemTrayAction {
                    Name = "Add to startup", Action = () => { AddToStartupAction.Execute(); }
                });
            }

            actions.Add(new SystemTrayAction {
                Name = "Exit", Action = () => { Application.Exit(); Program.CloseServiceToken.Cancel(); }
            });

            return(actions);
        }
        public GameTrackerService()
        {
            GamesDataUpdateTimer = new System.Timers.Timer(TimeSpan.FromDays(1).TotalMilliseconds)
            {
                AutoReset = true
            };
            GamesDataUpdateTimer.Elapsed += (sender, args) => GameStore.ReloadGamesFromCentralRepository();

            ProcessScannerTimer = new System.Timers.Timer(AppSettings.Instance.ProcessScanIntervalInSeconds * 1000)
            {
                AutoReset = true
            };
            ProcessScannerTimer.Elapsed += (sender, args) => { new ProcessScanner().ScanProcesses(ProcessScannerTimer); };

            UserActivityFileMonitor = new HostFileChangeMonitor(new[] { UserActivityStore.DataFilePath }.ToList());
            UserActivityFileMonitor.NotifyOnChanged((_) => { AllUserActivityCache.CancellationTokenSource.Cancel(); });

            WebAssetsFileMonitor = new HostFileChangeMonitor(WebAssets.AllAssetPaths.ToArray());
            WebAssetsFileMonitor.NotifyOnChanged((_) => { WebAssets.CancellationTokenSource.Cancel(); });

            WebHost = new WebHostBuilder()
                      .UseKestrel()
                      .UseStartup <WebHostConfiguration>()
                      .UseConfiguration(AppSettings.Instance.Configuration)
                      .UseSerilog()
                      .UseUrls(WebHostListenAddress)
                      .Build();
        }
Example #14
0
        public IActionResult StartGame([FromRoute] string code, string adminCode)
        {
            var game = GameStore.GetGame(code);

            if (game == null)
            {
                return(NotFound());
            }
            if (game.Status != GameStatus.NotStarted)
            {
                return(StatusCode(403, "Can only start unstarted games"));
            }
            if (game.Players.First().ConnectionId != adminCode)
            {
                return(Unauthorized());
            }

            game.Status = GameStatus.NormalTurn;

            TimerStore.SetupAnswerTimeout(game);

            // TODO _gameClient.GameUpdated(game);

            return(Ok());
        }
Example #15
0
        public IActionResult SendAnswer([FromRoute] string code, string playerCode, string answer, string rule)
        {
            var game = GameStore.GetGame(code);

            if (game == null)
            {
                return(NotFound());
            }
            if (game.CurrentPlayer.ConnectionId != playerCode)
            {
                return(Unauthorized());
            }
            if (game.Status == GameStatus.NameAnother && rule != null)
            {
                return(BadRequest("Adding rule not allowed when naming another"));
            }

            game.Turns.Add(new Turn(game.Turns.Count, game.CurrentPlayer, game.Status, answer, rule));
            game.CurrentPlayer = game.FindNextPlayer();

            TimerStore.SetupAnswerTimeout(game);

            // TODO _gameClient.GameUpdated(game);

            return(Ok());
        }
Example #16
0
    public void OnToggleDialog(bool forceClose)
    {
        bool isBuildingModeDialog = dialogType.Equals(DialogType.BuildingModeDialog);

        GameStore.SetOpenedDialog(dialogType);
        Tooltip.OnHideTooltip();
        // hide dialog
        if (gameObject.activeSelf)
        {
            GameStore.SetOpenedDialog(DialogType.Hidden);
            gameObject.SetActive(false);

            // Toggle off build mode
            if (isBuildingModeDialog)
            {
                GridBuildMode.OnToggleBuildMode();
            }

            return;
        }

        if (!forceClose)
        {
            if (isBuildingModeDialog)
            {
                GridBuildMode.OnToggleBuildMode();
            }
            gameObject.SetActive(true);
        }
    }
Example #17
0
    public static void _Store_4134(object val, GameStore gs)
    {
        BitArray array = val as BitArray;

        byte[] buffer = new byte[Mathf.CeilToInt(((float)array.Count) / 8f)];
        array.CopyTo(buffer, 0);
        gs.WriteArray(buffer);
    }
Example #18
0
        public async Task UpdateAvatar(Guid gameId, Guid playerId, Avatar avatar)
        {
            Game g = GameStore.GetGame(gameId);

            g.GetPlayer(playerId).Avatar = avatar;

            await Clients.Group(gameId.ToString()).GameUpdated(g);
        }
Example #19
0
        public async Task JoinGame(Guid gameId)
        {
            await Groups.AddToGroupAsync(Context.ConnectionId, gameId.ToString());

            Game g = GameStore.GetGame(gameId);

            await Clients.Group(gameId.ToString()).GameUpdated(g);
        }
Example #20
0
        public async Task SkipExpeditionVotes(Guid gameId)
        {
            Game g = GameStore.GetGame(gameId);

            g.NextRound();

            await Clients.Group(gameId.ToString()).GameUpdated(g);
        }
        public async Task <ActionResult <ReloadGamesMetadataResponse> > ReloadGames()
        {
            await GameStore.ReloadGamesFromCentralRepository();

            return(new ReloadGamesMetadataResponse {
                Success = true
            });
        }
Example #22
0
        public void AddGame()
        {
            Game g = new Game();

            GameStore.AddGame(g);

            Assert.AreEqual(g, GameStore.Instance.Games[g.Id]);
        }
Example #23
0
        public void DeleteGame()
        {
            Game g = SetupGameStoreWithSingleGame();

            GameStore.DeleteGame(g.Id);

            Assert.AreEqual(0, GameStore.Instance.Games.Keys.Count);
        }
        public async Task SubmitTeam(GameAndPlayerIdDto model)
        {
            Game g = GameStore.GetGame(model.GameId);

            g.CurrentRound.Status = RoundStatus.VotingForTeam;
            GameStore.AddOrUpdateGame(g);
            await _gameHub.Clients.Group(model.GameId.ToString()).SendAsync("UpdateAll");
        }
Example #25
0
        public async Task SkipRevealTeamVotes(Guid gameId)
        {
            Game g = GameStore.GetGame(gameId);

            g.SkipRevealTeamVote();

            await Clients.Group(gameId.ToString()).GameUpdated(g);
        }
        public void EndGame(Guid gameId)
        {
            var gameWrapper = GameStore[gameId];

            GameStore.Remove(gameId);

            GameEnded?.Invoke(this, new GameEndedEvent(gameId, gameWrapper.Player1, gameWrapper.Player2));
        }
Example #27
0
        public async Task SubmitTeamVote(Guid gameId, bool votedSuccess)
        {
            Game g = GameStore.GetGame(gameId);

            g.AddTeamVote(votedSuccess);

            await Clients.Group(gameId.ToString()).GameUpdated(g);
        }
Example #28
0
        public async Task SubmitSelectedTeam(Guid gameId)
        {
            Game g = GameStore.GetGame(gameId);

            g.SubmitCurrentTeam();

            await Clients.Group(gameId.ToString()).GameUpdated(g);
        }
Example #29
0
        public async Task ChangeSelectedTeam(Guid gameId, IEnumerable <Guid> playerIds)
        {
            Game g = GameStore.GetGame(gameId);

            g.SetCurrentTeam(playerIds);

            await Clients.Group(gameId.ToString()).GameUpdated(g);
        }
Example #30
0
        public async Task Assassinate(Guid gameId, Guid assassinationTargetId)
        {
            Game g = GameStore.GetGame(gameId);

            g.Assassinate(assassinationTargetId);

            await Clients.Group(gameId.ToString()).GameUpdated(g);
        }
Example #31
0
        /// <summary>
        /// Get collection of topics
        /// </summary>
        /// <param name="filter">Filter</param>
        /// <returns>Collection of topics</returns>
        public async Task<ICollection<Model.Common.ITopic>> GetRangeAsync(GameStore.Common.GenericFilter filter)
        {
            try
            {
                if (filter == null)
                    filter = new GenericFilter(1, 5);

                return Mapper.Map<ICollection<ITopic>>(await repository.Where<TopicEntity>()
                    .OrderBy(t => t.Title)
                    .Skip((filter.PageNumber * filter.PageSize) - filter.PageSize)
                    .Take(filter.PageSize).ToListAsync());
            }
            catch (Exception ex)
            {

                throw ex;
            }
        }
Example #32
0
        /// <summary>
        /// Get collection of reviews that belong to game
        /// </summary>
        /// <param name="gameId">game FK</param>
        /// <param name="filter">filter option</param>
        /// <returns>Collection of games</returns>
        public async Task<IEnumerable<IReview>> GetAsync(Guid gameId, GameStore.Common.GenericFilter filter)
        {
            try
            {
                if (filter == null)
                    filter = new GenericFilter(1, 5);

                return Mapper.Map<IEnumerable<IReview>>(await repository.Where<ReviewEntity>()
                    .Where(g => g.GameId == gameId)
                    .OrderBy(g => g.Score)
                    .Skip((filter.PageNumber * filter.PageSize) - filter.PageSize)
                    .Take(filter.PageSize).ToListAsync());
            }
            catch (Exception)
            {
                
                throw;
            }
        }
Example #33
0
 public ActionResult Index()
 {
     GameStore gameStoreContext = new GameStore();
     return View();
 }
Example #34
0
 /// <summary>
 /// Get collection of topics
 /// </summary>
 /// <param name="filer">Filter options</param>
 /// <returns>Topic collection</returns>
 public async Task<ICollection<Model.Common.ITopic>> GetRangeAsync(GameStore.Common.GenericFilter filter)
 {
     return await repository.GetRangeAsync(filter);
 }
Example #35
0
 /// <summary>
 /// Get all reviews for game
 /// </summary>
 /// <param name="gameId">Game id</param>
 /// <param name="filter">Filter options</param>
 /// <returns>Collection of games that belong to game with given id</returns>
 public async Task<IEnumerable<IReview>> GetAsync(Guid gameId, GameStore.Common.GenericFilter filter)
 {
     return await repository.GetAsync(gameId, filter);
 }
Example #36
0
 /// <summary>
 /// Get collection of comments that belong to post
 /// </summary>
 /// <param name="postId">Post id to search by</param>
 /// <param name="filter">Filter options</param>
 /// <returns>IEnumerable of comments</returns>
 public async Task<IEnumerable<Model.Common.IComment>> GetRangeAsync(Guid postId, GameStore.Common.GenericFilter filter)
 {
     return await repository.GetRangeAsync(postId, filter);
 }