Skip to content

Commit

Permalink
Improved consumables subtab
Browse files Browse the repository at this point in the history
  • Loading branch information
Pseudonian committed Feb 4, 2025
1 parent d338422 commit 8bc4dc2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/purchases/ConsumablesTab.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { sendToWebsocket } from '../Login'
import { Alert, Confirm } from '../UpdateHTML'
import { memoize } from '../Utility'

interface ConsumableListItems {
Expand All @@ -22,18 +23,22 @@ const initializeConsumablesTab = memoize(() => {
>
<img src='Pictures/PseudoShop/${u.internalName}.png' alt='${u.name} Consumable' />
<p>${u.name}</p>
<p>${u.description}</p>
<button><p>Cost: </p><p>${u.cost} PseudoCoins</p></button>
<p style="white-space: pre-line">${u.description}</p>
<button><p>ACTIVATE: </p><p>${u.cost} PseudoCoins</p></button>
</div>
`).join('')

tab.querySelectorAll('div > button').forEach((element) => {
const key = element.parentElement!.getAttribute('data-key')!
element.addEventListener('click', () => {
element.addEventListener('click', async () => {
const alert = await Confirm(`Please confirm you would like to activate a ${key} for 500 PseudoCoins`)
if (!alert) return Alert('Purchase cancelled')
else {
sendToWebsocket(JSON.stringify({
type: 'consume',
consumable: key
}))
}
})
})
})
Expand Down

0 comments on commit 8bc4dc2

Please sign in to comment.