本文整理汇总了PHP中Player::attack方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::attack方法的具体用法?PHP Player::attack怎么用?PHP Player::attack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player::attack方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rand
$player->buy($weapons[$weaponIndex]);
// buy 0 or 1 armor
$numArmors = rand(0, 1);
if ($numArmors == 1) {
$armorIndex = array_rand($armors, 1);
$player->buy($armors[$armorIndex]);
}
// buy 0, 1 or 2 rings
$numRings = rand(0, 2);
for ($i = 0; $i < $numRings; $i++) {
$ringIndex = array_rand($rings, 1);
$player->buy($rings[$ringIndex]);
}
$playerWins = false;
while ($boss->getHitpoints() > 0 && $player->getHitpoints() > 0) {
$player->attack($boss);
// boss can only attack back if he is alive
if ($boss->isAlive()) {
$boss->attack($player);
}
}
if ($player->isAlive()) {
if (!isset($leastSpent) || $player->getSpentCash() < $leastSpent) {
$leastSpent = $player->getSpentCash();
echo 'least spent: ' . $leastSpent . ' for a victory (part 1)' . PHP_EOL;
}
} else {
if (!isset($mostSpent) || $player->getSpentCash() > $mostSpent) {
$mostSpent = $player->getSpentCash();
echo 'most spent: ' . $mostSpent . ' for a defeat (part 2)' . PHP_EOL;
}
示例2: getAttack
{
// 誰が撃っても威力一緒
return self::PISTOL_ATK;
}
}
class Hammer implements WeaponInterface
{
public function getAttack(Player $player)
{
// 一撃でかいけどクリーンヒットしにくい
$damage_rate = 1 == mt_rand(1, 3) ? 0.2 : mt_rand(100, 250) / 100;
return $player->status_strength * $damage_rate;
}
}
$player = new Player('Onizuka');
$player->attack();
$player->attack();
$player->attack();
$player->attack();
$player->attack();
$player->setWeapon(new Knife());
$player->attack();
$player->attack();
$player->attack();
$player->attack();
$player->attack();
$player->setWeapon(new Pistol());
$player->attack();
$player->attack();
$player->attack();
$player->attack();
示例3: Player
if ($_POST['p2weapon'] == "scissors") {
$player2 = new Player($_POST['p2name'], $_POST['p2age'], $scissors);
}
}
}
$player1->save();
$player2->save();
var_dump($_SESSION['player_stats']);
$player1_spot = $_SESSION['player_stats'][1];
$player2_spot = $_SESSION['player_stats'][2];
$turn = Player::whoseTurn();
return $app['twig']->render('play.html.twig', array('player1' => $player1_spot, 'player2' => $player2_spot, 'turn' => $turn));
});
$app->post("/delete", function () use($app) {
Player::deleteAll();
return $app['twig']->render('home.html.twig');
});
$app->post("/attack", function () use($app) {
print_r($_SESSION['player_stats']);
$whoseturn = Player::whoseTurn();
$player = Player::decidePlayer();
$attack = Player::attack();
return $app['twig']->render('play.html.twig', array('turn' => $whoseturn, 'attack' => $attack));
});
// $app->post("/heal", function() use ($app) {
// print_r($_SESSION['player_stats']);
// Player::changeTurn();
// $whoseturn = Player::playerTurnName();
// return $app['twig']->render('play.html.twig', array('turn' => $whoseturn));
// });
return $app;
示例4: attack
public function attack($damage)
{
return $this->player->attack($damage);
}