How to define and register a message
Reply
payload that can be read by the game client.
In Cardinal, messages are defined using a pair of Go structs representing a Message
and a Reply
.
Example:
AttackPlayerMsg
message may contain the TargetNickname
of the player you want to attack.MoveMsg
message may contain the Direction
and Distance
of the move.msg
directory, with each message definition in its own separate file.
You can easily create a new message and register it to the world by following these steps:
Define the message and reply struct
Register the message in the world
RegisterMessage
function.WithMsgEVMSupport
option when you register your messages. This will generate the ABI types necessary for interactions with smart contracts.