Skip to content

Commit

Permalink
Mods Expedition Limit
Browse files Browse the repository at this point in the history
Added resource limitation mods during an expedition by admin panel
  • Loading branch information
HikeGame committed Jan 18, 2019
1 parent c5843b9 commit bb5b67c
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 2 deletions.
4 changes: 4 additions & 0 deletions admin.php
Expand Up @@ -66,6 +66,10 @@
include_once('includes/pages/adm/ShowConfigUniPage.php');
ShowConfigUniPage();
break;
case 'configmods':
include_once('includes/pages/adm/ShowConfigModsPage.php');
ShowConfigModsPage();
break;
case 'chat':
include_once('includes/pages/adm/ShowChatConfigPage.php');
ShowChatConfigPage();
Expand Down
6 changes: 5 additions & 1 deletion includes/classes/missions/MissionCaseExpedition.class.php
Expand Up @@ -122,7 +122,11 @@ function EndStayEvent()
$maxFactor = 2400;
}

$founded = round(min($fleetCapacity,min($maxFactor, max(200, $factor)) * $fleetPoints));
if ($config->expedition_limit_res_active == 1) {
$founded = round(min($config->expedition_limit_res, $fleetCapacity));
} else {
$founded = round(min($fleetCapacity,min($maxFactor, max(200, $factor)) * $fleetPoints));
}

$fleetColName = 'fleet_resource_'.$resource[$resourceId];
$this->UpdateFleet($fleetColName, $this->_fleet[$fleetColName] + $founded);
Expand Down
57 changes: 57 additions & 0 deletions includes/pages/adm/ShowConfigModsPage.php
@@ -0,0 +1,57 @@
<?php
/**
* 2moons-2.0
* The project is reserved for its owner for any bug or question you can contact him
* Created by 2moons-2.0.
* User: Danter14 (danter14000@gmail.com)
* Copyright: 2019 - Danter14
* GitHub: https://github.com/HikeGame/Spaccon-1.0
* Date: 17/01/2019
* File: ShowConfigModsPage.php
* Version: 1.0.0
*/
if (!allowedTo(str_replace(array(dirname(__FILE__), '\\', '/', '.php'), '', __FILE__))) throw new Exception("Permission error!");

function ShowConfigModsPage()
{
global $LNG;
$config = Config::get(Universe::getEmulated());

if (!empty($_POST))
{
$config_before = array(
'expedition_limit_res' => $config->expedition_limit_res,
'expedition_limit_res_active' => $config->expedition_limit_res_active,
);

$expedition_limit_res_active = isset($_POST['expedition_limit_res_active']) && $_POST['expedition_limit_res_active'] == 'on' ? 1 : 0;

$expedition_limit_res = HTTP::_GP('expedition_limit_res', 0);

$config_after = array(
'expedition_limit_res' => $expedition_limit_res,
'expedition_limit_res_active' => $expedition_limit_res_active,
);

foreach($config_after as $key => $value)
{
$config->$key = $value;
}
$config->save();

$LOG = new Log(3);
$LOG->target = 0;
$LOG->old = $config_before;
$LOG->new = $config_after;
$LOG->save();
}

$template = new template();

$template->assign_vars(array(
'expedition_limit_res' => $config->expedition_limit_res,
'expedition_limit_res_active' => $config->expedition_limit_res_active,
));

$template->show('ConfigModsBody.tpl');
}
2 changes: 2 additions & 0 deletions install/install.sql
Expand Up @@ -288,6 +288,8 @@ CREATE TABLE `%PREFIX%config` (
`disclamerMail` text NOT NULL,
`disclamerNotice` text NOT NULL,
`alliance_create_min_points` BIGINT UNSIGNED NOT NULL DEFAULT 0,
`expedition_limit_res_active` tinyint(1) unsigned NOT NULL DEFAULT '0',
`expedition_limit_res` double(255,0) unsigned NOT NULL DEFAULT '1000000',
PRIMARY KEY (`uni`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

Expand Down
14 changes: 13 additions & 1 deletion language/en/CUSTOM.php
Expand Up @@ -31,4 +31,16 @@
$LNG['ov_create_moon'] = "Create moon";
$LNG['ov_list_title_build'] = "Building";
$LNG['ov_list_title_tech'] = "Research";
$LNG['ov_list_title_fleet'] = "Fleet/Defense";
$LNG['ov_list_title_fleet'] = "Fleet/Defense";

/**
* Admin
*/
// ShowMenuPage.tpl
$LNG['mu_mods_settings'] = "Configure Mods";
// ConfigModsBody.tpl
$LNG['msg_expedition'] = "Shipping Configuration";
$LNG['msg_expedition_active'] = "Limit system";
$LNG['msg_expedition_active_desc'] = "When activating this system you can put a limit on the resources to find during an expedition by the players";
$LNG['msg_expedition_active_price'] = "Maximum amount of resources";
$LNG['msg_expedition_active_price_desc'] = "Maximum amount the player can find on an expedition even if the capacity is higher";
12 changes: 12 additions & 0 deletions language/fr/CUSTOM.php
Expand Up @@ -44,3 +44,15 @@
$LNG['ov_list_title_build'] = "Bâtiment";
$LNG['ov_list_title_tech'] = "Recherche";
$LNG['ov_list_title_fleet'] = "Flotte/Défense";

/**
* Admin
*/
// ShowMenuPage.tpl
$LNG['mu_mods_settings'] = "Configurer les Mods";
// ConfigModsBody.tpl
$LNG['msg_expedition'] = "Configuration Expédition";
$LNG['msg_expedition_active'] = "Système de limite";
$LNG['msg_expedition_active_desc'] = "Lors de l'activation de ce système vous pouvez mettre une limite sur les ressource trouver lors d'une expédition par les joueurs";
$LNG['msg_expedition_active_price'] = "Montant des ressources maximum";
$LNG['msg_expedition_active_price_desc'] = "Montant maximum que le joueur peut trouver lors d'une expédition même si la capacité est supérieur";
25 changes: 25 additions & 0 deletions styles/templates/adm/ConfigModsBody.tpl
@@ -0,0 +1,25 @@
{include file="overall_header.tpl"}
<center>
<form action="" method="post">
<input type="hidden" name="opt_save" value="1">
<table width="70%" cellpadding="2" cellspacing="2">
<tr>
<th colspan="2">{$LNG.msg_expedition}</th><th>&nbsp;</th>
</tr
<tr>
<td>{$LNG.msg_expedition_active}<br></td>
<td><input name="expedition_limit_res_active"{if $expedition_limit_res_active} checked="checked"{/if} type="checkbox"></td>
<td><img src="./styles/resource/images/admin/i.gif" width="16" height="16" alt="" class="tooltip" data-tooltip-content="{$LNG.msg_expedition_active_desc}"></td>
</tr>
<tr>
<td>{$LNG.msg_expedition_active_price}</td>
<td><input name="expedition_limit_res" maxlength="40" size="60" value="{$expedition_limit_res}" type="text"></td>
<td><img src="./styles/resource/images/admin/i.gif" width="16" height="16" alt="" class="tooltip" data-tooltip-content="{$LNG.msg_expedition_active_price_desc}"></td>
</tr>
<tr>
<td colspan="3"><input value="{$LNG.se_save_parameters}" type="submit"></td>
</tr>
</table>
</form>
</center>
{include file="overall_footer.tpl"}
1 change: 1 addition & 0 deletions styles/templates/adm/ShowMenuPage.tpl
Expand Up @@ -6,6 +6,7 @@
{if allowedTo('ShowInformationPage')}<li><a href="?page=infos" target="Hauptframe">{$LNG.mu_game_info}</a></li>{/if}
{if allowedTo('ShowConfigBasicPage')}<li><a href="?page=config" target="Hauptframe">{$LNG.mu_settings}</a></li>{/if}
{if allowedTo('ShowConfigUniPage')}<li><a href="?page=configuni" target="Hauptframe">{$LNG.mu_unisettings}</a></li>{/if}
{if allowedTo('ShowConfigModsPage')}<li><a href="?page=configmods" target="Hauptframe">{$LNG.mu_mods_settings}</a></li>{/if}
{if allowedTo('ShowChatConfigPage')}<li><a href="?page=chat" target="Hauptframe">{$LNG.mu_chat}</a></li>{/if}
{if allowedTo('ShowTeamspeakPage')}<li><a href="?page=teamspeak" target="Hauptframe">{$LNG.mu_ts_options}</a></li>{/if}
{if allowedTo('ShowFacebookPage')}<li><a href="?page=facebook" target="Hauptframe">{$LNG.mu_fb_options}</a></li>{/if}
Expand Down

0 comments on commit bb5b67c

Please sign in to comment.