本文整理汇总了PHP中Player::getPlayer方法的典型用法代码示例。如果您正苦于以下问题:PHP Player::getPlayer方法的具体用法?PHP Player::getPlayer怎么用?PHP Player::getPlayer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player::getPlayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: page_refreshUserData
function page_refreshUserData()
{
global $db;
$player = Player::getPlayer($_SESSION['player']->playerID);
if (!$player) {
return false;
}
$_SESSION['player'] = $player;
return true;
}
示例2: page_refreshUserData
function page_refreshUserData()
{
global $db, $params, $config;
$player = Player::getPlayer($params->SESSION->player->playerID);
if (!$player) {
return FALSE;
}
$_SESSION['player'] = $player;
$params->SESSION->player = $player;
return TRUE;
}
示例3: tribe_getContent
function tribe_getContent($caveID, $tribeID)
{
global $db, $template;
if (!$tribeID) {
$template->throwError('Der Stamm wurde nicht gefunden.');
return;
}
// open template
$template->setFile('tribeDetail.tmpl');
$template->setShowResource(false);
$tribe = Tribe::getByID($tribeID);
if ($tribe == null) {
$template->throwError('Der Stamm wurde nicht gefunden.');
return;
}
// parse tribe message
$parser = new parser();
$tribe['description'] = $parser->p($tribe['description']);
$ranking = Tribe::getRanking($tribeID);
$tribe['rank'] = $ranking;
// leader
if ($tribe['leaderID'] != 0) {
$leader = Player::getPlayer($tribe['leaderID']);
$tribe['leader_name'] = $leader->name;
}
$template->addVar('tribe_details', $tribe);
// history
$template->addVar('tribe_history', Tribe::getHistory($tribeID));
// player list
$template->addVar('tribe_player_list', Tribe::getPlayerList($tribeID, true, true));
// relations
$relations = TribeRelation::getRelations($tribeID);
$relationsData = array();
if (isset($relations['own'])) {
foreach ($relations['own'] as $target => $relationData) {
$relationsData[$target] = array('tribe' => $relationData['targetTag'], 'tribeID_target' => $relationData['tribeID_target'], 'relation_to' => $GLOBALS['relationList'][$relationData['relationType']]['name'], 'relation_from' => isset($relations['other'][$target]) && $relations['other'][$target] ? $GLOBALS['relationList'][$relations['other'][$target]['relationType']]['name'] : $GLOBALS['relationList'][0]['name']);
}
}
if (isset($relations['other'])) {
foreach ($relations['other'] as $target => $relationData) {
// already printed out this relation
if (isset($relationsData[$target])) {
continue;
}
$relationsData[$target] = array('tribe' => $relationData['targetTag'], 'tribeID_target' => $relationData['tribeID_target'], 'relation_to' => $GLOBALS['relationList'][0]['name'], 'relation_from' => $GLOBALS['relationList'][$relationData['relationType']]['name']);
}
}
$template->addVar('relations_data', $relationsData);
}
示例4: page_dberror
if (!$db) {
page_dberror();
}
//check user from Session-table with id
$query = "SELECT * FROM Session " . "WHERE s_id = '{$params->POST->id}' " . "AND playerID = '{$params->POST->userID}'";
$dbresult = $db->query($query);
if (!$dbresult || $dbresult->isEmpty()) {
page_error403(__FILE__ . ":" . __LINE__ . ": Falsche SessionID.");
}
$session_row = $dbresult->nextRow(MYSQL_ASSOC);
// sessionstart sollte nur einmal augerufen werden können
$query = "UPDATE `Session` SET s_id_used = 1 " . "WHERE s_id = '{$params->POST->id}' " . "AND playerID = '{$params->POST->userID}' " . "AND s_id_used = 0";
$dbresult = $db->query($query);
if (!$dbresult || !$db->affected_rows() == 1) {
page_error403(__FILE__ . ":" . __LINE__ . ": Ungültige SessionID.");
}
// get player by playerID for session
$player = Player::getPlayer($params->POST->userID);
if (!$player) {
page_error403(__FILE__ . ":" . __LINE__ . ": Ungültige SpielerID.");
}
// put user, its session and nogfx flag into session
$_SESSION['player'] = $player;
$_SESSION['nogfx'] = $params->POST->nogfx == 1;
$_SESSION['session'] = $session_row;
$_SESSION['logintime'] = date("YmdHis");
// initiate Session messages
$_SESSION['messages'] = array();
// go to ugastart.php
Header("Location: {$config->GAME_START_URL}");
exit;
示例5: takeover_transfer_cave_to
function takeover_transfer_cave_to($caveID, $playerID)
{
global $db;
// check parameters
$caveID = (int) $caveID;
$playerID = (int) $playerID;
// get player
$winner = Player::getPlayer($playerID, true);
if (!sizeof($winner)) {
echo "ERROR (takeover_transfer_cave_to): Could not transfer Cave {$caveID} to Player {$playerID}.\n";
return FALSE;
}
// secureCaveCredits
$hasCredits = $winner['secureCaveCredits'] > 0 ? 1 : 0;
// transfer cave to player
$sql = $db->prepare("UPDATE " . CAVE_TABLE . "\n SET playerID = :playerID,\n takeoverable = 0,\n secureCave = :secureCave\n WHERE caveID = :caveID");
$sql->bindValue('playerID', $playerID, PDO::PARAM_INT);
$sql->bindValue('secureCave', $hasCredits, PDO::PARAM_INT);
$sql->bindValue('caveID', $caveID, PDO::PARAM_INT);
if (!$sql->execute()) {
return FALSE;
}
// update secureCaveCredits
$sql = $db->prepare("UPDATE " . PLAYER_TABLE . "\n SET secureCaveCredits = GREATEST(0, secureCaveCredits - 1)\n WHERE playerID = :playerID");
$sql->bindValue('playerID', $playerID, PDO::PARAM_INT);
if (!$sql->execute()) {
echo "ERROR (takeover_transfer_cave_to): Could not update secureCaveCredits of Player {$playerID}.\n";
return FALSE;
}
// copy sciences
if (sizeof($GLOBALS['scienceTypeList'])) {
$set = array();
foreach ($GLOBALS['scienceTypeList'] as $science) {
$temp = $science->dbFieldName;
$set[] = "{$temp} = '{$winner[$temp]}'";
}
$set = implode(", ", $set);
$sql = $db->prepare("UPDATE " . CAVE_TABLE . "\n SET " . $set . "\n WHERE playerID = :playerID");
$sql->bindValue('playerID', $playerID, PDO::PARAM_INT);
if (!$sql->execute()) {
echo "ERROR (takeover_transfer_cave_to): Could not update sciences of Player {$playerID}.\n";
return FALSE;
}
}
// get the cave's data
$cave = getCaveByID($caveID);
takeover_send_transfer($playerID, $cave);
}
示例6: changeLeader
public static function changeLeader($tribeID, $newLeaderID, $oldLeaderID)
{
if (empty($tribeID) || $newLeaderID == $oldLeaderID) {
return false;
//nothing changed
}
if ($newLeaderID != $oldLeaderID) {
if ($oldLeaderID && !self::removeLeader($tribeID)) {
return -2;
}
if ($newLeaderID != 0 && !self::setLeader($newLeaderID, $tribeID)) {
return -3;
}
}
if ($newLeaderID != $oldLeaderID) {
if ($newLeaderID == 0) {
TribeMessage::sendIntern($tribeID, Tribe::MESSAGE_LEADER, _('Stammesführung'), _('Der Stamm hat momentan kein Oberhaupt mehr.'));
}
if ($newLeaderID > 0) {
$player = Player::getPlayer($newLeaderID);
TribeMessage::sendIntern($tribeID, Tribe::MESSAGE_LEADER, _('Stammesführung'), sprintf(_('Ihr Stamm hat ein neues Oberhaupt: %s.'), $player->name));
}
}
return $newLeaderID;
}
示例7: hero_usePotion
function hero_usePotion($potionID, $value)
{
global $db;
$playerID = $_SESSION['player']->playerID;
$playerData = Player::getPlayer($playerID, true);
$hero = getHeroByPlayer($playerID);
$potion = $GLOBALS['potionTypeList'][$potionID];
if (!$potion) {
return -8;
}
if ($potion->needed_level > $hero['lvl']) {
return -10;
}
if ($playerData[$potion->dbFieldName] < $value) {
return -9;
}
// remove potions
$sql = $db->prepare("UPDATE " . PLAYER_TABLE . "\n SET " . $potion->dbFieldName . " = " . $potion->dbFieldName . " - :value\n WHERE playerID = :playerID");
$sql->bindValue('value', $value, PDO::PARAM_INT);
$sql->bindValue('playerID', $playerID, PDO::PARAM_INT);
$sql_setback = $db->prepare("UPDATE " . PLAYER_TABLE . "\n SET " . $potion->dbFieldName . " = " . $potion->dbFieldName . " + :value\n WHERE playerID = :playerID");
$sql_setback->bindValue('value', $value, PDO::PARAM_INT);
$sql_setback->bindValue('playerID', $playerID, PDO::PARAM_INT);
if (!$sql->execute()) {
return -8;
}
// apply potion effects
$newHealPoints = $hero['healPoints'];
for ($i = 0; $i < $value; $i++) {
$newHealPoints += floor($hero['maxHealPoints'] * $potion->hp_prozentual_increase / 100) + $potion->hp_increase;
}
if ($hero['maxHealPoints'] < $newHealPoints) {
$newHealPoints = $hero['maxHealPoints'];
}
if ($potion->tp_setBack == false) {
$sql = $db->prepare("UPDATE " . HERO_TABLE . "\n SET healPoints = :newHealPoints\n WHERE playerID = :playerID");
$sql->bindValue('newHealPoints', $newHealPoints, PDO::PARAM_INT);
$sql->bindValue('playerID', $playerID, PDO::PARAM_INT);
if (!$sql->execute()) {
$sql_setback->execute();
return -8;
}
} else {
//remove hero effects from cave
if (!hero_removeHeroEffectsFromCave($playerID)) {
return -8;
}
//remove hero effect from hero
if (!hero_clearHeroEffectsAndSkills($playerID)) {
return -8;
}
$tpFree = $hero['maxHpLvl'] + $hero['regHpLvl'] + $hero['tpFree'];
foreach ($GLOBALS['heroSkillTypeList'] as $skill) {
if ($hero[$skill['dbFieldName']]) {
$tpFree += $skill['costTP'] * $hero[$skill['dbFieldName']];
}
}
$healPoints = eval("return " . hero_parseFormulas($GLOBALS['heroTypesList'][$hero['heroTypeID']]['maxHP_formula']) . ";");
$sql = $db->prepare("UPDATE " . HERO_TABLE . " SET\n maxHpLvl = 0, maxHealPoints = :maxHealPoints,\n healPoints = :healpoints,\n regHpLvl = 0, regHP = 0,\n tpFree = :tpFree,\n heroTypeID = 1000\n WHERE playerID = :playerID");
$sql->bindValue('playerID', $playerID, PDO::PARAM_INT);
$sql->bindValue('tpFree', $tpFree, PDO::PARAM_INT);
$sql->bindValue('maxHealPoints', $healPoints, PDO::PARAM_INT);
$sql->bindValue('healpoints', floor($healPoints / 2), PDO::PARAM_INT);
if (!$sql->execute()) {
$sql_setback->execute();
return -8;
}
return 6;
}
return 5;
}
示例8: getCaveReport
function getCaveReport($caveID, $ownCaves, $targetCaveID, $method)
{
global $template;
if (!$targetCaveID) {
$template->throwError('Es wurde keine Höhle ausgewählt.');
return;
}
if ($method == 'ajax') {
$shortVersion = true;
$template->setFile('mapDetailAjax.tmpl');
} else {
$shortVersion = false;
$template->setFile('mapDetail.tmpl');
}
$cave = getCaveByID($targetCaveID);
$caveDetails = array();
$playerDetails = null;
$showArtePossible = false;
if ($cave['playerID'] != 0) {
$caveDetails = getCaves($cave['playerID']);
$playerDetails = Player::getPlayer($cave['playerID']);
$showArtePossible = $playerDetails->tribe != GOD_ALLY ? true : false;
}
$cave['terrain_name'] = $GLOBALS['terrainList'][$cave['terrain']]['name'];
$cave['terrain_img'] = $GLOBALS['terrainList'][$cave['terrain']]['img'];
if ($GLOBALS['terrainList'][$cave['terrain']]['tribeRegion']) {
$cave['terrain_description'] = $GLOBALS['terrainList'][$cave['terrain']]['description'];
$cave['terrain_tribe_cave'] = $GLOBALS['terrainList'][$cave['terrain']]['tribeRegion'];
$attackerTribe = Tribe::getByID($cave['lastAttackingTribeID']);
$cave['tribe_cave_tag'] = $attackerTribe['tag'];
}
$region = getRegionByID($cave['regionID']);
// Wenn die Höhle ein Artefakt enthält und man berechtigt ist -> anzeigen
if ($cave['hasArtefact'] && ($showArtePossible || $_SESSION['player']->tribe == GOD_ALLY)) {
$cave['hasArtefact'] = true;
} else {
$cave['hasArtefact'] = false;
}
if ($cave['hasPet'] && ($showArtePossible || $_SESSION['player']->tribe == GOD_ALLY)) {
$cave['hasPet'] = true;
} else {
$cave['hasArtefact'] = false;
}
$template->addVar('cave_details', $cave);
if ($cave['playerID'] != 0) {
$template->addVar('player_details', $playerDetails);
/****************************************************************************************************
*
* Alle Höhlen des Spielers ausgeben
*
****************************************************************************************************/
$caves = array();
foreach ($caveDetails as $key => $value) {
$temp = array('caveName' => $value['name'], 'xCoord' => $value['xCoord'], 'yCoord' => $value['yCoord'], 'terrain' => $GLOBALS['terrainList'][$value['terrain']]['name'], 'caveSize' => floor($value[CAVE_SIZE_DB_FIELD] / 50) + 1, 'secureCave' => $value['secureCave']);
if ($value['hasArtefact'] && ($playerDetails->tribe != GOD_ALLY || $_SESSION['player']->tribe == GOD_ALLY)) {
$temp['artefact'] = true;
}
if ($value['hasPet'] && ($playerDetails->tribe != GOD_ALLY || $_SESSION['player']->tribe == GOD_ALLY)) {
$temp['pet'] = true;
}
$caves[] = $temp;
}
$template->addVar('player_caves', $caves);
} else {
if (sizeof($ownCaves) < $_SESSION['player']->takeover_max_caves) {
if ($cave['starting_position'] == 0 && $cave['takeoverable'] == 0 && $cave['takeover_level'] > 0) {
$template->addVar('maybe_takeoverable', true);
} else {
if ($cave['takeoverable'] == 1) {
$template->addVar('takeoverable', true);
}
}
}
}
}
示例9: player_getContent
function player_getContent($caveID, $playerID)
{
global $db, $template;
// open template
$template->setFile('playerDetail.tmpl');
$template->setShowResource(false);
// workaround, if no playerID is submitted! TODO
if ($playerID == 0) {
$playerID = $_SESSION['player']->playerID;
}
$playerDetails = Player::getPlayer($playerID, true);
if (!$playerDetails) {
$template->throwError('Da wollte irgendwie was nicht aus der Datenbank ausgelesen werden :(');
return;
}
if ($playerDetails['avatar']) {
$playerDetails['avatar'] = @unserialize($playerDetails['avatar']);
$template->addVars(array('player_avatar' => $playerDetails['avatar']['path'], 'player_avatar_width' => $playerDetails['avatar']['width'], 'player_avatar_height' => $playerDetails['avatar']['height']));
}
if (!empty($playerDetails['awards'])) {
$tmp = explode('|', $playerDetails['awards']);
$awards = array();
foreach ($tmp as $tag) {
$awards[] = $tag;
}
$playerDetails['award'] = $awards;
}
unset($playerDetails['awards']);
foreach ($playerDetails as $k => $v) {
if (!$v) {
$playerDetails[$k] = _('k.A.');
}
}
$playerDetails['mail_receiver'] = urlencode($playerDetails['name']);
$playerDetails['caveID'] = $caveID;
$playerTribe = $playerDetails['tribe'];
$timediff = getUgaAggaTimeDiff(time_fromDatetime($playerDetails['created']), time());
$playerDetails['age'] = 18 + $timediff['year'];
// init messages class
$parser = new parser();
$playerDetails['description'] = $parser->p($playerDetails['description']);
// show player's caves
$caves = getCaves($playerID);
if ($caves) {
$template->addVar('player_caves', $caves);
}
// show player's history
$history = Player::getHistory($playerID);
if (sizeof($history)) {
$template->addVar('player_history', $history);
}
//get player rank
$sql = $db->prepare("SELECT rank FROM " . RANKING_TABLE . " WHERE playerID = :playerID");
$sql->bindValue('playerID', $playerID, pDo::PARAM_INT);
if (!$sql->execute()) {
page_dberror();
}
if ($row = $sql->fetch()) {
$playerDetails['rank'] = $row['rank'];
} else {
$playerDetails['rank'] = '';
}
$template->addVars(array('player_details' => $playerDetails));
}
示例10: header
$sql->bindValue('playerID', $playerID, PDO::PARAM_INT);
if (!$sql->execute()) {
header("Location: " . Config::GAME_END_URL . "?id=wrongSessionID");
exit;
}
$sessionRow = $sql->fetch(PDO::FETCH_ASSOC);
$sql->closeCursor();
// sessionstart sollte nur einmal augerufen werden können
$sql = $db->prepare("UPDATE " . SESSION_TABLE . "\n SET s_id_used = 1\n WHERE s_id = :s_id\n AND playerID = :playerID\n AND s_id_used = 0");
$sql->bindValue('s_id', $sessionID, PDO::PARAM_STR);
$sql->bindValue('playerID', $playerID, PDO::PARAM_INT);
if (!$sql->execute() || $sql->rowCount() == 0) {
header("Location: " . Config::GAME_END_URL . "?id=wrongSessionID");
exit;
}
// get player by playerID for session
$player = Player::getPlayer($playerID);
if (!$player) {
header("Location: " . Config::GAME_END_URL . "?id=wrongSessionID");
exit;
}
// put user, its session and nogfx flag into session
$_SESSION['player'] = $player;
$_SESSION['nogfx'] = $noGfx == 1;
$_SESSION['session'] = $sessionRow;
$_SESSION['logintime'] = date("YmdHis");
// initiate Session messages
$_SESSION['messages'] = array();
// go to start url
header("Location: " . Config::GAME_START_URL);
exit;
示例11: unitAction
function unitAction($caveID, &$meineHoehlen)
{
global $config, $db, $MAX_RESOURCE, $MOVEMENTCOSTCONSTANT, $MOVEMENTSPEEDCONSTANT, $params, $resourceTypeList, $unitTypeList, $FUELRESOURCEID;
// get movements
$ua_movements = Movement::getMovements();
$details = $meineHoehlen[$caveID];
/***************************************************************************/
/** **/
/** CHECK ARTEFACTS **/
/** **/
/***************************************************************************/
// artefact moving: get ID if any
//
// $params->POST->myartefacts will be
// NULL, if it is not set at all
// -1 when choosing no artefact to move
// 0 if there was a real choice
// default: Move No Artefact (this var holds the artefactID to move)
$moveArtefact = 0;
// this array shall contain the artefacts if any
$myartefacts = array();
// does the cave contain an artefact at least?
if ($details['artefacts'] > 0) {
// get artefacts
$myartefacts = artefact_getArtefactsReadyForMovement($caveID);
// was an artefact chosen?
if ((int) $params->POST->myartefacts > 0) {
$tempID = (int) $params->POST->myartefacts;
// now check, whether this artefactID belongs to this cave
foreach ($myartefacts as $key => $value) {
// if found, set it
if ($tempID == $value['artefactID']) {
$moveArtefact = $tempID;
break;
}
}
}
}
// now $moveArtefact should contain 0 for 'move no artefact'
// or the artefactID of the artefact to be moved
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
// put user, its session and nogfx flag into session
$_SESSION['player'] = Player::getPlayer($params->SESSION->player->playerID);
$params->SESSION->player = $_SESSION['player'];
// get Map Size
$size = getMapSize();
$dim_x = ($size['maxX'] - $size['minX'] + 1) / 2;
$dim_y = ($size['maxY'] - $size['minY'] + 1) / 2;
$foodPerCave = eval('return ' . formula_parseToPHP($MOVEMENTCOSTCONSTANT . ';', '$details'));
$minutesPerCave = eval('return ' . formula_parseToPHP($MOVEMENTSPEEDCONSTANT . ';', '$details'));
$minutesPerCave *= MOVEMENT_TIME_BASE_FACTOR / 60;
if (isset($params->POST->moveit) && sizeof($params->POST->unit)) {
$targetXCoord = intval($params->POST->targetXCoord);
$targetYCoord = intval($params->POST->targetYCoord);
$targetCaveName = $params->POST->targetCaveName;
$targetCaveID = intval($params->POST->targetCaveID);
$movementID = intval($params->POST->movementID);
// check for scripters
check_timestamp($params->POST->tstamp);
$validCaveName = FALSE;
// targetCaveID >>> coords
if (isset($targetCaveID) && $targetCaveID > 0) {
$result = getCaveByID(intval($targetCaveID));
if (sizeof($result) != 0) {
$targetXCoord = $result['xCoord'];
$targetYCoord = $result['yCoord'];
$validCaveName = TRUE;
}
// name >>> coords
} else {
if (isset($targetCaveName)) {
$result = getCaveByName($targetCaveName);
if (sizeof($result) != 0) {
$targetXCoord = $result['xCoord'];
$targetYCoord = $result['yCoord'];
$validCaveName = TRUE;
}
}
}
// get target player
$result = getCaveByCoords(intval($targetXCoord), intval($targetYCoord));
if (sizeof($result) != 0) {
$targetPlayer = new Player(getPlayerByID($result['playerID']));
}
// Array von Nullwerten befreien
$unit = array_filter($params->POST->unit, "filterZeros");
$unit = array_map("checkFormValues", $unit);
$resource = array_map("checkFormValues", $params->POST->rohstoff);
// Test, ob Einheitentragekapazität ausgelastet
foreach ($resource as $resKey => $aRes) {
$capacity = 0;
foreach ($unit as $unitKey => $aUnit) {
$capacity += $aUnit * $unitTypeList[$unitKey]->encumbranceList[$resKey];
}
if ($capacity < $aRes) {
$overloaded = 1;
break;
}
//.........这里部分代码省略.........
示例12: unit_Movement
function unit_Movement($caveID, &$ownCave)
{
global $db, $template;
$safeForm = true;
// get movements
$ua_movements = Movement::getMovements();
$details = $ownCave[$caveID];
/***************************************************************************/
/** **/
/** CHECK ARTEFACTS **/
/** **/
/***************************************************************************/
// artefact moving: get ID if any
//
// $params->POST->myartefacts will be
// NULL, if it is not set at all
// -1 when choosing no artefact to move
// 0 if there was a real choice
// default: Move No Artefact (this var holds the artefactID to move)
$moveArtefact = 0;
// this array shall contain the artefacts if any
$myartefacts = array();
// does the cave contain an artefact at least?
if ($details['artefacts'] > 0) {
// get artefacts
$myartefacts = artefact_getArtefactsReadyForMovement($caveID);
$moveArtefactID = Request::getVar('myartefacts', 0);
// was an artefact chosen?
if ($moveArtefactID > 0) {
// now check, whether this artefactID belongs to this cave
foreach ($myartefacts as $key => $value) {
// if found, set it
if ($moveArtefactID == $value['artefactID']) {
$moveArtefact = $moveArtefactID;
break;
}
}
}
}
// now $moveArtefact should contain 0 for 'move no artefact'
// or the artefactID of the artefact to be moved
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
/**
* HERO MOVEMENT
*/
$moveHero = 0;
if ($details['hero'] != 0) {
$hero = getHeroByPlayer($_SESSION['player']->playerID);
if ($hero['isAlive'] != 1) {
$details['hero'] = 0;
}
}
if ($details['hero'] != 0 && Request::getVar('moveHero', false) == true) {
$moveHero = $details['hero'];
}
/**
* END HERO MOVEMENTS
*/
// put user, its session and nogfx flag into session
$_SESSION['player'] = Player::getPlayer($_SESSION['player']->playerID);
// get Map Size
$size = getMapSize();
$dim_x = ($size['maxX'] - $size['minX'] + 1) / 2;
$dim_y = ($size['maxY'] - $size['minY'] + 1) / 2;
$foodPerCave = eval('return ' . formula_parseToPHP(GameConstants::MOVEMENT_COST . ';', '$details'));
$minutesPerCave = eval('return ' . formula_parseToPHP(GameConstants::MOVEMENT_SPEED . ';', '$details'));
$minutesPerCave *= MOVEMENT_TIME_BASE_FACTOR / 60;
if (Request::getVar('moveit', false) && sizeof(Request::getVar('unit', array('' => '')))) {
$targetXCoord = Request::getVar('targetXCoord', 0);
$targetYCoord = Request::getVar('targetYCoord', 0);
$targetCaveName = Request::getVar('targetCaveName', '');
$targetCaveID = Request::getVar('targetCaveID', 0);
$movementID = Request::getVar('movementID', 0);
// check for scripters
check_timestamp(Request::getVar('tstamp', 0));
$validCaveName = false;
// targetCaveID >>> coords
if ($targetCaveID > 0) {
$result = getCaveByID(intval($targetCaveID));
if (sizeof($result) != 0) {
$targetXCoord = $result['xCoord'];
$targetYCoord = $result['yCoord'];
$validCaveName = true;
}
// name >>> coords
} else {
if ($targetCaveName != "") {
$result = getCaveByName($targetCaveName);
if (sizeof($result) != 0) {
$targetXCoord = $result['xCoord'];
$targetYCoord = $result['yCoord'];
$validCaveName = true;
}
}
}
// get target player
$result = getCaveByCoords(intval($targetXCoord), intval($targetYCoord));
if (sizeof($result) != 0) {
//.........这里部分代码省略.........
示例13: effect_getEffectWonderDetailContent
function effect_getEffectWonderDetailContent($caveID, $caveData)
{
global $buildingTypeList, $defenseSystemTypeList, $resourceTypeList, $scienceTypeList, $unitTypeList, $wonderTypeList, $effectTypeList, $terrainList, $config, $params, $db;
// don't show the resource bar
$no_resource_flag = 1;
// open the template
$template = tmpl_open($params->SESSION->player->getTemplatePath() . 'effectWonderDetail.ihtml');
$wonders = wonder_getActiveWondersForCaveID($caveID, $db);
$wondersData = array();
if ($wonders) {
foreach ($wonders as $key => $data) {
if ($wonderTypeList[$data['wonderID']]->groupID == 0 or $wonderTypeList[$data['wonderID']]->groupID == 3) {
$wonderData = array("name" => $wonderTypeList[$data['wonderID']]->name, "end" => $data['end_time']);
$effectsData = array();
// iterating through effectTypes
foreach ($effectTypeList as $effect) {
if ($value = $data[$effect->dbFieldName] + 0) {
$effectsData[] = array("name" => $effect->name, "value" => ($value > 0 ? "+" : "") . $value);
}
}
// iterating through resourceTypes
foreach ($resourceTypeList as $resource) {
if ($value = $data[$resource->dbFieldName] + 0) {
$effectsData[] = array("name" => $resource->name, "value" => ($value > 0 ? "+" : "") . $value);
}
}
// iterating through buildingTypes
foreach ($buildingTypeList as $building) {
if ($value = $data[$building->dbFieldName] + 0) {
$effectsData[] = array("name" => $building->name, "value" => ($value > 0 ? "+" : "") . $value);
}
}
// iterating through scienceTypes
foreach ($scienceTypeList as $science) {
if ($value = $data[$science->dbFieldName] + 0) {
$effectsData[] = array("name" => $science->name, "value" => ($value > 0 ? "+" : "") . $value);
}
}
// iterating through unitTypes
foreach ($unitTypeList as $unit) {
if ($value = $data[$unit->dbFieldName] + 0) {
$effectsData[] = array("name" => $unit->name, "value" => ($value > 0 ? "+" : "") . $value);
}
}
// iterating through defenseSystemTypes
foreach ($defenseSystemTypeList as $defenseSystem) {
if ($value = $data[$defenseSystem->dbFieldName] + 0) {
$effectsData[] = array("name" => $defenseSystem->name, "value" => ($value > 0 ? "+" : "") . $value);
}
}
$wonderData['EFFECT'] = $effectsData;
$wondersData[] = $wonderData;
}
}
// end iterating through active wonders
}
// ADDED by chris--- for terrain effects ****************************
global $effect, $effectname;
$terraineffectData = array();
$cave = getCaveByID($caveID);
$terrainvalue = $cave['terrain'];
$terraineffectsData[] = array("name" => $terrainList[$terrainvalue]['name'] . ":", "value" => "");
for ($t = 0; $t < count($effect[$terrainvalue]); $t++) {
$effectvalue = explode(" = ", $effect[$terrainvalue][$t]);
$effectkey[$t] = $effectvalue[0];
$effectv[$t] = substr($effectvalue[1], 1, -1);
$terraineffectsData[] = array("name" => $effectname[$terrainvalue][$t], "value" => $effectv[$t]);
}
// *******************************************************************
$effectsData = array();
foreach ($effectTypeList as $data) {
$value = $caveData[$data->dbFieldName] + 0;
if ($value) {
$effectsData[] = array("name" => $data->name, "value" => $value);
}
}
// end iterating through effectTypes
$data = array();
if (!sizeof($wondersData)) {
$data['NOWONDER'] = array('dummy' => "");
} else {
$data['WONDER'] = $wondersData;
}
if (!sizeof($effectsData)) {
$data['NOEFFECT'] = array('dummy' => "");
} else {
$data['EFFECT'] = $effectsData;
}
if (sizeof($terraineffectsData) < 2) {
$data['TERRAINNOEFFECT'] = array('dummy' => "");
} else {
$data['TERRAINEFFECT'] = $terraineffectsData;
}
// put user, its session and nogfx flag into session
$_SESSION['player'] = Player::getPlayer($params->SESSION->player->playerID);
$params->SESSION->player = $_SESSION['player'];
$data['farmpoints'] = $params->SESSION->player->fame;
$data['rules_path'] = RULES_PATH;
tmpl_set($template, "/", $data);
return tmpl_parse($template);
//.........这里部分代码省略.........
示例14: artefact_getDetail
function artefact_getDetail($caveID, &$myCaves)
{
global $template;
$messageText = array(-5 => array('type' => 'error', 'message' => _('Dieses Artefakt kann nicht noch einmal eingeweiht werden.')), -4 => array('type' => 'error', 'message' => _('Fehler: Artefakt konnte nicht auf ARTEFACT_INITIATING gestellt werden.')), -3 => array('type' => 'error', 'message' => _('Sie weihen bereits ein anderes Artefakt ein.')), -2 => array('type' => 'error', 'message' => _('Es fehlen die notwendigen Voraussetzungen.')), -1 => array('type' => 'error', 'message' => _('Fehler: Ritual nicht gefunden.')), 0 => array('type' => 'notice', 'message' => _('Über dieses Artefakt weiß man nichts!')), 1 => array('type' => 'success', 'message' => _('Die Einweihung des Artefakts wurde gestartet!')));
// open template
$template->setFile('artefactDetail.tmpl');
$show_artefact = TRUE;
$artefactID = Request::getVar('artefactID', 0);
$artefact = artefact_getArtefactByID($artefactID);
if (empty($artefact)) {
$messageID = 0;
} else {
$description_initiated = $artefact['description_initiated'];
unset($artefact['description_initiated']);
// Gott oder nicht?
if ($_SESSION['player']->tribe != GOD_ALLY) {
// gibts nicht oder nicht in einer Höhle
if (!$artefact['caveID']) {
$show_artefact = FALSE;
} else {
$cave = getCaveByID($artefact['caveID']);
// leere Höhle
if (!$cave['playerID']) {
$show_artefact = FALSE;
} else {
$owner = Player::getPlayer($cave['playerID']);
// Besitzer ist ein Gott
if ($owner->tribe == GOD_ALLY) {
$show_artefact = FALSE;
}
}
}
}
$showRitual = 0;
$showStatus = 0;
$template->addVars(array('show_artefact' => $show_artefact));
if ($show_artefact) {
$artefact['img'] = $artefact['uninitiationImg'];
// Bild vom uninitalisierten Artefakt per default anzeigen!
// eigene Höhle ...
if (isset($myCaves[$artefact['caveID']])) {
$showStatus = 1;
// Ritual ausführen?
if (Request::isPost('initiate')) {
$messageID = artefact_beginInitiation($artefact);
// reload
$myCaves = getCaves($_SESSION['player']->playerID);
// wenn noch uneingeweiht und in der "richtigen" Höhle, ritual zeigen
} else {
if ($artefact['caveID'] == $caveID && $artefact['initiated'] == ARTEFACT_UNINITIATED) {
// Check, ob bereits eingeweiht wird.
if (sizeof(artefact_getArtefactInitiationsForCave($caveID)) == 0) {
$showRitual = 1;
// Hol das Einweihungsritual
$ritual = artefact_getRitualByID($artefact['initiationID']);
// Hol die Kosten und beurteile ob genug da ist
$merged_game_rules = array_merge($GLOBALS['resourceTypeList'], $GLOBALS['buildingTypeList'], $GLOBALS['unitTypeList'], $GLOBALS['scienceTypeList'], $GLOBALS['defenseSystemTypeList']);
$cost = array();
foreach ($merged_game_rules as $val) {
if (isset($ritual[$val->dbFieldName])) {
if ($ritual[$val->dbFieldName]) {
$object_context = ceil($ritual[$val->dbFieldName]) > floor($myCaves[$artefact['caveID']][$val->dbFieldName]) ? 'less-' : 'enough ';
array_push($cost, array('object' => $val->name, 'amount' => $ritual[$val->dbFieldName], 'class' => $object_context));
}
}
}
$artefact['initiation'] = array('cost' => $cost, 'name' => $ritual['name'], 'description' => $ritual['description'], 'duration' => time_formatDuration($ritual['duration']), 'initiate' => 1);
} else {
$showRitual = -1;
}
} elseif ($artefact['caveID'] == $caveID && $artefact['initiated'] == ARTEFACT_INITIATING) {
// Arte wird gerade eingeweiht
$showRitual = -1;
}
}
// Besitzer des Artefaktes und initalisiert? Alle Daten des Artefakts anzeigen
if ($artefact['initiated'] == ARTEFACT_INITIATED && isset($myCaves[$artefact['caveID']])) {
$artefact['name'] = $artefact['name_initiated'];
$artefact['description_initiated'] = $description_initiated;
$artefact['img'] = $artefact['initiationImg'];
}
}
$template->addVars(array('artefact' => $artefact));
$template->addVars(array('showRitual' => $showRitual));
$template->addVars(array('showStatus' => $showStatus));
} else {
// über dieses Artefakt weiß man nichts!
$messageID = 0;
}
}
$template->addVar('status_msg', isset($messageID) ? $messageText[$messageID] : '');
}
示例15: hero_getHeroDetail
/** This function returns basic hero details
*
* @param caveID the current caveID
* @param ownCaves all the data of all your caves
*/
function hero_getHeroDetail($caveID, &$ownCaves)
{
global $db, $template;
// open template
$template->setFile('hero.tmpl');
// get current playerID by user
$playerID = $_SESSION['player']->playerID;
$player = Player::getPlayer($playerID, true);
$newhero = false;
$messageText = array(-24 => array('type' => 'error', 'message' => _('Es können nur Rohstoffe aus der aktuellen Höhle geopfert werden!')), -23 => array('type' => 'error', 'message' => _('Die Fähigkeit wurde schon erlernt!')), -22 => array('type' => 'error', 'message' => _('Dein Held hat den falschen Typ, um die Fähigkeit zu erlernen!')), -21 => array('type' => 'error', 'message' => _('Fehler beim Erlernen der Fähigkeit!')), -20 => array('type' => 'error', 'message' => _('Dein Held hat nicht das erforderliche Level!')), -19 => array('type' => 'error', 'message' => _('Fehler beim Eintragen des neuen Heldentyps!')), -18 => array('type' => 'error', 'message' => _('Euer Held ist tot!')), -17 => array('type' => 'error', 'message' => _('Euer Held ist gar nicht tot!')), -16 => array('type' => 'error', 'message' => _('Fehler beim Eintragen der Erfahrungspunkte nach der Opferung!')), -15 => array('type' => 'error', 'message' => _('Fehler beim Abziehen der geopferten Rohstoffe!')), -14 => array('type' => 'error', 'message' => _('Nicht genug Rohstoffe zum Opfern vorhanden!')), -13 => array('type' => 'error', 'message' => _('Fehler beim Holen der Opferwerte!')), -12 => array('type' => 'error', 'message' => _('Fehler beim Erhöhen des Levels!')), -11 => array('type' => 'error', 'message' => _('Nicht genug Talentpunkte vorhanden!')), -10 => array('type' => 'error', 'message' => _('Ihr Held ist noch nicht erfahren genug, diesen Trank zu nutzen!')), -9 => array('type' => 'error', 'message' => _('Nicht genug Tränke vorhanden!')), -8 => array('type' => 'error', 'message' => _('Fehler beim Anwenden des Trankes!')), -7 => array('type' => 'error', 'message' => _('Fehler beim Schreiben in die Datenbank.')), -6 => array('type' => 'error', 'message' => _('Der Held existiert bereits.')), -5 => array('type' => 'error', 'message' => _('Maximallevel des Skills erreicht.')), -4 => array('type' => 'notice', 'message' => _('Fehler beim Abbrechen der Wiederbelebung.')), -3 => array('type' => 'error', 'message' => _('Nicht genug Rohstoffe zum Wiederbeleben.')), -2 => array('type' => 'error', 'message' => _('Der Held wird bereits wiederbelebt.')), -1 => array('type' => 'error', 'message' => _('Dafür sind nicht genug Talentpunkte vorhanden.')), 0 => array('type' => 'error', 'message' => _('Euch steht noch kein Held zur Verfügung.')), 1 => array('type' => 'success', 'message' => _('Euer Held hat eine neue Fähigkeit erlernt.')), 2 => array('type' => 'notice', 'message' => _('Die Wiederbelebung eures Helden hat begonnen.')), 3 => array('type' => 'success', 'message' => _('Euer Held wurde erstellt.')), 4 => array('type' => 'notice', 'message' => _('Wählt mit Bedacht, dies lässt sich womöglich nicht mehr rückgängig machen.')), 5 => array('type' => 'success', 'message' => _('Der Trank hat seine Wirkung entfaltet. Die Lebenspunkte wurden erhöht.')), 6 => array('type' => 'success', 'message' => _('Der Trank des Vergessens hat Wirkung gezeigt. Der Held ist nun wieder unerfahren.')), 7 => array('type' => 'success', 'message' => _('Euer Held hat das nächste Level erreicht!')), 8 => array('type' => 'success', 'message' => _('Eurem Helden wurden expValue Erfahrungspunkte gutgeschrieben.')), 9 => array('type' => 'success', 'message' => _('Die Wiederbelebung wurde erfolgreich abgebrochen.')), 10 => array('type' => 'success', 'message' => _('Heldentyp erfolgreich gewechselt!')), 11 => array('type' => 'success', 'message' => _('Dein Held hat eine neue Fähigkeit erlernt!')));
// create new hero
$action = Request::getVar('action', '');
$newHeroID = Request::getVar('id', '');
if ($action == "createHero") {
if (isset($GLOBALS['heroTypesList'][$newHeroID])) {
$messageID = createNewHero($GLOBALS['heroTypesList'][$newHeroID]['heroTypeID'], $playerID, $caveID);
}
}
$hero = getHeroByPlayer($playerID);
$showTypesList = false;
$changeType = false;
if ($hero['heroTypeID'] == 1000) {
$hero = null;
$changeType = true;
$showTypesList = true;
}
if ($hero != null) {
$showLevelUp = false;
$ritual = getRitual($hero);
$resource['duration'] = $ritual['duration'];
$cave = getCaveSecure($caveID, $playerID);
foreach ($GLOBALS['resourceTypeList'] as $key) {
$dbFieldName = $key->dbFieldName;
if (!isset($ritual[$dbFieldName])) {
continue;
}
$enough = $ritual[$dbFieldName] <= $cave[$dbFieldName];
$tmp = array('enough' => $enough, 'value' => $ritual[$dbFieldName], 'missing' => $ritual[$dbFieldName] - $cave[$dbFieldName], 'dbFieldName' => $dbFieldName, 'name' => $key->name);
$resource[$key->dbFieldName] = $tmp;
}
$action = Request::getVar('action', '');
switch ($action) {
case 'reincarnate':
if ($hero['isAlive'] == 1) {
$messageID = -17;
break;
}
if (checkEventHeroExists($playerID)) {
$messageID = -2;
} else {
$messageID = createRitual($caveID, $playerID, $resource, $hero, $ownCaves);
}
break;
case 'cancelOrder':
if (checkEventHeroExists($playerID)) {
$messageID = hero_cancelOrder();
}
break;
case 'skill':
if ($hero['isAlive'] != 1) {
$messageID = -18;
break;
}
if ($hero['tpFree'] >= 1) {
$skill = Request::getVar('skill', '');
switch ($skill) {
// case 'force':
// //typ='force';
// if ($hero['forceLvl']<10) {
// if (skillForce($playerID, $hero)) {
// $messageID = 1;
// }
// break;
// }
//
// $messageID = -5;
// break;
case 'maxHP':
//typ='maxHP';
if ($hero['maxHpLvl'] < 10) {
if (skillMaxHp($playerID, $hero)) {
$messageID = 1;
} else {
$messageID = -5;
}
break;
}
$messageID = -5;
break;
case 'regHP':
//typ='regHP';
if ($hero['regHpLvl'] < 10) {
if (skillRegHp($playerID, $hero)) {
$messageID = 1;
} else {
//.........这里部分代码省略.........