Skip to content

Commit

Permalink
migrate tasks to lib-task
Browse files Browse the repository at this point in the history
  • Loading branch information
customcommander committed Oct 10, 2024
1 parent fdc23c1 commit 203628a
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 144 deletions.
45 changes: 15 additions & 30 deletions src/task-109.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,22 @@
import {base} from './task-lib.js';
/*
function replenish(_, game_context) {
game_context.tasks[109].quantity += 1;
return game_context;
}
Take x Reed
function collect(_, game_context) {
const {quantity} = game_context.tasks[109];
game_context.supply.reed += quantity;
game_context.tasks[109].quantity = 0;
return game_context;
}
*/

import task from './lib-task.js';

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: '109',
replenish: (_, game) => {
game.tasks[109].quantity += 1;
return game;
},
execute: (_, game) => {
const {quantity} = game.tasks[109];
game.supply.reed += quantity;
game.tasks[109].quantity = 0;
return game;
}
});

46 changes: 16 additions & 30 deletions src/task-110.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,22 @@
import {base} from './task-lib.js';
/*
function replenish(_, game_context) {
game_context.tasks[110].quantity += 1;
return game_context;
}
Fishing
Take x Food
function collect(_, game_context) {
const {quantity} = game_context.tasks[110];
game_context.supply.food += quantity;
game_context.tasks[110].quantity = 0;
return game_context;
}
*/
import task from './lib-task.js';

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: '110',
replenish: (_, game) => {
game.tasks[110].quantity += 1;
return game;
},
execute: (_, game) => {
const {quantity} = game.tasks[110];
game.supply.food += quantity;
game.tasks[110].quantity = 0;
return game;
}
});

29 changes: 11 additions & 18 deletions src/task-111.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import {base} from './task-lib.js';
/*
export default base.createMachine({
initial: 'idle',
states: {
idle: {
on: {
'task.selected': {
actions: {
type: 'abort',
params: {
task_id: 111,
err: 'TODO'
}
}
}
}
}
}
Fences
*/

import task from './lib-task.js';

export default task({
id: '111',
todo: true
});

29 changes: 11 additions & 18 deletions src/task-112.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
import {base} from './task-lib.js';
/*
export default base.createMachine({
initial: 'idle',
states: {
idle: {
on: {
'task.selected': {
actions: {
type: 'abort',
params: {
task_id: 112,
err: 'TODO'
}
}
}
}
}
}
Major Improvement
*/

import task from './lib-task.js';

export default task({
id: '112',
todo: true
});

38 changes: 9 additions & 29 deletions src/task-114.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,15 @@
*/

import {base} from './task-lib.js';
import task from './lib-task.js';

function replenish(_, game_context) {
game_context.tasks[114].quantity += 1;
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: 'abort',
params: {
task_id: 114,
err: 'TODO'
}
}
}
}
}
export default task({
id: '114',
todo: true,
replenish: (_, game) => {
game.tasks[114].quantity += 1;
return game;
}
});
})


26 changes: 7 additions & 19 deletions src/task-115.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,13 @@
/*
Family growth
Family growth
*/

import {base} from './task-lib.js';
import task from './lib-task.js';

export default base.createMachine({
initial: 'idle',
states: {
idle: {
on: {
'task.selected': {
actions: {
type: 'abort',
params: {
task_id: 115,
err: 'TODO'
}
}
}
}
}
}
export default task({
id: '115',
todo: true
});

0 comments on commit 203628a

Please sign in to comment.