Skip to content

Commit

Permalink
sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
tailuge committed Oct 24, 2023
1 parent f6bef7f commit 78e5388
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
27 changes: 13 additions & 14 deletions src/controller/rules/snooker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,24 @@ export class Snooker extends NineBall implements Rules {
this.respot(outcome)
} else if (Outcome.onlyRedsPotted(outcome)) {
this.previousPotRed = true
} else {
} else if (pots === 1) {
// out of order colour pot gets respotted
if (pots === 1) {
const id = Outcome.pots(outcome)[0].id
const lesserBallOnTable =
id > 1 &&
this.container.table.balls
.filter((b) => b.id < id)
.filter((b) => b.id > 0)
.some((b) => b.onTable())
if (lesserBallOnTable) {
this.respot(outcome)
}
} else {
// multiple colour pots get respotted
const id = Outcome.pots(outcome)[0].id
const lesserBallOnTable =
id > 1 &&
this.container.table.balls
.filter((b) => b.id < id)
.filter((b) => b.id > 0)
.some((b) => b.onTable())
if (lesserBallOnTable) {
this.respot(outcome)
}
} else {
// multiple colour pots get respotted
this.respot(outcome)
}
}

return super.update(outcome)
}

Expand Down
1 change: 0 additions & 1 deletion test/rules/snooker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { PlayShot } from "../../src/controller/playshot"
import { Aim } from "../../src/controller/aim"
import { PlaceBall } from "../../src/controller/placeball"
import { Snooker } from "../../src/controller/rules/snooker"
import { table } from "console"

initDom()

Expand Down

0 comments on commit 78e5388

Please sign in to comment.