@@ -2,7 +2,7 @@ import { strict as assert } from 'node:assert';
2
2
import { describe , it } from 'node:test' ;
3
3
import * as ExAsserts from '../../test/extra-asserts.js' ;
4
4
5
- import { COLOUR , PLAYER , expandShortCard , setup } from '../test-utils.js' ;
5
+ import { COLOUR , PLAYER , expandShortCard , preClue , setup } from '../test-utils.js' ;
6
6
import HGroup from '../../src/conventions/h-group.js' ;
7
7
8
8
import { ACTION , CLUE } from '../../src/constants.js' ;
@@ -20,45 +20,19 @@ describe('simple endgames with 1 card left', () => {
20
20
const game = setup ( HGroup , [
21
21
[ 'r5' , 'xx' , 'xx' , 'xx' ] ,
22
22
[ 'y5' , 'r1' , 'g1' , 'b1' ] ,
23
- [ 'r4' , 'b1 ' , 'b1 ' , 'g1 ' ] ,
23
+ [ 'r4' , 'r1 ' , 'g1 ' , 'b1 ' ] ,
24
24
[ 'r4' , 'p1' , 'p1' , 'b5' ] ,
25
25
] , {
26
26
play_stacks : [ 3 , 4 , 5 , 4 , 5 ] ,
27
27
clue_tokens : 2 ,
28
28
init : ( game ) => {
29
- const { common, state } = game ;
30
-
31
- const update1 = ( draft ) => {
32
- draft . clued = true ;
33
- draft . clues . push ( { giver : PLAYER . DONALD , type : CLUE . RANK , value : 5 , turn : - 1 } ) ;
34
- draft . clues . push ( { giver : PLAYER . DONALD , type : CLUE . COLOUR , value : COLOUR . RED , turn : - 1 } ) ;
35
- } ;
36
-
37
- const a_slot1 = state . hands [ PLAYER . ALICE ] [ 0 ] ;
38
- state . deck = state . deck . with ( a_slot1 , produce ( state . deck [ a_slot1 ] , update1 ) ) ;
39
-
40
- let { inferred, possible } = common . thoughts [ a_slot1 ] ;
41
- common . updateThoughts ( state . hands [ PLAYER . ALICE ] [ 0 ] , ( draft ) => {
42
- draft . inferred = inferred . intersect ( expandShortCard ( 'r5' ) ) ;
43
- draft . possible = possible . intersect ( expandShortCard ( 'r5' ) ) ;
44
- update1 ( draft ) ;
45
- } ) ;
46
-
47
- const update2 = ( draft ) => {
48
- draft . clued = true ;
49
- draft . clues . push ( { giver : PLAYER . ALICE , type : CLUE . RANK , value : 5 , turn : - 1 } ) ;
50
- draft . clues . push ( { giver : PLAYER . ALICE , type : CLUE . COLOUR , value : COLOUR . BLUE , turn : - 1 } ) ;
51
- } ;
52
-
53
- const d_slot4 = state . hands [ PLAYER . DONALD ] [ 3 ] ;
54
- state . deck = state . deck . with ( d_slot4 , produce ( state . deck [ d_slot4 ] , update2 ) ) ;
29
+ preClue ( game , game . state . hands [ PLAYER . ALICE ] [ 0 ] , [
30
+ { giver : PLAYER . DONALD , type : CLUE . RANK , value : 5 } ,
31
+ { giver : PLAYER . DONALD , type : CLUE . COLOUR , value : COLOUR . RED } ] ) ;
55
32
56
- ( { inferred, possible } = common . thoughts [ d_slot4 ] ) ;
57
- common . updateThoughts ( state . hands [ PLAYER . DONALD ] [ 3 ] , ( draft ) => {
58
- draft . inferred = inferred . intersect ( expandShortCard ( 'b5' ) ) ;
59
- draft . possible = possible . intersect ( expandShortCard ( 'b5' ) ) ;
60
- update2 ( draft ) ;
61
- } ) ;
33
+ preClue ( game , game . state . hands [ PLAYER . DONALD ] [ 3 ] , [
34
+ { giver : PLAYER . ALICE , type : CLUE . RANK , value : 5 } ,
35
+ { giver : PLAYER . ALICE , type : CLUE . COLOUR , value : COLOUR . BLUE } ] ) ;
62
36
63
37
game . state . cardsLeft = 1 ;
64
38
}
0 commit comments