Commit 606acf9 1 parent c09da9b commit 606acf9 Copy full SHA for 606acf9
File tree 3 files changed +12
-4
lines changed
3 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -458,6 +458,7 @@ export function stop(state: HeadlessState): void {
458
458
state . liftable . liftDests =
459
459
state . animation . current =
460
460
undefined ;
461
+ state . gameButtonsActive = false ;
461
462
cancelMove ( state ) ;
462
463
}
463
464
@@ -545,14 +546,18 @@ export function isPocketAtDomPos(
545
546
}
546
547
547
548
export function reorderDice ( state : HeadlessState ) : void {
548
- if ( state . dice . length === 2 && state . dice [ 0 ] . isAvailable && state . dice [ 1 ] . isAvailable ) {
549
- state . dice = [ state . dice [ 1 ] , state . dice [ 0 ] ] ;
549
+ if ( state . gameButtonsActive ) {
550
+ if ( state . dice . length === 2 && state . dice [ 0 ] . isAvailable && state . dice [ 1 ] . isAvailable ) {
551
+ state . dice = [ state . dice [ 1 ] , state . dice [ 0 ] ] ;
552
+ }
553
+ callUserFunction ( state . events . selectDice , state . dice ) ;
550
554
}
551
- callUserFunction ( state . events . selectDice , state . dice ) ;
552
555
}
553
556
554
557
export function undoButtonPressed ( state : HeadlessState ) : void {
555
- callUserFunction ( state . events . undoButton ) ;
558
+ if ( state . gameButtonsActive ) {
559
+ callUserFunction ( state . events . undoButton ) ;
560
+ }
556
561
}
557
562
558
563
export function p1Pov ( s : HeadlessState ) : boolean {
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ export interface Config {
17
17
dice ?: cg . Dice [ ] ; // dice to display on the board
18
18
canUndo ?: boolean ; // can user undo thier last action
19
19
showUndoButton ?: boolean ; //show the undo button
20
+ gameButtonsActive ?: boolean ; // can user process game buttons (e.g. swap dice, undo)
20
21
autoCastle ?: boolean ; // immediately complete the castle by moving the rook after king move
21
22
viewOnly ?: boolean ; // don't bind events: the user will never be able to move pieces around
22
23
selectOnly ?: boolean ; // only allow user to select squares/pieces (multiple selection allowed)
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ export interface HeadlessState {
22
22
dice : cg . Dice [ ] ; // dice to display on the board
23
23
canUndo : boolean ; // can user undo their last action (backgammon)
24
24
showUndoButton : boolean ; // render the undo button (backgammon)
25
+ gameButtonsActive : boolean ; // can user process game buttons (e.g. swap dice, undo)
25
26
autoCastle : boolean ; // immediately complete the castle by moving the rook after king move
26
27
viewOnly : boolean ; // don't bind events: the user will never be able to move pieces around
27
28
selectOnly : boolean ; // only allow user to select squares/pieces (multiple selection allowed)
@@ -154,6 +155,7 @@ export function defaults(): HeadlessState {
154
155
dice : [ ] ,
155
156
canUndo : false ,
156
157
showUndoButton : false ,
158
+ gameButtonsActive : true ,
157
159
autoCastle : true ,
158
160
selectedPieces : new Map < cg . Key , cg . Piece > ( ) ,
159
161
viewOnly : false ,
You can’t perform that action at this time.
0 commit comments