/
SelectInitialCards.ts
53 lines (48 loc) · 1.64 KB
/
SelectInitialCards.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import {AndOptions} from './AndOptions';
import {ICorporationCard} from '../cards/corporation/ICorporationCard';
import {IProjectCard} from '../cards/IProjectCard';
import {Player} from '../Player';
import {PlayerInput} from '../PlayerInput';
import {PlayerInputTypes} from '../common/input/PlayerInputTypes';
import {SelectCard} from './SelectCard';
export class SelectInitialCards extends AndOptions implements PlayerInput {
public override inputType = PlayerInputTypes.SELECT_INITIAL_CARDS;
constructor(player: Player, cb: (corporation: ICorporationCard) => undefined) {
super(() => {
cb(corporation);
return undefined;
});
let corporation: ICorporationCard;
this.title = ' ';
this.buttonLabel = 'Start';
this.options.push(
new SelectCard<ICorporationCard>(
'Select corporation', undefined, player.dealtCorporationCards,
(foundCards: Array<ICorporationCard>) => {
corporation = foundCards[0];
return undefined;
},
),
);
if (player.game.gameOptions.preludeExtension) {
this.options.push(
new SelectCard(
'Select 2 Prelude cards', undefined, player.dealtPreludeCards,
(preludeCards: Array<IProjectCard>) => {
player.preludeCardsInHand.push(...preludeCards);
return undefined;
}, 2, 2,
),
);
}
this.options.push(
new SelectCard(
'Select initial cards to buy', undefined, player.dealtProjectCards,
(foundCards: Array<IProjectCard>) => {
player.cardsInHand.push(...foundCards);
return undefined;
}, 10, 0,
),
);
}
}