mirror of
https://github.com/prosolis/gogobee.git
synced 2026-07-15 08:32:41 +00:00
Fix babysit logging, achievement table name, and blacksmith repair costs
- runAutoBabysitDay now logs daily totals (was silently skipping logBabysitActivity) - Stop wiping babysit_log on expiry/cancel; clear at next purchase instead so history persists between services - Fix achievement query referencing wrong table name (babysit_log -> adventure_babysit_log) - Tune blacksmith baseRates ([1,3,8,20,55,150] -> [1,2,5,12,30,80]) and soften the convexity (damage/100 -> damage/200) so mid-game repair drag isn't punitive Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1050,7 +1050,7 @@ func (p *AchievementsPlugin) buildAchievements() []achievementDef {
|
|||||||
Emoji: "🍼",
|
Emoji: "🍼",
|
||||||
Check: func(d *sql.DB, u id.UserID) bool {
|
Check: func(d *sql.DB, u id.UserID) bool {
|
||||||
var count int
|
var count int
|
||||||
_ = d.QueryRow(`SELECT COUNT(*) FROM babysit_log WHERE user_id = ?`, string(u)).Scan(&count)
|
_ = d.QueryRow(`SELECT COUNT(*) FROM adventure_babysit_log WHERE user_id = ?`, string(u)).Scan(&count)
|
||||||
return count > 0
|
return count > 0
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -137,6 +137,9 @@ func (p *AdventurePlugin) handleBabysitPurchase(ctx MessageContext, days int) er
|
|||||||
return p.SendDM(ctx.Sender, "Payment failed. The babysitter looked at your wallet and walked away.")
|
return p.SendDM(ctx.Sender, "Payment failed. The babysitter looked at your wallet and walked away.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear any leftover logs from prior service so this period's summary is clean
|
||||||
|
clearBabysitLogs(char.UserID)
|
||||||
|
|
||||||
// Set babysit fields
|
// Set babysit fields
|
||||||
skill := babysitWeakestSkill(char)
|
skill := babysitWeakestSkill(char)
|
||||||
expires := time.Now().UTC().Add(time.Duration(days) * 24 * time.Hour)
|
expires := time.Now().UTC().Add(time.Duration(days) * 24 * time.Hour)
|
||||||
@@ -243,9 +246,6 @@ func (p *AdventurePlugin) handleBabysitCancel(ctx MessageContext) error {
|
|||||||
slog.Error("babysit: failed to save character on cancel", "user", char.UserID, "err", err)
|
slog.Error("babysit: failed to save character on cancel", "user", char.UserID, "err", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear logs
|
|
||||||
clearBabysitLogs(char.UserID)
|
|
||||||
|
|
||||||
return p.SendDM(ctx.Sender, "🍼 Service cancelled. No refund. The babysitter was already there.\n\n"+summary)
|
return p.SendDM(ctx.Sender, "🍼 Service cancelled. No refund. The babysitter was already there.\n\n"+summary)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,13 +367,26 @@ func (p *AdventurePlugin) runAutoBabysitDay(char *AdventureCharacter) {
|
|||||||
skill := babysitWeakestSkill(char)
|
skill := babysitWeakestSkill(char)
|
||||||
activity := skillToActivity(skill)
|
activity := skillToActivity(skill)
|
||||||
|
|
||||||
|
var totalGold int
|
||||||
|
var totalXP int
|
||||||
|
var allItems []string
|
||||||
for char.HarvestActionsUsed < harvestMax {
|
for char.HarvestActionsUsed < harvestMax {
|
||||||
p.runBabysitAction(char, equip, activity, bonuses)
|
gold, xp, items := p.runBabysitAction(char, equip, activity, bonuses)
|
||||||
|
totalGold += gold
|
||||||
|
totalXP += xp
|
||||||
|
allItems = append(allItems, items...)
|
||||||
char.HarvestActionsUsed++
|
char.HarvestActionsUsed++
|
||||||
}
|
}
|
||||||
|
|
||||||
char.ActionTakenToday = true
|
char.ActionTakenToday = true
|
||||||
char.LastActionDate = time.Now().UTC().Format("2006-01-02")
|
char.LastActionDate = time.Now().UTC().Format("2006-01-02")
|
||||||
|
|
||||||
|
itemsJSON := ""
|
||||||
|
if len(allItems) > 0 {
|
||||||
|
itemsJSON = strings.Join(allItems, ", ")
|
||||||
|
}
|
||||||
|
logBabysitActivity(char.UserID, string(activity), "auto_babysit_daily",
|
||||||
|
totalGold, totalXP, itemsJSON)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Expiry Check ────────────────────────────────────────────────────────────
|
// ── Expiry Check ────────────────────────────────────────────────────────────
|
||||||
@@ -403,8 +416,6 @@ func (p *AdventurePlugin) checkBabysitExpiry(chars []AdventureCharacter) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
clearBabysitLogs(char.UserID)
|
|
||||||
|
|
||||||
if err := p.SendDM(char.UserID, summary); err != nil {
|
if err := p.SendDM(char.UserID, summary); err != nil {
|
||||||
slog.Error("babysit: failed to send expiry summary DM", "user", char.UserID, "err", err)
|
slog.Error("babysit: failed to send expiry summary DM", "user", char.UserID, "err", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
|
|
||||||
// ── Pricing ─────────────────────────────────────────────────────────────────
|
// ── Pricing ─────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
var blacksmithBaseRates = [6]int{1, 3, 8, 20, 55, 150}
|
var blacksmithBaseRates = [6]int{1, 2, 5, 12, 30, 80}
|
||||||
|
|
||||||
func blacksmithRepairCost(eq *AdvEquipment) int {
|
func blacksmithRepairCost(eq *AdvEquipment) int {
|
||||||
if eq == nil || eq.Condition >= 100 {
|
if eq == nil || eq.Condition >= 100 {
|
||||||
@@ -34,7 +34,7 @@ func blacksmithRepairCost(eq *AdvEquipment) int {
|
|||||||
}
|
}
|
||||||
baseRate := float64(blacksmithBaseRates[tier])
|
baseRate := float64(blacksmithBaseRates[tier])
|
||||||
damage := float64(100 - eq.Condition)
|
damage := float64(100 - eq.Condition)
|
||||||
condMult := 1.0 + damage/100.0
|
condMult := 1.0 + damage/200.0
|
||||||
costPerPoint := baseRate * condMult
|
costPerPoint := baseRate * condMult
|
||||||
return int(math.Ceil(costPerPoint * damage))
|
return int(math.Ceil(costPerPoint * damage))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user