21 lines
562 B
PHP
21 lines
562 B
PHP
<?php
|
|
namespace App\Core;
|
|
|
|
class GameFactory {
|
|
private static $map = [
|
|
'pk10' => PK10Algorithm::class,
|
|
'dice' => DiceAlgorithm::class,
|
|
'xocdia' => XocDiaAlgorithm::class,
|
|
];
|
|
|
|
public static function getAlgorithm(string $gameType): string {
|
|
$class = self::$map[$gameType] ?? null;
|
|
if (!$class) throw new \RuntimeException("Unknown game type: {$gameType}");
|
|
return $class;
|
|
}
|
|
|
|
public static function register(string $gameType, string $class): void {
|
|
self::$map[$gameType] = $class;
|
|
}
|
|
}
|