Fix Screen.php: replace Laravel class_basename with native PHP

This commit is contained in:
hant 2025-12-07 11:11:25 +08:00
parent cb4b955bca
commit ac5f57c3ca
6 changed files with 9 additions and 5667 deletions

5664
save.json

File diff suppressed because one or more lines are too long

View File

@ -103,7 +103,7 @@ class Game
$this->player->skillSlots = $p['skillSlots'] ?? $this->player->skillSlots; $this->player->skillSlots = $p['skillSlots'] ?? $this->player->skillSlots;
$this->dungeonId = $data['dungeonId'] ?? $this->dungeonId; $this->dungeonId = $data['dungeonId'] ?? $this->dungeonId;
$this->state = self::MENU; $this->state = $data['state'] ?? self::MENU;
} }
} }
} }

View File

@ -103,6 +103,9 @@ class GameSession
*/ */
private function runCurrentState(): void private function runCurrentState(): void
{ {
if ($this->game->state == 0){
$this->game->state = 1;
}
switch ($this->game->state) { switch ($this->game->state) {
case Game::MENU: case Game::MENU:
(new \Game\Modules\Menu($this->game))->show(); (new \Game\Modules\Menu($this->game))->show();

View File

@ -49,8 +49,8 @@ class Screen
usleep($microseconds); usleep($microseconds);
} elseif ($out) { } elseif ($out) {
// Web模式 // Web模式
// 检查是否是SSEOutput类名包含SSE // 检查是否是SSEOutput
$className = class_basename($out); $className = substr(strrchr(get_class($out), '\\'), 1);
if ($className === 'SSEOutput') { if ($className === 'SSEOutput') {
// SSE 模式:实际延迟以控制流式输出的速度 // SSE 模式:实际延迟以控制流式输出的速度
$milliseconds = max(1, (int)($microseconds / 1000)); $milliseconds = max(1, (int)($microseconds / 1000));

View File

@ -8,6 +8,7 @@ use Game\Core\ItemDisplay;
use Game\Core\SpellDisplay; use Game\Core\SpellDisplay;
use Game\Core\SpellCalculator; use Game\Core\SpellCalculator;
use Game\Core\Colors; use Game\Core\Colors;
use Game\Core\WebInput;
use Game\Entities\Player; use Game\Entities\Player;
use Game\Entities\Actor; use Game\Entities\Actor;
use Game\Entities\Monster; use Game\Entities\Monster;

View File

@ -192,7 +192,7 @@ function handleGameInput(): array
$data = getInput(); $data = getInput();
$input = $data['input'] ?? ''; $input = $data['input'] ?? '';
$session = new GameSession($_SESSION['user_id']); $session = new GameSession($_SESSION['user_id'],$input);
$output = $session->handleInput($input); $output = $session->handleInput($input);
// 如果输出是数组(时间戳数据),直接返回 // 如果输出是数组(时间戳数据),直接返回