Files
game1.shadow-land.de/www/public/market.php
madgerm 12ddf5a185 feat(phase2): aircraft market, fleet management, finances, loans
- market.php: Buy new aircraft (6 types: Dash8 to A380)
- aircraft.php: Fleet management, crew assignment, route planning
- finances.php: Account balance, transactions, loans
- Database.php: Extended with loan/transaction/aircraft methods
- schema.sql: Aircraft types table, 10M starting balance, INSERT OR IGNORE
- dashboard.php: Updated with fleet/financial overview
- Fixed: duplicate function declarations in Database.php
- Fixed: initializeSchema() with idempotent error handling
2026-04-24 17:27:02 +02:00

199 lines
9.3 KiB
PHP

<?php
/**
* Airline Tycoon - Flugzeug-Markt
* Kauf von neuen Flugzeugen
*/
require_once __DIR__ . '/../src/bootstrap.php';
// Auth Check
if (!Session::isLoggedIn()) {
header('Location: login.php');
exit;
}
$userId = Session::getUserId();
$user = $db->getUserById($userId);
$config = $db->getConfig();
$csrfToken = Session::generateCsrfToken();
?>
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Markt - <?= htmlspecialchars($user['airline_name']) ?> - <?= $config['app']['name'] ?></title>
<link rel="stylesheet" href="<?= $basePath ?>assets/css/style.css">
<link href="https://fonts.googleapis.com/css2?family=Bangers&family=Patrick+Hand&family=Nunito:wght@400;600;700&display=swap" rel="stylesheet">
</head>
<body data-theme="<?= $theme ?? 'light' ?>">
<!-- Navbar -->
<nav class="navbar">
<div class="navbar-brand">
<a href="<?= $basePath ?>dashboard.php" class="navbar-logo">✈️ <?= $config['app']['name'] ?></a>
</div>
<button class="navbar-toggle" aria-label="Menü">☰</button>
<div class="navbar-menu">
<a href="<?= $basePath ?>dashboard.php" class="navbar-item">Dashboard</a>
<a href="<?= $basePath ?>airports.php" class="navbar-item">Flughäfen</a>
<a href="<?= $basePath ?>aircraft.php" class="navbar-item">Flotte</a>
<a href="<?= $basePath ?>finances.php" class="navbar-item">Finanzen</a>
<a href="<?= $basePath ?>market.php" class="navbar-item active">Markt</a>
<button class="theme-toggle" id="themeToggle" title="Theme wechseln">🌙</button>
</div>
</nav>
<!-- Main Content -->
<main class="container">
<!-- Header -->
<section class="hero hero-sm">
<div class="hero-content">
<h1 class="hero-title">🛒 Flugzeug-Markt</h1>
<p class="hero-subtitle">Kaufe neue Flugzeuge für deine Airline</p>
</div>
</section>
<!-- Kontostand Hinweis -->
<div class="balance-banner panel mt-lg">
<div class="balance-info">
<span class="balance-label">Dein Kontostand:</span>
<span class="balance-value" id="currentBalance"><?= number_format($user['balance'], 2, ',', '.') ?> €</span>
</div>
<div class="balance-actions">
<a href="<?= $basePath ?>finances.php" class="btn btn-sm btn-secondary">
💰 Kontoauszug
</a>
</div>
</div>
<!-- Flugzeugtypen -->
<section class="panel mt-xl">
<h2 class="panel-title">🛩️ Verfügbare Flugzeuge</h2>
<p class="text-secondary mb-lg">Wähle einen Flugzeugtyp und gib ihm einen Namen.</p>
<div class="aircraft-market-grid">
<?php foreach ($config['aircraft_types'] as $type => $specs): ?>
<?php
$canAfford = $user['balance'] >= $specs['purchase_price'];
$fuelEff = $specs['fuel_efficiency'] ?? 1.0;
?>
<div class="market-aircraft-card <?= $canAfford ? '' : 'disabled' ?>">
<div class="market-aircraft-header">
<h3 class="market-aircraft-name"><?= htmlspecialchars($type) ?></h3>
<span class="market-aircraft-price <?= $canAfford ? 'text-success' : 'text-danger' ?>">
<?= number_format($specs['purchase_price'], 0, ',', '.') ?> €
</span>
</div>
<div class="market-aircraft-specs">
<div class="spec-row">
<span class="spec-label">✈️ Sitzplätze:</span>
<span class="spec-value"><?= $specs['seat_capacity'] ?></span>
</div>
<div class="spec-row">
<span class="spec-label">🌍 Reichweite:</span>
<span class="spec-value"><?= number_format($specs['range_km'], 0, ',', '.') ?> km</span>
</div>
<div class="spec-row">
<span class="spec-label">⛽ Effizienz:</span>
<span class="spec-value">
<?php if ($fuelEff < 0.9): ?>
🟢 Sehr gut
<?php elseif ($fuelEff < 1.0): ?>
🟡 Gut
<?php else: ?>
🟠 Normal
<?php endif; ?>
</span>
</div>
<div class="spec-row">
<span class="spec-label">💨 Geschwindigkeit:</span>
<span class="spec-value"><?= $specs['speed_kmh'] ?? 800 ?> km/h</span>
</div>
<div class="spec-row">
<span class="spec-label">👨‍✈️ Crew-Kosten:</span>
<span class="spec-value"><?= $specs['crew_cost_per_tick'] ?? 500 ?> €/Tick</span>
</div>
<div class="spec-row">
<span class="spec-label">🔧 Wartung:</span>
<span class="spec-value"><?= number_format($specs['maintenance_base_cost'] ?? 50000, 0, ',', '.') ?> €</span>
</div>
</div>
<?php if ($canAfford): ?>
<form class="purchase-form mt-md" data-ajax>
<input type="hidden" name="action" value="purchase">
<input type="hidden" name="csrf_token" value="<?= $csrfToken ?>">
<input type="hidden" name="aircraft_type" value="<?= htmlspecialchars($type) ?>">
<div class="form-group">
<input type="text" name="name" class="form-input"
placeholder="Flugzeugname (z.B. 'Hans')"
maxlength="30" required>
</div>
<button type="submit" class="btn btn-primary btn-lg w-100">
✈️ Kaufen für <?= number_format($specs['purchase_price'], 0, ',', '.') ?> €
</button>
</form>
<?php else: ?>
<div class="cannot-afford mt-md">
<span class="badge badge-danger">Nicht genug Guthaben</span>
<p class="text-secondary mt-sm">
Du brauchst noch <?= number_format($specs['purchase_price'] - $user['balance'], 0, ',', '.') ?> €
</p>
</div>
<?php endif; ?>
</div>
<?php endforeach; ?>
</div>
</section>
<!-- Informationen -->
<section class="panel mt-xl">
<h2 class="panel-title">📖 Informationen</h2>
<div class="info-grid mt-md">
<div class="info-card">
<h3>💡 Tipps zum Flugzeugkauf</h3>
<ul class="info-list">
<li>Propeller-Flugzeuge sind günstig und gut für kurze Strecken</li>
<li>Schmale Rumpf-Flugzeuge (Narrowbody) sind vielseitig einsetzbar</li>
<li>Widebody-Flugzeuge sind für Langstrecken gedacht</li>
<li>Der A380 ist das größte Passagierflugzeug der Welt</li>
</ul>
</div>
<div class="info-card">
<h3>🔧 Wartung</h3>
<ul class="info-list">
<li>Alle 50 Flüge muss ein Flugzeug zur Wartung</li>
<li>Die Wartung stellt den Zustand auf 100% zurück</li>
<li>Vernachlässigte Wartung erhöht die Kosten</li>
<li>Ein Flugzeug mit weniger als 20% Zustand kann nicht mehr fliegen</li>
</ul>
</div>
<div class="info-card">
<h3>⛽ Treibstoffkosten</h3>
<ul class="info-list">
<li>Treibstoff kostet <?= $config['game']['fuel_cost_per_km'] ?> € pro km</li>
<li>Effizientere Flugzeuge verbrauchen weniger</li>
<li>Die Treibstoffkosten werden pro Flug vom Gewinn abgezogen</li>
</ul>
</div>
</div>
</section>
</main>
<!-- Toast Container -->
<div id="toastContainer" class="toast-container"></div>
<script src="<?= $basePath ?>assets/js/main.js"></script>
<script>
// Erfolg beim Kauf
window.purchaseSuccess = function(data) {
document.getElementById('currentBalance').textContent =
new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(data.new_balance);
};
</script>
</body>
</html>