Skip to content

Commit

Permalink
ft: confirm and send loot ui
Browse files Browse the repository at this point in the history
  • Loading branch information
agustincarriso committed Dec 12, 2024
1 parent 13ee38b commit 80100bd
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 13 deletions.
43 changes: 40 additions & 3 deletions scene/src/ui/confirmloot/confirmAndSendLoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import ReactEcs, { Label, UiEntity } from '@dcl/react-ecs'
import { type UIController } from '../../controllers/ui.controller'
import { UiCanvasInformation, engine } from '@dcl/sdk/ecs'
import Canvas from '../canvas/Canvas'
import { ITEM_TYPES } from '../../inventory/playerInventoryMap'
import { type ConfirmLootType } from './confirmloot'
import { Player } from '../../player/player'

export class ConfirmAndSendLoot {
uiController: UIController
Expand Down Expand Up @@ -123,7 +126,37 @@ export class ConfirmAndSendLoot {
textureMode: 'stretch',
texture: { src: this.lootAcceptButton }
}}
onMouseDown={() => {}}
onMouseDown={() => {
const player = Player.getInstance()
if (
player.inventory.getItemCount(ITEM_TYPES.ICEHEART) +
player.inventory.getItemCount(ITEM_TYPES.ICESHARD) >=
this.amount
) {
this.isVisible = false
const confirmLootData: ConfirmLootType = {
item: this.name,
amount: this.amount,
currency: 'dungeonToken',
onConfirmCallback: () => {
// sendWearable(urn, {
// chicken: 0,
// wood: 0,
// iron: 0,
// bone: 0,
// })
}
}
console.log('Item claimed successfully!')
// hard coded for DT (need to add currency type to main function)
this.uiController.confirmLoot.openConfirmLoot(confirmLootData)
} else {
this.isVisible = false
this.uiController.displayAnnouncement(
'Need more dungeon tokens!'
)
}
}}
/>
{/* Decline Button */}
<UiEntity
Expand All @@ -137,7 +170,9 @@ export class ConfirmAndSendLoot {
textureMode: 'stretch',
texture: { src: this.lootDeclineButton }
}}
onMouseDown={() => {}}
onMouseDown={() => {
this.isVisible = false
}}
/>
{/* Exit Button */}
<UiEntity
Expand All @@ -151,7 +186,9 @@ export class ConfirmAndSendLoot {
textureMode: 'stretch',
texture: { src: this.lootExitButton }
}}
onMouseDown={() => {}}
onMouseDown={() => {
this.isVisible = false
}}
/>
</UiEntity>
</UiEntity>
Expand Down
15 changes: 5 additions & 10 deletions scene/src/ui/confirmloot/confirmloot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import { UiCanvasInformation, engine } from '@dcl/sdk/ecs'
import { Player } from '../../player/player'
import { ITEM_TYPES } from '../../inventory/playerInventoryMap'

type ConfirmLootType = {
export type ConfirmLootType = {
item: string
amount: number
currency: 'dungeonToken' | 'mana'
onConfirmCallback?: () => void
}
export class ConfirmLoot {
uiController: UIController
Expand Down Expand Up @@ -116,7 +117,9 @@ export class ConfirmLoot {
textureMode: 'stretch',
texture: { src: 'assets/images/confirmLoot/declineLoot.png' }
}}
onMouseDown={() => {}}
onMouseDown={() => {
this.isVisible = false
}}
/>
{/* Decline Button Unavail */}
<UiEntity
Expand Down Expand Up @@ -156,9 +159,6 @@ export class ConfirmLoot {

this.payClaim_visible = true
this.declineLoot_visible = true

// Save the callback for later use
// confirmCallback = onConfirmCallback
}

confirmLoot(confirmLoot: ConfirmLootType): void {
Expand All @@ -173,11 +173,6 @@ export class ConfirmLoot {
if (confirmLoot.currency === 'mana') {
// Take MANA
}

// Call the callback function if it exists
// if (confirmCallback) {
// confirmCallback({ item, amount, currency })
// }
}

hideConfirmLootUI(): void {
Expand Down

0 comments on commit 80100bd

Please sign in to comment.