Skip to content

Commit

Permalink
refactor task 108 to use lib-task
Browse files Browse the repository at this point in the history
  • Loading branch information
customcommander committed Oct 10, 2024
1 parent c92a890 commit fdc23c1
Showing 1 changed file with 16 additions and 32 deletions.
48 changes: 16 additions & 32 deletions src/task-108.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,21 @@
import {base} from './task-lib.js';
/*
@fileoverview
Take x CLay
*/

function replenish(_, game_context) {
game_context.tasks[108].quantity += 1;
return game_context;
}
import task from './lib-task.js';

function collect(_, game_context) {
const {quantity} = game_context.tasks[108];
game_context.supply.clay += quantity;
game_context.tasks[108].quantity = 0;
return game_context;
}


export default base.createMachine({
initial: 'idle',
states: {
idle: {
on: {
'task.replenish': {
actions: [
{type: 'game-update', params: {updater: replenish}},
{type: 'ack'}
]
},
'task.selected': {
actions: [
{type: 'game-update', params: {updater: collect}},
{type: 'task-complete'}
]
}
}
}
export default task({
id: '108',
replenish: (_, game) => {
game.tasks['108'].quantity += 1;
return game;
},
execute: (_, game) => {
const {quantity} = game.tasks['108'];
game.supply.clay += quantity;
game.tasks['108'].quantity = 0;
return game;
}
});

0 comments on commit fdc23c1

Please sign in to comment.