Commit graph

205 commits

Author SHA1 Message Date
NotARoomba
c9643e3df4 new shop calcs 2026-02-23 14:34:42 -05:00
NotARoomba
064a10578b update stuff 2026-02-23 13:33:43 -05:00
NotARoomba
472fea634a Update ysws.ts 2026-02-23 12:34:49 -05:00
End Nightshade
89069f3fa9
fix(admin): fix EV simulation using perRollMultiplier as base cost multiplier
Same bug as backend — perRollMultiplier (0.05) was applied as a direct
multiplier on base roll cost in the admin shop EV simulation, making
everything appear exploitable (red).
2026-02-22 18:46:49 -07:00
End Nightshade
55477673ab
fix(frontend): resolve all 5 pre-existing TypeScript errors
- i18n: widen Translations type to accept any string values
- home: fix async onMount returning cleanup function
- CreateProjectModal: import Project from stores instead of local interface
- user profile: non-null assert githubUrl inside existence check
2026-02-22 18:42:59 -07:00
End Nightshade
dfa61ff117
fix(shop): remove perRollMultiplier from base roll cost calculation
perRollMultiplier (default 0.05) was being applied as a direct multiplier
on the base roll cost, making everything cost 1-3 scraps instead of the
correct amount. It should only be used as an escalation factor per
previous roll: displayRollCost = baseRollCost * (1 + perRollMultiplier * rollCount)
2026-02-22 18:35:14 -07:00
End Nightshade
bd133c09d6 refactor(db): use new drizzle({ client: pool }) API 2026-02-22 17:04:45 -08:00
End Nightshade
69b0309811 chore(backend): rebuild dist 2026-02-22 17:04:45 -08:00
End Nightshade
85683b860a fix(admin): decrement stock on restore, preserve notes/isFulfilled/updatedAt
- Restore handler now decrements shop_items.count for purchase/luck_win
  orders (reverses the increment from delete), with GREATEST(..., 0) guard
- Delete handler now selects notes, isFulfilled, updatedAt so they're
  included in the archived deleted_payload JSONB
- Restore INSERT now includes notes, is_fulfilled, updated_at columns
2026-02-22 17:04:45 -08:00
End Nightshade
52b3e37c8f chore(backend): rebuild dist 2026-02-22 17:04:45 -08:00
End Nightshade
f85fde1937 feat(frontend): fetch server config on startup for canonical pricing
- Add fetchServerConfig to config.ts (fetches /admin/config endpoint)
- Call fetchServerConfig in +layout.svelte onMount for early client init
- Format long lines in admin dashboard page
2026-02-22 17:04:45 -08:00
End Nightshade
7367dac120 feat(shop): add displayRollCost and perRollMultiplier frontend support
- Add displayRollCost to ShopItem interface in stores
- ShopItemModal and shop page prefer server-provided displayRollCost
- Clean up as-any casts in ShopItemModal roll cost computation
- Admin shop: add perRollMultiplier to item type and EV simulation
- Remove unused modalEV derived (dead code, formEV used in template)
2026-02-22 17:04:45 -08:00
End Nightshade
719b4cb04d feat(admin): add order delete confirmation modal with undo toast
- Delete modal requires reason (min 3 chars) before sending DELETE
- Undo toast allows 30-second window to restore deleted order
- Admin user detail page: replace soft-delete + DELETE with single DELETE
  call including reason payload
- Add lightweight DOM toast helper for status messages
2026-02-22 17:04:45 -08:00
End Nightshade
e9e11101c8 fix(admin): fix order delete/restore with single JSONB payload archive
- Archive order + related rows (refinery, rolls, penalties) into single
  deleted_payload JSONB column matching migration 0014 schema
- Add runtime CREATE TABLE fallback for missing admin_deleted_orders
- Full restore handler restores order with original ID (OVERRIDING SYSTEM
  VALUE) plus all related rows; remove duplicate simple restore handler
- Delete transaction refunds stock count for purchase/luck_win orders
- Add detailed error logging for diagnostics
- Add batch compute-roll-costs endpoint and per-roll multiplier support
2026-02-22 17:04:45 -08:00
End Nightshade
ec726b0745 feat(shop): serve displayRollCost and perRollMultiplier from backend, add identity token refresh 2026-02-22 17:04:45 -08:00
End Nightshade
7db3230af4 fix(shop): rework pricing calculation with budget-capped upgrade costs and per-roll multiplier 2026-02-22 17:04:45 -08:00
End Nightshade
e80c0deb79 feat(shop): add perRollMultiplier and upgradeBudgetMultiplier columns to shop_items 2026-02-22 17:04:45 -08:00
End Nightshade
9fd24159d7 feat(db): use pg pool with error handling and graceful shutdown 2026-02-22 17:04:45 -08:00
santiago
a5cf64c1b0
fix bugs 2026-02-21 23:16:47 -05:00
NotARoomba
2348592b58 no hackatiem id sent 2026-02-21 01:14:19 -05:00
NotARoomba
42ce53ea15 remove ecvessive logging 2026-02-21 01:08:41 -05:00
NotARoomba
78a0ef69da fix hackatimea aaaaaaaaaaa 2026-02-21 01:05:56 -05:00
NotARoomba
ca20718445 fix hackatime hopefully 2026-02-21 00:13:04 -05:00
NotARoomba
c286a7a754 Update leaderboard.ts 2026-02-20 21:17:02 -05:00
NotARoomba
cd7a078e57 hackatime banned ppl 2026-02-20 20:06:57 -05:00
NotARoomba
ca8802922a Merge branch 'main' of https://github.com/hackclub/scraps 2026-02-20 19:41:07 -05:00
NotARoomba
5a1c06628e Update scraps.ts 2026-02-20 19:41:02 -05:00
End Nightshade
1fbcdaab93
idek 2026-02-20 17:33:06 -07:00
NotARoomba
3ced8845e9 scraps stuff 2026-02-20 19:04:32 -05:00
NotARoomba
2a0a9ec79b non buyer refinery 2026-02-20 18:55:55 -05:00
NotARoomba
fa338e9229 maybe final shop update 2026-02-20 18:40:22 -05:00
NotARoomba
9421db9672 aaa 2026-02-20 18:15:20 -05:00
NotARoomba
a25fe6eae4 Merge branch 'main' of https://github.com/hackclub/scraps 2026-02-20 17:16:51 -05:00
NotARoomba
d76aedf85e sold out items section 2026-02-20 17:16:45 -05:00
sbeltranc
90a42307a7 Merge branch 'main' of https://github.com/hackclub/scraps 2026-02-20 16:56:45 -05:00
sbeltranc
d4bb402702 rework in the orders page 2026-02-20 16:55:59 -05:00
NotARoomba
9289d0bbe9 add in more admin info 2026-02-20 16:50:50 -05:00
NotARoomba
68043e888a revert 2026-02-20 16:30:17 -05:00
NotARoomba
ec76d38eee fix stuff and cph 2026-02-20 16:17:55 -05:00
End Nightshade
cac54211c0
fix(auth): make dev work 2026-02-20 13:44:36 -07:00
End Nightshade
92fb79fe7a
feat(admin): show base and +1-upgrade roll costs in roll-cost placeholder and text 2026-02-20 13:37:24 -07:00
End Nightshade
674b7fe8f9
docs(admin): update pricing reference to match backend semantics (roll cost scales with effective probability, upgrade budget 3x) 2026-02-20 13:28:35 -07:00
Nathan
a8c3a05332 revert new budget 2026-02-20 10:32:39 -05:00
Nathan
ab6d711b49 add in cost breakdown 2026-02-20 10:14:54 -05:00
End Nightshade
aeb10b65ec
feat(admin): change rate to $4/hr and simplify order revert to single-step delete with logging
- change DOLLARS_PER_HOUR from 5 to 4 across backend and frontend
- merge soft-delete/restore/permanent-delete into single DELETE endpoint
- refund scraps, restore inventory, reverse penalties, and delete order row in one step
- add console.log for admin order reverts with full context
- simplify admin orders UI to single revert button with confirmation modal
2026-02-19 20:23:47 -07:00
End Nightshade
e55b939c3f
feat(shop): add admin roll cost override
- New nullable roll_cost_override column on shop_items (migration 0011)
- calculateRollCost uses override if set, otherwise auto-calculates
- Admin UI: new 'roll cost override' input with auto placeholder + reset button
- EV simulation and item cards respect the override
- Frontend shop page + ShopItemModal use override for display and affordability
- Backend try-luck endpoint uses override from locked row
2026-02-19 19:28:44 -07:00
End Nightshade
0a3e51e1e5
fix(admin): compute EV-safe upgrade costs against overridden scraps price
- calculatePricing now accepts optional priceOverride parameter
- When price is overridden, optimal pricing uses actual price for EV checks
- hasCustomPricing now also checks price mismatch
2026-02-19 19:18:33 -07:00
End Nightshade
5b4e239544
fix(shop): map snake_case columns from raw SQL SELECT * FOR UPDATE
Raw SQL returns snake_case (base_probability, base_upgrade_cost, etc.)
but code accessed camelCase (baseProbability, baseUpgradeCost, etc.),
getting undefined. This caused calculateRollCost to return NaN, making
canAfford always fail with 'Insufficient scraps — need: null'.
2026-02-19 19:12:12 -07:00
End Nightshade
37443fa48d
fix(shop): EV-safe pricing — iteratively increase upgrade cost until no level is exploitable
- calculateShopItemPricing now simulates all upgrade levels and bumps
  baseUpgradeCost until expectedTotalCost >= price at every level
- Synced to shop-pricing.ts (computeItemPricing) and frontend calculatePricing
- All price points from $5-$800 verified safe (house edge 0.2-18%)
- Show detailed required/available scraps in insufficient funds errors
2026-02-19 19:02:12 -07:00
End Nightshade
5633c3c4a5
fix(shop): show detailed insufficient funds error, add debug logging
- ShopItemModal: show required vs available scraps in error message
- Backend: log balance details on try-luck to debug mismatches
2026-02-19 18:39:02 -07:00