XG-Proyect-v3.x.x
XG-Proyect-v3.x.x copied to clipboard
[Feature] Pagina imperio completa
Pagina imperio mejorada
Ogame:
XGP con la plantilla:
<br />
<div id="content">
<table border="0" cellpadding="0" cellspacing="1" width="">
<tbody>
<tr height="20px" valign="left">
<td class="c" colspan="{amount_of_planets}">{em_imperium_title}</td>
</tr>
<tr>
<th width="120px" style="text-align:left!important;" rowspan="5">{em_planet}</th>
{name}
<th width="75px">
{planet_name}
</th>
{/name}
<th>Sum</th>
</tr>
<tr height="">
{image}
<th width="75px">
<a href="game.php?page=overview&cp={planet_id}&re=0">
<img src="{dpath}planets/{planet_image}_7.jpg">
</a>
</th>
{/image}
<th width="120px">
<a href="game.php?page=overview&cp={planet_id}&re=0">
<img src="{dpath}empire/sum-bg-empire.jpg">
</a>
</th>
</tr>
<tr>
{coords}
<th width="75px">
<span style="float:left!important;width:50px;">
<a href="game.php?page=galaxy&mode=3&galaxy={planet_galaxy}&system={planet_system}">{planet_coords}</a>
</span>
<span style="float:right!important;width:50px;">
{planet_field_current}/{planet_field_max}
</span>
</th>
{/coords}
<th rowspan="3"></th>
</tr>
<tr height="20px">
{energyInfo}
<th width="75px">
<span style="float:left!important;width:50px;">
{planet_energy}:
</span>
<span style="float:right!important;width:50px;">
<a href="" onmouseover="return overlib('<center><b>{planet_energy_data}{planet_energy_max}</b></center>', LEFT, WIDTH, 80);" onmouseout="return nd();">
{planet_energy_data}
</a>
</span>
</th>
{/energyInfo}
</tr>
<tr height="20px">
{temperature}
<th width="75px">
{em_of} {planet_temp_min}°C {em_to} {planet_temp_max}°C
</th>
{/temperature}
</tr>
<tr>
<td class="c" colspan="{amount_of_planets}" align="left">{em_resources}</td>
</tr>
<tr>
<th width="120px" style="text-align:left!important;">{metal}</th>
{metal_row}
<th width="75px">
<a href="game.php?page=resources&cp={planet_id}&re=0&planettype={planet_type}">{planet_current_amount}</a>
</th>
{/metal_row}
<th>{total_metal_sum}</th>
</tr>
<tr>
<th width="120px" style="text-align:left!important;">{crystal}</th>
{crystal_row}
<th width="75px">
<a href="game.php?page=resources&cp={planet_id}&re=0&planettype={planet_type}">{planet_current_amount}</a>
</th>
{/crystal_row}
<th></th>
</tr>
<tr>
<th width="120px" style="text-align:left!important;">{deuterium}</th>
{deuterium_row}
<th width="75px">
<a href="game.php?page=resources&cp={planet_id}&re=0&planettype={planet_type}">{planet_current_amount}</a>
</th>
{/deuterium_row}
<th></th>
</tr>
<tr>
<td class="c" colspan="{amount_of_planets}" style="text-align: left!important;">{em_storage}</td>
</tr>
<tr>
<th width="120px" style="text-align:left!important;">{building_metal_store}</th>
{metal_store_row}
<th width="75px">
{planet_resource_max}
</th>
{/metal_store_row}
<th></th>
</tr>
<tr>
<th width="120px" style="text-align:left!important;">{building_crystal_store}</th>
{crystal_store_row}
<th width="75px">
{planet_resource_max}
</th>
{/crystal_store_row}
<th></th>
</tr>
<tr>
<th width="120px" style="text-align:left!important;">{building_deuterium_tank}</th>
{deuterium_tank_row}
<th width="75px">
{planet_resource_max}
</th>
{/deuterium_tank_row}
<th></th>
</tr>
<tr>
<td class="c" colspan="{amount_of_planets}" style="text-align:left!important;">{em_resources}</td>
</tr>
{resources}
<tr>
{value}
<th>ø</th>
</tr>
{/resources}
<tr>
<td class="c" colspan="{amount_of_planets}" style="text-align:left!important;">{em_buildings}</td>
</tr>
{facilities}
<tr>
{value}
<th></th>
</tr>
{/facilities}
<tr height="20px">
<td class="c" colspan="{amount_of_planets}" style="text-align:left!important;">{em_defenses}</td>
</tr>
{defenses}
<tr>
{value}
<th></th>
</tr>
{/defenses}
{missiles}
<tr>
{value}
<th></th>
</tr>
{/missiles}
<tr height="20px">
<td class="c" colspan="{amount_of_planets}" style="text-align:left!important;">{em_technology}</td>
</tr>
{tech}
<tr>
{value}
<th></th>
</tr>
{/tech}
<tr height="20px">
<td class="c" colspan="{amount_of_planets}" style="text-align:left!important;">{em_ships}</td>
</tr>
{fleet}
<tr>
{value}
<th>ø</th>
</tr>
{/fleet}
</tbody>
</table>
</div>
Lenguaje Español/Ingles
$lang = [
'em_imperium_title' => 'Visión del Imperio',
'em_planet' => 'Planeta',
'em_name' => 'Nombre',
'em_coords' => 'Coordenadas',
'em_fields' => 'Campos',
'em_energy' => 'Energia',
'em_of' => 'de',
'em_to' => 'a',
'em_resources' => 'Recursos',
'em_buildings' => 'Edificios',
'em_technology' => 'Tecnologías',
'em_ships' => 'Naves',
'em_defenses' => 'Defensas',
];
$lang = [
'em_imperium_title' => 'Empire View',
'em_planet' => 'Planet',
'em_name' => 'Name',
'em_coords' => 'Coords',
'em_fields' => 'Fields',
'em_energy' => 'Energy',
'em_of' => '',
'em_to' => 'to',
'em_resources' => 'Resources',
'em_storage' => 'Storage Space',
'em_buildings' => 'Facilities',
'em_technology' => 'Research',
'em_ships' => 'Fleet',
'em_defenses' => 'Defenses',
];
Agregar a la sql del model
`planet_temp_min`,
`planet_temp_max`,
<?php
declare (strict_types = 1);
/**
* Empire Controller
*
* @category Controller
* @package Application
* @author XG Proyect Team
* @license http://www.xgproyect.org XG Proyect
* @link http://www.xgproyect.org
* @version 3.1.0
*/
namespace application\controllers\game;
use application\core\Controller;
use application\helpers\UrlHelper;
use application\libraries\DevelopmentsLib;
use application\libraries\ProductionLib;
use application\libraries\FormatLib;
use application\libraries\FunctionsLib;
use Exception;
/**
* Empire Class
*/
class Empire extends Controller
{
/**
* The module ID
*
* @var int
*/
const MODULE_ID = 2;
/**
*
* @var array
*/
private $user;
/**
* Constructor
*/
public function __construct()
{
parent::__construct();
// check if session is active
parent::$users->checkSession();
// load Model
parent::loadModel('game/empire');
// load Language
parent::loadLang(['game/global', 'game/constructions', 'game/defenses', 'game/technologies', 'game/ships', 'game/empire']);
// Check module access
FunctionsLib::moduleMessage(FunctionsLib::isModuleAccesible(self::MODULE_ID));
// set data
$this->user = $this->getUserData();
// build the page
$this->buildPage();
}
/**
* Build the page
*
* @return void
*/
private function buildPage()
{
parent::$page->display(
$this->getTemplate()->set(
'game/empire_view',
array_merge(
$this->langs->language,
$this->buildBlocks()
)
),
false,
'',
false
);
}
/**
* Build all the different blocks
*
* @return array
*/
private function buildBlocks(): array
{
$empire_data = $this->Empire_Model->getAllPlayerData((int) $this->user['user_id']);
$total_data = $this->Empire_Model->getSumAllPlayerData((int) $this->user['user_id']);
foreach ($empire_data as $planet) {
// general data
foreach (['image', 'name', 'coords', 'energyInfo', 'temperature'] as $element) {
$empire[$element][] = $this->{'set' . ucfirst($element)}($planet);
}
// resources data
foreach (['metal', 'crystal', 'deuterium', 'energy'] as $element) {
$empire[$element . '_row'][] = $this->setResources($planet, $element);
}
// resources storage data
foreach (['metal_store', 'crystal_store', 'deuterium_tank'] as $element) {
$empire[$element . '_row'][] = $this->setStorage($planet, $element);
}
// structures and technologies data
foreach (['resources', 'facilities', 'fleet', 'defenses', 'missiles', 'tech'] as $element) {
$source = $planet;
if ($element == 'tech') {
$source = $this->user;
}
foreach ($this->getObjects()->getObjectsList($element) as $element_id) {
if (!isset($empire[$element][$this->getObjects()->getObjects($element_id)])) {
$empire[$element][$this->getObjects()->getObjects($element_id)]['value'] = '<th width="75px" style="text-align:left!important;">' . (string) $this->langs->line($this->getObjects()->getObjects($element_id)) . '</th>';
}
$empire[$element][$this->getObjects()->getObjects($element_id)]['value'] .= '<th width="75px" >' . $this->setStructureData($planet, $source, $element, $element_id) . '</th>';
}
}
}
return array_merge(
[
'amount_of_planets' => count($empire_data) + 2,
'dpath' => DPATH,
],
$empire
);
}
/**
* Set the planet image
*
* @param array $planet
* @return array
*/
private function setImage(array $planet): array
{
return [
'planet_id' => $planet['planet_id'],
'planet_image' => $planet['planet_image'],
'dpath' => DPATH,
];
}
/**
* Set the planet image
*
* @param array $planet
* @return string
*/
private function setName(array $planet): array
{
return [
'planet_name' => $planet['planet_name'],
];
}
/**
* Set the planet coordinates
*
* @param array $planet
* @return array
*/
private function setCoords(array $planet): array
{
return [
'planet_coords' => FormatLib::prettyCoords((int) $planet['planet_galaxy'], (int) $planet['planet_system'], (int) $planet['planet_planet']),
'planet_galaxy' => $planet['planet_galaxy'],
'planet_system' => $planet['planet_system'],
'planet_field_current' => $planet['planet_field_current'],
'planet_field_max' => $planet['planet_field_max'],
];
}
/**
* Set the energy
*
* @param array $planet
* @param string $resource
* @return array
*/
private function setEnergyInfo(array $planet): array
{
$energy = FormatLib::prettyNumber(
$planet['planet_energy_max'] + $planet['planet_energy_used']
);
if (($planet['planet_energy_max'] + $planet['planet_energy_used']) < 0) {
$energy = '<font color=red>-' . $energy . '</font>';
} elseif (($planet['planet_energy_max'] + $planet['planet_energy_used']) == 0) {
$energy = $energy;
} else {
$energy = '<font color=lime>+' . $energy . '</font>';
}
return [
'planet_id' => $planet['planet_id'],
'planet_type' => $planet['planet_type'],
'planet_energy' => $this->langs->language['em_energy'],
'planet_energy_data' => $energy,
'planet_energy_max' => "/" . FormatLib::prettyNumber($planet['planet_energy_max']),
];
}
//
private function setTemperature(array $planet): array
{
return [
'planet_temp_min' => $planet['planet_temp_min'],
'planet_temp_max' => $planet['planet_temp_max'],
'em_of' => $this->langs->language['em_of'],
'em_to' => $this->langs->language['em_to']
];
}
/**
* Set the planet resources
*
* @param array $planet
* @param string $resource
* @return array
*/
private function setResources(array $planet, string $resource): array
{
if ($resource == 'energy') {
return [
'used_energy' => (FormatLib::prettyNumber($planet['planet_energy_max'] + $planet['planet_energy_used'])),
'max_energy' => FormatLib::prettyNumber($planet['planet_energy_max']),
];
}
return [
'planet_id' => $planet['planet_id'],
'planet_type' => $planet['planet_type'],
'planet_current_amount' => FormatLib::prettyNumber($planet['planet_' . $resource]),
/*'planet_production' => (
FormatLib::prettyNumber($planet['planet_' . $resource . '_perhour'] + FunctionsLib::readConfig($resource . '_basic_income'))
),*/
];
}
/**
* Set the planet storage data
*
* @param array $planet
* @param string $storage
* @return array
*/
private function setStorage(array $planet, string $store): array
{
return [
'planet_id' => $planet['planet_id'],
'planet_type' => $planet['planet_type'],
'planet_resource_max' => FormatLib::prettyNumber(
ProductionLib::maxStorable($planet['building_' . $store])
),
];
}
/**
* Sets the structure data
*
* @param array $planet
* @param array $source
* @param string $element
* @param integer $element_id
* @return string
*/
private function setStructureData(array $planet, array $source, string $element, int $element_id): string
{
switch ($element) {
case 'resources':
case 'facilities':
$page = DevelopmentsLib::setBuildingPage($element_id);
break;
case 'tech':
$page = 'research';
break;
case 'fleet':
$page = 'shipyard';
break;
case 'defenses':
case 'missiles':
$page = 'defense';
break;
default:
throw new Exception('Undefined element type "' . $element . '". Only possible: build, tech, fleet, defenses and missiles.');
break;
}
$url = 'game.php?page=' . $page . '&cp=' . $planet['planet_id'] . '&re=0&planettype=' . $planet['planet_type'];
return UrlHelper::setUrl(
$url,
$source[$this->getObjects()->getObjects($element_id)]
);
}
}
/* end of empire.php */
- Falta la parte de las lunas.
- Falta la suma total y el promedio.
- Falta mejorar la programación
Quiero aportar mas que se parezca el rediseño con el antiguo diseño y lo otro perdonen por mi programación recién estoy aprendiendo como manejar psr-4 XD jjajajaj me cuesta todavía un poco a manejar este estilo pero de apoco vamos a mejorar