Location commands

This commit is contained in:
Aslan 2026-01-20 20:16:47 -05:00
parent e7859248d7
commit 2bfce22530

View file

@ -39,8 +39,8 @@ const registerModuleGame = (
callbackFunc: onLocation, callbackFunc: onLocation,
}); });
callbackStore.messageCallbacks.push({ callbackStore.messageCallbacks.push({
startConditions: [`${gamePrefix} locations`], startConditions: [`${gamePrefix} nearby`],
callbackFunc: onLocations, callbackFunc: onNearby,
}); });
}; };
@ -54,7 +54,7 @@ const onHelp = (_text: string, roomId: string) => {
<li><b>!game inventory</b> - Shows your inventory</li> <li><b>!game inventory</b> - Shows your inventory</li>
<li><b>(WIP) !game inventory {index}</b> - Shows information about an item in your inventory</li> <li><b>(WIP) !game inventory {index}</b> - Shows information about an item in your inventory</li>
<li><b>!game location</b> - Shows information about your current location</li> <li><b>!game location</b> - Shows information about your current location</li>
<li><b>!game locations</b> - Shows nearby locations</li> <li><b>!game nearby</b> - Shows nearby locations</li>
<li><b>(WIP) !game travel {location}</b> - Travel to a location</li> <li><b>(WIP) !game travel {location}</b> - Travel to a location</li>
<li><b>(WIP) !game talk {entity}</b> - Talk to an entity</li> <li><b>(WIP) !game talk {entity}</b> - Talk to an entity</li>
<li><b>(WIP) !game fight {entity}</b> - Fight an entity</li> <li><b>(WIP) !game fight {entity}</b> - Fight an entity</li>
@ -99,7 +99,7 @@ const onInventory = (_text: string, roomId: string, sender: string) => {
const mapItem = (item: IItem, index: number): string => { const mapItem = (item: IItem, index: number): string => {
const fullName = getFullItemName(item); const fullName = getFullItemName(item);
return `<b>(${index})</b> ${fullName}, `; return `<b>(${index})</b> ${fullName}`;
}; };
client.sendHtmlMessage( client.sendHtmlMessage(
@ -107,7 +107,7 @@ const onInventory = (_text: string, roomId: string, sender: string) => {
"", "",
`<p>Your inventory (${player.name})</p> `<p>Your inventory (${player.name})</p>
<ul> <ul>
${player.inventory.items.map(mapItem)} ${player.inventory.items.map(mapItem).join(",")}
</ul>`, </ul>`,
); );
}; };
@ -129,7 +129,7 @@ const onLocation = (_text: string, roomId: string, sender: string) => {
); );
}; };
const onLocations = (_text: string, roomId: string, sender: string) => { const onNearby = (_text: string, roomId: string, sender: string) => {
const player = getPlayerById(sender); const player = getPlayerById(sender);
const location = getLocation(player.location); const location = getLocation(player.location);
@ -145,7 +145,7 @@ const onLocations = (_text: string, roomId: string, sender: string) => {
"", "",
`<p>There are ${location.childLocations.length} locations around you (${player.name})</p> `<p>There are ${location.childLocations.length} locations around you (${player.name})</p>
<ul> <ul>
${location.childLocations.map(mapLocation)} ${location.childLocations.map(mapLocation).join("\n")}
</ul>`, </ul>`,
); );
}; };