public async Task <IActionResult> UpdatePlayerGameInfo([FromRoute] int id, [FromBody] PlayerGameInfo tblPlayerGameInfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tblPlayerGameInfo.PlayerGameInfoId) { return(BadRequest()); } try { await playerGameInfoesService.Update(id, tblPlayerGameInfo); } catch (DbUpdateConcurrencyException) { if (!TblPlayerGameInfoExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public GameRepresentation(CommandFactory commandFactory, PlayerGameInfo playerGameInfo) { CommandFactory = commandFactory; PlayerGameInfo = playerGameInfo; PlayActionList = PlayerGameInfo?.ValidActionIdList ?.Select(id => CommandFactory.ConstructAction(id)) .Where(a => a.GetActionType() == ActionType.PlayAction) .Select(a => (PlayAction)a) .ToList(); BetActionList = PlayerGameInfo?.ValidActionIdList ?.Select(id => CommandFactory.ConstructAction(id)) .Where(a => a.GetActionType() == ActionType.BetAction) .Select(a => (BetAction)a) .ToList(); CardCommandDictionary = PlayActionList ?.ToDictionary(a => a.Card, a => CommandFactory.ConstructCommand(a.GetActionId()) as ICommand); BetActionCommandDictionary = BetActionList ?.ToDictionary(a => a, a => CommandFactory.ConstructCommand(a.GetActionId()) as ICommand); HandRepresentation = PlayerGameInfo?.PlayerHand != null ? new HandRepresentation(PlayerGameInfo?.PlayerHand, CardCommandDictionary) : null; BetActionsRepresentation = BetActionList != null ? new BetActionsRepresentation(BetActionList, BetActionCommandDictionary) : null; BoardRepresentation = GameStageInfo != null ? new BoardRepresentation(PlayerGameInfo.GameInfo, PlayerGameInfo.PlayerInfo, GameStageInfo) : null; // Remark: Since we receive relative player information we could also directly determine the player positions. // But this way the ViewModel would also work with "real" player informations. var topPlayer = PlayerGameInfo.GameInfo.PlayerGroupInfo.GetOppositePlayer(PlayerGameInfo.PlayerInfo.PlayerId); var rightPlayer = PlayerGameInfo.GameInfo.PlayerGroupInfo.GetNextPlayer(PlayerGameInfo.PlayerInfo.PlayerId); var leftPlayer = PlayerGameInfo.GameInfo.PlayerGroupInfo.GetPreviousPlayer(PlayerGameInfo.PlayerInfo.PlayerId); var previousBetActionList = PlayerGameInfo?.GameStageInfo?.ExpectedActionType == ActionType.BetAction ? PlayerGameInfo?.GameStageInfo?.CurrentBetActionList : null; var betActionKeyValuePairList = (previousBetActionList != null && previousBetActionList.Any()) ? previousBetActionList ?.Select((a, i) => new KeyValuePair <int, BetAction>(i, a)) ?.ToList() : null; var topBetActionDictionary = betActionKeyValuePairList ?.Where(p => p.Value.PlayerInfo.PlayerId == topPlayer.PlayerId) ?.ToDictionary(p => p.Key, p => p.Value); var rightBetActionDictionary = betActionKeyValuePairList ?.Where(p => p.Value.PlayerInfo.PlayerId == rightPlayer.PlayerId) ?.ToDictionary(p => p.Key, p => p.Value); var leftBetActionDictionary = betActionKeyValuePairList ?.Where(p => p.Value.PlayerInfo.PlayerId == leftPlayer.PlayerId) ?.ToDictionary(p => p.Key, p => p.Value); // TODO var currentPlayerId = GameStageInfo?.CurrentPlayer?.PlayerId; TopPlayerRepresentation = new PlayerRepresentation(topPlayer, topBetActionDictionary, null, 0, currentPlayerId == topPlayer.PlayerId); LeftPlayerRepresentation = new PlayerRepresentation(rightPlayer, leftBetActionDictionary, null, 0, currentPlayerId == leftPlayer.PlayerId); RightPlayerRepresentation = new PlayerRepresentation(leftPlayer, rightBetActionDictionary, null, 0, currentPlayerId == rightPlayer.PlayerId); }
public void OnGameSelected(PlayerGameInfo gameInfo, GameRow gameRow) { if (isCurSelected) { curSelectedRow.DeselectRow(); } curSelectedGame = gameInfo; curSelectedRow = gameRow; curSelectedRow.SelectRow(); isCurSelected = true; joinGameButton.interactable = true; joinGameButtonText.color = normalTextColor; }
public async Task <PlayerGameInfo> Insert(PlayerGameInfo tblPlayerGameInfo) { try { context.Add(tblPlayerGameInfo); await context.SaveChangesAsync(); return(tblPlayerGameInfo); } catch (Exception) { throw; } }
private void UpdateAllPlayerGameInfo() { foreach (var _playerGameInfo in m_playerGameInfos) { DestroyImmediate(_playerGameInfo.gameObject); } m_playerGameInfos.Clear(); foreach (var _pawn in GameplayManager.m_Instance.m_PawnsDict.Values) { PlayerGameInfo _playerGameInfo = Instantiate(m_playerGameInfoPrefab, m_allPlayerInfoContainer); _playerGameInfo.UpdatePlayerGameInfo(_pawn); m_playerGameInfos.Add(_playerGameInfo); } }
public async Task <IActionResult> InsertPlayerGameInfo([FromBody] PlayerGameInfo tblPlayerGameInfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var entity = await playerGameInfoesService.Insert(tblPlayerGameInfo); if (entity == null) { return(NotFound()); } return(CreatedAtAction("GetPlayerGameInfoByID", new { id = tblPlayerGameInfo.PlayerGameInfoId }, tblPlayerGameInfo)); }
void Start() { PlayerController[] _players = FindObjectsOfType <PlayerController>(); PlayerInfos = new PlayerGameInfo[_players.Length]; for (int i = 0; i < PlayerInfos.Length; i++) { int idx = _players[i].PlayerIndex; PlayerInfos[idx] = new PlayerGameInfo(false, 0); PlayerInfos[idx].Player = _players[i]; } for (int i = 0; i < PlayerInfos.Length; i++) { _spawnPlayer(i); } }
public void Setup(bool evenRow, PlayerGameInfo gameInfo, GameTable gameTable) { this.gameTable = gameTable; this.gameInfo = gameInfo; normalRowColor = (evenRow) ? evenRowBkg : oddRowBkg; this.username.text = gameInfo.opponent.username; this.rank.text = gameInfo.opponent.rank.ToString(); int hours = gameInfo.currentTimeLeft / 3600; int minutes = gameInfo.currentTimeLeft / 60 - hours * 60; int seconds = gameInfo.currentTimeLeft % 60; this.time.text = $"{hours}:{minutes}:{seconds}"; this.status.text = gameInfo.gameState.ToString(); this.background.color = normalRowColor; }
private List <PlayerGameInfo> GetPlayerInfos(List <Player> team, CacheGame game) { var gameKills = game.Rounds.SelectMany(round => round.Kills).ToList(); var playerInfos = team.Select(player => { var playerInfo = new PlayerGameInfo { Name = player.Name, SteamId = player.SteamId, Kills = gameKills.Count(kill => kill.Killer == player), Assists = gameKills.Count(kill => kill.Assistant == player), Deaths = gameKills.Count(kill => kill.Victim == player), }; return(playerInfo); }); playerInfos = playerInfos.OrderByDescending(player => player.Kills); return(playerInfos.ToList()); }
public bool SetPlayerGameInfo(PlayerGameInfo playerGameInfo) { var randomActionId = playerGameInfo?.ValidActionIdList ?.OrderBy(a => Guid.NewGuid()) ?.FirstOrDefault(); if (!randomActionId.HasValue) { return(true); } Task.Run(() => { if (DelayInMiliseconds > 0) { Thread.Sleep(DelayInMiliseconds); } ProcessAction(randomActionId.Value); }); return(true); }
public async Task Update(int Id, PlayerGameInfo tblPlayerGameInfo) { try { if (tblPlayerGameInfo == null) { throw new ArgumentNullException(nameof(tblPlayerGameInfo)); } if (Id != tblPlayerGameInfo.PlayerGameInfoId) { throw new NotImplementedException(); } context.TblPlayerGameInfo.Update(tblPlayerGameInfo); await context.SaveChangesAsync(); } catch (Exception) { throw; } }
void InitGameLog() { transform.FindChild("Body").FindChild("Changeables").FindChild("GameLog").gameObject.SetActive(true); UtilMgr.ClearList( transform.FindChild("Body").FindChild("Changeables").FindChild("GameLog").FindChild("Scroll View")); string month = ""; float height = 390f; int colorIndicator = 0; for (int i = 0; i < mGameEvent.Response.data.Count; i++) { GameObject go = null; PlayerGameInfo info = mGameEvent.Response.data[i]; if (!month.Equals(info.month)) { month = info.month; colorIndicator = 0; go = Instantiate(mItemGameMonth); go.transform.parent = transform.FindChild("Body").FindChild("Changeables").FindChild("GameLog").FindChild("Scroll View"); height -= 30f; go.transform.localPosition = new Vector3(0, height); height -= 30f; go.transform.localScale = new Vector3(1f, 1f, 1f); go.transform.FindChild("Label").GetComponent <UILabel>().text = info.month; if (IsPitcher) { go = Instantiate(mItemGameArticlesP); } else { go = Instantiate(mItemGameArticlesH); } go.transform.parent = transform.FindChild("Body").FindChild("Changeables").FindChild("GameLog").FindChild("Scroll View"); height -= 25f; go.transform.localPosition = new Vector3(0, height); height -= 25f; go.transform.localScale = new Vector3(1f, 1f, 1f); } if (IsPitcher) { go = Instantiate(mItemGameSubP); } else { go = Instantiate(mItemGameSubH); } go.transform.parent = transform.FindChild("Body").FindChild("Changeables").FindChild("GameLog").FindChild("Scroll View"); height -= 25f; go.transform.localPosition = new Vector3(0, height); height -= 25f; go.transform.localScale = new Vector3(1f, 1f, 1f); if (IsPitcher) { go.transform.FindChild("3").GetComponent <UILabel>().text = info.IP; go.transform.FindChild("4").GetComponent <UILabel>().text = info.PH; go.transform.FindChild("5").GetComponent <UILabel>().text = info.BB; go.transform.FindChild("6").GetComponent <UILabel>().text = info.SO; go.transform.FindChild("7").GetComponent <UILabel>().text = info.ER; go.transform.FindChild("8").GetComponent <UILabel>().text = info.W; } else { go.transform.FindChild("3").GetComponent <UILabel>().text = info.AB; go.transform.FindChild("4").GetComponent <UILabel>().text = info.H; go.transform.FindChild("5").GetComponent <UILabel>().text = info.HR; go.transform.FindChild("6").GetComponent <UILabel>().text = info.RBI; go.transform.FindChild("7").GetComponent <UILabel>().text = info.R; go.transform.FindChild("8").GetComponent <UILabel>().text = info.BB; } go.transform.FindChild("1").GetComponent <UILabel>().text = info.day; go.transform.FindChild("2").GetComponent <UILabel>().text = info.VS; go.transform.FindChild("9").GetComponent <UILabel>().text = info.FP; if (colorIndicator++ % 2 == 0) { go.transform.FindChild("BG").GetComponent <UISprite>().color = new Color(1f, 1f, 1f); } else { go.transform.FindChild("BG").GetComponent <UISprite>().color = new Color(230f / 255f, 230f / 255f, 230f / 255f); } } transform.FindChild("Body").FindChild("Changeables").FindChild("GameLog").FindChild("Scroll View") .GetComponent <UIScrollView>().ResetPosition(); }
public void SelectRow(PlayerGameInfo gameInfo, GameRow gameRow) { onGameSelected?.Invoke(gameInfo, gameRow); }