public void GetPlayerTest() { var playerName = "d03n3rfr1tz3"; using (var service = new PlayerService("http://minecraft.example.com:20059/", "admin", "changeme")) { var player = service.GetPlayer(playerName); Assert.IsNotNull(player); } }
/// <summary> /// Prevents a default instance of the <see cref="Database"/> class from being created. /// Use <see cref="Database.Instance"/> to access the Singleton. /// </summary> /// <param name="filePath">The file path providing the database configuration file.</param> private Database(string filePath) { database = PgDb.Create(filePath); // Init services playerService = PlayerService.GetInstance(database); teamService = TeamService.GetInstance(database); measurementService = MeasurementService.GetInstance(database); featureCategoryService = FeatureCategoryService.GetInstance(database); }
public ActionResult AddScore(string playerId, string gameId, string gameName) { var playerService = new PlayerService(); var score = new Score { GameId = new ObjectId(gameId), GameName = gameName, ScoreDateTime = DateTime.Now, ScoreValue = new Random().Next(0, 100) }; playerService.AddScore(playerId, score); return RedirectToAction("Details", new { id = playerId }); }
protected override void Dispose(bool disposing) { if (disposing) { this.ServiceLoader.EnableComplete -= this.ServiceLoader_EnableComplete; this._blocks = null; this._playerService = null; this.RoomHeight = 0; this.RoomWidth = 0; } base.Dispose(disposing); }
public ActionResult Delete(Player player) { try { var playerService = new PlayerService(); playerService.Delete(player.Id.ToString()); return RedirectToAction("Index"); } catch { return View(); } }
public async Task GetPlayerAsyncTest() { var playerName = "d03n3rfr1tz3"; using (var service = new PlayerService("http://minecraft.example.com:20059/", "admin", "changeme")) { var player = service.GetPlayerAsync(playerName); Assert.IsNotNull(player); await player; Assert.IsNotNull(player.Result); } }
public static void EnsureIntegrity() { var ctx = new GalaxyStormDbContext(); var shardsRepo = new Repository<Shard>(ctx); var playersRepo = new Repository<PlayerObject>(ctx); var usersRepo = new Repository<ApplicationUser>(ctx); var planetsRepo = new Repository<Planet>(ctx); var shardService = new ShardService(playersRepo, shardsRepo); var playerService = new PlayerService(usersRepo,planetsRepo, shardsRepo, playersRepo, null); AllocatePlanets(shardService); AssignPlayerObjects(playerService); }
public ActionResult Create(Player player) { try { if (ModelState.IsValid) { var playerService = new PlayerService(); playerService.Create(player); return RedirectToAction("Index"); } return View(); } catch { return View(); } }
public void AddPlayer() { var players = new List<Player>() { new Player { Code = "AAA" } }; var containerMock = GetContainerMock(players); var service = new PlayerService(containerMock.Object); service.AddPlayer(new Player() { Code = "BBB" }); _playersMock.Verify(m => m.Add(It.IsAny<Player>()), Times.Once()); containerMock.Verify(m => m.SaveChanges(), Times.Once()); var allPlayers = service.GetAllPlayers(); Assert.AreEqual(2, allPlayers.Count); Assert.IsNotNull(allPlayers.FirstOrDefault(p => p.Code == "AAA")); Assert.IsNotNull(allPlayers.FirstOrDefault(p => p.Code == "BBB")); }
public void GetAllPlayers() { var players = new List<Player>() { new Player { Code = "AAA" }, new Player { Code = "BBB" }, new Player { Code = "CCC" }, }; var containerMock = GetContainerMock(players); var service = new PlayerService(containerMock.Object); var allPlayers = service.GetAllPlayers(); containerMock.VerifyGet(m => m.PlayerSet, Times.Once()); Assert.AreEqual(3, allPlayers.Count); Assert.IsNotNull(allPlayers.FirstOrDefault(p => p.Code == "AAA")); Assert.IsNotNull(allPlayers.FirstOrDefault(p => p.Code == "BBB")); Assert.IsNotNull(allPlayers.FirstOrDefault(p => p.Code == "CCC")); }
public LogIn(PlayerService playerService) { this.playerService = playerService; }
/// <summary> /// Method to insert record of a player in database. /// </summary> /// <param name="errorMessage"></param> /// <param name="playerModel"></param> /// <returns></returns> public int PlayersInsert(out string errorMessage, PlayerModel playerModel) { PlayerService playerService = new PlayerService(); return(playerService.PlayersInsert(out errorMessage, playerModel)); }
public void PlayerService_Throw_Exception_If_Steam_API_Key_Is_Null_Or_Empty() { var playerService = new PlayerService(String.Empty); }
public VideoInterfaceController(PlayerService playerService) { _playerService = playerService; }
private static void RunServer() { Data.Data.DataPath = "data/"; Stopwatch sw = Stopwatch.StartNew(); AppDomain.CurrentDomain.UnhandledException += UnhandledException; Console.WriteLine("----===== GameServer =====----\n\n" + "Starting game server\n\n" + "Loading data files.\n" + "-------------------------------------------"); TcpServer = new TcpServer("*", 11101, 1000); Connection.SendAllThread.Start(); OpCodes.Init(); #region global_components //services FeedbackService = new FeedbackService(); AccountService = new AccountService(); PlayerService = new PlayerService(); MapService = new MapService(); ChatService = new ChatService(); VisibleService = new VisibleService(); ControllerService = new ControllerService(); CraftService = new CraftService(); ItemService = new ItemService(); AiService = new AiService(); GeoService = new GeoService(); StatsService = new StatsService(); ObserverService = new ObserverService(); AreaService = new AreaService(); InformerService = new InformerService(); TeleportService = new TeleportService(); PartyService = new PartyService(); SkillsLearnService = new SkillsLearnService(); CraftLearnService = new CraftLearnService(); GuildService = new GuildService(); EmotionService = new EmotionService(); RelationService = new RelationService(); DuelService = new DuelService(); StorageService = new StorageService(); TradeService = new TradeService(); MountService = new MountService(); //engines ActionEngine = new ActionEngine.ActionEngine(); AdminEngine = new AdminEngine.AdminEngine(); SkillEngine = new SkillEngine.SkillEngine(); QuestEngine = new QuestEngine.QuestEngine(); #endregion GlobalLogic.ServerStart(); TcpServer.BeginListening(); try { ServiceApplication = ScsServiceBuilder.CreateService(new ScsTcpEndPoint(23232)); ServiceApplication.AddService <IInformerService, InformerService>((InformerService)InformerService); ServiceApplication.Start(); Log.Info("InformerService started at *:23232."); } catch (Exception ex) { Log.ErrorException("InformerService can not be started.", ex); } sw.Stop(); Console.WriteLine("-------------------------------------------"); Console.WriteLine(" Server start in {0}", (sw.ElapsedMilliseconds / 1000.0).ToString("0.00s")); Console.WriteLine("-------------------------------------------"); }
private void PlaySong() { StartCoroutine(PlayerService.streamSong(identifier, filename.text, isPlaying)); isPlaying = !isPlaying; }
public RegisterPlayers(PlayerService playerService) { this.playerService = playerService; }
protected override void OnCreate(Bundle savedInstanceState) { try { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_game_board); int playerCount = Intent.GetIntExtra("playerCount", 2); int fieldCount = Intent.GetIntExtra("fieldCount", 9); int bombCount = Intent.GetIntExtra("bombCount", 1); int tempFieldCount = fieldCount; TextView textViewNumberOfFields = FindViewById <TextView>(Resource.Id.textViewNumberOfFields); TextView textViewRemainingFields = FindViewById <TextView>(Resource.Id.textViewRemainingFields); TextView textViewNumberOfBombs = FindViewById <TextView>(Resource.Id.textViewNumberOfBombs); TextView textViewCurrentPlayer = FindViewById <TextView>(Resource.Id.textViewCurrentPlayer); TextView textViewResult = FindViewById <TextView>(Resource.Id.textViewResult); textViewResult.Text = ""; textViewNumberOfFields.Text = fieldCount.ToString(); textViewRemainingFields.Text = fieldCount.ToString(); textViewNumberOfBombs.Text = bombCount.ToString(); GridView gridView = FindViewById <GridView>(Resource.Id.gridViewGameBoard); var playerService = new PlayerService(); List <Player> players = playerService.CreatePlayerList(playerCount); var nextPlayer = playerService.GetStartPlayer(players); textViewCurrentPlayer.Text = nextPlayer.PlayerName; gridView.Adapter = new ImageAdapter(this, fieldCount, bombCount); gridView.ItemClick += (sender, e) => { ImageView image = (ImageView)e.View; if ((bool)image.Tag == true) { textViewResult.Text = $"{nextPlayer.PlayerName} LOST"; textViewResult.SetTextColor(new Android.Graphics.Color(128, 0, 0)); EndTheGameAfterLoose(gridView); } else { tempFieldCount--; textViewRemainingFields.Text = tempFieldCount.ToString(); image.SetImageResource(Resource.Drawable.sheep); image.SetOnClickListener(null); if (tempFieldCount == bombCount) { textViewResult.Text = "DRAW!"; textViewResult.SetTextColor(new Android.Graphics.Color(0, 128, 0)); EndTheGameAfterDraw(gridView); } else { nextPlayer = playerService.GetNextPlayer(players, nextPlayer); textViewCurrentPlayer.Text = nextPlayer.PlayerName; } } }; //Restart a game Button buttonRestartGame = FindViewById <Button>(Resource.Id.buttonRestartGame); buttonRestartGame.Click += (sender, e) => { tempFieldCount = fieldCount; textViewRemainingFields.Text = fieldCount.ToString(); textViewResult.Text = ""; gridView.Adapter = new ImageAdapter(this, fieldCount, bombCount); }; } catch (Exception ex) { Toast.MakeText(this, ex.Message, ToastLength.Long); } }
public InitJoinArgs(PlayerService playerService, InitReceiveEvent initReceiveEvent) : base(playerService) { this.InitReceiveEvent = initReceiveEvent; }
void Start() { PlayerService = gameObject.GetComponent <PlayerService>(); }
public ListenLaterViewModel(ListenLaterService listen, PlayerService player) { listenLaterService = listen; playerService = player; Episodes = new ObservableCollection <EpisodeViewModel>(); }
public void Init() { _playerRepositoryMock = new Mock <IRepository <Player> >(); _playerService = new PlayerService(_playerRepositoryMock.Object); }
public PlayerController(PlayerService playerService) { this.playerService = playerService; }
private void BuildPerkDetails() { Model vm = GetDialogCustomData <Model>(); Data.Entity.Perk perk = PerkService.GetPerkByID(vm.SelectedPerkID); PCPerk pcPerk = PerkService.GetPCPerkByID(GetPC().GlobalID, perk.ID); Player player = PlayerService.GetPlayerEntity(GetPC().GlobalID); var perkLevels = DataService.Where <PerkLevel>(x => x.PerkID == perk.ID).ToList(); int rank = pcPerk?.PerkLevel ?? 0; int maxRank = perkLevels.Count(); string currentBonus = "N/A"; string currentFPCost = string.Empty; string currentConcentrationCost = string.Empty; string currentSpecializationRequired = "None"; string nextBonus = "N/A"; string nextFPCost = "N/A"; string nextConcentrationCost = string.Empty; string price = "N/A"; string nextSpecializationRequired = "None"; PerkLevel currentPerkLevel = PerkService.FindPerkLevel(perkLevels, rank); PerkLevel nextPerkLevel = PerkService.FindPerkLevel(perkLevels, rank + 1); SetResponseVisible("PerkDetailsPage", 1, PerkService.CanPerkBeUpgraded(GetPC(), vm.SelectedPerkID)); // Player has purchased at least one rank in this perk. Show their current bonuses. if (rank > 0 && currentPerkLevel != null) { var currentPerkFeat = DataService.SingleOrDefault <PerkFeat>(x => x.PerkID == vm.SelectedPerkID && x.PerkLevelUnlocked == currentPerkLevel.Level); currentBonus = currentPerkLevel.Description; // Not every perk is going to have a perk feat. Don't display this information if not necessary. if (currentPerkFeat != null) { currentFPCost = currentPerkFeat.BaseFPCost > 0 ? (ColorTokenService.Green("Current FP: ") + currentPerkFeat.BaseFPCost + "\n") : string.Empty; // If this perk level has a concentration cost and interval, display it on the menu. if (currentPerkFeat.ConcentrationFPCost > 0 && currentPerkFeat.ConcentrationTickInterval > 0) { currentConcentrationCost = ColorTokenService.Green("Current Concentration FP: ") + currentPerkFeat.ConcentrationFPCost + " / " + currentPerkFeat.ConcentrationTickInterval + "s\n"; } } // If this perk level has required specialization, change the text to that. if (currentPerkLevel.SpecializationID > 0) { // Convert ID to enum, then get the string of the enum value. If we ever get a specialization with // more than one word, another process will need to be used. currentSpecializationRequired = ((SpecializationType)currentPerkLevel.SpecializationID).ToString(); } } // Player hasn't reached max rank and this perk has another perk level to display. if (rank + 1 <= maxRank && nextPerkLevel != null) { var nextPerkFeat = DataService.SingleOrDefault <PerkFeat>(x => x.PerkID == vm.SelectedPerkID && x.PerkLevelUnlocked == rank + 1); nextBonus = nextPerkLevel.Description; price = nextPerkLevel.Price + " SP (Available: " + player.UnallocatedSP + " SP)"; if (nextPerkFeat != null) { nextFPCost = nextPerkFeat.BaseFPCost > 0 ? (ColorTokenService.Green("Next FP: ") + nextPerkFeat.BaseFPCost + "\n") : string.Empty; // If this perk level has a concentration cost and interval, display it on the menu. if (nextPerkFeat.ConcentrationFPCost > 0 && nextPerkFeat.ConcentrationTickInterval > 0) { nextConcentrationCost = ColorTokenService.Green("Next Concentration FP: ") + nextPerkFeat.ConcentrationFPCost + " / " + nextPerkFeat.ConcentrationTickInterval + "s\n"; } } if (nextPerkLevel.SpecializationID > 0) { nextSpecializationRequired = ((SpecializationType)nextPerkLevel.SpecializationID).ToString(); } } var perkCategory = DataService.Get <PerkCategory>(perk.PerkCategoryID); var cooldownCategory = perk.CooldownCategoryID == null ? null : DataService.Get <CooldownCategory>(perk.CooldownCategoryID); string header = ColorTokenService.Green("Name: ") + perk.Name + "\n" + ColorTokenService.Green("Category: ") + perkCategory.Name + "\n" + ColorTokenService.Green("Rank: ") + rank + " / " + maxRank + "\n" + ColorTokenService.Green("Price: ") + price + "\n" + currentFPCost + currentConcentrationCost + (cooldownCategory != null && cooldownCategory.BaseCooldownTime > 0 ? ColorTokenService.Green("Cooldown: ") + cooldownCategory.BaseCooldownTime + "s" : "") + "\n" + ColorTokenService.Green("Description: ") + perk.Description + "\n" + ColorTokenService.Green("Current Bonus: ") + currentBonus + "\n" + ColorTokenService.Green("Requires Specialization: ") + currentSpecializationRequired + "\n" + nextFPCost + nextConcentrationCost + ColorTokenService.Green("Next Bonus: ") + nextBonus + "\n" + ColorTokenService.Green("Requires Specialization: ") + nextSpecializationRequired + "\n"; if (nextPerkLevel != null) { List <PerkLevelSkillRequirement> requirements = DataService.Where <PerkLevelSkillRequirement>(x => x.PerkLevelID == nextPerkLevel.ID).ToList(); if (requirements.Count > 0) { header += "\n" + ColorTokenService.Green("Next Upgrade Skill Requirements:\n\n"); bool hasRequirement = false; foreach (PerkLevelSkillRequirement req in requirements) { if (req.RequiredRank > 0) { PCSkill pcSkill = SkillService.GetPCSkill(GetPC(), req.SkillID); Skill skill = SkillService.GetSkill(pcSkill.SkillID); string detailLine = skill.Name + " Rank " + req.RequiredRank; if (pcSkill.Rank >= req.RequiredRank) { header += ColorTokenService.Green(detailLine) + "\n"; } else { header += ColorTokenService.Red(detailLine) + "\n"; } hasRequirement = true; } } if (requirements.Count <= 0 || !hasRequirement) { header += "None\n"; } } } SetPageHeader("PerkDetailsPage", header); }
public AddJoinArgs(PlayerService playerService, AddReceiveEvent addReceiveEvent) : base(playerService) { this.AddReceiveEvent = addReceiveEvent; }
/// <summary> /// Constructeur principal /// </summary> public DatabasePlayers() { InitializeComponent(); _Service = new PlayerService(); ListPlayers.Title = Culture.Language.DatabaseRessources.DatabasePlayers; }
public ActionResult PlayGames(string id) { var playerService = new PlayerService(); var gameService = new GameService(); var player1 = playerService.GetById(id); var availableGames = gameService.List(100, 0).ToList(); var playergames = new PlayerGames() { Player = player1, AvailableGames = availableGames }; return View(playergames); }
protected override async Task OnParametersSetAsync() { Players = await PlayerService.GetAllPlayersAsync(); await base.OnParametersSetAsync(); }
public PlayerViewModel(int id) { _playerService = new PlayerService(id); _player = _playerService.Player(); }
public PlayerValuesController(PlayerService playerService) { _playerService = playerService; }
public async Task <ActionResult <DateTime> > UploadRequest([FromBody] DsUploadRequest uploadRequest) { var player = await PlayerService.GetPlayerName(context, uploadRequest); return(player.LatestReplay); }
// // GET: /Player/PlayGames/514b46581cbfe31ad86ec630 public ActionResult PlayGames(string id) { var playerService = new PlayerService(); var player = playerService.GetById(id); var gameService = new GameService(); var availableGames = gameService.GetGamesDetails(100, 0); var playerGames = new PlayerGames() { Player = player, AvailableGames = new List<Game>(availableGames) }; return View(playerGames); }
public EditModel(PlayerService playerService, ISharedCultureLocalizer locService) { _playerService = playerService; _locService = locService; }
/// <summary> /// Construtor /// </summary> public HexaID() { //instancia o serviço Service = new PlayerService(); }
private void Login(CometAsyncResult clientState, string email, string pass) { _jsonHelper = new JsonHelper<object>(); _cometProcessor = new CometClientProcessor(); _playerService = new PlayerService(); Player player = new Player(); player.password = pass; player.email = email; _playerService = new PlayerService(); if (_playerService.Verify(player)) { player = _playerService.FindByEmail(email); // Create Cookie HttpCookie time = new HttpCookie("LastLogined", DateTime.Now.ToString()); HttpCookie userEmail = new HttpCookie("userEMail", player.email); HttpCookie userId = new HttpCookie("userId", player.id.ToString()); time.Expires = DateTime.Now.AddDays(1); userEmail.Expires = DateTime.Now.AddDays(1); clientState.HttpContext.Response.Cookies.Add(time); clientState.HttpContext.Response.Cookies.Add(userEmail); clientState.HttpContext.Response.Cookies.Add(userId); currentAsyncRequestState.HttpContext.Session["Email"] = player.email; currentAsyncRequestState.HttpContext.Session["Username"] = player.username; _jsonHelper.message = "Welcome " + player.username + "!"; _jsonHelper.status = 200; string responseJSON = Newtonsoft.Json.JsonConvert.SerializeObject(_jsonHelper); clientState.HttpContext.Response.Write(responseJSON); } else { _jsonHelper.message = "This email and password not found,Please register or try again"; _jsonHelper.status = 404; string responseJSON = Newtonsoft.Json.JsonConvert.SerializeObject(_jsonHelper); clientState.HttpContext.Response.Write(responseJSON); } clientState.CompleteRequest(); }
/// <summary> /// Method to update recorde of a player in database. /// </summary> /// <param name="errorMessage"></param> /// <param name="playerModel"></param> /// <returns></returns> public bool PlayersUpdate(out string errorMessage, PlayerModel playerModel) { PlayerService playerService = new PlayerService(); return(playerService.PlayersUpdate(out errorMessage, playerModel)); }
private void Register(CometAsyncResult clientState, string email, string user, string pass, string passConfirm) { _playerService = new PlayerService(); _jsonHelper = new JsonHelper<Object>(); string responseJSON = null; if (pass == passConfirm) { Player newPlayer = new Player(); newPlayer.email = email; newPlayer.username = user; // kod zashivrovali v settere newPlayer.password = pass; newPlayer.image = "ehse netu picture"; newPlayer.registration_date = DateTime.Now; if (!_playerService.CheckIfExists(newPlayer)) { // do stuff here to log the user in ... if (_playerService.Insert(newPlayer)) { Login(clientState, newPlayer.email, newPlayer.password); } } else { _jsonHelper.status = 405; _jsonHelper.message = "This email is registered,Please login or register another one"; responseJSON = Newtonsoft.Json.JsonConvert.SerializeObject(_jsonHelper); clientState.HttpContext.Response.Headers.Add("Content-type", "application/json"); clientState.HttpContext.Response.Write(responseJSON); } } else { _jsonHelper.status = 406; _jsonHelper.message = "Passwords doesn't match!"; responseJSON = Newtonsoft.Json.JsonConvert.SerializeObject(_jsonHelper); HttpContext.Current.Response.Headers.Add("Content-type", "application/json"); HttpContext.Current.Response.Write(responseJSON); } }
public Player AddNewPlayer(string connectionId) { return(PlayerService.New(connectionId)); }
/// <summary> /// /// </summary> /// <param name="contextManager"></param> public PlayerController(IContextManager contextManager) { _fullService = new PlayerService(contextManager); }
public DeckService(CardUiManager cardUiManager, PlayerService playerService) { this.cardUiManager = cardUiManager; this.playerService = playerService; this.deckData = GameData.getInstance().deckData; }
public override nint RowsInSection(UITableView tableview, nint section) { Players = PlayerService.GetLeaderboard().ToList(); return(Players.Count); }
private void ProcessServiceRequest(Object state, DateTime requestTime) { string responseJSON = null; JsonHelper<Object> _jsonHelper = new JsonHelper<Object>(); CometAsyncResult _curAsyncResult = state as CometAsyncResult; JavaScriptSerializer serializer = new JavaScriptSerializer(); CometClientProcessor _cometProcessor = new CometClientProcessor(); _curAsyncResult.HttpContext.Response.ContentType = "text/plain"; try { uidForImage = new Guid(); string dirFullPath = _curAsyncResult.HttpContext.Server.MapPath("~/Content/img/avatars/"); string[] files; int numFiles; files = System.IO.Directory.GetFiles(dirFullPath); numFiles = files.Length; numFiles = numFiles + 1; string str_image = ""; string imgPath = "~/Content/img/avatars/"; foreach (string s in currentAsyncRequestState.HttpContext.Request.Files) { HttpPostedFile file = _curAsyncResult.HttpContext.Request.Files[s]; string fileName = file.FileName; string fileExtension = file.ContentType; if (!string.IsNullOrEmpty(fileName)) { fileExtension = Path.GetExtension(fileName); str_image = "MyPHOTO_" + numFiles.ToString() + fileExtension; string _saveLocation = _curAsyncResult.HttpContext.Server.MapPath(imgPath) + "" + uidForImage + fileName; // string pathToSave_100 = _curAsyncResult.HttpContext.Server.MapPath(imgPath) + str_image; file.SaveAs(_saveLocation); } } // database record update logic here () _curAsyncResult.HttpContext.Response.Write(str_image); } catch (Exception ac) { } _curAsyncResult.HttpContext.Request.InputStream.Position = 0; string jsonRequest = new StreamReader(_curAsyncResult.HttpContext.Request.InputStream).ReadToEnd(); Dictionary<string, string> values = serializer.Deserialize<Dictionary<string, string>>(jsonRequest); string command = values["command"]; switch (command) { case "CONNECT": CometClientProcessor.AddClient(_curAsyncResult); _curAsyncResult.HttpContext.Response.Write(_curAsyncResult.ClientGuid.ToString()); _curAsyncResult.CompleteRequest(); break; case "DISCONNECT": CometClientProcessor.RemoveClient(_curAsyncResult); _curAsyncResult.CompleteRequest(); break; case "CLIENTGUID": if (values["ClientID"] != null) { CometClientProcessor.UpdateClient(_curAsyncResult, values["ClientID"].ToString()); } break; case "login": Login(_curAsyncResult, values["email"], values["password"]); break; case "register": Register(_curAsyncResult, values["email"], values["user"], values["pass"], values["passConfirm"]); break; case "logout": CometClientProcessor.RemoveClient(_curAsyncResult); _curAsyncResult.HttpContext.Response.Cookies["LastLogined"].Expires = DateTime.Now.AddDays(-1); _curAsyncResult.HttpContext.Response.Cookies["userEMail"].Expires = DateTime.Now.AddDays(-1); _jsonHelper.status = 1000; // status 1000 logout _jsonHelper.message = "GoodBye "; responseJSON = Newtonsoft.Json.JsonConvert.SerializeObject(_jsonHelper); _curAsyncResult.HttpContext.Response.Headers.Add("Content-type", "application/json"); _curAsyncResult.HttpContext.Response.Write(responseJSON); ExpireAllCookies(); _curAsyncResult.HttpContext.Session.Clear(); _curAsyncResult.HttpContext.Session.RemoveAll(); _curAsyncResult.HttpContext.Session.Abandon(); _curAsyncResult.CompleteRequest(); break; case "getGames": JsonHelper<Category> _jsonHelperGames = new JsonHelper<Category>(); _jsonHelperGames.status = 200; //getGames _jsonHelperGames.listData = _cometProcessor.getGames(_curAsyncResult); responseJSON = Newtonsoft.Json.JsonConvert.SerializeObject(_jsonHelperGames); _curAsyncResult.HttpContext.Response.Headers.Add("Content-type", "application/json"); _curAsyncResult.HttpContext.Response.Write(responseJSON); _curAsyncResult.CompleteRequest(); break; case "startGame": int catId = Convert.ToInt32(values["categoryId"]); _cometProcessor.startGame(_curAsyncResult, catId); JsonHelper<Answer> _jsonHelperQandAnswers = new JsonHelper<Answer>(); // Cleaning Buffer for each response to client _curAsyncResult.HttpContext.Response.BufferOutput = false; _curAsyncResult.HttpContext.Response.Flush(); _jsonHelperQandAnswers.status = 10; // Continue Game _jsonHelperQandAnswers.message = StaticMembers._questionNumber + " / " + StaticMembers._questionListWas; ; _jsonHelperQandAnswers.objData = StaticMembers.question; _jsonHelperQandAnswers.listData = AnswerService.getAllByQuestionId(StaticMembers.question.id); responseJSON = Newtonsoft.Json.JsonConvert.SerializeObject(_jsonHelperQandAnswers); _curAsyncResult.HttpContext.Response.Write(responseJSON); _curAsyncResult.CompleteRequest(); break; case "continueGame": bool play = Convert.ToBoolean(values["gameAction"]); int score = Convert.ToInt32(values["score"]); GameService _gameService = new GameService(); if (_cometProcessor.continueGame(play, score)) { JsonHelper<Answer> _jsonHelperQandAns = new JsonHelper<Answer>(); // Cleaning Buffer for each response to client _curAsyncResult.HttpContext.Response.BufferOutput = false; _curAsyncResult.HttpContext.Response.Flush(); _jsonHelperQandAns.status = 10; // Continue Game _jsonHelperQandAns.message = StaticMembers._questionNumber + " / " + StaticMembers._questionListWas; ; _jsonHelperQandAns.objData = StaticMembers.question; _jsonHelperQandAns.listData = AnswerService.getAllByQuestionId(StaticMembers.question.id); responseJSON = Newtonsoft.Json.JsonConvert.SerializeObject(_jsonHelperQandAns); _curAsyncResult.HttpContext.Response.Write(responseJSON); _curAsyncResult.CompleteRequest(); break; } // when games End - show last Game Result; JsonHelper<Game> _jsonHelperGameResult = new JsonHelper<Game>(); _jsonHelperGameResult.status = 20; // end game _jsonHelperGameResult.objData = _gameService.GetPlayersLastGameResult(StaticMembers._game.player_id); responseJSON = Newtonsoft.Json.JsonConvert.SerializeObject(_jsonHelperGameResult); _curAsyncResult.HttpContext.Response.Write(responseJSON); _curAsyncResult.CompleteRequest(); break; case "getUserInfo": string _email = _curAsyncResult.HttpContext.Session["Email"].ToString(); PlayerService playerService = new PlayerService(); Player player = playerService.FindByEmail(_email); HttpCookie userId = new HttpCookie("userId", player.id.ToString()); _jsonHelper.status = 30; // 30 Fresh user info Loaded _jsonHelper.userData = PlayerService.GetProfileInfo(player.id); // returns Players Info _jsonHelper.userGamesData = PlayerService.GetPlayerAllStats(player.id); // returns all info about users games responseJSON = Newtonsoft.Json.JsonConvert.SerializeObject(_jsonHelper); _curAsyncResult.HttpContext.Response.Write(responseJSON); _curAsyncResult.CompleteRequest(); break; } }
public void Player_service_can_get_players(string stage) { IPlayerStatsService service = new PlayerService(); Assert.IsNotNull(service.GetAllPlayerStats(stage, "8531db79-ade3-4294-ae4a-ef639967c393")); }
public PlayerController(PlayerService service) { _playerService = service; }
public PlayerController(IShellService shellService, IEnvironmentService environmentService, ISelectionService selectionService, PlayerService playerService, IMusicPropertiesService musicPropertiesService, IPlaylistService playlistService, Lazy <PlayerViewModel> playerViewModel, ExportFactory <InfoViewModel> infoViewModelFactory) { this.shellService = shellService; this.environmentService = environmentService; this.selectionService = selectionService; this.playerService = playerService; this.musicPropertiesService = musicPropertiesService; this.playlistService = playlistService; this.playerViewModel = playerViewModel; this.infoViewModelFactory = infoViewModelFactory; this.playAllCommand = new DelegateCommand(PlayAll, CanPlayAll); this.playSelectedCommand = new DelegateCommand(PlaySelected, CanPlaySelected); this.enqueueAllCommand = new DelegateCommand(EnqueueAll, CanEnqueueAll); this.enqueueSelectedCommand = new DelegateCommand(EnqueueSelected, CanEnqueueSelected); this.previousTrackCommand = new DelegateCommand(PreviousTrack, CanPreviousTrack); this.nextTrackCommand = new DelegateCommand(NextTrack, CanNextTrack); this.infoCommand = new DelegateCommand(ShowInfo); this.showMusicPropertiesCommand = new DelegateCommand(ShowMusicProperties); this.showPlaylistCommand = new DelegateCommand(ShowPlaylist); }
public PlayerController() { var connector = new MongoDBConnector(); _playerService = new PlayerService(connector.GetDatabase()); }
public ActionResult Edit(string id) { var playerService = new PlayerService(); var player = playerService.GetById(id); return View(player); }
protected JoinArgs(PlayerService playerService) { this.PlayerService = playerService; }
private void ServiceLoader_EnableComplete(object sender, EventArgs e) { this._playerService = this.ServiceLoader.Get<PlayerService>(); }
// GET: Player public ActionResult Index() { var playerService = new PlayerService(); return View(playerService.GetPlayers(100,0)); }
private void Login(string email, string pass) { _jsonHelper = new JsonHelper<object>(); _cometProcessor = new CometClientProcessor(); _playerService = new PlayerService(); Player player = new Player(); player.password = pass; player.email = email; _playerService = new PlayerService(); if (_playerService.Verify(player)) { player = _playerService.FindByEmail(LoginEmail.Text); // Create Cookie HttpCookie time = new HttpCookie("LastLogined", DateTime.Now.ToString()); HttpCookie userEmail = new HttpCookie("userEMail", player.email); HttpCookie userId = new HttpCookie("userId", player.id.ToString()); time.Expires = DateTime.Now.AddDays(1); userEmail.Expires = DateTime.Now.AddDays(1); HttpContext.Current.Response.Cookies.Add(time); HttpContext.Current.Response.Cookies.Add(userEmail); HttpContext.Current.Response.Cookies.Add(userId); HttpContext.Current.Session["Email"] = player.email; HttpContext.Current.Session["Username"] = player.username; Response.Redirect("Games.aspx"); //if true - so code after this not working - its abort the thread } else { string message = "<div class='alert alert-warning'>This email and password not found,Please register or try again</div>"; Alert.Text = message; } }
/// <summary> /// Initializes a new instance of the <see cref="OutgoingbarViewModel" /> class. /// </summary> /// <param name="eventAggregator">The event aggregator.</param> /// <param name="clipboardLurker">The clipboard lurker.</param> /// <param name="clientLurker">The client lurker.</param> /// <param name="processLurker">The process lurker.</param> /// <param name="dockingHelper">The docking helper.</param> /// <param name="keyboardHelper">The keyboard helper.</param> /// <param name="settingsService">The settings service.</param> /// <param name="windowManager">The window manager.</param> /// <param name="playerService">The player service.</param> public OutgoingbarViewModel(IEventAggregator eventAggregator, ClipboardLurker clipboardLurker, ClientLurker clientLurker, ProcessLurker processLurker, DockingHelper dockingHelper, PoeKeyboardHelper keyboardHelper, SettingsService settingsService, IWindowManager windowManager, PlayerService playerService) : base(windowManager, dockingHelper, processLurker, settingsService) { this.Offers = new ObservableCollection <OutgoingOfferViewModel>(); this.FilteredOffers = new ObservableCollection <OutgoingOfferViewModel>(); this._timer = new Timer(50); this._timer.Elapsed += this.Timer_Elapsed; this._keyboardHelper = keyboardHelper; this._clipboardLurker = clipboardLurker; this._eventAggregator = eventAggregator; this._clientLurker = clientLurker; this._playerService = playerService; this.Offers.CollectionChanged += this.Offers_CollectionChanged; this._clipboardLurker.NewOffer += this.ClipboardLurker_NewOffer; }
public TestRegistration() { var players = new Players(); var draws = new Draws(); playerService = new PlayerService(players, draws); SetSystemUnderTest(playerService); }
public ActionResult Edit(Player player) { try { if (ModelState.IsValid) { var playerService = new PlayerService(); playerService.Update(player); return RedirectToAction("Index"); } } catch (Exception) { } return View(player); }
public Controller(ActivePlayersService activePlayerService, TeamService teamService, PlayerService playerService, GameService gameService) { this.activePlayerService = activePlayerService; this.teamService = teamService; this.playerService = playerService; this.gameService = gameService; }
public Menu() { Fts = new FootballStadiumService(new XMLProvider <FootballStadium>("footballl.xml")); ges = new GamesService(new XMLProvider <Games>("games.xml")); pls = new PlayerService(new XMLProvider <Player>("player.xml")); }
protected void Register_Click(object sender, EventArgs e) { uidForImage = Guid.NewGuid(); string fileName = System.IO.Path.GetFileName(PictureUpload.PostedFile.FileName); _playerService = new PlayerService(); _jsonHelper = new JsonHelper<Object>(); Player newPlayer = new Player(); newPlayer.username = RegisterUsername.Text; newPlayer.email = RegisterEmail.Text; // kod zashivrovali v settere newPlayer.password = RegisterPassword.Text; newPlayer.image = uidForImage + fileName; newPlayer.registration_date = DateTime.Now; if (!_playerService.CheckIfExists(newPlayer)) { // do stuff here to log the user in ... if (_playerService.Insert(newPlayer)) { UploadImage(sender, e); Login(newPlayer.email, newPlayer.password); } } else { string message = "<div class='alert alert-warning'>This email is registered,Please login or register another one</div>"; Alert.Text = message; Response.Redirect("Home.aspx"); } }