Add gameplay cap and DB parsing fix JB-patch-2#159
Open
JerryBorisov wants to merge 4 commits into
Open
Conversation
# PR Submission Texts (Ready to Copy/Paste) ## Branch Name `JerryBorisov-patch-2` ## Commit Summary `Add daily gameplay cap, cap commands, and DB datetime parsing fix` ## Optional Extended Description Implemented a gameplay-only daily credit cap system with configurable limits and reset window through `DailyEarnedCreditsCap` (`Enabled`, `MaxCreditsPerDay`, `ResetEveryHours`). Added bounded reward behavior to prevent over-cap grants (partial credit grant when reward exceeds remaining cap) while preserving existing behavior for non-gameplay credit sources (admin/manual/API/website) and negative credit adjustments. Introduced player/admin operational commands: `css_capstatus` for cap progress visibility and `css_capreset <player|steamid|target>` for targeted cap state reset with database persistence. Added one-time notification logic when a player reaches the daily gameplay cap, including config-driven messaging and localization support. Extended language resources with new cap-related keys (`cap_reached`, `cap_status`, `cap_disabled`, `cap_reset_success`) and added `bg.json` for Bulgarian localization coverage. Resolved player load instability by fixing `DailyGameplayCreditsWindowStart` deserialization/parsing in database load flow, preventing `Error parsing column ... - Object` failures and retry loops. ## PR Title `Add daily gameplay credits cap, cap status/reset commands, and DB datetime parsing fix` ## PR Description ```md ## Summary This PR adds a daily cap system for gameplay-earned Store credits, new cap-related commands, and a fix for player loading errors caused by `DailyGameplayCreditsWindowStart` parsing. ## What was added ### 1) Daily Gameplay Credits Cap - Added configurable daily cap section: ```toml [DailyEarnedCreditsCap] Enabled = true MaxCreditsPerDay = 70 ResetEveryHours = 24 ``` - Cap applies only to positive gameplay-earned credits. - Manual/admin/API/website credits are not capped. - Negative credits (penalties) still apply normally. - Partial reward support: - example: if player has 68/70 and earns +5, only +2 is granted. - Reset window is configurable (`ResetEveryHours`, default 24h). ### 2) New Commands - `css_capstatus` (player command) - Shows current cap progress, remaining credits, and reset time. - `css_capreset <player|steamid|target>` (admin command) - Resets cap progress for selected player/target. - Supports SteamID and target groups. - Persists reset in DB. ### 3) One-time cap reached notification - Added one-time message when player reaches cap. - Configurable via: - `NotifyOnceOnReached` - `ReachedCapMessage` ### 4) Localized messages support for cap - Added config toggle: - `UseLocalizedMessages = true` - Added language keys: - `cap_reached` - `cap_status` - `cap_disabled` - `cap_reset_success` - Added new `Store/lang/bg.json`. - Updated all existing language files with new keys. ### 5) DB/player-load parsing fix - Fixed parsing error: - `Error parsing column ... DailyGameplayCreditsWindowStart=... - Object` - `LoadPlayer` now reads window start as formatted SQL text and parses safely in C#. - Prevents load failure/retry loop for affected players. ## Config updates ### Commands - `CapStatus = [ "capstatus" ]` - `CapReset = [ "capreset" ]` ### Permissions - `CapReset = "@css/root"` (default) ### Daily cap extra options - `UseLocalizedMessages` - `NotifyOnceOnReached` - `StatusMessage` - `DisabledStatusMessage` - `ResetSuccessMessage` ## Notes - This PR does not modify store prices/items behavior. - Model resource warnings (missing models) are unrelated to this change. ## Testing - Project builds successfully. - Login/load issue related to `DailyGameplayCreditsWindowStart` parsing resolved. - `capstatus` and `capreset` commands verified. - Daily cap logic verified (including partial reward at cap boundary). ```
Owner
|
@JerryBorisov |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Submission Texts (Ready to Copy/Paste)
Branch Name
JerryBorisov-patch-2Commit Summary
Add daily gameplay cap, cap commands, and DB datetime parsing fixOptional Extended Description
Implemented a gameplay-only daily credit cap system with configurable limits and reset window through
DailyEarnedCreditsCap(Enabled,MaxCreditsPerDay,ResetEveryHours). Added bounded reward behavior to prevent over-cap grants (partial credit grant when reward exceeds remaining cap) while preserving existing behavior for non-gameplay credit sources (admin/manual/API/website) and negative credit adjustments. Introduced player/admin operational commands:css_capstatusfor cap progress visibility andcss_capreset <player|steamid|target>for targeted cap state reset with database persistence. Added one-time notification logic when a player reaches the daily gameplay cap, including config-driven messaging and localization support. Extended language resources with new cap-related keys (cap_reached,cap_status,cap_disabled,cap_reset_success) and addedbg.jsonfor Bulgarian localization coverage. Resolved player load instability by fixingDailyGameplayCreditsWindowStartdeserialization/parsing in database load flow, preventingError parsing column ... - Objectfailures and retry loops.PR Title
Add daily gameplay credits cap, cap status/reset commands, and DB datetime parsing fixPR Description
ResetEveryHours, default 24h).2) New Commands
css_capstatus(player command)css_capreset <player|steamid|target>(admin command)3) One-time cap reached notification
NotifyOnceOnReachedReachedCapMessage4) Localized messages support for cap
UseLocalizedMessages = truecap_reachedcap_statuscap_disabledcap_reset_successStore/lang/bg.json.5) DB/player-load parsing fix
Error parsing column ... DailyGameplayCreditsWindowStart=... - ObjectLoadPlayernow reads window start as formatted SQL text and parses safely in C#.Config updates
Commands
CapStatus = [ "capstatus" ]CapReset = [ "capreset" ]Permissions
CapReset = "@css/root"(default)Daily cap extra options
UseLocalizedMessagesNotifyOnceOnReachedStatusMessageDisabledStatusMessageResetSuccessMessageNotes
Testing
DailyGameplayCreditsWindowStartparsing resolved.capstatusandcapresetcommands verified.