public FirstTimeCount MapFirstTimeCount(int firstTimeCount,
                                         int numberOfCustomersWithinGroup)
 {
     return(new FirstTimeCount
     {
         Percentage = PercentageUtils
                      .FormatToPercentage(firstTimeCount, numberOfCustomersWithinGroup),
         Count = firstTimeCount,
     });
 }
 public OrderersCount MapOrderersCount(int orderersCount,
                                       int numberOfCustomersWithinGroup)
 {
     return(new OrderersCount
     {
         Percentage = PercentageUtils
                      .FormatToPercentage(orderersCount, numberOfCustomersWithinGroup),
         Count = orderersCount,
     });
 }
        public void FormatToPercentage_ReturnsFormattedPercentage(int current,
                                                                  int maximum,
                                                                  string expected)
        {
            //arrange

            //act
            string result = PercentageUtils.FormatToPercentage(current, maximum);

            //assert
            Assert.Equal(expected, result);
        }
        public void CalculatePercentage_ReturnsPercentage(int current,
                                                          int maximum,
                                                          double expected)
        {
            //arrange

            //act
            double result = PercentageUtils.CalculatePercentage(current, maximum);

            //assert
            Assert.Equal(expected.ToString(), result.ToString("#.##"));
        }
Esempio n. 5
0
    void AddBonusExpOnGameFinish()
    {
        if (PhotonNetwork.IsConnectedAndReady)
        {
            if (PhotonNetwork.CurrentRoom.CustomProperties.IsNullOrEmpty() && PhotonNetwork.LocalPlayer.CustomProperties.IsNullOrEmpty()) //sometimes null here?
            {
                Debug.LogError("We have nothing to add or game isn't player yet.. return");
                return;
            }
            else
            {
                //we add final bonus exp here
                int finalEXP    = 0;
                var playerProps = PhotonNetwork.LocalPlayer.CustomProperties;

                //add team exp
                if (playerProps.ContainsKey("Team" + myTeamID.ToString()))
                {
                    int teamEXP = (int)playerProps["Team" + myTeamID.ToString()];
                    finalEXP += teamEXP;
                    Debug.Log("FINAL_TEAM_EXP :" + teamEXP);
                }

                //add player exp
                if (playerProps.ContainsKey("playerEXP"))
                {
                    int playerEXP = (int)playerProps["playerEXP"];
                    finalEXP += playerEXP;
                    Debug.Log("FINAL_PLAYER_EXP :" + playerEXP);
                }

                //add final exp
                playerLevel.AddExperience(finalEXP);
                Debug.Log("I ADDED EXP FOR PAINTBALL. AMOUNT - " + finalEXP);

                //add soft currency
                int finalSoft = PercentageUtils.GetPercentageInt(softCurrencyBonusPercent, finalEXP);
                SaveManager.Instance.AddSoftCurrency(finalSoft);
                Debug.Log("I ADDED SOFT FOR PAINTBALL. AMOUNT - " + finalSoft);

                //show everything above to our player
                resultsPanel.SetActive(true);
                resultsPanel.GetComponent <PaintBallPointsPanel>().SetResult(finalEXP, finalSoft);
            }
        }
    }