Commit graph

182 commits

Author SHA1 Message Date
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
End Nightshade
42dd5eb229
fix(shop): fix try-luck error handling and roll cost display
- ShopItemModal: check data.error/data.success instead of response.ok
  (backend returns 200 for all responses including errors, so response.ok
  was always true and errors were silently swallowed, closing the modal)
- Shop page + ShopItemModal: use baseProbability for roll cost display
  (matching backend calculateRollCost which uses fixed base probability)
- Auth: anchor session cookie regex to prevent matching wrong cookies
- Auth: keep dev-mode reduced OAuth scopes
2026-02-19 18:29:15 -07:00
End Nightshade
0963b78cdb
fix(admin): sync pricing formula with backend, add scraps price override
- Fix upgradeBudget: was 3×price−rollCost, now 1.5×price to match backend
- Add direct scraps price override input (yellow border when overridden)
- Auto-detect overrides when editing existing items
- Update pricing model reference panel to match actual backend semantics
- Fix win condition display: show eff% × 17/20 threshold
2026-02-19 18:18:45 -07:00
Nathan
144993457a fix pricing 2026-02-19 16:32:41 -05:00
Nathan
ad001bd9ad add in markdown 2026-02-19 16:07:09 -05:00
Nathan
62a983f00d Update +page.svelte 2026-02-19 15:25:38 -05:00
Nathan
c7d0411fe5 Update +page.svelte 2026-02-19 14:52:00 -05:00
End Nightshade
b0c25fe2c8
fix(frontend): sync shop admin EV simulation with backend pricing semantics
- Use effectiveProbability (not baseProbability) for roll cost
- Add computeRollThreshold (17/20) for actual win chance calculation
- Rename EVSummary fields to bestPlayer* (remove old optimal*/base*/maxUpgrade*)
- Update modal form EV display to use new property names
- Add actualWinChance column to detailed EV table
- Simplify item card EV display to show house edge + best strategy
2026-02-19 10:53:22 -07:00
End Nightshade
366223a914
fix(auth): anchor session cookie regex and use manual Set-Cookie on redirect
The regex /session=([^;]+)/ was matching _theseus_session (from
HackClub auth) instead of the actual session cookie, since it matched
the first occurrence of 'session=' anywhere in the cookie string.

Changed to /(?:^|;\s*)session=([^;]+)/ which only matches 'session'
at the start of the string or after a semicolon separator.

Also returns a 200 HTML page with meta-refresh instead of a 302, to
ensure Set-Cookie is reliably stored by the browser before redirecting
to the frontend.
2026-02-19 10:32:58 -07:00
End Nightshade
3ada061ff3
feat(auth): request only basic OAuth scopes in development mode
In dev, only requests: openid, profile, email, name, slack_id,
verification_status. Skips birthdate, address, and basic_info
which require additional verification.
2026-02-19 10:19:07 -07:00
End Nightshade
176fadea63
fix(leaderboard): use refinery_spending_history and match canonical balance calc
- Changed refinery spent query from refinery_orders to refinery_spending_history
  (refinery_orders rows are deleted on item win, inflating displayed balance)
- Removed extra status != 'permanently_rejected' filter from earned subqueries
  to match getUserScrapsBalance which only checks scraps_paid_at IS NOT NULL
- Removed unused shopOrdersTable import
2026-02-19 09:54:40 -07:00
End Nightshade
75a4de7a49
fix(leaderboard): allow nullable username in topUser type 2026-02-19 09:53:24 -07:00
End Nightshade
0ed253ed99
feat(shop): change DOLLARS_PER_HOUR from 5 to 4 2026-02-19 09:53:24 -07:00
End Nightshade
5e445cbf9c
fix(shop): sync frontend pricing calc with backend and show optimal pricing in admin
- Fix calculatePricing: use 'price * 3.0 - rollCost' matching backend
  (was incorrectly using 'price * 1.5')
- Fix simulateEV: use baseProbability for rollCost (backend uses base,
  not effective probability for roll cost)
- Fix simulateEV: use effectiveProbability directly as win chance
  (backend has no threshold scaling, remove bogus computeRollThreshold)
- Fix house edge reference panel to reflect actual pricing model
- Add optimal pricing hint in add/edit modal showing server-calculated
  values with yellow highlights when fields diverge from optimal
- Add 'use optimal' button to reset pricing fields to calculated values
- Update shop-pricing.ts return type to Promise<number>
2026-02-19 09:53:00 -07:00
End Nightshade
93fee9d101
feat(admin): add shop pricing recalculation button
- Add POST /admin/recalculate-shop-pricing endpoint (admin only)
  that calls updateShopItemPricing() and returns updated item count
- Add recalculate button to admin dashboard under the admin-only
  tools section with loading/error/success states
- Pricing already recalculates on server startup; this gives admins
  a manual trigger after changing the calc formula or item data
2026-02-19 09:52:29 -07:00
Nathan
022e77a1bc
Merge pull request #7 from hackclub/dev
fix(shop): add penalty recovery on loss and filter deleted orders from buyers
2026-02-19 10:55:25 -05:00
End Nightshade
0fadf46be0
fix(shop): scale roll cost with effective probability and block refinery on out-of-stock items
- Roll cost now scales with effective probability (base + boosts - penalties)
  instead of being fixed at base probability. At any probability level p,
  expected roll spend = item price. Upgrades reduce variance, not expected
  value. The house edge is exactly the total spent on refinery upgrades.
- Block refinery upgrades on out-of-stock items (both frontend and backend)
- Frontend refinery page shows sold out badge instead of upgrade button
- Update pricing calculator upgrade budget to reflect new model
- Fix lint: remove debug forEach, != to !==, unused variable
2026-02-19 08:40:30 -07:00
sbeltranc
559e3788f5 stop using math.random for rolls 2026-02-18 19:25:29 -05:00
Nathan
fdbef64441 Update scraps.ts 2026-02-18 19:18:32 -05:00
Nathan
988b02c7d2 cph 2026-02-18 19:09:19 -05:00
Nathan
44048f3f03 Update admin.ts 2026-02-18 19:05:02 -05:00
Nathan
9d7404deef Update scraps.ts 2026-02-18 18:54:16 -05:00
Nathan
23f71c91da strop prefix lmao 2026-02-18 12:36:30 -05:00
Nathan
fda4c1a5ca Update ysws.ts 2026-02-18 12:30:03 -05:00