diff --git a/src/game.js b/src/game.js index 979892c..e6511da 100644 --- a/src/game.js +++ b/src/game.js @@ -332,12 +332,12 @@ const machine = src.createMachine({ }, "feed": { "after": { - "200": "breed" + "50": "breed" } }, "breed": { "after": { - "200": "done" + "50": "done" } }, "done": { diff --git a/src/task-104.js b/src/task-104.js index ff3ff1a..9265d65 100644 --- a/src/task-104.js +++ b/src/task-104.js @@ -1,7 +1,7 @@ import {base} from './task-lib.js'; function plow({params}, game_context) { - const {space_id} = params; + const {space_id} = params; // throw if undefined? game_context.farmyard[space_id] = {type: 'field'}; return game_context; } diff --git a/src/task-113.js b/src/task-113.js index 335d8ca..20102f5 100644 --- a/src/task-113.js +++ b/src/task-113.js @@ -27,14 +27,7 @@ const machine = base.createMachine({ 'task.selected': [ { target: 'select-space', - guard: and(['has-empty-fields?', or(['has-grain?', 'has-vegetable?'])]), - actions: { - type: 'display-selection', - params: { - task_id: 113, - opts: ['select.sow'] - } - } + guard: and(['has-empty-fields?', or(['has-grain?', 'has-vegetable?'])]) }, { actions: { diff --git a/test/acceptance/001.feature b/test/acceptance/001.feature index 96c2371..6ee6096 100644 --- a/test/acceptance/001.feature +++ b/test/acceptance/001.feature @@ -1,8 +1,47 @@ -Feature: +Feature: Harvest - Field Phase -Scenario: Turns +Scenario: Fields are automatically harvested Given I start playing - Then the current turn is 1 - When I select "Take 1 Grain" - And I select "Take x Wood" - Then the current turn is 2 \ No newline at end of file + + # Turn 1 + * I select "Take 1 Grain" + * I select "Plow 1 Field" + * I plow A1 + + # Turn 2 + * I select "Take 1 Grain" + * I select "Plow 1 Field" + * I plow A2 + + # Turn 3 + * I select "Sow and/or Bake bread" + * I sow grain on A1 + * I sow grain on A2 + * I select "Take x Wood" + + # Turn 4 + * I select "Take x Clay" + * I select "Take x Reed" + + # Harvest + Then I have 2 grain in my supply + And I have 2 grain on A1 + And I have 2 grain on A2 + + # Turn 5 + * I select "Take x Clay" + * I select "Take x Reed" + + # Turn 6 + * I select "Take x Clay" + * I select "Take x Reed" + + # Turn 7 + * I select "Take x Clay" + * I select "Take x Reed" + + # Harvest + Then I have 4 grain in my supply + And I have 1 grain on A1 + And I have 1 grain on A2 + diff --git a/test/acceptance/steps.js b/test/acceptance/steps.js index d5d6226..5a3fd9b 100644 --- a/test/acceptance/steps.js +++ b/test/acceptance/steps.js @@ -10,15 +10,36 @@ Given('I start playing', async function () { When('I select {string}', async function (selection) { const task_map = { - 'Take 1 Grain': 103, - 'Take x Wood': 107, - 'Take x Clay': 108, - 'Take x Reed': 109 + '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]}); }); +Then('I plow {word}', async function (space_id) { + await this.send({type: 'select.plow', task_id: '104', space_id}); +}); + +Then('I sow grain on {word}', async function (space_id) { + await this.send({type: 'select.sow-grain', task_id: '113', space_id}); +}); + +Then('I have {int} {word} in my supply', async function (quantity, type) { + await this.assert(({supply}) => supply[type] === quantity); +}); + +Then('I have {int} {word} on {word}', async function (quantity, type, space_id) { + await this.assert(({farmyard}) => { + const space = farmyard[space_id]; + return space[type] === quantity; + }); +}); + Then('the current turn is {int}', async function (expected_turn) { await this.assert(({turn}) => turn === expected_turn); }); diff --git a/test/acceptance/world.js b/test/acceptance/world.js index 12ef846..a0a186f 100644 --- a/test/acceptance/world.js +++ b/test/acceptance/world.js @@ -11,12 +11,12 @@ setWorldConstructor(class extends World { async start() { this.game = game(); this.game.start(); - await this.wait(200); + await this.wait(250); } async send(ev) { + await this.wait(250); this.game.send(ev); - await this.wait(200); } async wait(ms) {