refactor: renaming api
This commit is contained in:
@@ -42,7 +42,7 @@ async function place(game: BoopGame, row: number, col: number, player: PlayerTyp
|
||||
|
||||
return { row, col, player, type, partId };
|
||||
}
|
||||
const placeCommand = registry.register( 'place <row:number> <col:number> <player> <type>', place);
|
||||
const placeCommand = registry.asCommand( 'place <row:number> <col:number> <player> <type>', place);
|
||||
|
||||
/**
|
||||
* 执行boop - 推动周围棋子
|
||||
@@ -85,7 +85,7 @@ async function boop(game: BoopGame, row: number, col: number, type: PieceType) {
|
||||
|
||||
return { booped };
|
||||
}
|
||||
const boopCommand = registry.register('boop <row:number> <col:number> <type>', boop);
|
||||
const boopCommand = registry.asCommand('boop <row:number> <col:number> <type>', boop);
|
||||
|
||||
/**
|
||||
* 检查是否有玩家获胜(三个猫连线)
|
||||
@@ -109,7 +109,7 @@ async function checkWin(game: BoopGame): Promise<WinnerType | null> {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
const checkWinCommand = registry.register('check-win', checkWin);
|
||||
const checkWinCommand = registry.asCommand('check-win', checkWin);
|
||||
|
||||
/**
|
||||
* 检查并执行小猫升级(三个小猫连线变成猫)
|
||||
@@ -145,7 +145,7 @@ async function checkGraduates(game: BoopGame){
|
||||
}
|
||||
});
|
||||
}
|
||||
const checkGraduatesCommand = registry.register('check-graduates', checkGraduates);
|
||||
const checkGraduatesCommand = registry.asCommand('check-graduates', checkGraduates);
|
||||
|
||||
async function setup(game: BoopGame) {
|
||||
while (true) {
|
||||
@@ -163,7 +163,7 @@ async function setup(game: BoopGame) {
|
||||
|
||||
return game.value;
|
||||
}
|
||||
registry.register('setup', setup);
|
||||
registry.asCommand('setup', setup);
|
||||
|
||||
async function checkFullBoard(game: BoopGame, turnPlayer: PlayerType){
|
||||
// 检查8-piece规则: 如果玩家所有8个棋子都在棋盘上且没有获胜,强制升级一个小猫
|
||||
@@ -238,4 +238,4 @@ async function turn(game: BoopGame, turnPlayer: PlayerType) {
|
||||
await checkFullBoard(game, turnPlayer);
|
||||
return { winner: null };
|
||||
}
|
||||
const turnCommand = registry.register('turn <player>', turn);
|
||||
const turnCommand = registry.asCommand('turn <player>', turn);
|
||||
Reference in New Issue
Block a user