-
Notifications
You must be signed in to change notification settings - Fork 0
ArenaBuilder
ArenaBuilder
s are one of the main creative objects in the Spite Framework. As the name implies, they create Arena
s for you to manage your games. Arena Builders are also used to configure and set up other pieces of information, such as relationships between teams and so forth.
This example comes from the Battleship example from the Spite Framework Examples repository.
Arena arena = new ArenaBuilder<BattleshipTeam>()
// This sets the maximum number of teams. Could be useful if you're deserializing some kind of arena definition.
.SetTeamCount(2)
// Add the teams that are participating in this game
.AddTeam(playerTeam) // Teams may be created through teambuilders
.AddTeam(enemyTeam)
// Set up the relationship between the teams. Not crucial in Battleship, but important in other scenarios.
// See AllianceGraph for more information.
.AddBidirectionalTeamRelationship(playerTeam, enemyTeam, TeamRelationship.Opposing)
// This tells the arena to use the default "Discrete Player" turn scheme. She turn schemes for more information
.SetTurnScheme(TurnSchemeType.DiscretePlayer)
// Turn managers will use this to determine if a game has ended
.SetBattleOverCondition(() =>
{
return playerTeam.CurrentStanding == TeamStanding.Defeated || enemyTeam.CurrentStanding == TeamStanding.Defeated;
})
// You can react to changes in the current phase using this method
.AddPhaseChangedDelegateToTurnManager((ITurnPhase oldPhase, ITurnPhase nextPhase, ITurnManager turnManager) =>
{
if (nextPhase is PlayerPhase<ITeamExecutor> playerPhase)
{
currentTeam = (BattleshipTeam)playerPhase.CurrentPlayer;
}
})
// Get the actual arena
.Finish();
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!