Skip to content

Commit

Permalink
refactor error code management when aborting
Browse files Browse the repository at this point in the history
  • Loading branch information
customcommander committed Oct 11, 2024
1 parent 2fa3919 commit 37af455
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/lib-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ const lib = setup({
})),

'task-abort':
sendTo(gamesys, (_, {task_id, err}) => ({
sendTo(gamesys, ({event}, {task_id, err}) => ({
type: 'task.aborted',
task_id,
err
err: event.response || err || 'NOT_ENOUGH_RESOURCES'
})),

'task-ack':
Expand Down Expand Up @@ -208,7 +208,6 @@ export default function (definitions) {
type: 'task-abort',
params: {
task_id: id,
err: 'NOT_ENOUGH_RESOURCES'
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/messages_en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ action_ok: Ok

# Errors

NOTHING_TO_SOW: >
You have no grains and no vegetables.
NOT_ENOUGH_RESOURCES: >
You do not have all the resources
to complete this action.
Expand Down
5 changes: 3 additions & 2 deletions src/task-113.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ export default task({
check: (_, game) => {
const {supply: {grain, vegetable}, farmyard} = game;

// TODO: specific error code
if (!grain && !vegetable) return false;
if (!grain && !vegetable) {
return 'NOTHING_TO_SOW';
}

const spaces = Object.values(farmyard);

Expand Down

0 comments on commit 37af455

Please sign in to comment.