mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-26 07:28:45 -07:00
f6a4fdc5fb
Port the admin-editable weekly-challenge feature to the 2020.03 branch and fix the skin-reward bug it had on December: rewards now actually land in the player's inventory instead of only granting XP + tokens. Server config: add WeeklyChallenges* columns to ServerSettings (Postgres post-EnsureCreated patches + SQLite column patches), and port the ServerSettingsService weekly methods/records. The reward record carries the store item Slug — the reliable handle December lacked — so the grant can resolve the real item. ProgressionController: CurrentChallenge + updateProgress now read the configured slate and reward instead of a hardcoded one, keeping the 2020.03 ChallengeMap/ChallengeGift wire shapes (verified against the march dump: ChallengeGift TypeDefIndex 11455). The Gift now sends AvatarItemType (Outfit when an AvatarItemDesc is set) so the watch's gift-card render binds the avatar preview. On completing the week's challenges the configured skin/consumable is granted via the new StoreService.GrantItemFreeBySlugAsync (same inventory path as a purchase, no charge), gated behind the once-only reward sentinel. Admin: GET/POST settings/weekly-challenges + reward-options (avatar + consumable only — 2020.03 StoreService has no equipment payload helper), and the admin-ui Server settings page to edit the slate + reward. The reward picker keys on item slug rather than December's fragile descriptor-string match. Docs: README no longer lists weekly challenges as December-only; url-coverage notes the config-driven challenge endpoints + skin grant.
46 lines
2.2 KiB
C#
46 lines
2.2 KiB
C#
namespace DorkNet.Server.Data.Entities;
|
|
|
|
/// <summary>
|
|
/// Single-row table holding server-wide runtime toggles that admins can
|
|
/// flip from the SPA without a redeploy. Modelled after
|
|
/// <see cref="CommunityBoardEntity"/>: <see cref="Id"/> is pinned to 1
|
|
/// so EF Core has a key to track changes against, and reads/writes
|
|
/// touch one row.
|
|
///
|
|
/// Add new boolean (or scalar) columns directly to this entity as more
|
|
/// toggles appear — keeping them strongly typed beats a generic
|
|
/// key/value table for the dozen-or-so global switches we'll ever have.
|
|
/// </summary>
|
|
public class ServerSettingsEntity
|
|
{
|
|
public int Id { get; set; } = 1;
|
|
|
|
/// <summary>When true, the watch's account-creation endpoints
|
|
/// (<c>POST /account/create</c> and <c>POST /api/account/v1/create</c>)
|
|
/// short-circuit with <c>Success=false</c> and the watch surfaces
|
|
/// the error to the player. Existing logins are unaffected; only
|
|
/// brand-new account requests are blocked.</summary>
|
|
public bool SignupsDisabled { get; set; }
|
|
|
|
/// <summary>When true, the watch's weekly-challenge map reports
|
|
/// <c>CompletedRequired</c> — the player must finish every listed
|
|
/// challenge before the gift unlocks. Mirrors
|
|
/// <c>ChallengeMap.CompletedRequired</c> on the 2020.03 client.</summary>
|
|
public bool WeeklyChallengesCompletedRequired { get; set; } = true;
|
|
|
|
/// <summary>JSON-serialised <c>List<WeeklyChallengeTemplate></c>
|
|
/// (see <c>ServerSettingsService</c>). Empty string falls back to
|
|
/// <c>ServerSettingsService.DefaultWeeklyChallenges()</c>. Admin-
|
|
/// editable from the SPA Settings page so the weekly slate can change
|
|
/// without a redeploy.</summary>
|
|
public string WeeklyChallengesJson { get; set; } = string.Empty;
|
|
|
|
/// <summary>JSON-serialised <c>WeeklyChallengeReward</c> — the gift
|
|
/// granted when the week's challenges complete (XP + tokens, plus an
|
|
/// optional store skin identified by <c>Slug</c>). Empty string falls
|
|
/// back to <c>ServerSettingsService.DefaultWeeklyReward()</c>.</summary>
|
|
public string WeeklyChallengeRewardJson { get; set; } = string.Empty;
|
|
|
|
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
|
|
}
|