Skip to content

Fix daily reward eligibility to use configurable calendar days instead of 24-hour intervals#1

Merged
caprapaul merged 3 commits intomasterfrom
copilot/fix-42c713e7-7dc7-4113-9ce5-3a7d41dd8d88
Sep 2, 2025
Merged

Fix daily reward eligibility to use configurable calendar days instead of 24-hour intervals#1
caprapaul merged 3 commits intomasterfrom
copilot/fix-42c713e7-7dc7-4113-9ce5-3a7d41dd8d88

Conversation

Copy link
Copy Markdown

Copilot AI commented Sep 2, 2025

This PR updates the daily reward system in CasinoService to use calendar day-based eligibility with a configurable interval instead of fixed 24-hour periods.

Problem

Previously, users had to wait exactly 24 hours from their last daily reward claim before becoming eligible again. This meant:

  • A user claiming at 11 PM would have to wait until 11 PM the next day
  • Users in different time zones had varying optimal claim times
  • The system felt less intuitive than typical "daily" mechanics
  • The interval was hardcoded to 1 day and not configurable by server admins

Solution

The logic now compares calendar dates instead of time intervals and uses a configurable setting for the number of days:

// Before: 24-hour interval from last claim
var nextRewardTime = user.LastDailyReward.AddSeconds(_settings.CasinoDailyRewardIntervalSeconds);

// After: Configurable number of calendar days after last claim
var nextRewardTime = user.LastDailyReward.Date.AddDays(_settings.CasinoDailyRewardIntervalDays);

Changes Made

  • TryClaimDailyReward: Updated eligibility check to use user.LastDailyReward.Date.AddDays(_settings.CasinoDailyRewardIntervalDays)
  • TryClaimDailyReward: Updated return value to use now.Date.AddDays(_settings.CasinoDailyRewardIntervalDays) for consistent calendar logic
  • GetNextDailyRewardTime: Updated to use configurable interval setting
  • Settings: Renamed CasinoDailyRewardIntervalSeconds to CasinoDailyRewardIntervalDays with default value of 1

Impact

Users can now claim their daily reward once per configurable calendar day period (UTC), providing a more intuitive and flexible experience:

  • Claiming at 11 PM allows the next claim at 12 AM (1 hour later) when set to 1 day
  • All users become eligible at the same UTC midnight boundary
  • Server admins can configure the interval (e.g., daily=1, every 2 days=2, weekly=7)
  • Maintains the "once per period" restriction while improving user experience

This change is backward compatible with existing database schemas and user data.

This pull request was created as a result of the following prompt from Copilot chat.

Update TryClaimDailyReward in CasinoService so daily reward eligibility is checked by calendar day instead of interval seconds. Compare now.Date and user.LastDailyReward.Date, and set nextRewardTime to the start of the next calendar day after the last claim. Use nextRewardTime in both the eligibility check and the return value. The updated logic should look like:

var now = DateTime.UtcNow;
var nextRewardTime = user.LastDailyReward.Date.AddDays(1);
if (now < nextRewardTime)
{
// User has already claimed today
return (false, 0, user.Tokens, nextRewardTime);
}
// User can claim daily reward
// ... (rest unchanged)

This ensures users can claim their reward once per calendar day. All usages of the old interval-based logic should be replaced. Target the fork source branch for the PR.

References:
https://github.com/caprapaul/UDC-Bot/blob/master/DiscordBot/Services/Casino/CasinoService.cs#L318


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…conds

Co-authored-by: caprapaul <35493559+caprapaul@users.noreply.github.com>
Copilot AI changed the title [WIP] Make daily reward eligibility check by calendar day in CasinoService Fix daily reward eligibility to use calendar days instead of 24-hour intervals Sep 2, 2025
Copilot AI requested a review from caprapaul September 2, 2025 14:41
caprapaul

This comment was marked as duplicate.

@caprapaul
Copy link
Copy Markdown
Owner

@copilot Can you make the existing setting be used for the number of days? Also rename it from CasinoDailyRewardIntervalSeconds to CasinoDailyRewardIntervalDays

…ays and make interval configurable

Co-authored-by: caprapaul <35493559+caprapaul@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Sep 2, 2025

@copilot Can you make the existing setting be used for the number of days? Also rename it from CasinoDailyRewardIntervalSeconds to CasinoDailyRewardIntervalDays

Done! I've renamed CasinoDailyRewardIntervalSeconds to CasinoDailyRewardIntervalDays and updated all the hardcoded AddDays(1) calls to use _settings.CasinoDailyRewardIntervalDays. The default value is now 1 day, but server admins can configure it to any number of days (e.g., 2 for every 2 days, 7 for weekly rewards). Commit eb1e749

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • www.myget.org
    • Triggering command: dotnet build --no-restore (dns block)
    • Triggering command: dotnet restore (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Fix daily reward eligibility to use calendar days instead of 24-hour intervals Fix daily reward eligibility to use configurable calendar days instead of 24-hour intervals Sep 2, 2025
Copilot AI requested a review from caprapaul September 2, 2025 14:51
@caprapaul caprapaul marked this pull request as ready for review September 2, 2025 14:54
@caprapaul caprapaul merged commit 36cf0f5 into master Sep 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants