feat(economy): add /lottery - daily draw, weighted winner takes the pot
Buy tickets (200 coins each, max 100/draw); one winner is drawn daily at 21:00 Tallinn time weighted by ticket count and credited the whole pot. Coin-conserving by design: each ticket's cost is deducted at purchase and the winner is minted exactly the sum of all ticket spend - no shared pot record, so no cross-period race. Ticket state lives per-user keyed by draw period (full scan only at draw time and for the pot view). - New lottery.py: TICKET_COST/MAX_TICKETS/DRAW_HOUR, pure period_for, and do_buy_ticket / get_lottery_state / do_lottery_draw. New lottery_tickets + lottery_period schema fields (period added to _TEXT_FIELDS). - /lottery [kogus] command (view or buy) with full failure handling. - Scheduled lottery_draw_daily loop in bot.py (both profiles; each draws its own collection), announcing to the optional LOTTERY_CHANNEL_ID (config + .env). 14 tests: period boundary, buy/accumulate/reset/caps/guards, pot state, draw payout with coin conservation, and the more-tickets-wins-more weighting. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013VbAVsrZuYesea99mPMmPT
This commit is contained in:
@@ -31,6 +31,12 @@ BIRTHDAY_CHANNEL_ID=
|
||||
# How many days before a birthday the on-join check counts as "coming up"
|
||||
BIRTHDAY_WINDOW_DAYS=7
|
||||
|
||||
# Channel ID where the daily lottery draw result is announced (optional - the
|
||||
# draw still runs and pays the winner if unset; per-profile like BIRTHDAY_CHANNEL)
|
||||
LOTTERY_CHANNEL_ID_DEV=
|
||||
LOTTERY_CHANNEL_ID_ECONOMY=
|
||||
LOTTERY_CHANNEL_ID=
|
||||
|
||||
# PocketBase backend (https://pocketbase.io)
|
||||
PB_URL=http://127.0.0.1:8090
|
||||
PB_ADMIN_EMAIL=admin@example.com
|
||||
|
||||
Reference in New Issue
Block a user