68 lines
1.9 KiB
PHP
68 lines
1.9 KiB
PHP
<?php
|
|
require __DIR__ . '/../vendor/autoload.php';
|
|
|
|
use Game\Core\ServiceContainer;
|
|
use Game\Event\Event;
|
|
use Game\Model\Quest;
|
|
use Symfony\Component\Console\Input\ArrayInput;
|
|
use Symfony\Component\Console\Output\BufferedOutput;
|
|
use Symfony\Component\Console\Helper\HelperSet;
|
|
use Symfony\Component\Console\Helper\QuestionHelper;
|
|
|
|
$input = new ArrayInput([]);
|
|
$output = new BufferedOutput();
|
|
$helperSet = new HelperSet(['question' => new QuestionHelper()]);
|
|
|
|
$container = new ServiceContainer($input, $output, $helperSet);
|
|
$dispatcher = $container->registerServices();
|
|
$stateManager = $container->getStateManager();
|
|
|
|
// 创建测试玩家
|
|
$player = new \Game\Model\Player("QuestTest", 100, 10, 5);
|
|
$stateManager->setPlayer($player);
|
|
$stateManager->setCurrentTileId('TOWN_01');
|
|
|
|
echo "=== 任务列表功能测试 ===\n\n";
|
|
|
|
// 添加一些测试任务
|
|
$quest1 = new Quest(
|
|
'QUEST_001',
|
|
'清理野兽',
|
|
'击败5只野狼',
|
|
'kill',
|
|
['entityId' => 'wolf_001', 'count' => 5],
|
|
['gold' => 100, 'xp' => 50]
|
|
);
|
|
$quest1->incrementProgress(); // 已击败 1 只
|
|
|
|
$quest2 = new Quest(
|
|
'QUEST_002',
|
|
'收集草药',
|
|
'收集10个草药',
|
|
'collect',
|
|
['entityId' => 'herb_basic', 'count' => 10],
|
|
['gold' => 50, 'xp' => 30]
|
|
);
|
|
$quest2->incrementProgress();
|
|
$quest2->incrementProgress();
|
|
$quest2->incrementProgress(); // 已收集 3 个
|
|
|
|
$player->addActiveQuest($quest1);
|
|
$player->addActiveQuest($quest2);
|
|
|
|
// 添加已完成的任务
|
|
$player->markQuestCompleted('TUTORIAL_QUEST');
|
|
$player->markQuestCompleted('FIRST_BATTLE');
|
|
|
|
echo "1. 初始状态:\n";
|
|
echo " - 进行中任务: " . count($player->getActiveQuests()) . "\n";
|
|
echo " - 已完成任务: " . count($player->getCompletedQuests()) . "\n\n";
|
|
|
|
// 测试显示任务列表
|
|
echo "2. 显示任务列表...\n";
|
|
$dispatcher->dispatch(new Event('ShowQuestListRequest'));
|
|
|
|
echo "\n" . $output->fetch() . "\n";
|
|
|
|
echo "=== 测试完成 ===\n";
|