///<summary> /// Set up the veritical table of goal slots ///</summary> void initButtonTable() { // Use prefab to create the buttons //Object pf = Resources.Load("Prefabs/GoalButton"); if (buttonPrefab != null) { for (int ii = 0; ii < iGOAL_TOTAL; ii++) { GameObject inst = (GameObject)GameObject.Instantiate(buttonPrefab, Vector3.zero, Quaternion.identity); if (inst != null) { ScoreGoal sg = inst.GetComponent <ScoreGoal> (); sg.Rank = ii; sg.LabelText = aGoalName [ii] + " (x" + aScoreMultiplier [ii] + ")"; sg.Target = this.gameObject; sg.ClickCallback = "HandleGoalClick"; inst.name = "Goal Button " + ii.ToString(); inst.transform.parent = this.gameObject.transform; inst.transform.localScale = buttonPrefab.transform.localScale; inst.transform.localPosition = buttonPrefab.transform.localPosition; inst.transform.localRotation = buttonPrefab.transform.localRotation; aGoalButton [ii] = sg; } } buttonPrefab.SetActive(false); } buttonTable.repositionNow = true; }
///<summary> /// This call back function handles clicks from the Goal buttons ///</summary> void HandleGoalClick(GameObject srcGO) { ScoreGoal goal = srcGO.GetComponent <ScoreGoal> (); Debug.Log(goal.LabelText + " was click. Rank is " + goal.Rank); aRedemptGoal [goal.Rank] = true; goal.State = ScoreGoal.GoalButtonState.USED; int redempted = 0; foreach (ScoreGoal sg in aGoalButton) { if (sg.State == ScoreGoal.GoalButtonState.HIGHLIGHTED) { sg.State = ScoreGoal.GoalButtonState.NORMAL; } else if (sg.State == ScoreGoal.GoalButtonState.USED) { redempted++; } } if (RedemptActionCallback != null) { RedemptActionCallback(diceSum * aScoreMultiplier [goal.Rank], iGOAL_TOTAL - redempted); } }
public async Task ScoreGoal_EmptyPayload_ReturnsBadRequest() { var command = new ScoreGoal(); var response = await client.PutAsync($"/games/{Guid.NewGuid()}/statistics/score", command.ToContent()); response.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); }
public async Task <Unit> Handle(ScoreGoal request, CancellationToken cancellationToken) { await ValidateGame(request.GameId); var isSuccesful = await gameRepository.AddScore(new Persistence.Entities.Score() { GameId = request.GameId, PlayerNumber = request.PlayerNumber, Team = request.Team }); if (!isSuccesful) { throw new Exception($"Score with gameid :{request.GameId} couldnt be added"); } await this.eventBus.Publish(new PlayerHasScored(request.GameId, request.Team, request.PlayerNumber)); return(Unit.Value); }
public async Task <IActionResult> ScoreGoal([NotEmptyGuid, FromRoute] Guid id, [BindRequired, FromBody] ScoreGoal command) { command.GameId = id; await this.commandBus.Send(command); return(Ok()); }
private async Task ScoreGoal(ScoreGoal command) { var response = await client.PutAsync($"/games/{command.GameId}/statistics/score", command.ToContent()); response.StatusCode.Should().Be((int)HttpStatusCode.OK); }