-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontract.mjs
109 lines (100 loc) · 2.5 KB
/
contract.mjs
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import { Card, Suit, Rank } from './card.mjs';
import { Order } from './order.mjs';
export function Contract(factory) {
this.order = new Order();
this.partner = null;
factory.call(this);
}
Contract.prototype.assign = function(owner) {
this.owner = owner;
};
Contract.normal = {
get bell() {
return new Contract(function() {
this.value = 1;
this.name = 'normal';
this.variant = 'bell';
this.partner = Card[Suit.bell][Rank.ace];
this.order.promote([Suit.heart], [Rank.sergeant, Rank.officer]);
});
},
get leaf() {
return new Contract(function() {
this.value = 1;
this.name = 'normal';
this.variant = 'leaf';
this.partner = Card[Suit.leaf][Rank.ace];
this.order.promote([Suit.heart], [Rank.sergeant, Rank.officer]);
});
},
get acorn() {
return new Contract(function() {
this.value = 1;
this.name = 'normal';
this.variant = 'acorn';
this.partner = Card[Suit.acorn][Rank.ace];
this.order.promote([Suit.heart], [Rank.sergeant, Rank.officer]);
});
}
};
Contract.geier = {
get default() {
return new Contract(function() {
this.value = 2;
this.name = 'geier';
this.variant = 'default';
this.order.promote([], [Rank.officer]);
});
}
};
Contract.wenz = {
get default() {
return new Contract(function() {
this.value = 3;
this.name = 'wenz';
this.variant = 'default';
this.order.promote([], [Rank.sergeant]);
});
}
};
Contract.solo = {
get bell() {
return new Contract(function() {
this.value = 4;
this.name = 'solo';
this.variant = 'bell';
this.order.promote([Suit.bell], [Rank.sergeant, Rank.officer]);
});
},
get heart() {
return new Contract(function() {
this.value = 4;
this.name = 'solo';
this.variant = 'heart';
this.order.promote([Suit.heart], [Rank.sergeant, Rank.officer]);
});
},
get leaf() {
return new Contract(function() {
this.value = 4;
this.name = 'solo';
this.variant = 'leaf';
this.order.promote([Suit.leaf], [Rank.sergeant, Rank.officer]);
});
},
get acorn() {
return new Contract(function() {
this.value = 4;
this.name = 'solo';
this.variant = 'acorn';
this.order.promote([Suit.acorn], [Rank.sergeant, Rank.officer]);
});
}
};
Contract[Symbol.iterator] = function*() {
for (let name in Contract) {
for (let variant in Contract[name]) {
yield Contract[name][variant];
}
}
};