diff --git a/modules/attackSimulator/_includes.php b/modules/attackSimulator/_includes.php new file mode 100644 index 00000000..52dce636 --- /dev/null +++ b/modules/attackSimulator/_includes.php @@ -0,0 +1,13 @@ + diff --git a/modules/attackSimulator/components/ShipInput/ShipInput.component.php b/modules/attackSimulator/components/ShipInput/ShipInput.component.php new file mode 100644 index 00000000..ebaa4ddd --- /dev/null +++ b/modules/attackSimulator/components/ShipInput/ShipInput.component.php @@ -0,0 +1,47 @@ + ( + $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, + ]; +} + +?> diff --git a/modules/attackSimulator/components/ShipInput/body.tpl b/modules/attackSimulator/components/ShipInput/body.tpl new file mode 100644 index 00000000..10687005 --- /dev/null +++ b/modules/attackSimulator/components/ShipInput/body.tpl @@ -0,0 +1,11 @@ + + + ({lang_Button_Min} / {lang_Button_Max}) + diff --git a/modules/attackSimulator/components/ShipInput/index.php b/modules/attackSimulator/components/ShipInput/index.php new file mode 100644 index 00000000..bc99142d --- /dev/null +++ b/modules/attackSimulator/components/ShipInput/index.php @@ -0,0 +1,5 @@ + diff --git a/modules/attackSimulator/components/index.php b/modules/attackSimulator/components/index.php new file mode 100644 index 00000000..bc99142d --- /dev/null +++ b/modules/attackSimulator/components/index.php @@ -0,0 +1,5 @@ + diff --git a/modules/attackSimulator/index.php b/modules/attackSimulator/index.php new file mode 100644 index 00000000..bc99142d --- /dev/null +++ b/modules/attackSimulator/index.php @@ -0,0 +1,5 @@ + diff --git a/simulator.php b/simulator.php index 30975d74..a3847a51 100644 --- a/simulator.php +++ b/simulator.php @@ -4,10 +4,11 @@ $_EnginePath = './'; include($_EnginePath.'common.php'); +include_once($_EnginePath . 'modules/attackSimulator/_includes.php'); use UniEngine\Engine\Modules\Flights; - use UniEngine\Engine\Includes\Helpers\World; +use UniEngine\Engine\Modules\AttackSimulator; loggedCheck(); @@ -576,15 +577,31 @@ function ($value, $key) use ($TechEquivalents) { $ThisRow_InsertValue_Atk = isset($_POST['atk_ships'][$i][$Ships]) ? $_POST['atk_ships'][$i][$Ships] : null; $parse['RowText'] = $_Lang['tech'][$Ships]; - $parse['RowInput'] = " ({$_Lang['Button_Min']} / {$_Lang['Button_Max']})"; + $parse['RowInput'] = AttackSimulator\Components\ShipInput\render([ + 'slotIdx' => $i, + 'elementId' => $Ships, + 'columnType' => 'attacker', + 'initialValue' => $ThisRow_InsertValue_Atk, + ])['componentHTML']; + $parse['RowText2'] = $_Lang['tech'][$Ships]; - $parse['RowInput2'] = " ({$_Lang['Button_Min']} / {$_Lang['Button_Max']})"; + $parse['RowInput2'] = AttackSimulator\Components\ShipInput\render([ + 'slotIdx' => $i, + 'elementId' => $Ships, + 'columnType' => 'defender', + 'initialValue' => $ThisRow_InsertValue_Def, + ])['componentHTML']; $ThisSlot['txt'] .= parsetemplate($TPL_Row, $parse); } else { $parse['RowText'] = '-'; $parse['RowText2'] = $_Lang['tech'][$Ships]; - $parse['RowInput2'] = " ({$_Lang['Button_Min']} / {$_Lang['Button_Max']})"; + $parse['RowInput2'] = AttackSimulator\Components\ShipInput\render([ + 'slotIdx' => $i, + 'elementId' => $Ships, + 'columnType' => 'defender', + 'initialValue' => $ThisRow_InsertValue_Def, + ])['componentHTML']; $ThisSlot['txt'] .= parsetemplate($TPL_NoLeft, $parse); }