spicylobstergames / shotcaller-minigene

A moddable RTS/MOBA game made with bracket-lib and minigene.
https://www.notion.so/erlendsh/Shotcaller-7374d2b2819c42ccb40f01dc7089d419
Other
152 stars 12 forks source link

Add Item Purchasing implementation #47

Closed rodrigocam closed 3 years ago

rodrigocam commented 3 years ago

Description

This PR aims to implement basic item purchasing on the game. Currently, it is possible to buy items with the earned gold by selecting a leader with j k keys then clicking on an Entity with MouseSelectable and ShelfItem component, and finally clicking on an Entity with MouseClickable and BuyButton component. If the selected leader has enough gold and space on his inventory the item will be added to it and the gold will be charged. Otherwise, an error is printed to the console.

rodrigocam commented 3 years ago

I don't know if we have plans for that. But the way I implemented there is a SelectedItem resource, so it is possible to set this resource with the keyboard too. So, to add an option to buy by keyboard I imagine that we have only to modify the condition that verifies the buy button click in the purchasing system, adding an or keyboard key pressed.

AnneKitsune commented 3 years ago

Let's merge it as it is. We need to figure out a way to handle item purchasing using the keyboard, since the terminal version could be unable to buy things on some terminal emulators. Also, was this tested on wasm? I haven't verified if mouse input works properly before.

rodrigocam commented 3 years ago

I didn't test on wasm, gonna test before merging this PR.

rodrigocam commented 3 years ago

Apparently, it doesn't work in wasm, can we merge this PR or it is better to abort? @jojolepro

AnneKitsune commented 3 years ago

Would you mind adding keybinds to buy things using the keyboard? for example, J and K to select up/down in the item buy list?

rodrigocam commented 3 years ago

Gonna try!

erlend-sh commented 3 years ago

As long as computer-players can purchase items, I'm fine with having this merged.