本文整理汇总了PHP中Player::setTech方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::setTech方法的具体用法?PHP Player::setTech怎么用?PHP Player::setTech使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player::setTech方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildPlayerGroup
private function buildPlayerGroup($tech, $fleets)
{
$playerObj = new Player(1);
$playerObj->setName('bot');
$playerObj->setTech($tech['weapons'], $tech['shields'], $tech['armour']);
foreach ($fleets as $idFleet => $fleet) {
$fleetObj = new Fleet($idFleet);
foreach ($fleet as $id => $count) {
$count = floor($count);
$id = floor($id);
if ($count > 0 && $id > 0) {
$fleetObj->addShipType($this->getShipType($id, $count));
}
}
if (!$fleetObj->isEmpty()) {
$playerObj->addFleet($fleetObj);
}
}
if ($playerObj->isEmpty()) {
die("<meta http-equiv=\"refresh\" content=2;\"WebTest.php\">There should be at least an attacker and defender");
}
$playerGroupObj = new PlayerGroup();
$playerGroupObj->addPlayer($playerObj);
return $playerGroupObj;
}
示例2: getPlayerGroupFromQuery
function getPlayerGroupFromQuery($result, $targetUser = false)
{
$playerGroup = new PlayerGroup();
while ($fleetRow = mysql_fetch_assoc($result)) {
//making the current fleet object
$serializedTypes = explode(';', $fleetRow['fleet_array']);
$idPlayer = $fleetRow['fleet_owner'];
$fleet = new Fleet($fleetRow['fleet_id']);
foreach ($serializedTypes as $serializedType) {
list($id, $count) = explode(',', $serializedType);
if ($id != 0 && $count != 0) {
$fleet->addShipType(getShipType($id, $count));
}
}
//making the player object and add it to playerGroup object
if (!$playerGroup->existPlayer($idPlayer)) {
$player_info = $targetUser !== false && $targetUser['id'] == $idPlayer ? $targetUser : doquery("SELECT * FROM {{table}} WHERE id ={$idPlayer}", 'users', true);
$player = new Player($idPlayer, array($fleet));
$player->setTech($player_info['military_tech'], $player_info['shield_tech'], $player_info['defence_tech']);
$player->setName($player_info['name']);
$playerGroup->addPlayer($player);
} else {
$playerGroup->getPlayer($idPlayer)->addFleet($fleet);
}
}
return $playerGroup;
}
示例3: get_player_group_from_query
/**
* method get_player_group_from_query
* param $result
* param $target_user
* return the attack result
*/
private function get_player_group_from_query($result, $target_user = false)
{
$playerGroup = new PlayerGroup();
while ($fleet_row = parent::$db->fetch_assoc($result)) {
//making the current fleet object
$serializedTypes = explode(';', $fleet_row['fleet_array']);
$idPlayer = $fleet_row['fleet_owner'];
$fleet = new Fleet($fleet_row['fleet_id']);
foreach ($serializedTypes as $serializedType) {
list($id, $count) = explode(',', $serializedType);
if ($id != 0 && $count != 0) {
$fleet->add(get_ship_type($id, $count));
}
}
//making the player object and add it to playerGroup object
if (!$playerGroup->existPlayer($idPlayer)) {
if ($target_user !== FALSE && $target_user['id'] == $idPlayer) {
$player_info = $target_user;
} else {
$player_info = parent::$db->query_fetch("SELECT `research_weapons_technology`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`research_shielding_technology`,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t`research_armour_technology`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tFROM `" . RESEARCH . "`\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `research_user_id` = '" . $idPlayer . "';");
}
$player = new Player($idPlayer, array($fleet));
$player->setTech($player_info['military_tech'], $player_info['shield_tech'], $player_info['defence_tech']);
$playerGroup->addPlayer($player);
} else {
$playerGroup->getPlayer($idPlayer)->addFleet($fleet);
}
}
return $playerGroup;
}
示例4: getPlayerGroupFromQuery
/**
* getPlayerGroupFromQuery
*
* @param array $result Result
* @param boolean $target_user Target User
*
* @return \PlayerGroup
*/
private function getPlayerGroupFromQuery($result, $target_user = false)
{
$playerGroup = new PlayerGroup();
while ($fleet_row = parent::$db->fetch_assoc($result)) {
//making the current fleet object
$serializedTypes = explode(';', $fleet_row['fleet_array']);
$idPlayer = $fleet_row['fleet_owner'];
$fleet = new Fleet($fleet_row['fleet_id']);
foreach ($serializedTypes as $serializedType) {
if (!empty($serializedType)) {
list($id, $count) = explode(',', $serializedType);
if ($id != 0 && $count != 0) {
$fleet->addShipType($this->getShipType($id, $count));
}
}
}
//making the player object and add it to playerGroup object
if (!$playerGroup->existPlayer($idPlayer)) {
if ($target_user !== false && $target_user['user_id'] == $idPlayer) {
$player_info = $target_user;
} else {
$player_info = parent::$db->query_fetch("SELECT u.user_name,\n r.research_weapons_technology,\n r.research_shielding_technology,\n r.research_armour_technology\n FROM " . USERS . " AS u\n INNER JOIN " . RESEARCH . " AS r ON r.research_user_id = u.user_id\n WHERE u.user_id = '" . $idPlayer . "';");
}
$player = new Player($idPlayer, array($fleet));
$player->setTech($player_info['research_weapons_technology'], $player_info['research_shielding_technology'], $player_info['research_armour_technology']);
$player->setName($player_info['user_name']);
$playerGroup->addPlayer($player);
} else {
$playerGroup->getPlayer($idPlayer)->addFleet($fleet);
}
}
return $playerGroup;
}