mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-26 07:29:00 -07:00
Radicade Public Code
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using RadicadeServer.DB;
|
||||
using RadicadeServer.Extensions;
|
||||
using RadicadeServer.RecNet.Enums.Store;
|
||||
using RadicadeServer.RecNet.Responses;
|
||||
using RadicadeServer.Utils;
|
||||
|
||||
namespace RadicadeServer.API.Storefront.V4;
|
||||
|
||||
[Route("api/storefronts/v4")]
|
||||
[Route("econ/api/storefronts/v4")]
|
||||
public class StorefrontsV4(RecDBContext db) : Controller
|
||||
{
|
||||
[HttpGet("balance/{type}"), Authorize]
|
||||
public async Task<List<BalanceResponse>?> GetBalance(CurrencyType type)
|
||||
{
|
||||
var userId = User.GetUserId(); var data = await db.Currency.FirstOrDefaultAsync(x => x.AccountId == userId);
|
||||
|
||||
long balance;
|
||||
if (type == CurrencyType.RecRoyale_Season1)
|
||||
{
|
||||
|
||||
|
||||
var progression = await db.Progression.FirstOrDefaultAsync(x => x.PlayerId == userId);
|
||||
balance = progression == null ? 0 : LevelUpGiftService.XpIntoCurrentLevel(progression);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (data == null) return [];
|
||||
balance = type switch
|
||||
{
|
||||
CurrencyType.RecCenterTokens => data.RecTokens,
|
||||
CurrencyType.LaserTagTickets => data.LaserTagTickets,
|
||||
CurrencyType.LostSkullsGold => data.Gold,
|
||||
CurrencyType.DraculaSilver => data.DraculaSilver,
|
||||
_ => 0
|
||||
};
|
||||
}
|
||||
|
||||
return new List<BalanceResponse> { new() { CurrencyType = type, Balance = balance } };
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user