Docs » API reference » Battle

Battle

A turn-based battle between a player's Voxelmon and a wild one, a trainer's or a guardian.

A handle to something in the game. Once that thing is gone, its calls fail with Gone. You get one from events, and creature.challenge(player).

Methods

MethodDescription
fn player(&self) -> Result<Player>Player player()The player battling.
fn kind(&self) -> Result<BattleKind>BattleKind kind()What they face.
fn player_creature(&self) -> Result<Option<Creature>>Optional<Creature> playerCreature()The player's Voxelmon in the battle now.
fn opponents(&self) -> Result<Vec<Creature>>List<Creature> opponents()What they face.
fn turn(&self) -> Result<i64>long turn()The turn's number.
fn end(&self, result: BattleResult) -> Result<()>void end(BattleResult result)Ends it now with a result.

TurnAction

What one side did in a turn.

Plain data, copied between the server and the plugin.

FieldDescription
creature: CreatureCreature creature()Who acted.
r#move: Option<Move>Optional<Move> move()The move used, if one.
damage: i64long damage()Health it took.

BattleKind

What a battle is against.

One of a fixed set of values.

ValueMeaning
BattleKind::WildBattleKind.WILDA wild Voxelmon.
BattleKind::TrainerBattleKind.TRAINERA trainer.
BattleKind::BossBattleKind.BOSSA guardian or Voxelord.

BattleResult

How a battle ended.

One of a fixed set of values.

ValueMeaning
BattleResult::WonBattleResult.WONThe player won.
BattleResult::LostBattleResult.LOSTThe player lost.
BattleResult::FledBattleResult.FLEDThe player fled.
BattleResult::CaughtBattleResult.CAUGHTThe player caught it.
BattleResult::CancelledBattleResult.CANCELLEDEnded by the server or a plugin.

Events

Related events: BattleStarting, BattleStarted, BattleTurn, BattleEnded.