Skip to content

Commit

Permalink
Remove territoryRoll, beaconRoll, removeChipRoll - may be required mu…
Browse files Browse the repository at this point in the history
…ltiple times per turn
  • Loading branch information
stefanseifert committed Oct 21, 2024
1 parent 1437374 commit 2ea41d1
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 51 deletions.
3 changes: 1 addition & 2 deletions src/components/turn/DebugInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
<p class="debug">
<b>cardDeck</b>: {{cardDeck.toPersistence()}}<br/>
<b>currentCard</b>: {{cardDeck.currentCard}}<br/>
<b>rolls</b>: action={{navigationState.actionRoll}}, territory={{navigationState.territoryRoll}}, beacon={{navigationState.beaconRoll}}, removeChip={{navigationState.removeChipRoll}},
<b>difficultyLevel</b>: {{navigationState.difficultyLevel}}<br/>
<b>actionRoll</b>: {{navigationState.actionRoll}}, <b>difficultyLevel</b>: {{navigationState.difficultyLevel}}<br/>
</p>
</div>
</template>
Expand Down
3 changes: 0 additions & 3 deletions src/store/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ export interface BotPersistence {
blueDotCount: number
redDotCount: number
actionRoll: number
territoryRoll: number
beaconRoll: number
removeChipRoll: number
reset?: boolean
}
export interface CardDeckPersistence {
Expand Down
17 changes: 1 addition & 16 deletions src/util/NavigationState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
}
11 changes: 5 additions & 6 deletions src/views/TurnBot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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,
Expand All @@ -100,10 +102,7 @@ export default defineComponent({
prosperityCount,
blueDotCount,
redDotCount,
actionRoll,
territoryRoll,
beaconRoll,
removeChipRoll
actionRoll
}
}
if (this.isReset && turn.botPersistence) {
Expand Down
9 changes: 1 addition & 8 deletions tests/unit/helper/mockTurn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,14 @@ 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,
prosperityCount: params?.prosperityCount ?? 0,
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
}
}
Expand All @@ -37,8 +33,5 @@ export interface MockTurnParams {
blueDotCount?: number
redDotCount?: number
actionRoll?: number
territoryRoll?: number
beaconRoll?: number
removeChipRoll?: number
reset?: boolean
}
3 changes: 1 addition & 2 deletions tests/unit/services/BotActions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
15 changes: 1 addition & 14 deletions tests/unit/util/NavigationState.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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})
]})
]})

Expand Down Expand Up @@ -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', () => {
Expand All @@ -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', () => {
Expand All @@ -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', () => {
Expand All @@ -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)
})
})

0 comments on commit 2ea41d1

Please sign in to comment.