Skip to content
Joseph Newman edited this page Sep 22, 2021 · 2 revisions

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.

Clone this wiki locally