<?php use ShipBattle\Service\Container; require __DIR__ . '/bootstrap.php'; $container = new Container($configuration); $shipLoader = $container->getShipLoader(); $ships = $shipLoader->getShips(); $ship1Id = isset($_POST['ship1_id']) ? $_POST['ship1_id'] : NULL; $ship1Quantity = isset($_POST['ship1_quantity']) ? $_POST['ship1_quantity'] : 1; $ship2Id = isset($_POST['ship2_id']) ? $_POST['ship2_id'] : NULL; $ship2Quantity = isset($_POST['ship2_quantity']) ? $_POST['ship2_quantity'] : 1; if (!$ship1Id || !$ship2Id) { header('Location: /index.php?error=missing_data'); die; } $ship1 = $shipLoader->findOneById($ship1Id); $ship2 = $shipLoader->findOneById($ship2Id); if (!$ship1 || !$ship2) { header('Location: /index.php?error=bad_ships'); die; } if ($ship1Quantity <= 0 || $ship2Quantity <= 0) { header('Location: /index.php?error=bad_quantities'); die; } $battleManager = $container->getBattleManager(); $battleResult = $battleManager->battle($ship1, $ship1Quantity, $ship2, $ship2Quantity); ?> <html> <head>