-
Notifications
You must be signed in to change notification settings - Fork 0
Arenas
Arenas are the core utility for all things Spite. Arenas manage teams, their relationships, and more. Understanding the Arena is crucial for being able to work with Spite, as the core game loop revolves around the Arena.
Take this example from the Battleship project in the examples repository:
do
{
// Get the current player's command
...
// Pass it to the arena
var results = arena.ReceiveAndExecuteCommand(command);
// Process the results
foreach (var result in results)
{
// Process the result one by one
...
}
} while (!arena.IsBattleOver);Let's break this example down.
In this example, I use a do... while loop because I assume that a battle can't end before it begins. We'll want one team to perform at least one action before doing something.
var results = arena.ReceiveAndExecuteCommand(command); - Commands are how players interact with Arenas. This often takes the form of moves or actions. The results variable is an array of IReaction objects, which you can iterate over to handle things like animations, showing a health bar depleting, etc. This is done in the following foreach loop.
Finally, the while statement makes sure that players can get their actions in while a battle is ongoing.
If you have any suggestions for improvements to the documentation, please submit an issue, and if you've got time for it, please help me out by making that improvement!
Furthermore, since Spite is in the alpha stages, things are prone to change quickly and without much notice. While I try to keep the documentation up-to-date, I'm only one guy and I only have so much time. Your patience is appreciated!