public IEnumerator GetTopScores(int levelID, Text textbox) { WWWForm form = new WWWForm(); form.AddField("LevelID", levelID); form.AddField("Limit", limit); UnityWebRequest www = UnityWebRequest.Post(TopScoresURL, form); yield return(www.SendWebRequest()); if (www.isNetworkError || www.isHttpError) { Debug.Log("an error occured when feching scores from " + levelID + "...\n" + www.error); textbox.text = "\nAn Error occured...\n" + www.error; } else { Debug.Log("sucessfully fetched from " + levelID); string jsonString = www.downloadHandler.text; Debug.Log(jsonString); ScoreList scores = new ScoreList(); scores = ScoreList.CreateFromJSON(jsonString); textbox.text = scores.ToString(); } }
public void CalculateFinalScoreBasedOnMostFrequentWinner() { var scores = new [] { Score.Player1Wins, Score.Draw, Score.Player1Wins }; var scoreList = new ScoreList(scores); Assert.Equal( @"Final score after 3 turns: Player1Wins!! - 2 times Player1Wins - 0 times Player2Wins - 1 times Draw", scoreList.ToString()); }
public void CalculateFinalScoreAsDrawWhenNumberOfWinsAreTheEqual() { var scores = new [] { Score.Player1Wins, Score.Draw, Score.Player2Wins, Score.Player1Wins, Score.Player2Wins }; var scoreList = new ScoreList(scores); Assert.Equal( @"Final score after 5 turns: Draw!! - 2 times Player1Wins - 2 times Player2Wins - 1 times Draw", scoreList.ToString()); }