Skip to content

Commit

Permalink
fix(command): only take items in the current room, prevent accidental…
Browse files Browse the repository at this point in the history
… pickpocketing (fixes #64)
  • Loading branch information
ssube committed May 23, 2021
1 parent e46165e commit dbb6634
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/service/script/common/ActorStep.ts
Expand Up @@ -257,14 +257,25 @@ export async function ActorStepTake(this: Actor, context: ScriptContext): Promis
const room = mustExist(context.room);
context.logger.debug({ cmd, room }, 'taking item from room');

const valid = new Set(room.items.map((it) => it.meta.id));
const results = searchState(context.state, {
meta: {
name: cmd.target,
},
room: {
id: room.meta.id,
},
}, FUZZY_MATCHERS);
}, {
...FUZZY_MATCHERS,
entity: (entity, search) => {
// exclude own and other's inventory items
if (valid.has(entity.meta.id)) {
return FUZZY_MATCHERS.entity(entity, search);
} else {
return false;
}
},
});

const moving = indexEntity(results, cmd.index, isItem);

Expand Down

0 comments on commit dbb6634

Please sign in to comment.