public function testPCHasVariousAttributesAndCanSetSome() { $char = new Player($this->char_id); $this->assertTrue(is_int($char->gold())); $this->assertTrue(is_int($char->turns())); $this->assertTrue(is_int($char->set_gold(45))); $this->assertTrue(is_int($char->set_turns(32))); $this->assertEquals(444, $char->set_bounty(444)); $char->save(); $char_dup = new Player($this->char_id); $this->assertEquals(444, $char_dup->bounty()); $this->assertEquals(32, $char_dup->turns()); $this->assertEquals(45, $char_dup->gold()); }
$private = true; if ($error = init($private, $alive)) { display_error($error); } else { $turn_cost = 1; $health = 1; $victim = in('victim'); $random_encounter = rand(1, 400) == 1; $combat_data = array(); $char_id = self_char_id(); $player = new Player($char_id); $error_template = 'npc.no-one.tpl'; // Error template also used down below. $npc_template = $error_template; // Error condition by default. $turns = $player->turns(); $is_villager = false; $ninja_str = $player->getStrength(); $ninja_health = $player->vo->health; $static_npcs = array('peasant', 'thief', 'merchant', 'guard', 'samurai'); $npcs = NpcFactory::npcsData(); $possible_npcs = array_merge($static_npcs, array_keys($npcs)); $victim = restrict_to($victim, $possible_npcs); // Filter to only the correct options. if ($turns > 0 && !empty($victim)) { // Strip stealth when attacking samurai or oni if ($player->hasStatus('stealth') && (strtolower($victim) == 'samurai' || strtolower($victim) == 'oni')) { $player->subtractStatus(STEALTH); } $attacker_str = $player->getStrength(); $attacker_health = $player->vo->health;
$private = true; $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');
$classes = classes_info(); $in_upgrade = in('upgrade'); // Level up request. $dimmak_sequence = in('dimmak_sequence', ''); $classChangeSequence = in('classChangeSequence'); $current_class_untrusted = in('current_class'); // Untrusted courtesy check to prevent doubled class change in the event of a refresh. $requested_identity = in('requested_identity'); // Untrusted class identity request. if (is_logged_in()) { // Get the character data. $char_id = self_char_id(); $char = $player = new Player($char_id); $userLevel = $player->vo->level; $userKills = $player->vo->kills; $user_turns = $player->turns(); $userClass = $player->class_identity(); $user_class_display = $player->class_display_name(); $user_class_theme = class_theme($userClass); // Pull info for the class requested to change to. $destination_class_identity = isset($requested_identity) && isset($classes[$requested_identity]) ? $requested_identity : null; $destination_class_info = $destination_class_display = $destination_class_theme = null; if ($destination_class_identity) { $destination_class_info = $classes[$destination_class_identity]; $destination_class_display = $destination_class_info['class_name']; $destination_class_theme = $destination_class_info['theme']; } // Pull the number of kills required to get to the next level. $required_kills = required_kills_to_level($player->level()); $current_class_untrusted = whichever($current_class_untrusted, $userClass); // Initialize the class record to prevent double change on refresh.
public function testCloneKillKillingWipesHealthAndTurns() { $char_id = TestAccountCreateAndDestroy::char_id(); $charObj = new Player($char_id); $char_id_2 = TestAccountCreateAndDestroy::char_id_2(); $charObj_2 = new Player($char_id_2); // Will create characters with 127.0.0.1 ip, but that shouldn't be clone kill able. $this->assertFalse(CloneKill::canKill($char_id, $char_id_2)); $this->syncIps('222.244.244.222', $char_id, $char_id_2); $this->assertTrue(CloneKill::canKill($char_id, $char_id_2), 'Should be able to clone kill similar and same ip characters!'); CloneKill::kill($charObj, $charObj, $charObj_2); // Obliterate them. $pc1 = new Player($char_id); $pc2 = new Player($char_id_2); $this->assertEquals(0, $pc1->health()); $this->assertEquals(0, $pc2->health()); $this->assertEquals(0, $pc1->turns()); $this->assertEquals(0, $pc2->turns()); }