Skip to content

Commit

Permalink
GH-230 Move FirstLogin screen completely to its own module place
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed Jul 3, 2022
1 parent 231b6ca commit 4660d8f
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 56 deletions.
74 changes: 73 additions & 1 deletion modules/overview/screens/FirstLogin/FirstLogin.screen.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,83 @@

namespace UniEngine\Engine\Modules\Overview\Screens\FirstLogin;

use UniEngine\Engine\Modules\Overview;

/**
* @param array $params
* @param arrayRef $params['user']
* @param number $params['currentTimestamp']
*/
function render($props) {
// TODO: Placeholder
global $_Lang, $_GameConfig, $_DontShowMenus;

$user = &$props['user'];
$currentTimestamp = $props['currentTimestamp'];

includeLang('firstlogin');

// Run effects
Overview\Screens\FirstLogin\Utils\Effects\updateUserOnFirstLogin([
'userId' => $user['id'],
'currentTimestamp' => $currentTimestamp,
]);

if ($user['referred'] > 0) {
$referringUserWithTasksData = Overview\Screens\FirstLogin\Utils\Helpers\getReferrerTasksData([
'referredById' => $user['referred'],
]);

Overview\Screens\FirstLogin\Utils\Effects\triggerUserReferralTask([
'referringUserWithTasksData' => &$referringUserWithTasksData,
]);
Overview\Screens\FirstLogin\Utils\Effects\handleReferralMultiAccountDetection([
'user' => &$user,
'referredById' => $user['referred'],
'referringUserWithTasksData' => &$referringUserWithTasksData,
'currentTimestamp' => $currentTimestamp,
]);
}

// Check, if this IP is Proxy
Overview\Screens\FirstLogin\Utils\Effects\handleProxyDetection([
'user' => &$user,
'currentTimestamp' => $currentTimestamp,
]);

// TODO: move this to utils
// Give Free ProAccount for 7 days
// doquery("INSERT INTO {{table}} VALUES (NULL, {$user['id']}, UNIX_TIMESTAMP(), 0, 0, 11, 0);", 'premium_free');

Overview\Screens\FirstLogin\Utils\Effects\createUserDevLogDump([
'userId' => $user['id'],
]);

// Render the screen
$_DontShowMenus = true;

$screenTitle = $_Lang['FirstLogin_Title'];
$localTemplateLoader = createLocalTemplateLoader(__DIR__);

$_Lang['LoginPage_Text'] = parsetemplate(
$_Lang['LoginPage_Text'],
[
'GameName' => $_GameConfig['game_name'],
'GameSpeed' => prettyNumber($_GameConfig['game_speed'] / 2500),
'ResSpeed' => prettyNumber($_GameConfig['resource_multiplier']),
'FleetSpeed' => prettyNumber($_GameConfig['fleet_speed'] / 2500),
'FleetDebris' => $_GameConfig['Fleet_Cdr'],
'DefFlDebris' => $_GameConfig['Defs_Cdr'],
'DefMiDebris' => $_GameConfig['Debris_Def_Rocket'],
'MotherSize' => $_GameConfig['initial_fields'],
'OpenTime' => prettyDate('d m Y - H:i:s', SERVER_MAINOPEN_TSTAMP, 1),
'Protection_NewPlayerTime' => prettyNumber($_GameConfig['Protection_NewPlayerTime'] / 3600),
'Protection_PointsLimit' => prettyNumber($_GameConfig['no_noob_protect'] * 1000),
]
);

$componentHTML = parsetemplate($localTemplateLoader('body'), $_Lang);

display($componentHTML, $screenTitle, false);
}

?>
File renamed without changes.
58 changes: 3 additions & 55 deletions overview.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,65 +21,13 @@

$Now = time();

if($_User['first_login'] == 0)
{
// Show First Login Message
includeLang('firstlogin');
$TPL = gettemplate('firstlogin');
$_DontShowMenus = true;

$_Lang['LoginPage_Text'] = parsetemplate(
$_Lang['LoginPage_Text'],
[
'GameName' => $_GameConfig['game_name'],
'GameSpeed' => prettyNumber($_GameConfig['game_speed'] / 2500),
'ResSpeed' => prettyNumber($_GameConfig['resource_multiplier']),
'FleetSpeed' => prettyNumber($_GameConfig['fleet_speed'] / 2500),
'FleetDebris' => $_GameConfig['Fleet_Cdr'],
'DefFlDebris' => $_GameConfig['Defs_Cdr'],
'DefMiDebris' => $_GameConfig['Debris_Def_Rocket'],
'MotherSize' => $_GameConfig['initial_fields'],
'OpenTime' => prettyDate('d m Y - H:i:s', SERVER_MAINOPEN_TSTAMP, 1),
'Protection_NewPlayerTime' => prettyNumber($_GameConfig['Protection_NewPlayerTime'] / 3600),
'Protection_PointsLimit' => prettyNumber($_GameConfig['no_noob_protect'] * 1000),
]
);

Overview\Screens\FirstLogin\Utils\Effects\updateUserOnFirstLogin([
'userId' => $_User['id'],
'currentTimestamp' => $Now,
]);

if ($_User['referred'] > 0) {
$referringUserWithTasksData = Overview\Screens\FirstLogin\Utils\Helpers\getReferrerTasksData([
'referredById' => $_User['referred'],
]);

Overview\Screens\FirstLogin\Utils\Effects\triggerUserReferralTask([
'referringUserWithTasksData' => &$referringUserWithTasksData,
]);
Overview\Screens\FirstLogin\Utils\Effects\handleReferralMultiAccountDetection([
'user' => &$_User,
'referredById' => $_User['referred'],
'referringUserWithTasksData' => &$referringUserWithTasksData,
'currentTimestamp' => $Now,
]);
}

// Check, if this IP is Proxy
Overview\Screens\FirstLogin\Utils\Effects\handleProxyDetection([
if ($_User['first_login'] == 0) {
Overview\Screens\FirstLogin\render([
'user' => &$_User,
'currentTimestamp' => $Now,
]);

// Give Free ProAccount for 7 days
//doquery("INSERT INTO {{table}} VALUES (NULL, {$_User['id']}, UNIX_TIMESTAMP(), 0, 0, 11, 0);", 'premium_free');

Overview\Screens\FirstLogin\Utils\Effects\createUserDevLogDump([
'userId' => $_User['id'],
]);

display(parsetemplate($TPL, $_Lang), $_Lang['FirstLogin_Title'], false);
die();
}

$mode = (isset($_GET['mode']) ? $_GET['mode'] : '');
Expand Down

0 comments on commit 4660d8f

Please sign in to comment.