refactor
This commit is contained in:
@@ -21,75 +21,11 @@ export interface GameConstraintsProps {
|
||||
constraints: GameConstraintsData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Game-specific constraints for popular sim racing games
|
||||
*/
|
||||
const GAME_CONSTRAINTS: Record<string, GameConstraintsData> & { default: GameConstraintsData } = {
|
||||
iracing: {
|
||||
maxDrivers: 64,
|
||||
maxTeams: 32,
|
||||
defaultMaxDrivers: 24,
|
||||
minDrivers: 2,
|
||||
supportsTeams: true,
|
||||
supportsMultiClass: true,
|
||||
},
|
||||
acc: {
|
||||
maxDrivers: 30,
|
||||
maxTeams: 15,
|
||||
defaultMaxDrivers: 24,
|
||||
minDrivers: 2,
|
||||
supportsTeams: true,
|
||||
supportsMultiClass: false,
|
||||
},
|
||||
rf2: {
|
||||
maxDrivers: 64,
|
||||
maxTeams: 32,
|
||||
defaultMaxDrivers: 24,
|
||||
minDrivers: 2,
|
||||
supportsTeams: true,
|
||||
supportsMultiClass: true,
|
||||
},
|
||||
ams2: {
|
||||
maxDrivers: 32,
|
||||
maxTeams: 16,
|
||||
defaultMaxDrivers: 20,
|
||||
minDrivers: 2,
|
||||
supportsTeams: true,
|
||||
supportsMultiClass: true,
|
||||
},
|
||||
lmu: {
|
||||
maxDrivers: 32,
|
||||
maxTeams: 16,
|
||||
defaultMaxDrivers: 24,
|
||||
minDrivers: 2,
|
||||
supportsTeams: true,
|
||||
supportsMultiClass: true,
|
||||
},
|
||||
// Default for unknown games
|
||||
default: {
|
||||
maxDrivers: 32,
|
||||
maxTeams: 16,
|
||||
defaultMaxDrivers: 20,
|
||||
minDrivers: 2,
|
||||
supportsTeams: true,
|
||||
supportsMultiClass: false,
|
||||
},
|
||||
};
|
||||
|
||||
function getConstraintsForId(gameId: string): GameConstraintsData {
|
||||
const lower = gameId.toLowerCase();
|
||||
const fromMap = GAME_CONSTRAINTS[lower];
|
||||
if (fromMap) {
|
||||
return fromMap;
|
||||
}
|
||||
return GAME_CONSTRAINTS.default;
|
||||
}
|
||||
|
||||
export class GameConstraints implements IValueObject<GameConstraintsProps> {
|
||||
readonly gameId: string;
|
||||
readonly constraints: GameConstraintsData;
|
||||
|
||||
private constructor(gameId: string, constraints: GameConstraintsData) {
|
||||
constructor(gameId: string, constraints: GameConstraintsData) {
|
||||
this.gameId = gameId;
|
||||
this.constraints = constraints;
|
||||
}
|
||||
@@ -105,22 +41,6 @@ export class GameConstraints implements IValueObject<GameConstraintsProps> {
|
||||
return this.props.gameId === other.props.gameId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get constraints for a specific game
|
||||
*/
|
||||
static forGame(gameId: string): GameConstraints {
|
||||
const constraints = getConstraintsForId(gameId);
|
||||
const lowerId = gameId.toLowerCase();
|
||||
return new GameConstraints(lowerId, constraints);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all supported game IDs
|
||||
*/
|
||||
static getSupportedGames(): string[] {
|
||||
return Object.keys(GAME_CONSTRAINTS).filter(id => id !== 'default');
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum drivers allowed for this game
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user