Day Six - Ok, still testing, always testing, buying/selling mechanics
Still testing?!
So yesterday, I was like, yaya testing is done, I’m moving on to functionality. However, I soon hit a bug where when you move a pack that’s equipped from the player into the shop, it throws an error because now the shop window is expecting a pack and when you remove the pack, it’s value is undefined. So I wrote some tests, ended up starting on my redux state repository, then wrote some tests for that, fixed adding and removing of items and forgot about the original goal which was to fix empty packs!
Long story short, I kind of fixed the bug and created the tests for it in parallel so that when a pack is not equipped, I expect that the component does not render a pack rather than throw errors. Don’t know if I’m still in honeymoon period right now, but the endorphins are flying about right now. Am loving the flow.
Actually, I just realised there’s another bug, if you put a pack in itself, I think that will fail.
Buy/sell
Since I’m in the shop, I’m going to work on the buying/selling feature next, it should work something like this:
- Drag item from shop into empty equipment slot or pack to buy.
- Drag item to shop to sell.
- Rather than CotW’s original popup confirmation in your face for every action, I’ll have a 5 second undo option ‘Crap! I didn’t want to buy THAT!? Undo!’
- Money should be represented by the purse.
Hum… the original purse mechanics from CotW was a bit convoluted. You could have many purses but they are not a real pack in the sense that if a purse got emptied, it no longer existed… I think. And when you drop a purse onto another one, the coins just combined and the second purse disappeared. Also there is no weight/bulk limit so you were typically lugging around thousands of solid copper, silver and gold coins by the end of the dungeon run!!!
On thinking about it, I think this is probably the easiest method to implement money.
- Monsters drop coins or purses
- Purses are not real containers so it exists as a method to group coins
- Combining purses will combine the content and remove the additional purse
- In the backend, I will still have to keep track of a purse object for both purses and just remove the second one when combined
- Purses are containers with no weight/bulk limit… or alternatively the contents do not have weight/bulk