mirror of
https://github.com/JogmansonReal/Radicade.git
synced 2026-10-26 07:29:00 -07:00
167 lines
5.6 KiB
C#
167 lines
5.6 KiB
C#
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using RadicadeServer.DB;
|
|
using RadicadeServer.Extensions;
|
|
using RadicadeServer.RecNet.Avatar;
|
|
using RadicadeServer.RecNet.Enums.Store;
|
|
using RadicadeServer.RecNet.Store;
|
|
using RadicadeServer.RecNet.Storefront;
|
|
using RadicadeServer.API.Storefront;
|
|
|
|
namespace RadicadeServer.API.Storefront.V1;
|
|
|
|
[Route("api/storefronts/v1")]
|
|
[Route("econ/api/storefronts/v1")]
|
|
public class StorefrontsV1(RecDBContext db) : Controller
|
|
{
|
|
[HttpGet("season/{type}")]
|
|
public IActionResult GetSeason(StorefrontTypes type)
|
|
{
|
|
if (type != StorefrontTypes.RecRoyale)
|
|
return NotFound();
|
|
|
|
const int maxTiers = 20;
|
|
const int elitePurchasableItemId = 200100;
|
|
const int tierPriceTokens = 500;
|
|
|
|
var tiers = new List<SeasonTierDTO>();
|
|
for (int tier = 1; tier <= maxTiers; tier++)
|
|
{
|
|
var gift = new Gift
|
|
{
|
|
GiftDropId = StorefrontShared.NewGiftDropId(),
|
|
FriendlyName = $"Season 1 Tier {tier} Reward",
|
|
Tooltip = "Rec Royale Season 1 reward.",
|
|
CurrencyType = CurrencyType.RecRoyale_Season1,
|
|
Currency = 100 + tier * 50,
|
|
Context = GiftContext.RecRoyale,
|
|
Rarity = tier >= 15 ? Rarity.Epic : tier >= 8 ? Rarity.Rare : Rarity.Common
|
|
};
|
|
tiers.Add(new SeasonTierDTO
|
|
{
|
|
PurchasableItemId = 200000 + tier,
|
|
Type = PurchasableItem.PurchasableItemType.SeasonTier,
|
|
IsFeatured = tier == 1,
|
|
Prices = new List<PurchasablePrice>
|
|
{
|
|
new() { CurrencyType = CurrencyType.RecCenterTokens, Price = tierPriceTokens + (tier - 1) * 250 }
|
|
},
|
|
SubscriberPrices = new List<PurchasablePrice>(),
|
|
EndDate = null,
|
|
NewUntil = DateTime.MaxValue,
|
|
GiftDrops = new List<Gift> { gift },
|
|
Tier = tier,
|
|
Rewards = new List<SeasonRewardItemDTO>
|
|
{
|
|
new()
|
|
{
|
|
RequiresEliteUpgrade = false,
|
|
GiftDrop = gift,
|
|
SeasonXpBoost = 0f
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
var eliteGift = new Gift
|
|
{
|
|
GiftDropId = StorefrontShared.NewGiftDropId(),
|
|
FriendlyName = "Rec Royale Season 1 Elite Upgrade",
|
|
Tooltip = "Unlocks the elite track for every tier.",
|
|
CurrencyType = CurrencyType.RecRoyale_Season1,
|
|
Currency = 500,
|
|
Context = GiftContext.RecRoyale,
|
|
Rarity = Rarity.Epic
|
|
};
|
|
var eliteUpgrade = new PurchasableGiftDrop
|
|
{
|
|
PurchasableItemId = elitePurchasableItemId,
|
|
Type = PurchasableItem.PurchasableItemType.SeasonEliteUpgrade,
|
|
IsFeatured = true,
|
|
Prices = new List<PurchasablePrice>
|
|
{
|
|
new() { CurrencyType = CurrencyType.RecCenterTokens, Price = 2000 }
|
|
},
|
|
SubscriberPrices = new List<PurchasablePrice>(),
|
|
EndDate = null,
|
|
GiftDrops = new List<Gift> { eliteGift }
|
|
};
|
|
|
|
var now = DateTime.UtcNow;
|
|
var season = new SeasonStorefrontDTO
|
|
{
|
|
StorefrontType = StorefrontTypes.RecRoyale,
|
|
NextUpdate = DateTime.MaxValue,
|
|
NewUntil = DateTime.MaxValue,
|
|
EndDate = DateTime.MaxValue,
|
|
Season = 1,
|
|
Name = "Rec Royale Season 1",
|
|
StartAt = now.AddDays(-30),
|
|
EndAt = now.AddDays(30),
|
|
CurrencyType = CurrencyType.RecRoyale_Season1,
|
|
EliteUpgrade = eliteUpgrade,
|
|
Tiers = tiers,
|
|
PersonalDetails = new SeasonPersonalDetailsDTO
|
|
{
|
|
HasEliteUpgrade = false,
|
|
HasEliteUpgradePlatformMask = 0,
|
|
CurrentSeasonTier = 0,
|
|
ModifiedAt = now
|
|
}
|
|
};
|
|
return Ok(season);
|
|
}
|
|
|
|
[HttpGet("balanceAddType/{type}/{addType}"), Authorize]
|
|
public IActionResult GetBalanceAddConfig(CurrencyType type, StorefrontBalanceAddTypes addType)
|
|
{
|
|
var userId = User.GetUserId();
|
|
|
|
return Ok(new StorefrontBalanceAddConfigDTO
|
|
{
|
|
BalanceAddType = addType,
|
|
CurrencyType = type,
|
|
BaseAward = 10,
|
|
RateLimit = 0,
|
|
Multiplier = 1f
|
|
});
|
|
}
|
|
|
|
[HttpGet("{type}")]
|
|
public async Task<IActionResult> GetStorefront(StorefrontTypes type)
|
|
{
|
|
var items = await StorefrontShared.GetStoreItems(db, (long)type);
|
|
if (items.Count == 0 && !Enum.IsDefined(typeof(StorefrontTypes), type))
|
|
return NotFound();
|
|
return Ok(new GiftDropStorefront
|
|
{
|
|
NextUpdate = DateTime.MaxValue,
|
|
NewUntil = null,
|
|
StorefrontType = type,
|
|
StoreItems = items
|
|
});
|
|
}
|
|
|
|
[HttpGet("toptoday")]
|
|
public async Task<IActionResult> GetTopItems()
|
|
{
|
|
var items = await StorefrontShared.GetStoreItems(db, (long)StorefrontTypes.Watch);
|
|
|
|
return Ok(items.Where(x => x.IsFeatured).Select(x => x.PurchasableItemId).ToList());
|
|
}
|
|
|
|
[HttpPost("objectives"), Authorize]
|
|
public IActionResult CompleteObjectives([FromBody] List<CompleteObjectiveDTO> objectives)
|
|
{
|
|
var userId = User.GetUserId();
|
|
|
|
return Ok();
|
|
}
|
|
|
|
[HttpGet("adcarouselitems")]
|
|
public IActionResult GetAdCarouselItems()
|
|
{
|
|
return Ok(Array.Empty<AdCarouselItemDTO>());
|
|
}
|
|
}
|