Skip to content

Commit

Permalink
Add inline actions to objects
Browse files Browse the repository at this point in the history
  • Loading branch information
tiliv committed May 6, 2024
1 parent 189064d commit 3d7aea9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion public/world/Terra Montans.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@
23,40=25,42:Room 3
25,42=23,40:Tavern
28,36:bed
31,39:bed
31,39:bed#Look=The bed seems nice.
28,42:bed
13 changes: 10 additions & 3 deletions src/interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const OptionalAttributes = "(?<attributes>(#[^=]+=[^#]+)*)";

const WORLD_SPEC = RegExp(`^${RowCol}=${NewRowCol}:${Label}/${DataFile}$`);
const DOOR_SPEC = RegExp(`^${RowCol}=${NewRowCol}:${Label}${OptionalAttributes}$`);
const NPC_SPEC = RegExp(`^${RowCol}:${Label}/${DataFile}${OptionalInventory}$`);
const OBJ_SPEC = RegExp(`^${RowCol}:${Label}$`);
const NPC_SPEC = RegExp(`^${RowCol}:${Label}/${DataFile}$`);
const OBJ_SPEC = RegExp(`^${RowCol}:${Label}${OptionalInventory}${OptionalAttributes}$`);

const TYPE_SPECS = {
world: WORLD_SPEC,
Expand Down Expand Up @@ -145,6 +145,13 @@ function amendWorld(target, { inventory }) {
}

function amendObj(target, { inventory }) {
target.Inspect = { name: 'Inspect', text: null };
const { attributes={} } = target;
Object.entries(attributes)
.filter(([name]) => /^[A-Z]/.test(name))
.map(([name, text]) => {
target[name] = { name, text };
})
;
// target.Inspect = { name: 'Inspect', text: null };
return;
}

0 comments on commit 3d7aea9

Please sign in to comment.