Exemple #1
0
 /**
  * Short description for function
  *
  * Long description (if any) ...
  *
  * @param  object  $char Parameter description (if any) ...
  * @return boolean Return description (if any) ...
  * @access public
  */
 public function arePrerequisitesMet(Character $char)
 {
     if ($char->getRace()->getName() == Constants\Common::RACE_HUMAN) {
         Logger::debug('Character %s mets the prerequisites of Action Surge', array($char->getName()));
         return true;
     }
     return false;
 }
Exemple #2
0
 private function doRoll()
 {
     $results = array();
     for ($i = 0; $i < $this->repeat; $i++) {
         $results[] = $roll = rand(1, $this->sides);
         Logger::debug('Rolled %d', array($roll));
     }
     if (!is_null($this->keep)) {
         switch ($this->use) {
             case iDice::USE_HIGH:
                 sort($results);
                 break;
             case iDice::USE_LOW:
                 rsort($results);
                 break;
         }
         for ($i = $this->repeat; $i <= $this->keep; $i--) {
             array_shift($results);
         }
     }
     $result = array_sum($results) + $this->modifier;
     Logger::info('Roll result for %dd%d + %d: %d', array($this->repeat, $this->sides, $this->modifier, $result));
     return $result;
 }
Exemple #3
0
 /**
  * Short description for function
  *
  * Long description (if any) ...
  *
  * @param  object  $char Parameter description (if any) ...
  * @return boolean Return description (if any) ...
  * @access public
  */
 public function arePrerequisitesMet(C $char)
 {
     if ($char->getAbility(Constants\Abilities::STR) > 15) {
         Logger::debug('Character %s mets the prerequisites of Power Attack', array($char->getName()));
         return true;
     }
     return false;
 }
Exemple #4
0
$standardArray->assignAbilities(array(Constants\Abilities::STR => 16, Constants\Abilities::CON => 14, Constants\Abilities::DEX => 13, Constants\Abilities::WIS => 12, Constants\Abilities::CHA => 11, Constants\Abilities::INT => 10));
$berdir->setAbilityScore($standardArray);
// $rollScore = AbilityHelper::factoryGenerator('RollingScore');
// $rollScore->rollAbilities();
// $berdir->setAbilityScore($rollScore);
$berdir->build();
$level = new Level($berdir);
$level->chooseFeat(new Feats\Powerattack());
$level->finish();
$berdir->activateFeat(Feats\Powerattack::Name);
$berdir->deactivateFeat(Feats\Powerattack::Name);
$berdir->rollInitiative();
Logger::debug($berdir->dump());
$curunair = Game::addCharacter('Curunair');
$curunair->setRace(new Race\Dwarf());
$fighter = $curunair->setClass(new Classes\Fighter());
$fighter->chooseTrainedSkill(array(Constants\Skills::ATHLETHICS, Constants\Skills::ENDURANCE, Constants\Skills::STREETWISE));
$standardArray = AbilityHelper::factoryGenerator('StandardArray');
$standardArray->assignAbilities(array(Constants\Abilities::STR => 16, Constants\Abilities::CON => 14, Constants\Abilities::DEX => 13, Constants\Abilities::WIS => 12, Constants\Abilities::CHA => 11, Constants\Abilities::INT => 10));
$curunair->setAbilityScore($standardArray);
// $rollScore = AbilityHelper::factoryGenerator('RollingScore');
// $rollScore->rollAbilities();
// $berdir->setAbilityScore($rollScore);
$curunair->build();
$level = new Level($curunair);
$level->chooseFeat(new Feats\Powerattack());
$level->finish();
$curunair->rollInitiative();
Logger::debug($curunair->dump());
$encounter = Game::startEncounter();
$encounter->start();
Exemple #5
0
 /**
  * Short description for function
  *
  * Long description (if any) ...
  *
  * @return void
  * @access public
  */
 public function build()
 {
     $l = Language::singleton();
     Logger::debug('Character building has started...');
     Logger::debug('Calculating Abilities');
     foreach ($this->race->getAbilities() as $ability => $value) {
         $this->updateAbility($ability, $value);
     }
     Logger::debug('Calculating speed, vision and size');
     $this->updateSpeed($this->race->getSpeed());
     $this->updateVision($this->race->getVision());
     $this->updateSize($this->race->getSize());
     Logger::debug('Calculating languages');
     foreach ($this->race->getLanguages() as $lang) {
         $this->addLanguage($lang);
     }
     Logger::debug('Calculating skills');
     foreach ($this->race->getSkillBonuses() as $skill => $value) {
         $this->updateSkill($skill, $value);
     }
     Logger::debug('Calculating profiencies');
     foreach ($this->class->getProfiencies() as $prof) {
         $this->addProfiency($prof);
     }
     Logger::debug('Calculating hitpoints');
     $this->updateMaxHitPoints($this->class->getBaseHitPoints($this));
     $this->updateHitPoints($this->getMaxHitpoints());
 }
Exemple #6
0
 /**
  * Short description for function
  *
  * Long description (if any) ...
  *
  * @param  object                          $feat Parameter description (if any) ...
  * @return object                          Return description (if any) ...
  * @access public
  * @throws Exception_NotAviableAtThisLevel Exception description (if any) ...
  * @throws Exception_PrerequitesNotMet     Exception description (if any) ...
  */
 public function chooseFeat(iFeat $feat)
 {
     if (!isset($this->gain[self::FEAT])) {
         throw new Exception_NotAviableAtThisLevel($feat);
     }
     if (!$feat->arePrerequisitesMet($this->char)) {
         throw new Exception\PrerequisitesNotMet($feat->getPrerequisites(), $this->char);
     }
     $this->gain[self::FEAT]--;
     if ($this->gain[self::FEAT] == 0) {
         unset($this->gain[self::FEAT]);
     }
     Logger::debug('Still aviable at this level: ' . $this->getAviable());
     $this->feats[] = $feat;
     return $feat;
 }