Fix location share

This commit is contained in:
Aslan 2026-01-23 09:18:11 -05:00
parent 77f74ccb08
commit 5f168fc067
3 changed files with 13 additions and 11 deletions

View file

@ -113,7 +113,7 @@ const onStatus = (_text: string, roomId: string, sender: string) => {
<li><b>Race:</b> ${race.name}</li>
<li><b>Location:</b> ${location.name}</li>
<li><b>Level:</b> ${level.level} - ${level.experienceInLevel}/${level.experienceToNextLevel} exp</li>
<li><b>Health:</b> ${entity.health}/${getMaxHealth(entity)} (${getHealthPercentage(entity)}%)</li>
<li><b>Health:</b> ${entity.health.toFixed(0)}/${getMaxHealth(entity)} (${getHealthPercentage(entity).toFixed(0)}%)</li>
<li><b>Vitality:</b> ${entity.vitality}</li>
<li><b>Strength:</b> ${entity.strength}</li>
<li><b>Endurance:</b> ${entity.endurance}</li>
@ -143,7 +143,7 @@ const onInventory = (text: string, roomId: string, sender: string) => {
const totalStats = getTotalStats(item);
const mapDamage = (stat: IStat): string => {
return `<li><b>Damage type:</b> ${stat.damageType}</li><li><b>Damage:</b> ${stat.damage}</li>`;
return `<li><b>Damage type:</b> ${stat.damageType}</li><li><b>Damage:</b> ${stat.damage.toFixed(0)}</li>`;
};
const mapAbility = (stat: IStat): string => {
@ -160,8 +160,8 @@ const onInventory = (text: string, roomId: string, sender: string) => {
<li><b>Value:</b> ${item.value}</li>
<li><b>Type:</b> ${item.type}</li>
<li><b>Rarity:</b> ${item.rarity}</li>
<li><b>Total damage:</b> ${totalStats.damage}</li>
<li><b>Total defence:</b> ${totalStats.defense}</li>
<li><b>Total damage:</b> ${totalStats.damage.toFixed(0)}</li>
<li><b>Total defence:</b> ${totalStats.defense.toFixed(0)}</li>
</ul>
<p>Damage:</p>
<ul>
@ -201,10 +201,10 @@ const onLocation = (_text: string, roomId: string, sender: string) => {
"",
`<p>Location info:</p>
<ul>
<li><b>X:</b> ${location.X}</li>
<li><b>Y:</b> ${location.Y}</li>
<li><b>Location Name:</b> ${location.name}</li>
<li><b>Location Description:</b> ${location.description}</li>
<li><b>Local X:</b> ${location.X}</li>
<li><b>Local Y:</b> ${location.Y}</li>
</ul>`,
);
};

View file

@ -97,7 +97,9 @@ const getNpc = (id: NPC): INPC => {
};
const getNpcByName = (name: string): INPC => {
const npc = npcs.find((npc) => npc.id === name);
const npc = npcs.find(
(npc) => npc.name.toLowerCase() === name.toLowerCase(),
);
return npc ? npc : npcBecky;
};
@ -155,16 +157,16 @@ const getLevel = (experience: number): ILevel => {
};
const getMaxHealth = (entity: IEntity): number => {
return entity.vitality * 10;
return 100 + entity.vitality * 10;
};
const getHealthPercentage = (entity: IPlayer | INPC): number => {
if ("health" in entity) {
return entity.health / getMaxHealth(entity);
return (entity.health / getMaxHealth(entity)) * 100;
}
const npcData = getNpcData(entity.id);
return npcData.health / getMaxHealth(entity);
return (npcData.health / getMaxHealth(entity)) * 100;
};
const getSpeed = (entity: IEntity) => {

View file

@ -75,7 +75,7 @@ export const npcBecky: INPC = {
export const npcTato: INPC = {
id: NPC.TATO,
name: "Tato",
description: "A ",
description: "A drunk troll",
race: Race.TROLL,
location: Location.HIGHMERE_TAVERN,
inventory: {