/** * Casting level to experiences is mostly lossy conversion! * Gives experiences needed from previous (current -1) to given level. * @param Level $level * @return Experiences */ public function toExperiences(Level $level) { if ($level->getValue() > 1) { $woundsBonus = new WoundsBonus($this->levelToBonusValue($level), $this->woundsTable); $wounds = $this->woundsTable->toWounds($woundsBonus); $experiencesValue = $wounds->getValue(); } else { $experiencesValue = 0; // including first level which is for free for main profession } return new Experiences($experiencesValue, $this); }
/** * @test * @expectedException \DrdPlus\Tables\Measurements\Partials\Exceptions\RequestedDataOutOfTableRange */ public function I_can_not_convert_too_high_value_to_bonus() { $woundsTable = new WoundsTable(); $woundsTable->toBonus(new Wounds(28001, $woundsTable)); }
/** * @return Wounds */ public function getWounds() { return $this->woundsTable->toWounds($this); }
/** * @param FatigueBonus $bonus * * @return Fatigue */ public function toFatigue(FatigueBonus $bonus) { return new Fatigue($this->woundsTable->toWounds(new WoundsBonus($bonus->getValue(), $this->woundsTable))->getValue(), Fatigue::FATIGUE, $this); }
/** * @test */ public function I_get_values_same_as_from_wounds_table() { $experiencesTable = new ExperiencesTable($woundsTable = new WoundsTable()); self::assertEquals($woundsTable->getValues(), $experiencesTable->getValues()); self::assertEquals($woundsTable->getIndexedValues(), $experiencesTable->getIndexedValues()); }
/** * @param Toughness $toughness * @param WoundsTable $woundsTable */ public function __construct(Toughness $toughness, WoundsTable $woundsTable) { /** @noinspection ExceptionsAnnotatingAndHandlingInspection */ parent::__construct($woundsTable->toWounds(new WoundsBonus($toughness->getValue() + 10, $woundsTable))->getValue()); }
/** * @return WoundsBonus */ public function getBonus() { return $this->woundsTable->toBonus($this); }