mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 08:32:41 +00:00
Add blacksmith repair system, community lottery, and audit fixes
Blacksmith: equipment repair with tier-based pricing, DM confirmation flow, masterwork/arena surcharges, full flavor text pools. Added to main adventure menu as option 6 (rest bumped to 7). Lottery: weekly draw (Friday 23:59 UTC), ticket purchases with 100/week cap, Fisher-Yates number generation, fixed+jackpot prize tiers, community pot funding, Thursday reminders, draw history. Audit fixes: TOCTOU in blacksmith repair costs (recompute from fresh equipment), user lock in DM slot selection, partial repair refund tracking, error logging on save failures, Fisher-Yates bias correction, communityPotDebit return value checks in draw execution. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -169,6 +169,24 @@ func communityPotAdd(amount int) {
|
||||
)
|
||||
}
|
||||
|
||||
func communityPotBalance() int {
|
||||
d := db.Get()
|
||||
var balance int
|
||||
_ = d.QueryRow(`SELECT COALESCE(balance, 0) FROM community_pot WHERE id = 1`).Scan(&balance)
|
||||
return balance
|
||||
}
|
||||
|
||||
func communityPotDebit(amount int) bool {
|
||||
d := db.Get()
|
||||
res, err := d.Exec(`UPDATE community_pot SET balance = balance - ?, updated_at = CURRENT_TIMESTAMP
|
||||
WHERE id = 1 AND balance >= ?`, amount, amount)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
n, _ := res.RowsAffected()
|
||||
return n == 1
|
||||
}
|
||||
|
||||
func loadExpiredRivalChallenges() ([]advRivalChallenge, error) {
|
||||
d := db.Get()
|
||||
rows, err := d.Query(`
|
||||
|
||||
Reference in New Issue
Block a user