/// <summary> /// Registers gamer into a bracket /// </summary> /// /// <param name="gamer"> /// User's Gamer info /// </param> /// /// <param name="bracketID"> /// The bracket ID to reference the bracket that the user is being /// registered to /// </param> /// /// <returns> /// BracketPlayer object if registration is successful /// </returns> public BracketPlayer RegisterGamerIntoBracket(GamerInfo gamer, int bracketID) { try { bool checkGamerExistence = _tournamentBracketService.CheckGamerExistence(gamer); bool checkBracketExistence = _tournamentBracketService.CheckBracketExistenceByID(bracketID); if (!(checkGamerExistence && checkBracketExistence)) { throw new ArgumentException(); } else { var bracket = _tournamentBracketService.GetBracketByID(bracketID); if (!(bracket.StatusCode == 0 && bracket.PlayerCount < 128)) { throw new ArgumentException(); } _loggingManager.Log("Bracket Registration", ""); return(_tournamentBracketService.InsertGamerToBracket(gamer, bracket)); } } catch (Exception e) { _loggingManager.Log("Bracket Registration", "Registration Error"); throw e; } }
public GamerInfo GetGamerInfo(GamerInfo gamer) { //PROBLEM: exactly what is this trying to accomplish? //more importatnly what if some particularly memey gamers all //desided to have THE SAME GAMER TAG? can they even do that? try { var DB = new Database(); using (MySqlConnection conn = new MySqlConnection(DB.GetConnString())) { using (MySqlCommand comm = conn.CreateCommand()) { comm.CommandText = "SELECT * FROM gamer_info WHERE gamerTag=@GamerTag"; comm.Parameters.AddWithValue("@GamerTag", gamer.GamerTag); conn.Open(); using (MySqlDataReader reader = comm.ExecuteReader()) { reader.Read(); gamer.GamerTag = reader.GetString("gamerTag"); //gamer.GamerTagID = reader.GetInt32("gamerTagID"); gamer.HashedUserID = reader.GetString("hashedUserID"); conn.Close(); return(gamer); } } } } catch (Exception) { return(null); } }
public Round PlayRound(GamerInfo gamer1, GameActions action1, GamerInfo gamer2, GameActions action2) { if (gamer1 == null) { throw new ArgumentNullException(nameof(gamer1)); } if (gamer2 == null) { throw new ArgumentNullException(nameof(gamer2)); } if (action1 == GameActions.None || action2 == GameActions.None) { throw new ArgumentException("Invalid action!"); } var result1 = _rspService.GetWinner(action1, action2); var result2 = _rspService.GetWinner(action2, action1); return(new Round { Gamer1 = gamer1, Gamer2 = gamer2, RoundResultForGamer1 = result1, RoundResultForGamer2 = result2, UserAction1 = action1, UserAction2 = action2 }); }
/// <summary> /// Fill the godfather panel with godfather. /// </summary> /// <param name="godfather">Godfather gamer info.</param> public void FillGodfatherPanel(GamerInfo godfather) { // Clear the godfather panel ClearGodfatherPanel(false); // If there is godfather to display, fill the godfather panel with gamer prefab if (!string.IsNullOrEmpty(godfather.GamerId)) { // Create a godfather gamer GameObject and hook it at the godfather items layout GameObject prefabInstance = Instantiate <GameObject>(godfatherGamerPrefab); prefabInstance.transform.SetParent(godfatherItemsLayout.transform, false); // Fill the newly created GameObject with gamer data GodfatherGamerHandler godfatherGamerHandler = prefabInstance.GetComponent <GodfatherGamerHandler>(); godfatherGamerHandler.FillData(godfather["profile"], godfather.GamerId); // Add the newly created GameObject to the list godfatherItems.Add(prefabInstance); } // Else, show the "no godfather" text else { noGodfatherText.gameObject.SetActive(true); } }
/// <summary> /// Reads all the gamers whose gamer tag contains the search request. /// </summary> /// <param name="gamerRequest"> String of gamer request </param> /// <returns> A list of Gamers </returns> public List <GamerInfo> ReadGamers(string gamerRequest) { var DB = new Database(); var DQ = new DatabaseQuery(); var listOfGamers = new List <GamerInfo>(); using (MySqlConnection conn = new MySqlConnection(DB.GetConnString())) { string selectQuery = string.Format("SELECT * FROM gamer_info WHERE gamerTag LIKE \'%{0}%\'", gamerRequest); Console.WriteLine(selectQuery); MySqlCommand selectCmd = new MySqlCommand(selectQuery, conn); conn.Open(); using (MySqlDataReader reader = selectCmd.ExecuteReader()) { while (reader.Read()) { GamerInfo gamerObj = new GamerInfo(); gamerObj.GamerTag = reader.GetString("gamerTag"); gamerObj.BracketCount = DQ.GetBracketCount(gamerObj.GamerTag); gamerObj.Region = reader.GetString("region"); listOfGamers.Add(gamerObj); } } } return(listOfGamers); }
public void RegisterUserToBracket_Fail_UserAlreadyRegisteredToBracket() { // Arrange var result = true; var gamerInfo = new GamerInfo(); var bracketID = 1; gamerInfo.GamerTag = "GamerTag1"; // Act try { var actual = _tournamentBracketManager.RegisterGamerIntoBracket(gamerInfo, bracketID); if (actual == null) { result = false; } } catch (ArgumentException) { result = false; } // Assert Assert.IsFalse(result); }
public static Task <string> PostAsync(HttpClient client, GamerInfo gamer, string path) { if (client == null || gamer == null) { return(null); } var json = JsonConvert.SerializeObject(gamer); var content = new StringContent(json, Encoding.UTF8, "application/json"); try { var message = client.PostAsync($"/api/rooms/{path}", content).Result; return(message.Content.ReadAsStringAsync()); } catch (AggregateException) { return(null); } catch (NullReferenceException) { return(null); } }
internal GamerInfo GetGamerInfoByHashedID(string hashedUserID) { try { var DB = new Database(); using (MySqlConnection conn = new MySqlConnection(DB.GetConnString())) { using (MySqlCommand comm = conn.CreateCommand()) { comm.CommandText = "SELECT * FROM gamer_info WHERE hashedUserID=@HashedUserID"; comm.Parameters.AddWithValue("@HashedUserID", hashedUserID); conn.Open(); using (MySqlDataReader reader = comm.ExecuteReader()) { GamerInfo gamer = new GamerInfo(); reader.Read(); gamer.GamerTag = reader.GetString("gamerTag"); gamer.HashedUserID = reader.GetString("hashedUserID"); conn.Close(); return(gamer); } } } } catch (Exception) { return(null); } }
/// <summary> /// Requests the current receipts from the Store. If the Store is not available, the cached /// receipts from a previous call are returned. /// </summary> /// <returns>The list of Receipt objects.</returns> public async Task <IList <Receipt> > RequestReceiptsAsync() { // We need the gamer UUID for the encryption of the cached receipts, so if the dev // hasn't retrieved the gamer UUID yet, we'll grab it now. var task = Task <IList <Receipt> > .Factory.StartNew(() => { if (_gamerInfo == null) { _gamerInfo = RequestGamerInfoAsync().Result; } // No gamerInfo means no receipts if (_gamerInfo == null) { return(null); } var tcs = new TaskCompletionSource <IList <Receipt> >(); var listener = new ReceiptsListener(tcs, _publicKey, _gamerInfo.Uuid); RequestReceipts(listener); return(tcs.Task.TimeoutAfter(timeout).Result); }); try { return(await task); } catch (Exception e) { Log(e.GetType().Name + ": " + e.Message); } return(_gamerInfo != null?ReceiptsListener.FromCache(_gamerInfo.Uuid) : null); }
/// <summary> /// Inserts gamer into bracket /// </summary> /// /// <param name="gamer"> /// Gamer object to be inserted /// </param> /// /// <param name="bracketID"> /// BracketID associated with bracket, where the gamer will be inserted /// </param> /// /// <returns> /// BracketPlayer object if insertion successful; null if not /// </returns> public BracketPlayer InsertGamerToBracket(GamerInfo gamer, BracketInfo bracket) { try { DatabaseQuery databaseQuery = new DatabaseQuery(); TournamentBracketDatabaseQuery tournamentBracketDatabaseQuery = new TournamentBracketDatabaseQuery(); GamerInfo tempGamer = databaseQuery.GetGamerInfo(gamer); BracketPlayer bracketPlayer = new BracketPlayer(); bracketPlayer.BracketID = bracket.BracketID; bracketPlayer.HashedUserID = tempGamer.HashedUserID; bracketPlayer.StatusCode = 1; bracketPlayer.Claim = null; bracketPlayer.Reason = null; bool insertionResult = tournamentBracketDatabaseQuery.InsertBracketPlayer(bracketPlayer); if (insertionResult) { tournamentBracketDatabaseQuery.UpdateBracketPlayerCount(bracket.BracketID, 1); return(bracketPlayer); } return(null); } catch (Exception e) { Console.WriteLine(e); return(null); } }
protected override void Run(GamerEnter message) { UI uiRoom = Hotfix.Scene.GetComponent <UIComponent>().Get(UIType.Room); GamerComponent gamerComponent = uiRoom.GetComponent <GamerComponent>(); //隐藏匹配提示 GameObject matchPrompt = uiRoom.GameObject.Get <GameObject>("MatchPrompt"); if (matchPrompt.activeSelf) { matchPrompt.SetActive(false); uiRoom.GameObject.Get <GameObject>("ReadyButton").SetActive(true); } //添加未显示玩家 for (int i = 0; i < message.GamersInfo.Length; i++) { GamerInfo info = message.GamersInfo[i]; if (gamerComponent.Get(info.PlayerID) == null) { Gamer gamer = EntityFactory.CreateWithId <Gamer, long>(info.PlayerID, info.UserID); gamer.IsReady = info.IsReady; gamer.AddComponent <GamerUIComponent, UI>(uiRoom); gamerComponent.Add(gamer); } } }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } GamerInfo = await _context.GamerInfo .Include(a => a.Purchases) .FirstOrDefaultAsync(gamr => gamr.ID == id); if (GamerInfo == null) { return(NotFound()); } UpdateGamerForm = new UpdateGamerForm(); UpdateGamerForm.GamerID = GamerInfo.ID; return(Page()); }
public static void CreateSave(GamerInfo gamer) { string path = Environment.CurrentDirectory + "\\Saves" + $"\\{gamer.Name}.txt"; FileStream fs = File.Create(path); fs.Close(); File.AppendAllText(path, $"{gamer.Name} {gamer.Scores} {ConvertArrayToString(gamer.Table)} {(int)MenuOptionsData.TableColor} {(int)MenuOptionsData.CursorColor} {(int)MenuOptionsData.WordColor} {(int)MenuOptionsData.TrueWordColor} {(int)MenuOptionsData.TableHeight} {(int)MenuOptionsData.TableWidth}"); }
public static GamerInfo CreateGamerInfo(Gamer gamer) { GamerInfo gamerInfo = new GamerInfo(); gamerInfo.GamerId = gamer.Id; gamerInfo.GamerName = gamer.Namer; return(gamerInfo); }
public void ChangeOnlineTime_MustBeAddedTime() { var onlineTime = new TimeSpan(1, 1, 1, 1); var gamerInfo = new GamerInfo(); _service.ChangeOnlineTime(gamerInfo, onlineTime); Assert.Equal(onlineTime, gamerInfo.OnlineTime); }
internal MatchListResult(Bundle serverData) { Creator = new GamerInfo(serverData["creator"]); CustomProperties = serverData["customProperties"]; Description = serverData["description"]; MatchId = serverData["_id"]; MaxPlayers = serverData["maxPlayers"]; Status = Common.ParseEnum<MatchStatus>(serverData["status"]); }
public static Gamer Create(Entity domain, GamerInfo gamerInfo) { Gamer gamer = EntityFactory.CreateWithId <Gamer, string>(domain, gamerInfo.GamerId, gamerInfo.GamerName); GamerComponent gamerComponent = domain.GetComponent <GamerComponent>(); gamerComponent.Add(gamer); return(gamer); }
/// <summary>Build from existing JSON data.</summary> public SocialNetworkFriend(Bundle serverData) { Id = serverData["id"]; Name = serverData["name"]; FirstName = serverData["first_name"]; LastName = serverData["last_name"]; if (serverData.Has("clan")) { ClanInfo = new GamerInfo(serverData["clan"]); } }
public async Task <IActionResult> CreateRoom([FromBody] GamerInfo gamer) { if (gamer == null) { return(BadRequest()); } var result = await _roomService.CreateRoom(gamer, RoomStatus.Private); return(Ok(result)); }
public static void WriteRecord(GamerInfo gamer) { string[] records = Records; for (int i = 0; i < records.Length; i++) { if (gamer.Scores > int.Parse(records[i].Split(" ")[3])) { records[i] = $"{records[i].Split(" ")[0]} {gamer.Name} - {gamer.Scores}"; break; } } }
public void ChangeOnlineTime(GamerInfo gamerInfo, TimeSpan onlineTime) { if (gamerInfo == null) { throw new ArgumentNullException(nameof(gamerInfo)); } if (onlineTime == TimeSpan.Zero) { throw new ArgumentException("Online time is zero!"); } gamerInfo.OnlineTime += onlineTime; }
/// <summary> /// Check gamer object's existence in the database. Used for /// registering for bracket /// </summary> /// /// <param name="gamer"> /// Gamer object to be searched for /// </param> /// /// <returns> /// Boolean indicating success or fail in finding Gamer object /// </returns> public bool CheckGamerExistence(GamerInfo gamer) { var gamerResult = _gamerDataAccess.GetGamerInfo(gamer); if (gamerResult == null) { return(false); } else { return(true); } }
public override void OnSuccess(Java.Lang.Object jObject) { GamerInfo gamerInfo = jObject.JavaCast <GamerInfo>(); if (null == gamerInfo) { m_debugText = string.Format("GamerInfo is null!"); } else { m_debugText = string.Format("Request Gamer UUID={0} Username={1}", gamerInfo.Uuid, gamerInfo.Username); Log.Info(TAG, "OnSuccess uuid=" + gamerInfo.Uuid + " username=" + gamerInfo.Username); } }
public IActionResult RegisterNewUser(RegistrationInput userInput) { try { User user = new User(userInput); // HACK: this is fixed in another branch, so for now this will HOPEFULLY // keep away any possible collisions. when that happend comment out the next 2 lines. //Random rnd = new Random(); //user.SystemID = rnd.Next(Int32.MinValue, Int32.MaxValue); //HACK: due to time constraints, I realised that gamer tags need to be unique. GamerInfo verifyGamer = _gamerDataAccess.GetGamerInfo(new GamerInfo(null, userInput.GamerTag, 0, 0)); if (verifyGamer == null) { _userManagementManager.SingleCreateUsers(doAsUser.systemAdmin(), user); _userManagementManager.updateGamerTag(user, userInput.GamerTag); } else { user.ErrorMessage = "Gamer tag is already in use"; } ContentResult serverReply = Content(user.ErrorMessage); switch (user.ErrorMessage) { case "Invalid permissions": serverReply.StatusCode = StatusCodes.Status401Unauthorized; break; case "Password is not secured": case "ID already exists": case "Email already registered": case "Email malformed": case "Invalid names": case "Gamer tag is already in use": serverReply.StatusCode = StatusCodes.Status400BadRequest; break; case "Email failed to register": serverReply.StatusCode = StatusCodes.Status500InternalServerError; break; default: serverReply.StatusCode = StatusCodes.Status200OK; break; } return(serverReply); } catch (ArgumentException) { return(StatusCode(StatusCodes.Status400BadRequest)); } }
public void AssignGamerTag(int userID, string newTag) { DatabaseQuery query = new DatabaseQuery(); string hashID = query.GetHashedUserID(userID); GamerInfo newGamer = new GamerInfo(hashID, newTag, 0, 0); GamerInfo verifyGamer = query.GetGamerInfoByHashedID(hashID); if (verifyGamer != null) { //update entry query.UpdateQuery("gamer_info", "gamerTag", newGamer.GamerTag, "hashedUserID", hashID); } query.InsertGamerInfo(newGamer); //im guessing they cant have a gamertag some one else has. }
public static GamerInfo Parse(JSONObject jsonObject) { GamerInfo result = new GamerInfo(); //Debug.Log(jsonData); if (jsonObject.has("uuid")) { result.uuid = jsonObject.getString("uuid"); } if (jsonObject.has("username")) { result.username = jsonObject.getString("username"); } return(result); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } GamerInfo = await _context.GamerInfo.FirstOrDefaultAsync(m => m.ID == id); if (GamerInfo == null) { return(NotFound()); } return(Page()); }
public static GamerInfo GetOneSave(string path) { string file = File.ReadAllText(path); string[] save = file.Split(' '); MenuOptionsData.EnterColorTable((ConsoleColor)(int.Parse(save[3]))); MenuOptionsData.EnterCursorColor((ConsoleColor)(int.Parse(save[4]))); MenuOptionsData.EnterWordColor((ConsoleColor)(int.Parse(save[5]))); MenuOptionsData.EnterTrueWordColor((ConsoleColor)(int.Parse(save[6]))); MenuOptionsData.EnterTableHeight(int.Parse(save[7])); MenuOptionsData.EnterTableWidth(int.Parse(save[8])); GamerInfo gamer = new GamerInfo(save[0], int.Parse(save[1]), ConvertStringToArray(save[2])); return(gamer); }
public GamerInfo ChangeGamerInfoAfterRound(GamerInfo gamerInfo, GamerInfo gamerNewInfo) { if (gamerInfo == null || gamerNewInfo == null) { throw new ArgumentNullException(nameof(gamerInfo)); } gamerInfo.CountDraws += gamerNewInfo.CountDraws; gamerInfo.CountLoses += gamerNewInfo.CountLoses; gamerInfo.CountWins += gamerNewInfo.CountWins; gamerInfo.CountPapers += gamerNewInfo.CountPapers; gamerInfo.CountRocks += gamerNewInfo.CountRocks; gamerInfo.CountScissors += gamerNewInfo.CountScissors; gamerInfo.OnlineTime += gamerNewInfo.OnlineTime; return(gamerInfo); }
public void RegisterUserToBracket_Pass() { // Arrange var gamerInfo = new GamerInfo(); var bracketID = 1; gamerInfo.GamerTag = "GamerTag1"; var expected = new BracketPlayer(1, "LkKpHSN1+aOvzoj3ZrCXSIxasfWSZ5j1mJI5S3er3Vw=", 0, 0, 0, null, 1, null); // Act var actual = _tournamentBracketManager.RegisterGamerIntoBracket(gamerInfo, bracketID); // Assert Assert.AreEqual(expected.BracketID, actual.BracketID); Assert.AreEqual(expected.HashedUserID, actual.HashedUserID); }
/// <summary> /// Gets gamer info associated with user's email /// </summary> /// /// <param name="email"> /// User's email /// </param> /// <returns> /// Gamer info /// </returns> public GamerInfo GetGamerInfoByEmail(string email) { DatabaseQuery databaseQuery = new DatabaseQuery(); User user = databaseQuery.GetUserInfo(email); if (user != null) { string hashedUserID = databaseQuery.GetHashedUserID(user.SystemID); GamerInfo gamer = databaseQuery.GetGamerInfoByHashedID(hashedUserID); return(gamer); } else { throw new ArgumentException(); } }
public IActionResult RegisterGamerIntoBracket(int bracketID, GamerInfo gamer) { try { return(Ok(TournamentBracketManager.RegisterGamerIntoBracket(gamer, bracketID))); } catch (ArgumentException) { // Registering unsuccessful return(StatusCode(StatusCodes.Status400BadRequest)); } catch { // Generic error return(StatusCode(StatusCodes.Status500InternalServerError)); } }
private void AutoRelogin() { // On the first time, we need to log in anonymously, else log back with the stored credentials if (!PlayerPrefs.HasKey ("GamerInfo")) { MakeAnonymousAccount().Done(); } else { // Log back in GamerInfo info = new GamerInfo(PlayerPrefs.GetString("GamerInfo")); Debug.Log ("Attempting to log back with existing credentials"); Cloud.Login ( network: LoginNetwork.Anonymous, networkId: info.GamerId, networkSecret: info.GamerSecret) .Catch (ex => { Debug.LogError("Failed to log back in with stored credentials. Restarting process."); MakeAnonymousAccount().Done(); }) .Done(gamer => DidLogin(gamer)); } }
public static GamerInfo Parse(JSONObject jsonObject) { GamerInfo result = new GamerInfo(); //Debug.Log(jsonData); if (jsonObject.has("uuid")) { result.uuid = jsonObject.getString("uuid"); } if (jsonObject.has("username")) { result.username = jsonObject.getString("username"); } return result; }
/// <summary> /// Requests the current receipts from the Store. If the Store is not available, the cached /// receipts from a previous call are returned. /// </summary> /// <returns>The list of Receipt objects.</returns> public async Task<IList<Receipt>> RequestReceiptsAsync() { // We need the gamer UUID for the encryption of the cached receipts, so if the dev // hasn't retrieved the gamer UUID yet, we'll grab it now. var task = Task<IList<Receipt>>.Factory.StartNew(() => { if (_gamerInfo == null) _gamerInfo = RequestGamerInfoAsync().Result; // No gamerInfo means no receipts if (_gamerInfo == null) return null; var tcs = new TaskCompletionSource<IList<Receipt>>(); var listener = new ReceiptsListener(tcs, _publicKey, _gamerInfo.Uuid); RequestReceipts(listener); return tcs.Task.TimeoutAfter(timeout).Result; }); try { return await task; } catch (Exception e) { Log(e.GetType().Name + ": " + e.Message); } return _gamerInfo != null ? ReceiptsListener.FromCache(_gamerInfo.Uuid) : null; }
/// <summary> /// Requests the current gamer's info. /// </summary> /// <returns>The GamerInfo of the user to whom the console is currently registered.</returns> public async Task<GamerInfo> RequestGamerInfoAsync() { if (_gamerInfo != null) return _gamerInfo; var tcs = new TaskCompletionSource<GamerInfo>(); var listener = new GamerInfoListener(tcs); try { RequestGamerInfo(listener); _gamerInfo = await tcs.Task.TimeoutAfter(timeout); } catch (Exception e) { Log(e.GetType().Name + ": " + e.Message); _gamerInfo = GamerInfoListener.FromCache(); } return _gamerInfo; }
public static GamerInfo Parse(string jsonData) { GamerInfo result = new GamerInfo(); #if UNITY_ANDROID && !UNITY_EDITOR //Debug.Log(jsonData); using (JSONObject json = new JSONObject(jsonData)) { if (json.has("uuid")) { result.uuid = json.getString("uuid"); } if (json.has("username")) { result.username = json.getString("username"); } } #endif return result; }
public static GamerInfo Parse(string jsonData) { GamerInfo result = new GamerInfo(); if(Application.platform != RuntimePlatform.Android) return result; //Debug.Log(jsonData); using (JSONObject json = new JSONObject(jsonData)) { if (json.has("uuid")) { result.uuid = json.getString("uuid"); } if (json.has("username")) { result.username = json.getString("username"); } } return result; }