Skip to content

Commit

Permalink
関数名の修正
Browse files Browse the repository at this point in the history
  • Loading branch information
takenaka committed Oct 21, 2021
1 parent 699e69c commit 5a95342
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { StoneCreator } from './model/stone';
const io = new IO(prompt);

const othello = new Othello(board, new StoneCreator, new PlayerCreator, io);
othello.init();
othello.start();
} catch (e) {
const _e = e as Error;
console.error(_e.message);
Expand Down
11 changes: 5 additions & 6 deletions src/model/othello.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class Othello {
this.turnPlayer = this.player1;
}

public init = async () => {
public start = async () => {
try {
const answer = await this.io.selectBoardSize();
this.board.init(answer);
Expand All @@ -60,8 +60,9 @@ export class Othello {
this.io.message(`先行は${this.turnPlayer.name}です`);

// 2連続パスか盤面が一杯になるまで
while (this.pass < 2 && !this.board.isFull) {
await this.turn();
while (this.pass < 2 && !this.board.isFull()) {
await this.playTurn();
this.changeTurn();
}

this.end();
Expand Down Expand Up @@ -89,7 +90,7 @@ export class Othello {
this.turnPlayer = this.turnPlayer === this.player1 ? this.player2 : this.player1;
};

private turn = async () => {
private playTurn = async () => {
this.io.showBoard(this.board);
this.io.message(`${this.turnPlayer.name}の番`);

Expand Down Expand Up @@ -117,7 +118,6 @@ export class Othello {
console.log(`\n${_e.message}\n`);
}
}
this.changeTurn();
return;
}
}
Expand All @@ -127,7 +127,6 @@ export class Othello {
this.pass++;

this.io.message(`${this.turnPlayer.name}は置けないのでパス`);
this.changeTurn();
};

// 全方向を見て裏返せる石を探す
Expand Down

0 comments on commit 5a95342

Please sign in to comment.