Add desktop games, robot pet and TCG app
This commit is contained in:
1 parent
812503251b
commit
c664f573b8
55 files changed
+5090
-15
No files matched your search
@@ -0,0 +1,37 @@
|
||||
import type { GameName } from '#lib/content';
|
||||
import { line, span } from '../output';
|
||||
import type { Command } from './types';
|
||||
|
||||
const gameDescriptions: Record<GameName, string> = {
|
||||
snake: 'Eat the food and avoid your own tail',
|
||||
breakout: 'Bounce the ball and clear every brick'
|
||||
};
|
||||
|
||||
const gameNames = Object.keys(gameDescriptions) as GameName[];
|
||||
|
||||
const launchCommands: Command[] = gameNames.map((game) => ({
|
||||
name: game,
|
||||
description: gameDescriptions[game],
|
||||
hidden: true,
|
||||
run: (_args, context) => context.openApp(game)
|
||||
}));
|
||||
|
||||
const gamesCommand: Command = {
|
||||
name: 'games',
|
||||
description: 'List or launch the games',
|
||||
usage: 'games [name]',
|
||||
argumentOptions: () => gameNames,
|
||||
run: (args, context) => {
|
||||
const requestedGame = gameNames.find((game) => game === args[0]?.toLowerCase());
|
||||
if (requestedGame) {
|
||||
context.openApp(requestedGame);
|
||||
return;
|
||||
}
|
||||
gameNames.forEach((game) =>
|
||||
context.print(line(span(game.padEnd(12), 'accent', { bold: true }), gameDescriptions[game]))
|
||||
);
|
||||
context.print(line(span('Run ', 'muted'), span('games <name>', 'accent'), span(' to play', 'muted')));
|
||||
}
|
||||
};
|
||||
|
||||
export const gameCommands: Command[] = [gamesCommand, ...launchCommands];
|
||||
Reference in new issue
Block a user