Trading Game Dev Diary #6

First all of all: I have found the time to add the game data to a Github repo, so no danger of permanent data loss anymore. 😉

The new private repo for further development.

Now to the new stuff!

I didn’t like how the market module and the player data was bundled. And a wise developer once said; code mechanics, not games! Following that, I added some new modules: Wallets & Tokens.

The wallet module holds any bag data for the player and allows to deposit / withdraw tokens via TXNS (transactions). The token module itself provides an API to create token data (aka adding new coins). Per default, it holds USD as the game default stable coin.

This token data is referenced in wallets and transaction to get stuff like tickers and labels.

Another new cool module is the transactions or TXNS module. It allows to create a transaction with token data, sender and recipient etc. The module automatically triggers the deposit function in the receiving wallet and the withdrawal function in the sending wallet. You can also “mint” funds by sending tokens to your wallet from the genesis wallet address.

The callable txns struct.
The player wallet creation and USD minting transaction at game start. Using all the three new modules.

Wait! Wallet addresses? Ah, right! Every wallet has a simulated blockchain address (42 byte HEX string) as ID. This is kinda cool, because you can use this address to easily create correct transactions but might be also useful in other -later- game mechanics.

The blockchain addresses are random and based on the Etherium format and even work on etherscan. (But it’s not a real address outside of the game!)
The function to create blockchain addresses. It’s just a 40+2 byte hex string.
The deposit function of the wallet struct. Checking if a token already exists within the wallet, either it adds the amount of deposit or does that + importing the token from the transaction reference.

Writing those modules was really easy, fast and fun. I think I found a good data and struct structure for all the modules now. The game’s further development will benefit from this achievement.