-
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-91 Move tech inputs section to a component
- Loading branch information
Showing
6 changed files
with
131 additions
and
28 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
81 changes: 81 additions & 0 deletions
81
modules/attackSimulator/components/TechInputsSection/TechInputsSection.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,81 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\AttackSimulator\Components\TechInputsSection; | ||
|
||
use UniEngine\Engine\Modules\AttackSimulator; | ||
|
||
/** | ||
* @param array $props | ||
* @param number $props['slotIdx'] | ||
* @param arrayRef $props['input'] | ||
*/ | ||
function render($props) { | ||
global $_Lang; | ||
|
||
$slotIdx = $props['slotIdx']; | ||
$input = &$props['input']; | ||
|
||
$combatTechs = AttackSimulator\Utils\CombatTechs\getTechsList(); | ||
|
||
$localTemplateLoader = createLocalTemplateLoader(__DIR__); | ||
$tplBodyCache = [ | ||
'body' => $localTemplateLoader('body'), | ||
'techRow' => $localTemplateLoader('techRow'), | ||
]; | ||
|
||
$techRows = array_map_withkeys( | ||
$combatTechs, | ||
function ($elementId) use ($slotIdx, &$input, &$_Lang, &$tplBodyCache) { | ||
$formInputValueAttacker = ( | ||
isset($input['atk_techs'][$slotIdx][$elementId]) ? | ||
$input['atk_techs'][$slotIdx][$elementId] : | ||
null | ||
); | ||
$formInputValueDefender = ( | ||
isset($input['def_techs'][$slotIdx][$elementId]) ? | ||
$input['def_techs'][$slotIdx][$elementId] : | ||
null | ||
); | ||
|
||
$rowTemplateBodyProps = [ | ||
'prop_techName' => $_Lang['tech'][$elementId], | ||
'prop_AttackerInput' => AttackSimulator\Components\TechInput\render([ | ||
'slotIdx' => $slotIdx, | ||
'elementId' => $elementId, | ||
'columnType' => 'attacker', | ||
'initialValue' => $formInputValueAttacker, | ||
])['componentHTML'], | ||
'prop_DefenderInput' => AttackSimulator\Components\TechInput\render([ | ||
'slotIdx' => $slotIdx, | ||
'elementId' => $elementId, | ||
'columnType' => 'defender', | ||
'initialValue' => $formInputValueDefender, | ||
])['componentHTML'], | ||
]; | ||
|
||
return parsetemplate( | ||
$tplBodyCache['techRow'], | ||
$rowTemplateBodyProps | ||
); | ||
} | ||
); | ||
|
||
$templateBodyProps = [ | ||
'lang_Technology' => $_Lang['Technology'], | ||
'lang_FillMyTechs' => $_Lang['FillMyTechs'], | ||
'lang_Fill_Clean' => $_Lang['Fill_Clean'], | ||
|
||
'prop_techRowsHTML' => implode('', $techRows), | ||
]; | ||
|
||
$componentHTML = parsetemplate( | ||
$tplBodyCache['body'], | ||
$templateBodyProps | ||
); | ||
|
||
return [ | ||
'componentHTML' => $componentHTML, | ||
]; | ||
} | ||
|
||
?> |
26 changes: 26 additions & 0 deletions
26
modules/attackSimulator/components/TechInputsSection/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,26 @@ | ||
<tr> | ||
<th colspan="4" class="c"> | ||
{lang_Technology} | ||
</th> | ||
</tr> | ||
<tr> | ||
<th class="c pad5 r_b" colspan="2"> | ||
<a class="orange point fillTech_atk"> | ||
{lang_FillMyTechs} | ||
</a> | ||
/ | ||
<a class="orange point clnTech_atk"> | ||
{lang_Fill_Clean} | ||
</a> | ||
</th> | ||
<th class="c pad5 r_b" colspan="2"> | ||
<a class="orange point fillTech_def"> | ||
{lang_FillMyTechs} | ||
</a> | ||
/ | ||
<a class="orange point clnTech_def"> | ||
{lang_Fill_Clean} | ||
</a> | ||
</th> | ||
</tr> | ||
{prop_techRowsHTML} |
5 changes: 5 additions & 0 deletions
5
modules/attackSimulator/components/TechInputsSection/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"); | ||
|
||
?> |
14 changes: 14 additions & 0 deletions
14
modules/attackSimulator/components/TechInputsSection/techRow.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,14 @@ | ||
<tr> | ||
<th class="c pad5 ta_r r_l"> | ||
{prop_techName}: | ||
</th> | ||
<th class="c pad5 ta_l r_i"> | ||
{prop_AttackerInput} | ||
</th> | ||
<th class="c pad5 ta_r r_l"> | ||
{prop_techName}: | ||
</th> | ||
<th class="c pad5 ta_l r_i"> | ||
{prop_DefenderInput} | ||
</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