$clone_1_id = get_char_id($clone1); $clone_2_id = get_char_id($clone2); $clones = false; if (!$clone_1_id || !$clone_2_id) { $not_a_ninja = $clone1; if (!$clone_2_id) { $not_a_ninja = $clone2; } $generic_skill_result_message = "There is no such ninja as {$not_a_ninja}."; } elseif ($clone_1_id == $clone_2_id) { $generic_skill_result_message = '__TARGET__ is just the same ninja, so not the same thing as a clone at all.'; } elseif ($clone_1_id == $char_id || $clone_2_id == $char_id) { $generic_skill_result_message = 'You cannot clone kill yourself.'; } else { // The two potential clones will be obliterated immediately if the criteria are met in CloneKill. $kill_or_fail = CloneKill::kill($player, new Player($clone_1_id), new Player($clone_2_id)); if ($kill_or_fail !== false) { $generic_skill_result_message = $kill_or_fail; } else { $generic_skill_result_message = "Those two ninja don't seem to be clones."; } } } } } } } } } } }
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()); }