Implementing Role-Play Style Games on the Blockchain

Stefan Beyer
CryptoFights
Published in
5 min readMar 7, 2018

In our recent article on CryptoFights.io we talked about how we are taking crypto gaming to something different from breeding collectible cat pictures and glorified gambling.

The response and feedback from the community have been beyond our expectations and gamers see the blockchain as a way of ensuring fairness and transparency, especially in long-term games which involve creating and improving a game character, which can be represented as a digital asset.

One of the most asked questions about the game is how we are representing battling heroes and their interactions on the blockchain, and how this fits together with amazing 3D graphics and role play-style game interaction. Therefore, in this article, we will go into some details of the game mechanics and how the blockchain makes this possible.

CryptoFights.io Recap

In case you missed the previous article, let’s recap what the game is about: Gamers get a 3D role play-style hero with a certain customizable configuration. Heroes can be equipped with items (weapons and other accessories) from a marketplace and are unique digital assets. These heroes battle in an arena, gaining experience and winning items from their opponents if they succeed. Gamers may stake a bounty if they wish, betting on the outcome of the battles they enter.

Lobby Screenshot

On-chain vs Off-chain Components

As in any decentralized application, we have to distinguish the parts of the game run on the blockchain and the part implemented off-chain. We are firm believers in implementing any asset that may represent a value and any gaming activity that could be suspected of non-impartiality in smart contracts on the blockchain. In contrast, we implement anything requiring improved performance, such as our 3D battle animations, off-chain. Any action you see on-screen directly results from blockchain transactions traceable by anyone.

3D Graphics

Whilst our battling heroes are implemented as tokens on the blockchain, they are represented on screen as 3D characters. We use the Unity3D game engine to generate state of the art 3D characters and battle scenes. HTML5 and WebGL allow us to make all this possible in the web browser.

Concept Image

Heroes and Accessories Token Economy

As we have pointed out in our previous article, heroes have many configuration options and characteristics, some of which may change during the game. They are not only of a certain race (human, dwarf or elf) but also possess physical traits, such as style and color of hair and beard or skin and eye color. They also feature parameters, such as strength, vitality and agility, which evolve during the game. All this makes heroes unique digital assets, each with a distinct value.

Readers well versed in blockchain terminology will have realized by now that heroes are therefore non-fungible assets, which is why we represent them as a non-fungible token in a smart contract.

Accessories that might be associated with a hero, such as weapons and similar items, in contrast, are fungible assets. Hence, we represent each item class as a fungible token. One such token might be called heavy battle ax and there is a total number of heavy battle axes available, each of which exactly alike. These items can be traded on the marketplace, similar to trading cryptocurrencies on exchanges. However, they can also be won (and lost!) in battle. There is an additional twist making the game more interesting: Whilst each heavy battle ax is the same and of equal price, the value it has in terms of improving a hero’s chances in battle depends on the hero’s characteristics. For example, a heavy battle ax will be far more useful in the hands of a hero with a high strength rating.

Representing heroes and their accessories as non-fungible and fungible tokens respectively on the blockchain allows us to offer gamers a unique token ecosystem with many possible combinations.

Smart Battle Contracts

Battles are 3D animations backed by smart contracts on the blockchain. The outcome of battles is determined by several moves whose result depends on a battle algorithm implemented in the contracts.

The dynamic of a battle is modeled after traditional pen & paper role-playing games. Players take turns attacking by rolling a dice twice, an attack roll and a damage roll. The attack roll determines the likelihood of hitting the opponent, whilst the damage roll determines the damage inflicted.

The outcome of dice rolling introduces an element of luck into the game, but there are plenty of ways strategy and skill can affect a battle. This is achieved by factoring in hero specifics, such as strength and agility. These values also interact with the type of weapon used. Besides the ability of the hero to use a certain weapon, weapons also produce different types of damage. Certain heroes might be equipped with certain types of shields, designed to mitigate the effect of certain types of damage. All these variables introduce a large set of combinations the battle contracts use to determine the outcome of a battle, allowing gamers to apply strategy and skill and prepare their hero for success.

Battles and individual moves are visible as transactions on the blockchain, allowing transparency and ensuring fairness. A nice side-effect of this is that your heroic exploits in the arena are forever eternalized on the blockchain!

Conclusion

CryptoFights.io uses the blockchain and smart contract-backed tokens to ensure open and decentralized game asset representation. We also turn battle moves into traceable on-chain transactions to ensure transparency and fairness. There is no fund-raising crowd sale as in so many other blockchain projects, nor do you need to purchase a specific in-game currency to play.

Yes, Ether is required, and a hero needs to be bought. However, this is the equivalent of buying a traditional video game, with an important difference: users may eventually make money from winning battles and recover their investment.

Signing up for beta use is now possible at cryptofights.io. See you in the arena!

--

--

Stefan Beyer
CryptoFights

Computer Scientist with research background in Operating Systems, Distributed Systems, Fault Tolerance and Cybersecurity.