idle/bin/game
2025-12-10 18:07:57 +08:00

38 lines
870 B
PHP
Executable File

#!/usr/bin/env php
<?php
/**
* 凡人修仙传 - 文字版
* CLI 游戏入口
*/
// 自动加载
if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
require __DIR__ . '/../vendor/autoload.php';
} elseif (file_exists('phar://hanli-idle.phar/vendor/autoload.php')) {
require 'phar://hanli-idle.phar/vendor/autoload.php';
}
use Game\Core\Input;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Output\ConsoleOutput;
use Game\Core\Game;
// 设置终端为 UTF-8
if (function_exists('mb_internal_encoding')) {
mb_internal_encoding('UTF-8');
}
// 检查是否在终端中运行
if (php_sapi_name() !== 'cli') {
echo "此游戏需要在命令行终端中运行\n";
exit(1);
}
// 创建输入输出
$input = new Input();
$output = new ConsoleOutput();
// 启动游戏
$game = new Game($input, $output);
$game->run();