dyo-tools 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants.js +4 -4
- package/dist/constants.js.map +1 -1
- package/dist/core/DTAction.d.ts +10 -0
- package/dist/core/DTAction.js +24 -0
- package/dist/core/DTAction.js.map +1 -0
- package/dist/core/DTBunch.d.ts +6 -7
- package/dist/core/DTBunch.js +16 -13
- package/dist/core/DTBunch.js.map +1 -1
- package/dist/core/DTComponentPhysical.d.ts +6 -4
- package/dist/core/DTComponentPhysical.js +6 -0
- package/dist/core/DTComponentPhysical.js.map +1 -1
- package/dist/core/DTElement.d.ts +5 -0
- package/dist/core/DTElement.js +12 -2
- package/dist/core/DTElement.js.map +1 -1
- package/dist/core/DTManager.d.ts +3 -1
- package/dist/core/DTManager.js +24 -14
- package/dist/core/DTManager.js.map +1 -1
- package/dist/core/DTMaster.d.ts +24 -0
- package/dist/core/DTMaster.js +133 -0
- package/dist/core/DTMaster.js.map +1 -0
- package/dist/core/DTModule.d.ts +14 -0
- package/dist/core/DTModule.js +39 -0
- package/dist/core/DTModule.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/libs/player/DTPlayer.element.d.ts +5 -0
- package/dist/libs/player/DTPlayer.element.js +11 -0
- package/dist/libs/player/DTPlayer.element.js.map +1 -0
- package/dist/libs/player/DTPlayer.manager.d.ts +11 -0
- package/dist/libs/player/DTPlayer.manager.js +42 -0
- package/dist/libs/player/DTPlayer.manager.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/core.d.ts +103 -0
- package/dist/types/core.js +15 -0
- package/dist/types/core.js.map +1 -0
- package/dist/types/index.d.ts +2 -98
- package/dist/types/index.js +16 -12
- package/dist/types/index.js.map +1 -1
- package/dist/types/player.d.ts +5 -0
- package/dist/types/player.js +3 -0
- package/dist/types/player.js.map +1 -0
- package/docs/assets/highlight.css +29 -29
- package/docs/assets/main.js +59 -58
- package/docs/assets/navigation.js +1 -0
- package/docs/assets/search.js +1 -1
- package/docs/assets/style.css +1414 -1367
- package/docs/classes/core_DTAction.DYOToolsAction.html +89 -0
- package/docs/classes/core_DTBunch.DYOToolsBunch.html +254 -0
- package/docs/classes/core_DTComponent.DYOToolsComponent.html +76 -0
- package/docs/classes/core_DTComponentPhysical.DYOToolsComponentPhysical.html +110 -0
- package/docs/classes/core_DTComponentWithMeta.DYOToolsComponentWithMeta.html +96 -0
- package/docs/classes/core_DTElement.DYOToolsElement.html +135 -0
- package/docs/classes/core_DTError.DYOToolsError.html +37 -0
- package/docs/classes/core_DTManager.DYOToolsManager.html +237 -0
- package/docs/classes/core_DTMaster.DYOToolsMaster.html +150 -0
- package/docs/classes/core_DTModule.DYOToolsModule.html +92 -0
- package/docs/classes/libs_DYOFinder.DYOFinder.html +34 -0
- package/docs/classes/libs_player_DTPlayer_element.DYOToolsPlayer.html +134 -0
- package/docs/classes/libs_player_DTPlayer_manager.DYOToolsPlayerManager.html +243 -0
- package/docs/enums/types_core.FilterOperatorType.html +10 -0
- package/docs/hierarchy.html +1 -0
- package/docs/index.html +1 -46
- package/docs/interfaces/types_core.DTBunchFilters.html +6 -0
- package/docs/interfaces/types_core.DTBunchOptions.html +19 -0
- package/docs/interfaces/types_core.DTBunchToObject.html +7 -0
- package/docs/interfaces/types_core.DTComponentOptions.html +5 -0
- package/docs/interfaces/types_core.DTComponentToObject.html +4 -0
- package/docs/interfaces/types_core.DTElementToObject.html +7 -0
- package/docs/interfaces/types_core.DTManagerFilters.html +6 -0
- package/docs/interfaces/types_core.DTManagerOptions.html +8 -0
- package/docs/interfaces/types_core.DTManagerToObject.html +5 -0
- package/docs/interfaces/types_core.DTMasterToObject.html +8 -0
- package/docs/interfaces/types_core.DTModuleToObject.html +6 -0
- package/docs/interfaces/types_core.DYOFinderConfigurationPropDefault.html +4 -0
- package/docs/interfaces/types_core.DYOFinderConfigurationPropObjectSearch.html +4 -0
- package/docs/interfaces/types_core.DYOFinderFilterOperatorAdvanced.html +5 -0
- package/docs/interfaces/types_core.DYOFinderFilterOperatorBase.html +5 -0
- package/docs/interfaces/types_player.DTPlayerManagerSimpleConfiguration.html +3 -0
- package/docs/modules/constants.html +6 -0
- package/docs/modules/core_DTAction.html +2 -0
- package/docs/modules/core_DTBunch.html +2 -0
- package/docs/modules/core_DTComponent.html +2 -0
- package/docs/modules/core_DTComponentPhysical.html +2 -0
- package/docs/modules/core_DTComponentWithMeta.html +2 -0
- package/docs/modules/core_DTElement.html +2 -0
- package/docs/modules/core_DTError.html +2 -0
- package/docs/modules/core_DTManager.html +2 -0
- package/docs/modules/core_DTMaster.html +2 -0
- package/docs/modules/core_DTModule.html +2 -0
- package/docs/modules/libs_DYOFinder.html +2 -0
- package/docs/modules/libs_player_DTPlayer_element.html +2 -0
- package/docs/modules/libs_player_DTPlayer_manager.html +2 -0
- package/docs/modules/types.html +29 -0
- package/docs/modules/types_core.html +28 -0
- package/docs/modules/types_player.html +2 -0
- package/docs/types/types_core.DTAcceptedMetaData.html +2 -0
- package/docs/types/types_core.DTManagerItemType.html +1 -0
- package/docs/types/types_core.DTManagerItemsType.html +2 -0
- package/docs/types/types_core.DYOFinderComponentType.html +1 -0
- package/docs/types/types_core.DYOFinderConfiguration.html +2 -0
- package/docs/types/types_core.DYOFinderConfigurationProp.html +1 -0
- package/docs/types/types_core.DYOFinderFilterOperator.html +1 -0
- package/docs/types/types_core.DYOFinderFilterOperatorArgument.html +1 -0
- package/docs/types/types_core.DYOFinderFilters.html +1 -0
- package/docs/types/types_core.StandardPrimitiveType.html +2 -0
- package/docs/types/types_core.StandardPrimitiveTypeWithArray.html +1 -0
- package/docs/variables/constants.bunchDefaultOptions.html +2 -0
- package/docs/variables/constants.componentBunchDefaultFinderConfiguration.html +1 -0
- package/docs/variables/constants.componentManagerDefaultFinderConfiguration.html +1 -0
- package/docs/variables/constants.componentPhysicalDefaultFinderConfiguration.html +1 -0
- package/docs/variables/constants.managerDefaultOptions.html +2 -0
- package/package.json +16 -17
- package/src/constants.ts +85 -85
- package/src/core/DTAction.ts +52 -0
- package/src/core/DTBunch.ts +467 -461
- package/src/core/DTComponent.ts +225 -225
- package/src/core/DTComponentPhysical.ts +53 -39
- package/src/core/DTComponentWithMeta.ts +65 -65
- package/src/core/DTElement.ts +102 -69
- package/src/core/DTError.ts +78 -78
- package/src/core/DTManager.ts +465 -446
- package/src/core/DTMaster.ts +318 -0
- package/src/core/DTModule.ts +90 -0
- package/src/index.ts +17 -9
- package/src/libs/DYOFinder.ts +175 -175
- package/src/libs/player/DTPlayer.element.ts +9 -0
- package/src/libs/player/DTPlayer.manager.ts +84 -0
- package/src/types/core.ts +169 -0
- package/src/types/index.ts +2 -162
- package/src/types/player.ts +6 -0
- package/test/core/DTAction.double.ts +78 -0
- package/test/core/DTAction.spec.ts +76 -0
- package/test/core/DTBunch.double.ts +18 -10
- package/test/core/DTBunch.spec.ts +70 -68
- package/test/core/DTComponentPhysical.double.ts +3 -3
- package/test/core/DTComponentPhysical.spec.ts +25 -11
- package/test/core/DTElement.double.ts +21 -5
- package/test/core/DTElement.spec.ts +52 -8
- package/test/core/DTError.double.ts +1 -1
- package/test/core/DTManager.double.ts +29 -5
- package/test/core/DTManager.spec.ts +80 -17
- package/test/core/DTMaster.double.ts +141 -0
- package/test/core/DTMaster.spec.ts +584 -0
- package/test/core/DTModule.double.ts +80 -0
- package/test/core/DTModule.spec.ts +138 -0
- package/test/core/copy.spec.ts +20 -4
- package/test/{core/DTPlayer.double.ts → libs/player/DTPlayer.element.double.ts} +15 -24
- package/test/libs/player/DTPlayer.element.spec.ts +28 -0
- package/test/libs/player/DTPlayer.manager.double.ts +92 -0
- package/test/libs/player/DTPlayer.manager.spec.ts +178 -0
- package/LICENSE +0 -21
- package/cucumber.js +0 -9
- package/dist/core/DTPlayer.d.ts +0 -8
- package/dist/core/DTPlayer.js +0 -30
- package/dist/core/DTPlayer.js.map +0 -1
- package/e2e/0.2.0/epic1.feature +0 -29
- package/e2e/0.2.0/epic2.feature +0 -22
- package/e2e/0.2.0/epic3.feature +0 -25
- package/e2e/0.2.0/resources/dominion.js +0 -195
- package/e2e/0.2.0/resources/utils.js +0 -27
- package/e2e/0.2.0/support/steps.js +0 -108
- package/e2e/future/epic4.feature +0 -39
- package/e2e/future/resources/dominion.js +0 -238
- package/e2e/future/resources/utils.js +0 -27
- package/src/core/DTPlayer.ts +0 -57
- package/test/core/DTPlayer.spec.ts +0 -80
package/e2e/0.2.0/epic2.feature
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
Feature: Epic 2 - Manager and Library
|
|
2
|
-
|
|
3
|
-
Scenario: Store of all elements
|
|
4
|
-
Given my dominion manager
|
|
5
|
-
Then I should have 104 elements in my library
|
|
6
|
-
|
|
7
|
-
Scenario: Autodetect already existing element
|
|
8
|
-
Given my dominion manager
|
|
9
|
-
When I add a new trash pile with 2 already existing elements into the scope "default"
|
|
10
|
-
Then I should have 107 elements in my library
|
|
11
|
-
|
|
12
|
-
Scenario: Library isn't a manager bunch
|
|
13
|
-
Given my dominion manager
|
|
14
|
-
Then I shouldn't find my library id into bunches
|
|
15
|
-
|
|
16
|
-
Scenario: Auto adding new element in bunch
|
|
17
|
-
Given my dominion manager
|
|
18
|
-
When I add a new external card in my current hand
|
|
19
|
-
Then I should have 105 elements in my library
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
package/e2e/0.2.0/epic3.feature
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
Feature: Epic 3 - Manager and Scopes
|
|
2
|
-
|
|
3
|
-
Scenario: Scope configuration
|
|
4
|
-
Given my dominion manager
|
|
5
|
-
Then I should have 7 scopes in my manager
|
|
6
|
-
And I should have 9 bunches in my scope "supply"
|
|
7
|
-
|
|
8
|
-
Scenario: Adding bunch into a scope
|
|
9
|
-
Given my dominion manager
|
|
10
|
-
When I add a new trash pile with 2 already existing elements into the scope "supply"
|
|
11
|
-
Then I should have 10 bunches in my scope "supply"
|
|
12
|
-
|
|
13
|
-
Scenario: No adding in non-declared scope
|
|
14
|
-
Given my dominion manager
|
|
15
|
-
When I add a new trash pile with 2 already existing elements into the scope "trash"
|
|
16
|
-
Then I should see an error "invalid_scope"
|
|
17
|
-
|
|
18
|
-
Scenario: Moving bunch through scopes
|
|
19
|
-
Given my dominion manager
|
|
20
|
-
When I move my current hand to the scope "supply"
|
|
21
|
-
Then I should have 10 bunches in my scope "supply"
|
|
22
|
-
And I should have 1 bunches in my scope "hand"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
const {DTElement, DTManager, DTBunch, DTPlayer} = require("../../../dist/src");
|
|
2
|
-
|
|
3
|
-
/****************** CARDS REFERENCE ************************/
|
|
4
|
-
const cards = {
|
|
5
|
-
"COPPER": {
|
|
6
|
-
meta: {
|
|
7
|
-
type: 'treasure',
|
|
8
|
-
cost: 0,
|
|
9
|
-
treasurePoints: 1
|
|
10
|
-
},
|
|
11
|
-
events: {
|
|
12
|
-
play: (ctx) => {
|
|
13
|
-
ctx.getOwner.setMeta('coin', 1);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"SILVER": {
|
|
18
|
-
meta: {
|
|
19
|
-
type: 'treasure',
|
|
20
|
-
cost: 3,
|
|
21
|
-
treasurePoints: 2
|
|
22
|
-
},
|
|
23
|
-
events: {
|
|
24
|
-
play: (ctx) => {
|
|
25
|
-
ctx.getOwner.setMeta('coin', 2);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"GOLD": {
|
|
30
|
-
meta: {
|
|
31
|
-
type: 'treasure',
|
|
32
|
-
cost: 6,
|
|
33
|
-
treasurePoints: 3
|
|
34
|
-
},
|
|
35
|
-
events: {
|
|
36
|
-
play: (ctx) => {
|
|
37
|
-
ctx.getOwner.setMeta('coin', 3);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"ESTATE": {
|
|
42
|
-
meta: {
|
|
43
|
-
type: 'victory',
|
|
44
|
-
cost: 2,
|
|
45
|
-
victoryPoints: 1
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"DUCHY": {
|
|
49
|
-
meta: {
|
|
50
|
-
type: 'victory',
|
|
51
|
-
cost: 5,
|
|
52
|
-
treasurePoints: 3
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
"PROVINCE": {
|
|
56
|
-
meta: {
|
|
57
|
-
type: 'victory',
|
|
58
|
-
cost: 8,
|
|
59
|
-
treasurePoints: 6
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
"SMITHY": {
|
|
63
|
-
meta: {
|
|
64
|
-
type: 'action',
|
|
65
|
-
cost: 4,
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
"WORKSHOP": {
|
|
69
|
-
meta: {
|
|
70
|
-
type: 'action',
|
|
71
|
-
cost: 3,
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
"MILITIA": {
|
|
75
|
-
meta: {
|
|
76
|
-
type: 'action',
|
|
77
|
-
cost: 4,
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/****************** BUILDERS ************************/
|
|
83
|
-
|
|
84
|
-
const buildCard = (key) => {
|
|
85
|
-
const element = new DTElement(key);
|
|
86
|
-
element.setManyMeta(cards[key].meta);
|
|
87
|
-
return element;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const duplicateCard = (card, nb) => {
|
|
91
|
-
const items = [card];
|
|
92
|
-
let i = 1;
|
|
93
|
-
while (i <= nb) {
|
|
94
|
-
items.push(card.copy());
|
|
95
|
-
i++;
|
|
96
|
-
}
|
|
97
|
-
return items;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const initializeDominionManager = () => {
|
|
101
|
-
const scopes = [
|
|
102
|
-
'supply',
|
|
103
|
-
'hand',
|
|
104
|
-
'playZone',
|
|
105
|
-
'discard',
|
|
106
|
-
'deck'
|
|
107
|
-
];
|
|
108
|
-
const library = [
|
|
109
|
-
...duplicateCard(buildCard('COPPER'), 13),
|
|
110
|
-
...duplicateCard(buildCard('ESTATE'), 5)
|
|
111
|
-
];
|
|
112
|
-
const manager = new DTManager('dominionCard', library, scopes, { errors: true });
|
|
113
|
-
|
|
114
|
-
// Initialize Supply zone
|
|
115
|
-
const copperPile = new DTBunch('copperPile', duplicateCard(buildCard('COPPER'), 11));
|
|
116
|
-
copperPile.setMeta('cost', cards["COPPER"].cost);
|
|
117
|
-
const silverPile = new DTBunch('silverPile', duplicateCard(buildCard('SILVER'), 11));
|
|
118
|
-
silverPile.setMeta('cost', cards["SILVER"].cost);
|
|
119
|
-
const goldPile = new DTBunch('goldPile', duplicateCard(buildCard('GOLD'), 11));
|
|
120
|
-
goldPile.setMeta('cost', cards["GOLD"].cost);
|
|
121
|
-
|
|
122
|
-
const estatePile = new DTBunch('estatePile', duplicateCard(buildCard('ESTATE'), 7));
|
|
123
|
-
estatePile.setMeta('cost', cards["ESTATE"].cost);
|
|
124
|
-
const duchyPile = new DTBunch('duchyPile', duplicateCard(buildCard('DUCHY'), 7));
|
|
125
|
-
duchyPile.setMeta('cost', cards["DUCHY"].cost);
|
|
126
|
-
const provincePile = new DTBunch('provincePile', duplicateCard(buildCard('PROVINCE'), 7));
|
|
127
|
-
provincePile.setMeta('cost', cards["PROVINCE"].cost);
|
|
128
|
-
|
|
129
|
-
const militiaPile = new DTBunch('militiaPile', duplicateCard(buildCard('MILITIA'), 7));
|
|
130
|
-
militiaPile.setMeta('cost', cards["MILITIA"].cost);
|
|
131
|
-
const smithyPile = new DTBunch('smithyPile', duplicateCard(buildCard('SMITHY'), 7));
|
|
132
|
-
smithyPile.setMeta('cost', cards["SMITHY"].cost);
|
|
133
|
-
const workshopPile = new DTBunch('workshopPile', duplicateCard(buildCard('WORKSHOP'), 7));
|
|
134
|
-
workshopPile.setMeta('cost', cards["WORKSHOP"].cost);
|
|
135
|
-
|
|
136
|
-
manager.addMany([
|
|
137
|
-
copperPile,
|
|
138
|
-
silverPile,
|
|
139
|
-
goldPile,
|
|
140
|
-
estatePile,
|
|
141
|
-
duchyPile,
|
|
142
|
-
provincePile,
|
|
143
|
-
militiaPile,
|
|
144
|
-
smithyPile,
|
|
145
|
-
workshopPile
|
|
146
|
-
], 'supply');
|
|
147
|
-
|
|
148
|
-
// Initialize players
|
|
149
|
-
const players = [
|
|
150
|
-
new DTPlayer('PRIAM'),
|
|
151
|
-
new DTPlayer('ECTESIAM'),
|
|
152
|
-
]
|
|
153
|
-
|
|
154
|
-
// Initialize players deck, discard and hand
|
|
155
|
-
let current = {};
|
|
156
|
-
for (let player of players) {
|
|
157
|
-
const deck = new DTBunch('deck');
|
|
158
|
-
deck.setOwner(player);
|
|
159
|
-
manager.add(deck, 'deck');
|
|
160
|
-
|
|
161
|
-
const discard = new DTBunch('discard');
|
|
162
|
-
discard.setOwner(player);
|
|
163
|
-
manager.add(discard, 'discard');
|
|
164
|
-
|
|
165
|
-
const hand = new DTBunch('hand');
|
|
166
|
-
hand.setOwner(player);
|
|
167
|
-
manager.add(hand, 'hand');
|
|
168
|
-
|
|
169
|
-
const playZone = new DTBunch('playZone');
|
|
170
|
-
playZone.setOwner(player);
|
|
171
|
-
manager.add(playZone, 'playZone');
|
|
172
|
-
|
|
173
|
-
const playerCards = new DTBunch('playerCards', [], { virtualContext: true });
|
|
174
|
-
playerCards.setOwner(player);
|
|
175
|
-
manager.add(playerCards);
|
|
176
|
-
|
|
177
|
-
if (player.getKey() === 'PRIAM') {
|
|
178
|
-
current = {
|
|
179
|
-
player,
|
|
180
|
-
deck,
|
|
181
|
-
hand,
|
|
182
|
-
playZone
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// Return
|
|
188
|
-
return {
|
|
189
|
-
manager,
|
|
190
|
-
current,
|
|
191
|
-
players
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
module.exports = initializeDominionManager
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const transformDataTableToBunchFinderArgs = (table) => {
|
|
3
|
-
const validArgs = ['key', 'id', 'owner', 'scope'];
|
|
4
|
-
const finalArgs = {};
|
|
5
|
-
|
|
6
|
-
for (let [arg, value] of Object.entries(table.rowsHash())) {
|
|
7
|
-
if (validArgs.includes(arg)) {
|
|
8
|
-
finalArgs[arg] = { $eq: value };
|
|
9
|
-
} else {
|
|
10
|
-
if (!finalArgs.meta) {
|
|
11
|
-
finalArgs.meta = {};
|
|
12
|
-
}
|
|
13
|
-
finalArgs.meta[arg] = { $eq: value };
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return finalArgs;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const extractKeysElement = (elements) => {
|
|
21
|
-
return elements.map((element) => element.getKey());
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = {
|
|
25
|
-
transformDataTableToBunchFinderArgs,
|
|
26
|
-
extractKeysElement
|
|
27
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
const expect = require('expect')
|
|
2
|
-
const { Given, When, Then } = require('@cucumber/cucumber')
|
|
3
|
-
const {DTManager, DTPlayer, DTBunch, DTElement} = require("../../../dist/src");
|
|
4
|
-
const initializeDominionManager = require("../resources/dominion");
|
|
5
|
-
const {transformDataTableToBunchFinderArgs, extractKeysElement } = require("../resources/utils");
|
|
6
|
-
|
|
7
|
-
/******************* INSTALLATION (GIVEN) STEPS *************************/
|
|
8
|
-
|
|
9
|
-
Given('my empty manager', function () {
|
|
10
|
-
this.manager = new DTManager('emptyManager', [], [], { errors: true });
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
Given('my dominion manager', function () {
|
|
14
|
-
const { manager, current, players } = initializeDominionManager();
|
|
15
|
-
this.manager = manager;
|
|
16
|
-
this.current = current;
|
|
17
|
-
this.players = players;
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**************************** ACT STEPS ********************************/
|
|
22
|
-
|
|
23
|
-
When('I add {int} physical bunches and {int} virtual bunches', function (nbBunches, nbVirtualBunches) {
|
|
24
|
-
let i = 1;
|
|
25
|
-
while (i <= nbBunches) {
|
|
26
|
-
this.manager.add(new DTBunch('hand'));
|
|
27
|
-
i++;
|
|
28
|
-
}
|
|
29
|
-
let j = 1;
|
|
30
|
-
while (i <= nbVirtualBunches) {
|
|
31
|
-
this.manager.add(new DTBunch('virtualHand', [], { virtualContext: true }));
|
|
32
|
-
j++;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
Then('I should have {int} bunches in my manager', function (nbBunches) {
|
|
37
|
-
expect(this.manager.getAll().length).toBe(nbBunches);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
When('I add an already existing bunch', function () {
|
|
41
|
-
this.manager.add(this.current.hand);
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
Then('I should see an error {string}', function (errorCode) {
|
|
45
|
-
expect(this.manager.getLastError().getCode()).toBe(errorCode);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
Then('I should find my current hand', function (pred) {
|
|
49
|
-
expect(this.manager.get(this.current.hand.getId()).getId()).toBe(this.current.hand.getId());
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
Then('I shouldn\'t find my current hand', function (pred) {
|
|
53
|
-
expect(this.manager.get(this.current.hand.getId())).toBeUndefined();
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
Then('I should find {int} bunches with', function (nbBunches, table) {
|
|
57
|
-
const findArgs = transformDataTableToBunchFinderArgs(table);
|
|
58
|
-
expect(this.manager.find(findArgs).length).toBe(nbBunches);
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
When('I move my current hand to the scope {string}', function (scope) {
|
|
63
|
-
this.manager.moveToScope(scope, this.current.hand.getId());
|
|
64
|
-
})
|
|
65
|
-
When('I remove my current hand', function () {
|
|
66
|
-
this.manager.remove(this.current.hand.getId());
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
Then('I should have {int} elements in my library', function (nbElements) {
|
|
70
|
-
expect(this.manager.getLibrary().getAll().length).toBe(nbElements);
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
When('I add a new trash pile with 2 already existing elements into the scope {string}', function (scope) {
|
|
74
|
-
const coppers = this.manager.getLibrary().find({ key: { $eq: 'COPPER' }});
|
|
75
|
-
const trashPile = new DTBunch('trash', [
|
|
76
|
-
new DTElement('CURSE'),
|
|
77
|
-
new DTElement('CURSE'),
|
|
78
|
-
new DTElement('CURSE'),
|
|
79
|
-
coppers[0],
|
|
80
|
-
coppers[1]
|
|
81
|
-
]);
|
|
82
|
-
this.manager.add(trashPile, scope);
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
Then('I shouldn\'t find my library id into bunches', function () {
|
|
86
|
-
const libraryId = this.manager.getLibrary().getId();
|
|
87
|
-
expect(this.manager.get(libraryId)).toBeUndefined();
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
When('I add a new external card in my current hand', function () {
|
|
91
|
-
const curseCard = new DTElement('CURSE');
|
|
92
|
-
this.current.hand.add(curseCard);
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
Then('I should have {int} scopes in my manager', function (nbScopes) {
|
|
96
|
-
expect(this.manager.getScopes().length).toBe(nbScopes);
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
Then('I should have {int} bunches in my scope {string}', function (nbBunches, scope) {
|
|
100
|
-
expect(this.manager.getAll(scope).length).toBe(nbBunches);
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
package/e2e/future/epic4.feature
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
Feature: Epic 4 - Action and Events
|
|
2
|
-
|
|
3
|
-
Scenario: Configuring action into the manager
|
|
4
|
-
Given my dominion manager
|
|
5
|
-
When I add a new action "trash"
|
|
6
|
-
Then I should have 4 actions in my manager
|
|
7
|
-
|
|
8
|
-
Scenario: No duplicated action
|
|
9
|
-
Given my dominion manager
|
|
10
|
-
When I add a new action "shuffle"
|
|
11
|
-
Then I should see an error "action_key_conflict"
|
|
12
|
-
|
|
13
|
-
Scenario: Shuffle my current deck
|
|
14
|
-
Given my dominion manager
|
|
15
|
-
And deal is done
|
|
16
|
-
When I shuffle my current "deck"
|
|
17
|
-
Then I should have copper,estate,copper,estate,copper at the top of my current deck
|
|
18
|
-
|
|
19
|
-
Scenario: Drawing my first hand
|
|
20
|
-
Given my dominion manager
|
|
21
|
-
And deal is done
|
|
22
|
-
When I draw my 5 cards hand
|
|
23
|
-
Then I should have copper,estate,copper,estate,copper in my current hand
|
|
24
|
-
|
|
25
|
-
Scenario: Playing a copper
|
|
26
|
-
Given my dominion manager
|
|
27
|
-
And deal is done
|
|
28
|
-
When I draw my 5 cards hand
|
|
29
|
-
And I play my first card Copper
|
|
30
|
-
Then I should have 1 copper into my play zone
|
|
31
|
-
And my player should have 1 coin for the turn
|
|
32
|
-
|
|
33
|
-
Scenario: No triggering of action outside the restricted scope
|
|
34
|
-
Given my dominion manager
|
|
35
|
-
And deal is done
|
|
36
|
-
When I shuffle my current "hand"
|
|
37
|
-
Then I should see an error "invalid_action_scope"
|
|
38
|
-
|
|
39
|
-
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
const {DTElement, DTManager, DTBunch, DTPlayer} = require("../../../dist/src");
|
|
2
|
-
|
|
3
|
-
/****************** CARDS REFERENCE ************************/
|
|
4
|
-
const cards = {
|
|
5
|
-
"COPPER": {
|
|
6
|
-
meta: {
|
|
7
|
-
type: 'treasure',
|
|
8
|
-
cost: 0,
|
|
9
|
-
treasurePoints: 1
|
|
10
|
-
},
|
|
11
|
-
events: {
|
|
12
|
-
play: (ctx) => {
|
|
13
|
-
ctx.getOwner.setMeta('coin', 1);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
},
|
|
17
|
-
"SILVER": {
|
|
18
|
-
meta: {
|
|
19
|
-
type: 'treasure',
|
|
20
|
-
cost: 3,
|
|
21
|
-
treasurePoints: 2
|
|
22
|
-
},
|
|
23
|
-
events: {
|
|
24
|
-
play: (ctx) => {
|
|
25
|
-
ctx.getOwner.setMeta('coin', 2);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
"GOLD": {
|
|
30
|
-
meta: {
|
|
31
|
-
type: 'treasure',
|
|
32
|
-
cost: 6,
|
|
33
|
-
treasurePoints: 3
|
|
34
|
-
},
|
|
35
|
-
events: {
|
|
36
|
-
play: (ctx) => {
|
|
37
|
-
ctx.getOwner.setMeta('coin', 3);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
"ESTATE": {
|
|
42
|
-
meta: {
|
|
43
|
-
type: 'victory',
|
|
44
|
-
cost: 2,
|
|
45
|
-
victoryPoints: 1
|
|
46
|
-
}
|
|
47
|
-
},
|
|
48
|
-
"DUCHY": {
|
|
49
|
-
meta: {
|
|
50
|
-
type: 'victory',
|
|
51
|
-
cost: 5,
|
|
52
|
-
treasurePoints: 3
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
"PROVINCE": {
|
|
56
|
-
meta: {
|
|
57
|
-
type: 'victory',
|
|
58
|
-
cost: 8,
|
|
59
|
-
treasurePoints: 6
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
"SMITHY": {
|
|
63
|
-
meta: {
|
|
64
|
-
type: 'action',
|
|
65
|
-
cost: 4,
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
"WORKSHOP": {
|
|
69
|
-
meta: {
|
|
70
|
-
type: 'action',
|
|
71
|
-
cost: 3,
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
"MILITIA": {
|
|
75
|
-
meta: {
|
|
76
|
-
type: 'action',
|
|
77
|
-
cost: 4,
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/****************** BUILDERS ************************/
|
|
83
|
-
|
|
84
|
-
const buildCard = (key) => {
|
|
85
|
-
const element = new DTElement(key);
|
|
86
|
-
element.setManyMeta(cards[key].meta);
|
|
87
|
-
if (cards[key].events) {
|
|
88
|
-
for (let actionKey of Object.keys(cards[key].events)) {
|
|
89
|
-
element.addEvent(actionKey, cards[key].events[actionKey]);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return element;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const duplicateCard = (card, nb) => {
|
|
96
|
-
const items = [card];
|
|
97
|
-
let i = 1;
|
|
98
|
-
while (i <= nb) {
|
|
99
|
-
items.push(card.copy());
|
|
100
|
-
i++;
|
|
101
|
-
}
|
|
102
|
-
return items;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const initializeDominionManager = () => {
|
|
106
|
-
const scopes = [
|
|
107
|
-
'supply',
|
|
108
|
-
'hand',
|
|
109
|
-
'playZone',
|
|
110
|
-
'discard',
|
|
111
|
-
'deck'
|
|
112
|
-
];
|
|
113
|
-
const library = [
|
|
114
|
-
...duplicateCard(buildCard('COPPER'), 13),
|
|
115
|
-
...duplicateCard(buildCard('ESTATE'), 5)
|
|
116
|
-
];
|
|
117
|
-
const manager = new DTManager('dominionCard', library, scopes, { errors: true });
|
|
118
|
-
|
|
119
|
-
// Initialize Supply zone
|
|
120
|
-
const copperPile = new DTBunch('copperPile', duplicateCard(buildCard('COPPER'), 11));
|
|
121
|
-
copperPile.setMeta('cost', cards["COPPER"].cost);
|
|
122
|
-
const silverPile = new DTBunch('silverPile', duplicateCard(buildCard('SILVER'), 11));
|
|
123
|
-
silverPile.setMeta('cost', cards["SILVER"].cost);
|
|
124
|
-
const goldPile = new DTBunch('goldPile', duplicateCard(buildCard('GOLD'), 11));
|
|
125
|
-
goldPile.setMeta('cost', cards["GOLD"].cost);
|
|
126
|
-
|
|
127
|
-
const estatePile = new DTBunch('estatePile', duplicateCard(buildCard('ESTATE'), 7));
|
|
128
|
-
estatePile.setMeta('cost', cards["ESTATE"].cost);
|
|
129
|
-
const duchyPile = new DTBunch('duchyPile', duplicateCard(buildCard('DUCHY'), 7));
|
|
130
|
-
duchyPile.setMeta('cost', cards["DUCHY"].cost);
|
|
131
|
-
const provincePile = new DTBunch('provincePile', duplicateCard(buildCard('PROVINCE'), 7));
|
|
132
|
-
provincePile.setMeta('cost', cards["PROVINCE"].cost);
|
|
133
|
-
|
|
134
|
-
const militiaPile = new DTBunch('militiaPile', duplicateCard(buildCard('MILITIA'), 7));
|
|
135
|
-
militiaPile.setMeta('cost', cards["MILITIA"].cost);
|
|
136
|
-
const smithyPile = new DTBunch('smithyPile', duplicateCard(buildCard('SMITHY'), 7));
|
|
137
|
-
smithyPile.setMeta('cost', cards["SMITHY"].cost);
|
|
138
|
-
const workshopPile = new DTBunch('workshopPile', duplicateCard(buildCard('WORKSHOP'), 7));
|
|
139
|
-
workshopPile.setMeta('cost', cards["WORKSHOP"].cost);
|
|
140
|
-
|
|
141
|
-
manager.addMany([
|
|
142
|
-
copperPile,
|
|
143
|
-
silverPile,
|
|
144
|
-
goldPile,
|
|
145
|
-
estatePile,
|
|
146
|
-
duchyPile,
|
|
147
|
-
provincePile,
|
|
148
|
-
militiaPile,
|
|
149
|
-
smithyPile,
|
|
150
|
-
workshopPile
|
|
151
|
-
], 'supply');
|
|
152
|
-
|
|
153
|
-
// Initialize players
|
|
154
|
-
const players = [
|
|
155
|
-
new DTPlayer('PRIAM'),
|
|
156
|
-
new DTPlayer('ECTESIAM'),
|
|
157
|
-
]
|
|
158
|
-
|
|
159
|
-
// Initialize players deck, discard and hand
|
|
160
|
-
let current = {};
|
|
161
|
-
for (let player of players) {
|
|
162
|
-
const deck = new DTBunch('deck');
|
|
163
|
-
deck.setOwner(player);
|
|
164
|
-
manager.add(deck, 'deck');
|
|
165
|
-
|
|
166
|
-
const discard = new DTBunch('discard');
|
|
167
|
-
discard.setOwner(player);
|
|
168
|
-
manager.add(discard, 'discard');
|
|
169
|
-
|
|
170
|
-
const hand = new DTBunch('hand');
|
|
171
|
-
hand.setOwner(player);
|
|
172
|
-
manager.add(hand, 'hand');
|
|
173
|
-
|
|
174
|
-
const playZone = new DTBunch('playZone');
|
|
175
|
-
playZone.setOwner(player);
|
|
176
|
-
manager.add(playZone, 'playZone');
|
|
177
|
-
|
|
178
|
-
const playerCards = new DTBunch('playerCards', [], { virtualContext: true });
|
|
179
|
-
playerCards.setOwner(player);
|
|
180
|
-
manager.add(playerCards);
|
|
181
|
-
|
|
182
|
-
if (player.getKey() === 'PRIAM') {
|
|
183
|
-
current = {
|
|
184
|
-
player,
|
|
185
|
-
deck,
|
|
186
|
-
hand,
|
|
187
|
-
playZone
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Initialize actions
|
|
193
|
-
const fakeShuffle = (bunch) => {
|
|
194
|
-
const estates = bunch.find({ key: { $eq: 'ESTATE' }});
|
|
195
|
-
const coppers = bunch.find({ key: { $eq: 'COPPER' }});
|
|
196
|
-
|
|
197
|
-
bunch.removeAll();
|
|
198
|
-
bunch.addMany([
|
|
199
|
-
coppers[0],
|
|
200
|
-
estates[0],
|
|
201
|
-
coppers[1],
|
|
202
|
-
estates[1],
|
|
203
|
-
coppers[2],
|
|
204
|
-
estates[2],
|
|
205
|
-
coppers[3],
|
|
206
|
-
coppers[4],
|
|
207
|
-
coppers[5],
|
|
208
|
-
coppers[6],
|
|
209
|
-
])
|
|
210
|
-
};
|
|
211
|
-
const fakeShuffleAction = new DTSimpleAction('shuffle', fakeShuffle, {
|
|
212
|
-
target: 'bunch',
|
|
213
|
-
scopes: ['deck']
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
const drawAction = new DTTransferAction('draw', {
|
|
217
|
-
scopes: ['deck'],
|
|
218
|
-
destinationScope: 'hand'
|
|
219
|
-
});
|
|
220
|
-
|
|
221
|
-
const playAction = new DTTransferAction('play', {
|
|
222
|
-
scopes: ['hand'],
|
|
223
|
-
destinationScope: 'playZone'
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
manager.addAction(fakeShuffleAction);
|
|
227
|
-
manager.addAction(drawAction);
|
|
228
|
-
manager.addAction(playAction);
|
|
229
|
-
|
|
230
|
-
// Return
|
|
231
|
-
return {
|
|
232
|
-
manager,
|
|
233
|
-
current,
|
|
234
|
-
players
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
module.exports = initializeDominionManager
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const transformDataTableToBunchFinderArgs = (table) => {
|
|
3
|
-
const validArgs = ['key', 'id', 'owner', 'scope'];
|
|
4
|
-
const finalArgs = {};
|
|
5
|
-
|
|
6
|
-
for (let [arg, value] of Object.entries(table.rowsHash())) {
|
|
7
|
-
if (validArgs.includes(arg)) {
|
|
8
|
-
finalArgs[arg] = { $eq: value };
|
|
9
|
-
} else {
|
|
10
|
-
if (!finalArgs.meta) {
|
|
11
|
-
finalArgs.meta = {};
|
|
12
|
-
}
|
|
13
|
-
finalArgs.meta[arg] = { $eq: value };
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return finalArgs;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const extractKeysElement = (elements) => {
|
|
21
|
-
return elements.map((element) => element.getKey());
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = {
|
|
25
|
-
transformDataTableToBunchFinderArgs,
|
|
26
|
-
extractKeysElement
|
|
27
|
-
}
|