/** * group char **/ function testCreatePlayerObjectCanSaveChanges() { $char = new Player($this->char_id); $ki = $char->ki(); $char->add_ki(55); $player_factory = new PlayerDAO(); $this->markTestIncomplete('Player objects not yet self-saving'); $player_factory->save($char->vo); $char_copy = new Player($this->char_id); $this->assertEquals($char_copy->ki(), $ki + 55); }
$alive = false; if ($error = init($private, $alive)) { display_error($error); } else { require_once LIB_ROOT . "control/lib_status.php"; // statuses for quickstats require_once LIB_ROOT . "control/lib_player.php"; // Player info display pieces. require_once LIB_ROOT . "control/Skill.php"; $skillsListObj = new Skill(); $player = new Player(self_char_id()); $level = $player->level(); $class = $player->class_display_name(); // Just to be displayed in the template. $starting_turns = $player->turns(); $starting_ki = $player->ki(); $status_list = get_status_list(); $no_skills = true; $stealth = $skillsListObj->hasSkill('Stealth'); if ($stealth) { $no_skills = false; } $stealth_turn_cost = $skillsListObj->getTurnCost('Stealth'); $unstealth_turn_cost = $skillsListObj->getTurnCost('Unstealth'); $chi = $skillsListObj->hasSkill('Chi'); $speed = $skillsListObj->hasSkill('speed'); $hidden_resurrect = $skillsListObj->hasSkill('hidden resurrect'); $midnight_heal = $skillsListObj->hasSkill('midnight heal'); $kampo_turn_cost = $skillsListObj->getTurnCost('Kampo'); $kampo = $skillsListObj->hasSkill('kampo'); $heal = $skillsListObj->hasSkill('heal');
function harmonize_chakra(Player $char) { // Heal at most 100 or ki available or hurt by AND at least 0 $heal_for = (int) max(0, min(100, $char->is_hurt_by(), $char->ki())); if ($heal_for > 0) { // If there's anything to heal, try. // Subtract the ki used for healing. $char->heal($heal_for); $char->set_ki($char->ki() - $heal_for); $char->save(); } return $char; }
public function testCreatePlayerObjectCanSaveChanges() { $char = new Player($this->char_id); $ki = $char->ki(); $char->set_ki($ki + 55); $char->set_gold(343); $char->save(); $char_copy = new Player($this->char_id); $this->assertEquals($char_copy->ki(), $ki + 55); $this->assertEquals($char_copy->gold(), 343); }