-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GH-230 Move combat stats to own component
- Loading branch information
Showing
7 changed files
with
149 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
modules/overview/screens/Overview/components/CombatStatsList/CombatStatsList.component.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\Overview\Screens\Overview\Components\CombatStatsList; | ||
|
||
/** | ||
* @param array $props | ||
* @param array $props['stats'] | ||
*/ | ||
function render($props) { | ||
global $_Lang; | ||
|
||
$stats = $props['stats']; | ||
|
||
$localTemplateLoader = createLocalTemplateLoader(__DIR__); | ||
$tplBodyCache = [ | ||
'body' => $localTemplateLoader('body'), | ||
'statCategoryRow' => $localTemplateLoader('statCategoryRow'), | ||
]; | ||
|
||
$categories = [ | ||
'allBattles' => [ | ||
'label' => $_Lang['Box_battlesAll'], | ||
'statsTableKeys' => [ | ||
'ustat_raids_won', | ||
'ustat_raids_draw', | ||
'ustat_raids_lost', | ||
'ustat_raids_inAlly', | ||
], | ||
], | ||
'battlesWon' => [ | ||
'label' => $_Lang['Box_battlesWon'], | ||
'statsTableKeys' => [ | ||
'ustat_raids_won', | ||
], | ||
], | ||
'battlesWonUnited' => [ | ||
'label' => $_Lang['Box_battlesACSWon'], | ||
'statsTableKeys' => [ | ||
'ustat_raids_acs_won', | ||
], | ||
'colorClass' => 'orange', | ||
], | ||
'battlesDrawn' => [ | ||
'label' => $_Lang['Box_battlesDraw'], | ||
'statsTableKeys' => [ | ||
'ustat_raids_draw', | ||
], | ||
], | ||
'battlesLost' => [ | ||
'label' => $_Lang['Box_battlesLost'], | ||
'statsTableKeys' => [ | ||
'ustat_raids_lost', | ||
], | ||
], | ||
'battlesInAlly' => [ | ||
'label' => $_Lang['Box_battlesInAlly'], | ||
'statsTableKeys' => [ | ||
'ustat_raids_inAlly', | ||
], | ||
], | ||
'missileStrikes' => [ | ||
'label' => $_Lang['Box_missileAttacks'], | ||
'statsTableKeys' => [ | ||
'ustat_raids_missileAttack', | ||
], | ||
], | ||
]; | ||
|
||
$categoriesHTML = []; | ||
|
||
foreach ($categories as $categoryKey => $category) { | ||
$categorySubValues = array_map_withkeys($category['statsTableKeys'], function ($key) use ($stats) { | ||
return $stats[$key]; | ||
}); | ||
$categoryTotalValue = array_sum($categorySubValues); | ||
|
||
$categoryTplBodyParams = [ | ||
'statCategoryColorClass' => ( | ||
!empty($category['colorClass']) ? | ||
$category['colorClass'] : | ||
'' | ||
), | ||
'statCategoryLabel' => $category['label'], | ||
'statCategoryValue' => prettyNumber($categoryTotalValue), | ||
]; | ||
|
||
$categoriesHTML[$categoryKey] = parsetemplate( | ||
$tplBodyCache['statCategoryRow'], | ||
$categoryTplBodyParams | ||
); | ||
} | ||
|
||
$tplBodyParams = [ | ||
'categoryRow_allBattles' => $categoriesHTML['allBattles'], | ||
'categoryRow_battlesWon' => $categoriesHTML['battlesWon'], | ||
'categoryRow_battlesWonUnited' => $categoriesHTML['battlesWonUnited'], | ||
'categoryRow_battlesDrawn' => $categoriesHTML['battlesDrawn'], | ||
'categoryRow_battlesLost' => $categoriesHTML['battlesLost'], | ||
'categoryRow_battlesInAlly' => $categoriesHTML['battlesInAlly'], | ||
'categoryRow_missileStrikes' => $categoriesHTML['missileStrikes'], | ||
]; | ||
$tplBodyParams = array_merge($_Lang, $tplBodyParams); | ||
|
||
$componentHTML = parsetemplate( | ||
$tplBodyCache['body'], | ||
$tplBodyParams | ||
); | ||
|
||
return [ | ||
'componentHTML' => $componentHTML, | ||
]; | ||
} | ||
|
||
?> |
18 changes: 18 additions & 0 deletions
18
modules/overview/screens/Overview/components/CombatStatsList/body.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<table width="100%" align="center"> | ||
<tr> | ||
<td colspan="2" class="c pad3">{YourBattles}</td> | ||
</tr> | ||
{categoryRow_allBattles} | ||
<tr> | ||
<th class="invNF"> </th> | ||
</tr> | ||
{categoryRow_battlesWon} | ||
{categoryRow_battlesWonUnited} | ||
{categoryRow_battlesDrawn} | ||
{categoryRow_battlesLost} | ||
{categoryRow_battlesInAlly} | ||
<tr> | ||
<th class="invNF"> </th> | ||
</tr> | ||
{categoryRow_missileStrikes} | ||
</table> |
5 changes: 5 additions & 0 deletions
5
modules/overview/screens/Overview/components/CombatStatsList/index.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?php | ||
|
||
header("Location: ../index.php"); | ||
|
||
?> |
4 changes: 4 additions & 0 deletions
4
modules/overview/screens/Overview/components/CombatStatsList/statCategoryRow.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<tr> | ||
<th class="{statCategoryColorClass}">{statCategoryLabel}</th> | ||
<th>{statCategoryValue}</th> | ||
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters