diff --git a/test/acceptance/replenish.feature b/test/acceptance/replenish.feature new file mode 100644 index 0000000..80041ae --- /dev/null +++ b/test/acceptance/replenish.feature @@ -0,0 +1,41 @@ +Feature: Replenish + +Scenario: Game automatically replenishes stock + Given I start playing + Then I have the following stock on the board + | Stock | Quantity | + | Wood | 2 | + | Clay | 1 | + | Reed | 1 | + | Food | 1 | + + # Turn 1 + When I select "Take 1 Grain" + And I select "Day Laborer" + Then I have the following stock on the board + | Stock | Quantity | + | Wood | 4 | + | Clay | 2 | + | Reed | 2 | + | Food | 2 | + + # Turn 2 + When I select "Take 1 Grain" + And I select "Day Laborer" + Then I have the following stock on the board + | Stock | Quantity | + | Wood | 6 | + | Clay | 3 | + | Reed | 3 | + | Food | 3 | + + # Turn 3 + When I select "Take 1 Grain" + And I select "Day Laborer" + Then I have the following stock on the board + | Stock | Quantity | + | Wood | 8 | + | Clay | 4 | + | Reed | 4 | + | Food | 4 | + diff --git a/test/acceptance/steps.js b/test/acceptance/steps.js index 5a3fd9b..85d27c1 100644 --- a/test/acceptance/steps.js +++ b/test/acceptance/steps.js @@ -4,20 +4,28 @@ import { Then } from '@cucumber/cucumber'; +const task_map = { + 'Day Laborer' : 106, + 'Plow 1 Field' : 104, + 'Sow and/or Bake bread': 113, + 'Take 1 Grain' : 103, + 'Take x Clay' : 108, + 'Take x Reed' : 109, + 'Take x Wood' : 107, +}; + +const stock_map = { + 'Clay': 108, + 'Food': 110, + 'Reed': 109, + 'Wood': 107, +} + Given('I start playing', async function () { await this.start(); }); When('I select {string}', async function (selection) { - const task_map = { - 'Take 1 Grain' : 103, - 'Plow 1 Field' : 104, - 'Take x Wood' : 107, - 'Take x Clay' : 108, - 'Take x Reed' : 109, - 'Sow and/or Bake bread': 113 - }; - await this.send({type: 'task.selected', task_id: task_map[selection]}); }); @@ -44,3 +52,11 @@ Then('the current turn is {int}', async function (expected_turn) { await this.assert(({turn}) => turn === expected_turn); }); +Then('I have the following stock on the board', async function (table) { + await this.assert(game => table.hashes().every(({Stock, Quantity}) => { + const task_id = stock_map[Stock]; + const {quantity} = game.tasks[task_id]; + return quantity === Number(Quantity); + })); +}); +