hanli/src/Modules/DungeonSelectPanel.php
2025-12-01 18:13:15 +08:00

46 lines
1.3 KiB
PHP

<?php
namespace Game\Modules;
use Game\Core\Screen;
use Game\Core\Input;
use Game\Core\Game;
class DungeonSelectPanel
{
public function __construct(public Game $game) {}
public function show()
{
Screen::clear($this->game->output);
$out = $this->game->output;
$out->writeln("╔════════════════════════════════════╗");
$out->writeln("║ 选择副本 ║");
$out->writeln("╚════════════════════════════════════╝");
$out->writeln("");
$maps = require __DIR__ . '/../../src/Data/maps.php';
foreach ($maps as $id => $map) {
$out->writeln("[{$id}] {$map['name']} (Lv.{$map['min_level']})");
}
$out->writeln("");
$out->writeln("[0] 返回");
$dungeonId = Input::ask($out, "请选择副本: ");
if ($dungeonId == 0) {
$this->game->state = Game::MENU;
return;
}
if (isset($maps[$dungeonId])) {
$this->game->dungeonId = (int)$dungeonId;
$this->game->state = Game::BATTLE;
} else {
$out->writeln("无效副本");
Screen::sleep(1);
}
}
}