Menu

## Battle
in package

Battle.php : 23

Class for managing and running battles between 2 participants.

Original damage calculation is from LotGD 0.9.7+jt by Eric Stevens and JTraub, released originally under GPL 2.0.

### Table of Contents

DAMAGEROUND_BOTH = 0b11
DAMAGEROUND_MONSTER = 0b10
DAMAGEROUND_PLAYER = 0b1
RESULT_MONSTERDEATH = 2
RESULT_PLAYERDEATH = 1
RESULT_UNDECIDED = 0
$configuration : array<string|int, mixed>
$events : ArrayCollection
$game : Game
$monster : FighterInterface|null
$player : FighterInterface
$result : int
$round : int
__construct() : mixed
  Takes a game object and two participants (Player and Monster) to fight a battle.
disableCriticalHit() : void
  Disable critical hits.
disableLevelAdjustement() : void
  Disables level adjustement.
disableRiposte() : void
  Disables ripostes.
enableCriticalHit() : void
  enables critical hits.
enableLevelAdjustement() : void
  Enables level adjustement.
enableRiposte() : void
  Enables ripostes.
fightNRounds() : int
  Fights the number of rounds given by the parameter $n and returns the number of actual rounds fought.
getEvents() : Collection
  Returns a list of all battle events.
getLoser() : FighterInterface
  Returns the loser of this fight.
getMonster() : FighterInterface
  Returns the montser instance.
getPlayer() : FighterInterface
  Returns the player instance.
getWinner() : FighterInterface
  Returns the winner of this fight.
isCriticalHitEnabled() : bool
  Returns true if critical hit events are enabled.
isLevelAdjustementEnabled() : bool
  Returns true if level adjustements are enabled.
isOver() : bool
  Returns true if the battle is over.
isRiposteEnabled() : bool
  Returns true if ripostes are enabled.
serialize() : string
  Returns a string which contains the important fields that must be serialized.
unserialize() : self
fightOneRound() : void
  Fights exactly 1 round.
turn() : ArrayCollection
  Runs one turn.

### Constants

#### DAMAGEROUND_BOTH

Battle.php : 27
`public mixed DAMAGEROUND_BOTH = 0b11`

#### DAMAGEROUND_MONSTER

Battle.php : 26
`public mixed DAMAGEROUND_MONSTER = 0b10`

#### DAMAGEROUND_PLAYER

Battle.php : 25
`public mixed DAMAGEROUND_PLAYER = 0b1`

#### RESULT_MONSTERDEATH

Battle.php : 31
`public mixed RESULT_MONSTERDEATH = 2`

#### RESULT_PLAYERDEATH

Battle.php : 30
`public mixed RESULT_PLAYERDEATH = 1`

#### RESULT_UNDECIDED

Battle.php : 29
`public mixed RESULT_UNDECIDED = 0`

### Properties

#### $configuration

Battle.php : 36
`protected array<string|int, mixed> $configuration = ["riposteEnabled" => true, "levelAdjustementEnabled" => true, "criticalHitEnabled" => true]`

#### $events

Battle.php : 33
`protected ArrayCollection $events`

#### $game

Battle.php : 49
`protected Game $game`

#### $monster

Battle.php : 51
`protected FighterInterface|null $monster`

#### $player

Battle.php : 50
`protected FighterInterface $player`

#### $result

Battle.php : 34
`protected int $result = 0`

#### $round

Battle.php : 35
`protected int $round = 0`

### Methods

#### __construct()

Battle.php : 48

Takes a game object and two participants (Player and Monster) to fight a battle.

`public __construct(Game $game, FighterInterface $player, FighterInterface|null $monster) : mixed`

##### Parameters

$game : Game
$player : FighterInterface
$monster : FighterInterface|null

##### Return values

mixed —

#### disableCriticalHit()

Battle.php : 160

Disable critical hits.

`public disableCriticalHit() : void`

##### Return values

void —

#### disableLevelAdjustement()

Battle.php : 134

Disables level adjustement.

`public disableLevelAdjustement() : void`

##### Return values

void —

#### disableRiposte()

Battle.php : 101

Disables ripostes.

`public disableRiposte() : void`

##### Return values

void —

#### enableCriticalHit()

Battle.php : 168

enables critical hits.

`public enableCriticalHit() : void`

##### Return values

void —

#### enableLevelAdjustement()

Battle.php : 126

Enables level adjustement.

`public enableLevelAdjustement() : void`

##### Return values

void —

#### enableRiposte()

Battle.php : 109

Enables ripostes.

`public enableRiposte() : void`

##### Return values

void —

#### fightNRounds()

Battle.php : 237

Fights the number of rounds given by the parameter $n and returns the number of actual rounds fought.

`public fightNRounds([int $n = 1 ][, int $firstDamageRound = self::DAMAGEROUND_BOTH ]) : int`

##### Parameters

$n : int = 1
$firstDamageRound : int = self::DAMAGEROUND_BOTH

  Which damage rounds are calculated. Cannot be 0.

##### Tags

throws
  ArgumentException

  if firstDamageRound is 0.

throws
  BattleIsOverException

##### Return values

int —

Number of fights fought.

#### getEvents()

Battle.php : 93

Returns a list of all battle events.

`public getEvents() : Collection`

##### Return values

Collection —

#### getLoser()

Battle.php : 219

Returns the loser of this fight.

`public getLoser() : FighterInterface`

##### Tags

throws
  BattleNotOverException

  if battle is not over.

##### Return values

FighterInterface —

#### getMonster()

Battle.php : 195

Returns the montser instance.

`public getMonster() : FighterInterface`

##### Return values

FighterInterface —

#### getPlayer()

Battle.php : 186

Returns the player instance.

`public getPlayer() : FighterInterface`

##### Return values

FighterInterface —

#### getWinner()

Battle.php : 205

Returns the winner of this fight.

`public getWinner() : FighterInterface`

##### Tags

throws
  BattleNotOverException

  if battle is not over.

##### Return values

FighterInterface —

#### isCriticalHitEnabled()

Battle.php : 152

Returns true if critical hit events are enabled.

`public isCriticalHitEnabled() : bool`

##### Return values

bool —

#### isLevelAdjustementEnabled()

Battle.php : 143

Returns true if level adjustements are enabled.

`public isLevelAdjustementEnabled() : bool`

##### Return values

bool —

#### isOver()

Battle.php : 177

Returns true if the battle is over.

`public isOver() : bool`

##### Return values

bool —

#### isRiposteEnabled()

Battle.php : 118

Returns true if ripostes are enabled.

`public isRiposteEnabled() : bool`

##### Return values

bool —

#### serialize()

Battle.php : 60

Returns a string which contains the important fields that must be serialized.

`public serialize() : string`

##### Return values

string —

#### unserialize()

Battle.php : 76
`public static unserialize(Game $game, FighterInterface $player, string $serialized) : self`

##### Parameters

$game : Game
$player : FighterInterface
$serialized : string

##### Return values

self —

#### fightOneRound()

Battle.php : 263

Fights exactly 1 round.

`protected fightOneRound(int $firstDamageRound) : void`

##### Parameters

$firstDamageRound : int

##### Return values

void —

#### turn()

Battle.php : 326

Runs one turn.

`protected turn(FighterInterface $attacker, FighterInterface $defender) : ArrayCollection`

##### Parameters

$attacker : FighterInterface
$defender : FighterInterface

##### Return values

ArrayCollection —

## Search results