1- import { Round , State } from '@/store/state'
1+ import { Round , State , TechDraftStep } from '@/store/state'
22import { RouteLocation } from 'vue-router'
33import getIntRouteParam from '@brdgm/brdgm-commons/src/util/router/getIntRouteParam'
44import Player from '@/services/enum/Player'
@@ -10,6 +10,7 @@ import TechCardSelection from '@/services/TechCardSelection'
1010export default class NavigationState {
1111
1212 readonly round : number
13+ readonly draftingStep : number
1314 readonly prosperityCards : ProsperityCards
1415 readonly botCards : BotCards
1516 readonly rowPlaceholders : RowPlaceholders
@@ -19,6 +20,7 @@ export default class NavigationState {
1920
2021 constructor ( route : RouteLocation , state : State ) {
2122 this . round = getIntRouteParam ( route , 'round' )
23+ this . draftingStep = getIntRouteParam ( route , 'step' )
2224
2325 let roundData = state . rounds . find ( item => item . round === this . round )
2426 if ( ! roundData ) {
@@ -42,11 +44,17 @@ export default class NavigationState {
4244 }
4345
4446 public get startPlayer ( ) : Player {
45- return this . roundData . nextStartPlayer ?? this . roundData . startPlayer
47+ return this . lastDraftStep ?. nextStartPlayer ?? this . roundData . nextStartPlayer ?? this . roundData . startPlayer
4648 }
4749
4850 public get architectPlayer ( ) : Player {
49- return this . roundData . nextArchitectPlayer ?? this . roundData . architectPlayer
51+ return this . lastDraftStep ?. nextArchitectPlayer ?? this . roundData . nextArchitectPlayer ?? this . roundData . architectPlayer
52+ }
53+
54+ private get lastDraftStep ( ) : TechDraftStep | undefined {
55+ if ( this . roundData . techDraftSteps ) {
56+ return this . roundData . techDraftSteps . toSorted ( ( a , b ) => a . step - b . step ) [ this . roundData . techDraftSteps . length - 1 ]
57+ }
5058 }
5159
5260}
0 commit comments