From 2ea41d15fe7b7c2f2f3546e418028846860f269c Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Mon, 21 Oct 2024 21:13:46 +0200 Subject: [PATCH] Remove territoryRoll, beaconRoll, removeChipRoll - may be required multiple times per turn --- src/components/turn/DebugInfo.vue | 3 +-- src/store/state.ts | 3 --- src/util/NavigationState.ts | 17 +---------------- src/views/TurnBot.vue | 11 +++++------ tests/unit/helper/mockTurn.ts | 9 +-------- tests/unit/services/BotActions.spec.ts | 3 +-- tests/unit/util/NavigationState.spec.ts | 15 +-------------- 7 files changed, 10 insertions(+), 51 deletions(-) diff --git a/src/components/turn/DebugInfo.vue b/src/components/turn/DebugInfo.vue index fe3da34..5ce07f3 100644 --- a/src/components/turn/DebugInfo.vue +++ b/src/components/turn/DebugInfo.vue @@ -4,8 +4,7 @@

cardDeck: {{cardDeck.toPersistence()}}
currentCard: {{cardDeck.currentCard}}
- rolls: action={{navigationState.actionRoll}}, territory={{navigationState.territoryRoll}}, beacon={{navigationState.beaconRoll}}, removeChip={{navigationState.removeChipRoll}}, - difficultyLevel: {{navigationState.difficultyLevel}}
+ actionRoll: {{navigationState.actionRoll}}, difficultyLevel: {{navigationState.difficultyLevel}}

diff --git a/src/store/state.ts b/src/store/state.ts index 0eb9f4d..cb2c92a 100644 --- a/src/store/state.ts +++ b/src/store/state.ts @@ -72,9 +72,6 @@ export interface BotPersistence { blueDotCount: number redDotCount: number actionRoll: number - territoryRoll: number - beaconRoll: number - removeChipRoll: number reset?: boolean } export interface CardDeckPersistence { diff --git a/src/util/NavigationState.ts b/src/util/NavigationState.ts index b862d1f..671f19c 100644 --- a/src/util/NavigationState.ts +++ b/src/util/NavigationState.ts @@ -25,9 +25,6 @@ export default class NavigationState { readonly prosperityCount : number readonly currentCard : Card readonly actionRoll : number - readonly territoryRoll : number - readonly beaconRoll : number - readonly removeChipRoll : number readonly blueDotCount : number readonly redDotCount : number readonly currentTurnBotPersistence : boolean @@ -57,9 +54,6 @@ export default class NavigationState { this.blueDotCount = botPersistence.blueDotCount this.redDotCount = botPersistence.redDotCount this.actionRoll = botPersistence.actionRoll - this.territoryRoll = botPersistence.territoryRoll - this.beaconRoll = botPersistence.beaconRoll - this.removeChipRoll = botPersistence.removeChipRoll this.currentTurnBotPersistence = true } // otherwise prepare new turn based on previous card deck @@ -87,15 +81,9 @@ export default class NavigationState { // roll dice for action selection if (this.player == Player.BOT) { this.actionRoll = rollDice(6) - this.territoryRoll = rollDice(6) - this.beaconRoll = rollDice(6) - this.removeChipRoll = rollDice(6) } else { this.actionRoll = 0 - this.territoryRoll = 0 - this.beaconRoll = 0 - this.removeChipRoll = 0 } this.currentTurnBotPersistence = false } @@ -170,9 +158,6 @@ function getPreviousBotPersistence(state: State, round: number, turn: number) : prosperityCount: 2, blueDotCount: 0, redDotCount: 0, - actionRoll: 0, - territoryRoll: 0, - beaconRoll: 0, - removeChipRoll: 0 + actionRoll: 0 } } diff --git a/src/views/TurnBot.vue b/src/views/TurnBot.vue index 4fa5247..4f508ee 100644 --- a/src/views/TurnBot.vue +++ b/src/views/TurnBot.vue @@ -50,6 +50,7 @@ import DebugInfo from '@/components/turn/DebugInfo.vue' import BotActions from '@/services/BotActions' import AppIcon from '@/components/structure/AppIcon.vue' import BotActionsDisplay from '@/components/turn/BotActionsDisplay.vue' +import rollDice from '@brdgm/brdgm-commons/src/util/random/rollDice' export default defineComponent({ name: 'TurnBot', @@ -83,12 +84,13 @@ export default defineComponent({ return this.botActions.isReset }, removeChipNumber() : number { - return Math.ceil(this.navigationState.removeChipRoll / 2) + const removeChipRoll = rollDice(6) + return Math.ceil(removeChipRoll / 2) } }, methods: { saveTurn() : void { - const { player, cardDeck, blueDotCount, redDotCount, actionRoll, territoryRoll, beaconRoll, removeChipRoll } = this.navigationState + const { player, cardDeck, blueDotCount, redDotCount, actionRoll } = this.navigationState const { evolutionCount, prosperityCount } = this.botActions const turn : Turn = { round: this.round, @@ -100,10 +102,7 @@ export default defineComponent({ prosperityCount, blueDotCount, redDotCount, - actionRoll, - territoryRoll, - beaconRoll, - removeChipRoll + actionRoll } } if (this.isReset && turn.botPersistence) { diff --git a/tests/unit/helper/mockTurn.ts b/tests/unit/helper/mockTurn.ts index 2deb546..3a29333 100644 --- a/tests/unit/helper/mockTurn.ts +++ b/tests/unit/helper/mockTurn.ts @@ -9,8 +9,7 @@ export default function (params?: MockTurnParams) : Turn { player: params?.player ?? Player.PLAYER } if (params?.cardDeck || params?.evolutionCount || params?.prosperityCount - || params?.actionRoll || params?.territoryRoll || params?.beaconRoll - || params?.blueDotCount || params?.redDotCount) { + || params?.actionRoll || params?.blueDotCount || params?.redDotCount || params?.reset) { turn.botPersistence = { cardDeck: params?.cardDeck ?? CardDeck.new().toPersistence(), evolutionCount: params?.evolutionCount ?? 0, @@ -18,9 +17,6 @@ export default function (params?: MockTurnParams) : Turn { blueDotCount: params?.blueDotCount ?? 0, redDotCount: params?.redDotCount ?? 0, actionRoll: params?.actionRoll ?? 0, - territoryRoll: params?.territoryRoll ?? 0, - beaconRoll: params?.beaconRoll ?? 0, - removeChipRoll: params?.removeChipRoll ?? 0, reset: params?.reset } } @@ -37,8 +33,5 @@ export interface MockTurnParams { blueDotCount?: number redDotCount?: number actionRoll?: number - territoryRoll?: number - beaconRoll?: number - removeChipRoll?: number reset?: boolean } diff --git a/tests/unit/services/BotActions.spec.ts b/tests/unit/services/BotActions.spec.ts index 03b97da..e170b3c 100644 --- a/tests/unit/services/BotActions.spec.ts +++ b/tests/unit/services/BotActions.spec.ts @@ -125,8 +125,7 @@ function getState(difficultyLevel: DifficultyLevel) { mockRound({round:1, turns:[ mockTurn({round:1,turn:1,player:Player.PLAYER}), mockTurn({round:1,turn:2,player:Player.BOT,cardDeck:{pile:[2,3,4],discard:[1]}, - evolutionCount:2, prosperityCount:1, blueDotCount:3, redDotCount:2, - actionRoll:3, territoryRoll:4, beaconRoll:5}), + evolutionCount:2, prosperityCount:1, blueDotCount:3, redDotCount:2, actionRoll:3}), mockTurn({round:1,turn:3,player:Player.PLAYER}), mockTurn({round:1,turn:4,player:Player.BOT,cardDeck:{pile:[3,4],discard:[2,1]}, evolutionCount:2, prosperityCount:1, blueDotCount:5, redDotCount:4}) diff --git a/tests/unit/util/NavigationState.spec.ts b/tests/unit/util/NavigationState.spec.ts index b853cb7..0863486 100644 --- a/tests/unit/util/NavigationState.spec.ts +++ b/tests/unit/util/NavigationState.spec.ts @@ -12,8 +12,7 @@ const stateBotData = mockState({initialCardDeck:{pile:[1,2,3,4],discard:[]}, rou mockTurn({round:1,turn:2,player:Player.BOT,cardDeck:{pile:[2,3,4],discard:[1]}}), mockTurn({round:1,turn:3,player:Player.PLAYER}), mockTurn({round:1,turn:4,player:Player.BOT,cardDeck:{pile:[3,4],discard:[2,1]}, - evolutionCount:2, prosperityCount:1, blueDotCount:3, redDotCount:1, - actionRoll:3, territoryRoll:4, beaconRoll:5, removeChipRoll:6}) + evolutionCount:2, prosperityCount:1, blueDotCount:3, redDotCount:1, actionRoll:3}) ]}) ]}) @@ -71,9 +70,6 @@ describe('util/NavigationState', () => { expect(navigationState.blueDotCount).to.eq(3) expect(navigationState.redDotCount).to.eq(1) expect(navigationState.actionRoll).to.eq(3) - expect(navigationState.territoryRoll).to.eq(4) - expect(navigationState.beaconRoll).to.eq(5) - expect(navigationState.removeChipRoll).to.eq(6) }) it('turnBot-lastTurn', () => { @@ -87,9 +83,6 @@ describe('util/NavigationState', () => { expect(navigationState.blueDotCount).to.eq(5) // card3.blueDotCount = 2 expect(navigationState.redDotCount).to.eq(2) // card3.redDotCount = 1 expect(navigationState.actionRoll).to.greaterThanOrEqual(1) - expect(navigationState.territoryRoll).to.greaterThanOrEqual(1) - expect(navigationState.beaconRoll).to.greaterThanOrEqual(1) - expect(navigationState.removeChipRoll).to.greaterThanOrEqual(1) }) it('turnBot-lastRoundLastTurn', () => { @@ -103,9 +96,6 @@ describe('util/NavigationState', () => { expect(navigationState.blueDotCount).to.eq(2) // card3.blueDotCount = 2 expect(navigationState.redDotCount).to.eq(1) // card3.redDotCount = 1 expect(navigationState.actionRoll).to.greaterThanOrEqual(1) - expect(navigationState.territoryRoll).to.greaterThanOrEqual(1) - expect(navigationState.beaconRoll).to.greaterThanOrEqual(1) - expect(navigationState.removeChipRoll).to.greaterThanOrEqual(1) }) it('turnBot-initialCardDeck', () => { @@ -119,8 +109,5 @@ describe('util/NavigationState', () => { expect(navigationState.blueDotCount).to.eq(0) expect(navigationState.redDotCount).to.eq(0) expect(navigationState.actionRoll).to.eq(0) - expect(navigationState.territoryRoll).to.eq(0) - expect(navigationState.beaconRoll).to.eq(0) - expect(navigationState.removeChipRoll).to.eq(0) }) })