Fix Screen.php: replace Laravel class_basename with native PHP
This commit is contained in:
parent
cb4b955bca
commit
ac5f57c3ca
|
|
@ -103,7 +103,7 @@ class Game
|
|||
$this->player->skillSlots = $p['skillSlots'] ?? $this->player->skillSlots;
|
||||
|
||||
$this->dungeonId = $data['dungeonId'] ?? $this->dungeonId;
|
||||
$this->state = self::MENU;
|
||||
$this->state = $data['state'] ?? self::MENU;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,6 +103,9 @@ class GameSession
|
|||
*/
|
||||
private function runCurrentState(): void
|
||||
{
|
||||
if ($this->game->state == 0){
|
||||
$this->game->state = 1;
|
||||
}
|
||||
switch ($this->game->state) {
|
||||
case Game::MENU:
|
||||
(new \Game\Modules\Menu($this->game))->show();
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ class Screen
|
|||
usleep($microseconds);
|
||||
} elseif ($out) {
|
||||
// Web模式
|
||||
// 检查是否是SSEOutput(类名包含SSE)
|
||||
$className = class_basename($out);
|
||||
// 检查是否是SSEOutput
|
||||
$className = substr(strrchr(get_class($out), '\\'), 1);
|
||||
if ($className === 'SSEOutput') {
|
||||
// SSE 模式:实际延迟以控制流式输出的速度
|
||||
$milliseconds = max(1, (int)($microseconds / 1000));
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use Game\Core\ItemDisplay;
|
|||
use Game\Core\SpellDisplay;
|
||||
use Game\Core\SpellCalculator;
|
||||
use Game\Core\Colors;
|
||||
use Game\Core\WebInput;
|
||||
use Game\Entities\Player;
|
||||
use Game\Entities\Actor;
|
||||
use Game\Entities\Monster;
|
||||
|
|
|
|||
|
|
@ -192,7 +192,7 @@ function handleGameInput(): array
|
|||
$data = getInput();
|
||||
$input = $data['input'] ?? '';
|
||||
|
||||
$session = new GameSession($_SESSION['user_id']);
|
||||
$session = new GameSession($_SESSION['user_id'],$input);
|
||||
$output = $session->handleInput($input);
|
||||
|
||||
// 如果输出是数组(时间戳数据),直接返回
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user