-
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.
Browse files
Browse the repository at this point in the history
GH-91 | Battle Simulator - Overall code refactor
- Loading branch information
Showing
37 changed files
with
1,018 additions
and
490 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
// TODO: Migrate to IIFE once PHP 5 support is removed | ||
call_user_func(function () { | ||
global $_EnginePath; | ||
|
||
$includePath = $_EnginePath . 'modules/attackSimulator/'; | ||
|
||
include($includePath . './components/MoraleInput/MoraleInput.component.php'); | ||
include($includePath . './components/MoraleInputsSection/MoraleInputsSection.component.php'); | ||
include($includePath . './components/ShipInput/ShipInput.component.php'); | ||
include($includePath . './components/TechInput/TechInput.component.php'); | ||
include($includePath . './components/TechInputsSection/TechInputsSection.component.php'); | ||
include($includePath . './components/UnitInputsSection/UnitInputsSection.component.php'); | ||
|
||
include($includePath . './utils/combatTechs.utils.php'); | ||
|
||
}); | ||
|
||
?> |
41 changes: 41 additions & 0 deletions
41
modules/attackSimulator/components/MoraleInput/MoraleInput.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,41 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\AttackSimulator\Components\MoraleInput; | ||
|
||
/** | ||
* @param array $props | ||
* @param number $props['slotIdx'] | ||
* @param enum ("attacker" | "defender") $props['columnType'] | ||
* @param number $props['initialValue'] | ||
*/ | ||
function render($props) { | ||
$slotIdx = $props['slotIdx']; | ||
|
||
$inputNamePrefix = ( | ||
$props['columnType'] === 'attacker' ? | ||
'atk_morale' : | ||
'def_morale' | ||
); | ||
|
||
$templateBodyProps = [ | ||
'prop_tabIndex' => ( | ||
$props['columnType'] === 'attacker' ? | ||
'1' : | ||
'2' | ||
), | ||
'prop_inputName' => "{$inputNamePrefix}[{$slotIdx}]", | ||
'prop_initialValue' => $props['initialValue'], | ||
]; | ||
|
||
$localTemplateLoader = createLocalTemplateLoader(__DIR__); | ||
$componentHTML = parsetemplate( | ||
$localTemplateLoader('body'), | ||
$templateBodyProps | ||
); | ||
|
||
return [ | ||
'componentHTML' => $componentHTML, | ||
]; | ||
} | ||
|
||
?> |
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,7 @@ | ||
<input | ||
type="text" | ||
tabindex="{prop_tabIndex}" | ||
name="{prop_inputName}" | ||
value="{prop_initialValue}" | ||
autocomplete="off" | ||
/>% |
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"); | ||
|
||
?> |
45 changes: 45 additions & 0 deletions
45
modules/attackSimulator/components/MoraleInputsSection/MoraleInputsSection.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,45 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\AttackSimulator\Components\MoraleInputsSection; | ||
|
||
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']; | ||
|
||
$templateBodyProps = [ | ||
'lang_Morale' => $_Lang['Morale'], | ||
'lang_Morale_Level' => $_Lang['Morale_Level'], | ||
|
||
'prop_AttackerInput' => AttackSimulator\Components\MoraleInput\render([ | ||
'slotIdx' => $slotIdx, | ||
'columnType' => 'attacker', | ||
'initialValue' => $input['atk_morale'][$slotIdx], | ||
])['componentHTML'], | ||
'prop_DefenderInput' => AttackSimulator\Components\MoraleInput\render([ | ||
'slotIdx' => $slotIdx, | ||
'columnType' => 'defender', | ||
'initialValue' => $input['def_morale'][$slotIdx], | ||
])['componentHTML'], | ||
]; | ||
|
||
$localTemplateLoader = createLocalTemplateLoader(__DIR__); | ||
$componentHTML = parsetemplate( | ||
$localTemplateLoader('body'), | ||
$templateBodyProps | ||
); | ||
|
||
return [ | ||
'componentHTML' => $componentHTML, | ||
]; | ||
} | ||
|
||
?> |
19 changes: 19 additions & 0 deletions
19
modules/attackSimulator/components/MoraleInputsSection/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,19 @@ | ||
<tr> | ||
<th colspan="4" class="c"> | ||
{lang_Morale} | ||
</th> | ||
</tr> | ||
<tr> | ||
<th class="c pad5 ta_r r_l"> | ||
{lang_Morale_Level}: | ||
</th> | ||
<th class="c pad5 ta_l r_i"> | ||
{prop_AttackerInput} | ||
</th> | ||
<th class="c pad5 ta_r r_l"> | ||
{lang_Morale_Level}: | ||
</th> | ||
<th class="c pad5 ta_l r_i"> | ||
{prop_DefenderInput} | ||
</th> | ||
</tr> |
5 changes: 5 additions & 0 deletions
5
modules/attackSimulator/components/MoraleInputsSection/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"); | ||
|
||
?> |
47 changes: 47 additions & 0 deletions
47
modules/attackSimulator/components/ShipInput/ShipInput.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,47 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\AttackSimulator\Components\ShipInput; | ||
|
||
/** | ||
* @param array $props | ||
* @param number $props['slotIdx'] | ||
* @param number $props['elementId'] | ||
* @param enum ("attacker" | "defender") $props['columnType'] | ||
* @param number $props['initialValue'] | ||
*/ | ||
function render($props) { | ||
global $_Lang; | ||
|
||
$slotIdx = $props['slotIdx']; | ||
$elementId = $props['elementId']; | ||
|
||
$inputNamePrefix = ( | ||
$props['columnType'] === 'attacker' ? | ||
'atk_ships' : | ||
'def_ships' | ||
); | ||
|
||
$templateBodyProps = [ | ||
'prop_tabIndex' => ( | ||
$props['columnType'] === 'attacker' ? | ||
'1' : | ||
'2' | ||
), | ||
'prop_inputName' => "{$inputNamePrefix}[{$slotIdx}][{$elementId}]", | ||
'prop_initialValue' => $props['initialValue'], | ||
'lang_Button_Min' => $_Lang['Button_Min'], | ||
'lang_Button_Max' => $_Lang['Button_Max'], | ||
]; | ||
|
||
$localTemplateLoader = createLocalTemplateLoader(__DIR__); | ||
$componentHTML = parsetemplate( | ||
$localTemplateLoader('body'), | ||
$templateBodyProps | ||
); | ||
|
||
return [ | ||
'componentHTML' => $componentHTML, | ||
]; | ||
} | ||
|
||
?> |
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,11 @@ | ||
<input | ||
type="text" | ||
tabindex="{prop_tabIndex}" | ||
name="{prop_inputName}" | ||
value="{prop_initialValue}" | ||
autocomplete="off" | ||
class="pad2 fl" | ||
/> | ||
<span class="fr"> | ||
(<span class="clnOne point">{lang_Button_Min}</span> / <span class="maxOne point">{lang_Button_Max}</span>) | ||
</span> |
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"); | ||
|
||
?> |
43 changes: 43 additions & 0 deletions
43
modules/attackSimulator/components/TechInput/TechInput.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,43 @@ | ||
<?php | ||
|
||
namespace UniEngine\Engine\Modules\AttackSimulator\Components\TechInput; | ||
|
||
/** | ||
* @param array $props | ||
* @param number $props['slotIdx'] | ||
* @param number $props['elementId'] | ||
* @param enum ("attacker" | "defender") $props['columnType'] | ||
* @param number $props['initialValue'] | ||
*/ | ||
function render($props) { | ||
$slotIdx = $props['slotIdx']; | ||
$elementId = $props['elementId']; | ||
|
||
$inputNamePrefix = ( | ||
$props['columnType'] === 'attacker' ? | ||
'atk_techs' : | ||
'def_techs' | ||
); | ||
|
||
$templateBodyProps = [ | ||
'prop_tabIndex' => ( | ||
$props['columnType'] === 'attacker' ? | ||
'1' : | ||
'2' | ||
), | ||
'prop_inputName' => "{$inputNamePrefix}[{$slotIdx}][{$elementId}]", | ||
'prop_initialValue' => $props['initialValue'], | ||
]; | ||
|
||
$localTemplateLoader = createLocalTemplateLoader(__DIR__); | ||
$componentHTML = parsetemplate( | ||
$localTemplateLoader('body'), | ||
$templateBodyProps | ||
); | ||
|
||
return [ | ||
'componentHTML' => $componentHTML, | ||
]; | ||
} | ||
|
||
?> |
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,7 @@ | ||
<input | ||
type="text" | ||
tabindex="{prop_tabIndex}" | ||
name="{prop_inputName}" | ||
value="{prop_initialValue}" | ||
autocomplete="off" | ||
/> |
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"); | ||
|
||
?> |
Oops, something went wrong.