Add golden berry to profile/stats menu, modify XP calculation and switch to new Profile endpoint
This commit is contained in:
@@ -186,7 +186,10 @@ public class LeaderboardsMenu : MonoBehaviour
|
||||
entry.Stats.TotalSlowBerries,
|
||||
entry.Stats.TotalUltraBerries,
|
||||
entry.Stats.TotalSpeedyBerries,
|
||||
entry.Stats.TotalCoinBerries
|
||||
entry.Stats.TotalCoinBerries,
|
||||
entry.Stats.TotalRandomBerries,
|
||||
entry.Stats.TotalAntiBerries,
|
||||
entry.Stats.TotalGoldenBerries
|
||||
);
|
||||
|
||||
return new
|
||||
|
||||
@@ -13,8 +13,7 @@ public class Endpoints
|
||||
public const string LEADERBOARDS_COIN_ENDPOINT = LEADERBOARDS_ENDPOINT + "/coin";
|
||||
public const string LEADERBOARDS_LEGACY_ENDPOINT = LEADERBOARDS_ENDPOINT + "/legacy";
|
||||
public const string LEADERBOARDS_TOTAL_ENDPOINT = LEADERBOARDS_ENDPOINT + "/total";
|
||||
public const string PROFILE_ENDPOINT = BERRYDASH_ENDPOINT + "/profile";
|
||||
public const string PROFILE_POSTS_ENDPOINT = PROFILE_ENDPOINT + "/posts";
|
||||
public const string PROFILE_POSTS_ENDPOINT = BERRYDASH_ENDPOINT + "/profile/posts";
|
||||
public const string ICON_MARKETPLACE_ENDPOINT = BERRYDASH_ENDPOINT + "/icon-marketplace";
|
||||
public const string ICON_MARKETPLACE_UPLOAD_ENDPOINT = ICON_MARKETPLACE_ENDPOINT + "/upload";
|
||||
public const string ICON_MARKETPLACE_ICON_ENDPOINT = ICON_MARKETPLACE_ENDPOINT + "/icon";
|
||||
|
||||
@@ -28,6 +28,7 @@ public class ProfileMenu : MonoBehaviour
|
||||
[SerializeField] private TMP_Text coinBerryStat;
|
||||
[SerializeField] private TMP_Text randomBerryStat;
|
||||
[SerializeField] private TMP_Text antiBerryStat;
|
||||
[SerializeField] private TMP_Text goldenBerryStat;
|
||||
[SerializeField] private TMP_Text coinStat;
|
||||
[SerializeField] private TMP_Text playerNameText;
|
||||
[SerializeField] private Image playerIconImage;
|
||||
@@ -53,6 +54,7 @@ public class ProfileMenu : MonoBehaviour
|
||||
string coinBerries,
|
||||
string randomBerries,
|
||||
string antiBerries,
|
||||
string goldenBerries,
|
||||
string coins,
|
||||
string playerName,
|
||||
BigInteger playerID,
|
||||
@@ -71,6 +73,7 @@ public class ProfileMenu : MonoBehaviour
|
||||
coinBerryStat.text = Tools.FormatWithCommas(coinBerries);
|
||||
randomBerryStat.text = Tools.FormatWithCommas(randomBerries);
|
||||
antiBerryStat.text = Tools.FormatWithCommas(antiBerries);
|
||||
goldenBerryStat.text = Tools.FormatWithCommas(goldenBerries);
|
||||
coinStat.text = Tools.FormatWithCommas(coins);
|
||||
playerNameText.text = playerName;
|
||||
|
||||
@@ -109,7 +112,7 @@ public class ProfileMenu : MonoBehaviour
|
||||
public async Task Init(BigInteger playerID)
|
||||
{
|
||||
if (BazookaManager.Instance.GetAccountID() == playerID) { await Init(); return; }
|
||||
using UnityWebRequest request = UnityWebRequest.Get(Endpoints.PROFILE_ENDPOINT + "?userId=" + playerID.ToString());
|
||||
using UnityWebRequest request = UnityWebRequest.Get(Endpoints.BD_ACCOUNT_ENDPOINT + "?id=" + playerID.ToString() + "&exact=true");
|
||||
request.SetRequestHeader("Requester", "BerryDashClient");
|
||||
request.SetRequestHeader("ClientVersion", Application.version);
|
||||
request.SetRequestHeader("ClientPlatform", Application.platform.ToString());
|
||||
@@ -125,27 +128,31 @@ public class ProfileMenu : MonoBehaviour
|
||||
var jsonResponse = JObject.Parse(response);
|
||||
if ((bool)jsonResponse["success"])
|
||||
{
|
||||
var iconColorArray = jsonResponse["data"]["iconColor"].Type == JTokenType.Null ? new JArray(255, 255, 255) : (JArray)jsonResponse["data"]["iconColor"];
|
||||
var overlayColorArray = jsonResponse["data"]["overlayColor"].Type == JTokenType.Null ? new JArray(255, 255, 255) : (JArray)jsonResponse["data"]["overlayColor"];
|
||||
var iconColor = new Color((int)iconColorArray[0] / 255f, (int)iconColorArray[1] / 255f, (int)iconColorArray[2] / 255f);
|
||||
var overlayColor = new Color((int)overlayColorArray[0] / 255f, (int)overlayColorArray[1] / 255f, (int)overlayColorArray[2] / 255f);
|
||||
|
||||
var data = jsonResponse["data"].ToObject<Account>();
|
||||
|
||||
var iconColorArray = data.BirdColor;
|
||||
var overlayColorArray = data.OverlayColor;
|
||||
var iconColor = new Color(iconColorArray[0] / 255f, iconColorArray[1] / 255f, iconColorArray[2] / 255f);
|
||||
var overlayColor = new Color(overlayColorArray[0] / 255f, overlayColorArray[1] / 255f, overlayColorArray[2] / 255f);
|
||||
await Init(
|
||||
(string)jsonResponse["data"]["stats"]["totalNormalBerries"],
|
||||
(string)jsonResponse["data"]["stats"]["totalPoisonBerries"],
|
||||
(string)jsonResponse["data"]["stats"]["totalSlowBerries"],
|
||||
(string)jsonResponse["data"]["stats"]["totalUltraBerries"],
|
||||
(string)jsonResponse["data"]["stats"]["totalSpeedyBerries"],
|
||||
(string)jsonResponse["data"]["stats"]["totalCoinBerries"],
|
||||
(string)jsonResponse["data"]["stats"]["totalRandomBerries"],
|
||||
(string)jsonResponse["data"]["stats"]["totalAntiBerries"],
|
||||
(string)jsonResponse["data"]["stats"]["coins"],
|
||||
(string)jsonResponse["data"]["username"],
|
||||
data.Stats.TotalNormalBerries.ToString(),
|
||||
data.Stats.TotalPoisonBerries.ToString(),
|
||||
data.Stats.TotalSlowBerries.ToString(),
|
||||
data.Stats.TotalUltraBerries.ToString(),
|
||||
data.Stats.TotalSpeedyBerries.ToString(),
|
||||
data.Stats.TotalCoinBerries.ToString(),
|
||||
data.Stats.TotalRandomBerries.ToString(),
|
||||
data.Stats.TotalAntiBerries.ToString(),
|
||||
data.Stats.TotalGoldenBerries.ToString(),
|
||||
data.Stats.Coins.ToString(),
|
||||
data.Username,
|
||||
playerID,
|
||||
int.Parse(jsonResponse["data"]["icon"].Type == JTokenType.Null ? "1" : jsonResponse["data"]["icon"].ToString()),
|
||||
int.Parse(jsonResponse["data"]["overlay"].Type == JTokenType.Null ? "0" : jsonResponse["data"]["overlay"].ToString()),
|
||||
data.Icon,
|
||||
data.Overlay,
|
||||
iconColor,
|
||||
overlayColor,
|
||||
(string)jsonResponse["data"]["customIcon"]
|
||||
data.CustomIcon
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -173,6 +180,7 @@ public class ProfileMenu : MonoBehaviour
|
||||
BazookaManager.Instance.GetGameStoreTotalCoinBerries().ToString(),
|
||||
BazookaManager.Instance.GetGameStoreTotalRandomBerries().ToString(),
|
||||
BazookaManager.Instance.GetGameStoreTotalAntiBerries().ToString(),
|
||||
BazookaManager.Instance.GetGameStoreTotalGoldenBerries().ToString(),
|
||||
customIconData.Balance.ToString(),
|
||||
BazookaManager.Instance.GetAccountName().ToString(),
|
||||
BazookaManager.Instance.GetAccountID() ?? 0,
|
||||
|
||||
@@ -17,6 +17,7 @@ public class StatsMenu : MonoBehaviour
|
||||
[SerializeField] private TMP_Text coinBerryStat;
|
||||
[SerializeField] private TMP_Text randomBerryStat;
|
||||
[SerializeField] private TMP_Text antiBerryStat;
|
||||
[SerializeField] private TMP_Text goldenBerryStat;
|
||||
[SerializeField] private TMP_Text coinStat;
|
||||
|
||||
[SerializeField] private Image playerIcon;
|
||||
@@ -38,6 +39,7 @@ public class StatsMenu : MonoBehaviour
|
||||
coinBerryStat.text = Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalCoinBerries());
|
||||
randomBerryStat.text = Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalRandomBerries());
|
||||
antiBerryStat.text = Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalAntiBerries());
|
||||
goldenBerryStat.text = Tools.FormatWithCommas(BazookaManager.Instance.GetGameStoreTotalGoldenBerries());
|
||||
coinStat.text = Tools.FormatWithCommas(BazookaManager.Instance.GetCustomBirdIconData().Balance);
|
||||
|
||||
var customIcon = BazookaManager.Instance.GetCustomBirdIconData().Selected;
|
||||
|
||||
@@ -78,7 +78,7 @@ public static class Tools
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static BigInteger CalculateXP(BigInteger normalBerries, BigInteger poisonBerries, BigInteger slowBerries, BigInteger ultraBerries, BigInteger speedyBerries, BigInteger coinBerries)
|
||||
public static BigInteger CalculateXP(BigInteger normalBerries, BigInteger poisonBerries, BigInteger slowBerries, BigInteger ultraBerries, BigInteger speedyBerries, BigInteger coinBerries, BigInteger randomBerries, BigInteger antiBerries, BigInteger goldenBerries)
|
||||
{
|
||||
BigInteger totalXp = 0;
|
||||
totalXp += normalBerries;
|
||||
@@ -87,6 +87,9 @@ public static class Tools
|
||||
totalXp += ultraBerries * 5;
|
||||
totalXp += speedyBerries * 10;
|
||||
totalXp += coinBerries * 10;
|
||||
totalXp += randomBerries;
|
||||
totalXp -= antiBerries;
|
||||
totalXp += goldenBerries * 4;
|
||||
if (totalXp < 0) totalXp = 0;
|
||||
return totalXp;
|
||||
}
|
||||
@@ -99,7 +102,10 @@ public static class Tools
|
||||
BazookaManager.Instance.GetGameStoreTotalSlowBerries(),
|
||||
BazookaManager.Instance.GetGameStoreTotalUltraBerries(),
|
||||
BazookaManager.Instance.GetGameStoreTotalSpeedyBerries(),
|
||||
BazookaManager.Instance.GetGameStoreTotalCoinBerries()
|
||||
BazookaManager.Instance.GetGameStoreTotalCoinBerries(),
|
||||
BazookaManager.Instance.GetGameStoreTotalRandomBerries(),
|
||||
BazookaManager.Instance.GetGameStoreTotalAntiBerries(),
|
||||
BazookaManager.Instance.GetGameStoreTotalGoldenBerries()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,10 @@ public class Stats
|
||||
[JsonProperty("totalAntiBerries")]
|
||||
public BigInteger TotalAntiBerries { get; set; }
|
||||
|
||||
[Preserve]
|
||||
[JsonProperty("totalGoldenBerries")]
|
||||
public BigInteger TotalGoldenBerries { get; set; }
|
||||
|
||||
[Preserve]
|
||||
[JsonProperty("coins")]
|
||||
public BigInteger Coins { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user