From 57261e63db833175fdc95b969b9410017d7fc51a Mon Sep 17 00:00:00 2001 From: xangelo Date: Fri, 15 Nov 2024 12:08:07 -0500 Subject: [PATCH] chore(deps): introduce `@shared` path alias --- package-lock.json | 14 +++++++------- package.json | 4 ++-- src/server/admin.ts | 2 +- src/server/api.ts | 8 ++++---- src/server/auth.ts | 4 ++-- src/server/chat-commands.ts | 4 ++-- src/server/dungeon.ts | 4 ++-- src/server/equipment.ts | 4 ++-- src/server/events.ts | 2 +- src/server/fight.ts | 8 ++++---- src/server/inventory.ts | 4 ++-- src/server/items.ts | 2 +- src/server/map.ts | 6 +++--- src/server/monster.ts | 8 ++++---- src/server/player.ts | 6 +++--- src/server/shopEquipment.ts | 2 +- src/server/skills.ts | 2 +- src/server/socket-event.server.ts | 2 +- src/server/views/chat.ts | 2 +- src/server/views/components/stats.ts | 10 +++++----- src/server/views/dungeons/room.ts | 4 ++-- src/server/views/fight.ts | 9 +++++---- src/server/views/inventory.ts | 24 ++++++++++++------------ src/server/views/map.ts | 2 +- src/server/views/monster-selector.ts | 5 ++--- src/server/views/player-bar.ts | 2 +- src/server/views/profile.ts | 4 ++-- src/server/views/repair.ts | 10 +++++----- src/server/views/skills.ts | 2 +- src/server/views/stores.ts | 18 +++++++++--------- src/server/views/travel.ts | 2 +- src/shared/stats.ts | 2 +- tsconfig.json | 8 +++++++- webpack.config.js | 10 ++++++++-- 34 files changed, 106 insertions(+), 94 deletions(-) diff --git a/package-lock.json b/package-lock.json index e3c640c..840c440 100644 --- a/package-lock.json +++ b/package-lock.json @@ -49,7 +49,7 @@ "ts-jest": "^29.1.1", "ts-loader": "^9.4.3", "ts-node": "^10.9.1", - "tsconfig-paths": "^3.14.2", + "tsconfig-paths": "^3.15.0", "tsconfig-paths-webpack-plugin": "^4.0.1", "typescript": "^4.9.5" } @@ -11356,9 +11356,9 @@ } }, "node_modules/tsconfig-paths": { - "version": "3.14.2", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz", - "integrity": "sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==", + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", + "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", "dev": true, "dependencies": { "@types/json5": "^0.0.29", @@ -20410,9 +20410,9 @@ } }, "tsconfig-paths": { - "version": "3.14.2", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz", - "integrity": "sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==", + "version": "3.15.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.15.0.tgz", + "integrity": "sha512-2Ac2RgzDe/cn48GvOe3M+o82pEFewD3UPbyoUHHdKasHwJKjds4fLXWf/Ux5kATBKN20oaFGu+jbElp1pos0mg==", "dev": true, "requires": { "@types/json5": "^0.0.29", diff --git a/package.json b/package.json index f1f0f2b..97f74b9 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "seed": "npx ts-node ./node_modules/knex/bin/cli.js seed:run", "seed:prod": "NODE_ENV=production npm run seed", "dev:client": "npx webpack -w", - "dev": "npx nodemon src/server/api.ts", + "dev": "npx nodemon -r tsconfig-paths/register src/server/api.ts", "prepare": "husky install", "release": "npx standard-version && npm run copy-changelog", "copy-changelog": "cp ./CHANGELOG.md ~/repos/xangelo.ca/static/", @@ -39,7 +39,7 @@ "ts-jest": "^29.1.1", "ts-loader": "^9.4.3", "ts-node": "^10.9.1", - "tsconfig-paths": "^3.14.2", + "tsconfig-paths": "^3.15.0", "tsconfig-paths-webpack-plugin": "^4.0.1", "typescript": "^4.9.5" }, diff --git a/src/server/admin.ts b/src/server/admin.ts index e45466d..f7dbd2e 100644 --- a/src/server/admin.ts +++ b/src/server/admin.ts @@ -1,4 +1,4 @@ -import { Permission } from "../shared/player"; +import { Permission } from "@shared/player"; import { db } from './lib/db'; export async function givePlayerPermission(player_id: string, permission: Permission) { diff --git a/src/server/api.ts b/src/server/api.ts index 45f7992..e4e27db 100644 --- a/src/server/api.ts +++ b/src/server/api.ts @@ -8,15 +8,15 @@ import { rateLimit } from 'express-rate-limit'; import http from 'http'; import { Server, Socket } from 'socket.io'; -import * as CONSTANT from '../shared/constants'; +import * as CONSTANT from '@shared/constants'; import { logger } from './lib/logger'; import { loadPlayer, createPlayer, updatePlayer } from './player'; import { random, each } from 'lodash'; -import {broadcastMessage} from '../shared/message'; -import { Player } from '../shared/player'; +import {broadcastMessage} from '@shared/message'; +import { Player } from '@shared/player'; import {createFight, getMonsterList, getMonsterLocation, getRandomMonster, loadMonster, loadMonsterFromFight} from './monster'; import { addInventoryItem } from './inventory'; -import {FightTrigger, Monster} from '../shared/monsters'; +import {FightTrigger, Monster} from '@shared/monsters'; import {getShopEquipment } from './shopEquipment'; import { getAllPaths, getAllServices, getCityDetails, getService, getTravelPlan, getDungeon } from './map'; import { signup, login, authEndpoint } from './auth'; diff --git a/src/server/auth.ts b/src/server/auth.ts index 9b4a3a4..1d60a50 100644 --- a/src/server/auth.ts +++ b/src/server/auth.ts @@ -1,8 +1,8 @@ -import { Player } from 'shared/player'; +import { Player } from '@shared/player'; import xss from 'xss'; import bcrypt from 'bcrypt'; import { loadPlayer } from './player'; -import { Auth } from '../shared/auth'; +import { Auth } from '@shared/auth'; import { db } from './lib/db'; import { Request, Response } from 'express'; diff --git a/src/server/chat-commands.ts b/src/server/chat-commands.ts index 527e77e..da43c1c 100644 --- a/src/server/chat-commands.ts +++ b/src/server/chat-commands.ts @@ -1,6 +1,6 @@ import { Server, Socket } from 'socket.io'; -import { Player } from '../shared/player'; -import { broadcastMessage } from '../shared/message'; +import { Player } from '@shared/player'; +import { broadcastMessage } from '@shared/message'; import { renderChatMessage } from './views/chat'; import { Commands } from './chat-commands/'; diff --git a/src/server/dungeon.ts b/src/server/dungeon.ts index 33558a9..5bb6652 100644 --- a/src/server/dungeon.ts +++ b/src/server/dungeon.ts @@ -1,5 +1,5 @@ -import { Fight } from "shared/monsters"; -import { Dungeon, DungeonRoom, DungeonPlayer, DungeonState, DungeonStateSummaryVists, DungeonStateSummaryFights } from "../shared/dungeon"; +import { Fight } from "@shared/monsters"; +import { Dungeon, DungeonRoom, DungeonPlayer, DungeonState, DungeonStateSummaryVists, DungeonStateSummaryFights } from "@shared/dungeon"; import { db } from './lib/db'; import { Request, Response } from 'express'; import { ErrorAlert } from "./views/alert"; diff --git a/src/server/equipment.ts b/src/server/equipment.ts index d1a73ba..994aea5 100644 --- a/src/server/equipment.ts +++ b/src/server/equipment.ts @@ -1,6 +1,6 @@ import {db} from "./lib/db"; -import {EquippedItemDetails} from "../shared/equipped"; -import {EquipmentSlot, InventoryItem} from "../shared/inventory"; +import {EquippedItemDetails} from "@shared/equipped"; +import {EquipmentSlot, InventoryItem} from "@shared/inventory"; export async function getEquippedItems(playerId: string): Promise { return db.raw(` diff --git a/src/server/events.ts b/src/server/events.ts index 7b52951..fcbe009 100644 --- a/src/server/events.ts +++ b/src/server/events.ts @@ -1,6 +1,6 @@ import { db } from './lib/db'; import { version } from '../../package.json'; -import { CreatedEvent, Event, EventName } from '../shared/event'; +import { CreatedEvent, Event, EventName } from '@shared/event'; import { isEqual } from 'lodash'; import { logger } from './lib/logger'; import { EVENT_FLUSH_INTERVAL } from '../shared/constants'; diff --git a/src/server/fight.ts b/src/server/fight.ts index b5a04b0..34425f6 100644 --- a/src/server/fight.ts +++ b/src/server/fight.ts @@ -1,4 +1,4 @@ -import { FightRound } from "../shared/fight"; +import { FightRound } from "@shared/fight"; import { clearFight, loadMonster, @@ -23,9 +23,9 @@ import { increaseExp, updateAp, } from "./inventory"; -import { EquippedItemDetails } from "../shared/equipped"; -import { EquipmentSlot, levelFromExp } from "../shared/inventory"; -import { MonsterWithFaction, MonsterForFight, Fight } from "../shared/monsters"; +import { EquippedItemDetails } from "@shared/equipped"; +import { EquipmentSlot, levelFromExp } from "@shared/inventory"; +import { MonsterWithFaction, MonsterForFight, Fight } from "@shared/monsters"; import { getPlayerSkillsAsObject, updatePlayerSkills } from "./skills"; import { SkillID, Skills } from "../shared/skills"; import { Request, Response } from "express"; diff --git a/src/server/inventory.ts b/src/server/inventory.ts index 6c8d44a..560ad30 100644 --- a/src/server/inventory.ts +++ b/src/server/inventory.ts @@ -1,7 +1,7 @@ -import {expToLevel, InventoryItem, levelFromExp, ShopEquipment} from "../shared/inventory"; +import {expToLevel, InventoryItem, levelFromExp, ShopEquipment} from "@shared/inventory"; import { v4 as uuid } from 'uuid'; import { db} from './lib/db'; -import {EquippedItemDetails} from "../shared/equipped"; +import {EquippedItemDetails} from "@shared/equipped"; import { unequipItems } from "./equipment"; export type DbReturnInventoryExp = { diff --git a/src/server/items.ts b/src/server/items.ts index 1811923..fc39bbc 100644 --- a/src/server/items.ts +++ b/src/server/items.ts @@ -1,5 +1,5 @@ import { db } from './lib/db'; -import {Item, PlayerItem, ShopItem} from '../shared/items'; +import {Item, PlayerItem, ShopItem} from '@shared/items'; export async function getShopItems(location_id: number): Promise<(ShopItem & Item)[]> { const res = await db.raw(`select si.*, i.* from shop_items si diff --git a/src/server/map.ts b/src/server/map.ts index 6b99a6c..fb88b0a 100644 --- a/src/server/map.ts +++ b/src/server/map.ts @@ -1,6 +1,6 @@ -import { City, Location, LocationWithCity, Path } from "../shared/map"; -import type { Player } from '../shared/player'; -import type { Travel, TravelWithNames } from '../shared/travel'; +import { City, Location, LocationWithCity, Path } from "@shared/map"; +import type { Player } from "@shared/player"; +import type { Travel, TravelWithNames } from "@shared/travel"; import { db } from './lib/db'; import { random } from 'lodash'; diff --git a/src/server/monster.ts b/src/server/monster.ts index ced4834..c0e6651 100644 --- a/src/server/monster.ts +++ b/src/server/monster.ts @@ -1,9 +1,9 @@ import { db } from './lib/db'; -import { Fight, Monster, MonsterWithFaction, MonsterForList, FightTrigger, MonsterVariant, MonsterVariants } from '../shared/monsters'; -import { TimePeriod, TimeManager } from '../shared/time'; -import { LocationWithCity } from '../shared/map'; +import { Fight, Monster, MonsterWithFaction, MonsterForList, FightTrigger, MonsterVariant, MonsterVariants } from '@shared/monsters'; +import { TimePeriod, TimeManager } from '@shared/time'; +import { LocationWithCity } from '@shared/map'; import { random, sample } from 'lodash'; -import { CHANCE_TO_FIGHT_SPECIAL } from '../shared/constants'; +import { CHANCE_TO_FIGHT_SPECIAL } from '@shared/constants'; const time = new TimeManager(); diff --git a/src/server/player.ts b/src/server/player.ts index 82118e1..ff55ab1 100644 --- a/src/server/player.ts +++ b/src/server/player.ts @@ -1,8 +1,8 @@ import { db } from './lib/db'; -import {Player, maxHp, maxVigor} from "../shared/player"; +import {Player, maxHp, maxVigor} from "@shared/player"; import { random } from 'lodash'; -import { Skills } from '../shared/skills'; -import {Profession} from 'shared/profession'; +import { Skills } from '@shared/skills'; +import {Profession} from '@shared/profession'; import {logger} from './lib/logger'; export async function loadPlayer(authToken: string): Promise { diff --git a/src/server/shopEquipment.ts b/src/server/shopEquipment.ts index ab28a6c..e9aa2f1 100644 --- a/src/server/shopEquipment.ts +++ b/src/server/shopEquipment.ts @@ -1,5 +1,5 @@ import { db } from './lib/db'; -import {ShopEquipment} from '../shared/inventory'; +import {ShopEquipment} from '@shared/inventory'; export function listShopItems(where: Partial): Promise { return db.select('*').from('shop_equipment') diff --git a/src/server/skills.ts b/src/server/skills.ts index 17ef69c..6ee2e19 100644 --- a/src/server/skills.ts +++ b/src/server/skills.ts @@ -1,4 +1,4 @@ -import {Skills, Skill, SkillID} from '../shared/skills'; +import {Skills, Skill, SkillID} from '@shared/skills'; import { db } from './lib/db'; import { each } from 'lodash'; diff --git a/src/server/socket-event.server.ts b/src/server/socket-event.server.ts index a2711f0..bd7022b 100644 --- a/src/server/socket-event.server.ts +++ b/src/server/socket-event.server.ts @@ -1,5 +1,5 @@ import {Server, Socket} from "socket.io"; -import {Player} from "../shared/player"; +import {Player} from "@shared/player"; export type API = { socket: Socket; diff --git a/src/server/views/chat.ts b/src/server/views/chat.ts index bca4f8c..69cc27d 100644 --- a/src/server/views/chat.ts +++ b/src/server/views/chat.ts @@ -1,4 +1,4 @@ -import {Message} from "../../shared/message"; +import {Message} from "@shared/message"; export function renderChatMessage(msg: Message): string { return `
diff --git a/src/server/views/components/stats.ts b/src/server/views/components/stats.ts index 2e313fd..61c3a1e 100644 --- a/src/server/views/components/stats.ts +++ b/src/server/views/components/stats.ts @@ -1,6 +1,6 @@ -import { EquippedItemDetails } from "../../../shared/equipped"; -import { ItemStatBoostAbbr, ShopEquipment } from "../../../shared/inventory"; -import { baseDamage, Player } from "../../../shared/player"; +import { EquippedItemDetails } from "@shared/equipped"; +import { ItemStatBoostAbbr, ShopEquipment } from "@shared/inventory"; +import { baseDamage, Player } from "@shared/player"; export function renderStatBoostWithPlayerIncrease(player: Player, name: ItemStatBoostAbbr, item: ShopEquipment | EquippedItemDetails) { const val = item.boosts.damage; @@ -16,6 +16,6 @@ export function renderStatBoostWithPlayerIncrease(player: Player, name: ItemStat const diff = effectiveDamage - val; // calculate any stat boost from the player - return `${name}: -${valSign}${effectiveDamage}`; + return `
${name}: +${valSign}${effectiveDamage}
`; } diff --git a/src/server/views/dungeons/room.ts b/src/server/views/dungeons/room.ts index a4e3552..e257c05 100644 --- a/src/server/views/dungeons/room.ts +++ b/src/server/views/dungeons/room.ts @@ -1,5 +1,5 @@ -import { DUNGEON_TRAVEL_BLOCK } from '../../../shared/constants'; -import { Dungeon, DungeonPlayer, DungeonRewards, DungeonRoom, DungeonState, DungeonStateSummaryVists } from '../../../shared/dungeon'; +import { DUNGEON_TRAVEL_BLOCK } from '@shared/constants'; +import { Dungeon, DungeonPlayer, DungeonRewards, DungeonRoom, DungeonState, DungeonStateSummaryVists } from '@shared/dungeon'; import { Button, ButtonWithBlock } from '../components/button'; import { Details, Title } from '../components/city'; diff --git a/src/server/views/fight.ts b/src/server/views/fight.ts index 46d962b..b773fba 100644 --- a/src/server/views/fight.ts +++ b/src/server/views/fight.ts @@ -1,9 +1,10 @@ -import { Dungeon } from "shared/dungeon"; -import { FightRound } from "shared/fight"; -import { LocationWithCity } from "shared/map"; -import { Fight, MonsterForFight } from "../../shared/monsters"; +import { Dungeon } from "@shared/dungeon"; +import { FightRound } from "@shared/fight"; +import { LocationWithCity } from "@shared/map"; +import { Fight, MonsterForFight } from "@shared/monsters"; import { Button, ButtonWithBlock } from "./components/button"; import { Details, Title } from "./components/city"; +import { Player } from "@shared/player"; export function renderRoundDetails(roundData: FightRound): string { let html: string[] = roundData.roundDetails.map(d => `
${d}
`); diff --git a/src/server/views/inventory.ts b/src/server/views/inventory.ts index 14cf7a2..ca9cd47 100644 --- a/src/server/views/inventory.ts +++ b/src/server/views/inventory.ts @@ -1,12 +1,12 @@ -import { EquipmentSlot } from "shared/inventory"; -import { EquippedItemDetails } from "../../shared/equipped"; -import { PlayerItem } from "../../shared/items"; +import { EquipmentSlot, meetsRequirements } from "@shared/inventory"; +import { EquippedItemDetails } from "@shared/equipped"; +import { PlayerItem } from "@shared/items"; import { capitalize } from "lodash"; import { ProgressBar } from "./components/progress-bar"; -import { Player } from "../../shared/player"; +import { Player } from "@shared/player"; import { renderStatBoostWithPlayerIncrease } from "./components/stats"; -import { getDurabilityApproximation, expToLevel, levelFromExp } from "../../shared/inventory"; -import { slugify } from "../../shared/utils"; +import { getDurabilityApproximation, expToLevel, levelFromExp } from "@shared/inventory"; +import { slugify } from "@shared/utils"; function icon(icon_name?: string): string { const placeholder = 'https://placehold.co/64x64/af936c/6d5f4d'; @@ -79,19 +79,20 @@ function renderRequirement(name: string, val: number | string, currentVal?: numb if(currentVal && typeof val === 'number') { colorIndicator = currentVal >= val ? 'success' : 'error'; } - return `${name}: ${val.toLocaleString()}`; + return `
${name}: ${val.toLocaleString()}
`; } -function renderStatBoost(name: string, val: number | string): string { +function renderStatBoost(name: string, val: number | string, percent: boolean = false): string { let valSign: string = ''; if(typeof val === 'number') { valSign = val > 0 ? '+' : '-'; } - return `${name}: ${valSign}${val}`; + return `
${name}: ${valSign}${val}${percent ? '%' : ''}
`; } function renderInventoryItem(player: Player, item: EquippedItemDetails , action: (item: EquippedItemDetails) => string): string { const itemLevel = levelFromExp(item.current_exp); + const requirements = meetsRequirements(item, player); return `
@@ -101,7 +102,7 @@ function renderInventoryItem(player: Player, item: EquippedItemDetails , action:
-
${item.name}
+
${item.name} ${item.profession} (REQ)
${item.boosts.defence ? renderStatBoost('DEF', item.boosts.defence) : ''} ${item.boosts.strength ? renderStatBoost('STR', item.boosts.strength) : ''} @@ -109,7 +110,7 @@ function renderInventoryItem(player: Player, item: EquippedItemDetails , action: ${item.boosts.dexterity ? renderStatBoost('DEX', item.boosts.dexterity) : ''} ${item.boosts.intelligence ? renderStatBoost('INT', item.boosts.intelligence) : ''} ${item.boosts.damage ? renderStatBoostWithPlayerIncrease(player, item.affectedSkills.includes('restoration_magic') ? 'HP' : 'DMG', item) : ''} - ${item.boosts.damage_mitigation ? renderStatBoost('MIT', item.boosts.damage_mitigation.toString())+'%' : ''} + ${item.boosts.damage_mitigation ? renderStatBoost('MIT', item.boosts.damage_mitigation.toString(), true) : ''}
${item.requirements.level ? renderRequirement('LVL', item.requirements.level): ''} @@ -117,7 +118,6 @@ function renderInventoryItem(player: Player, item: EquippedItemDetails , action: ${item.requirements.constitution ? renderRequirement('CON', item.requirements.constitution): ''} ${item.requirements.dexterity ? renderRequirement('DEX', item.requirements.dexterity): ''} ${item.requirements.intelligence ? renderRequirement('INT', item.requirements.intelligence): ''} - ${renderRequirement('PRF', item.profession)}
${ProgressBar(item.current_exp - expToLevel(itemLevel), expToLevel(itemLevel + 1) - expToLevel(itemLevel), `exp-${item.item_id}`, { startingColor: '#7be67b', diff --git a/src/server/views/map.ts b/src/server/views/map.ts index 0b6f2c2..45975c2 100644 --- a/src/server/views/map.ts +++ b/src/server/views/map.ts @@ -1,4 +1,4 @@ -import { LocationType, Location, Path, City } from "../../shared/map"; +import { LocationType, Location, Path, City } from "@shared/map"; export async function renderMap(data: { city: City, locations: Location[], paths: Path[]}, closestTown: number): Promise { diff --git a/src/server/views/monster-selector.ts b/src/server/views/monster-selector.ts index 0fc5e5b..80c5179 100644 --- a/src/server/views/monster-selector.ts +++ b/src/server/views/monster-selector.ts @@ -1,6 +1,5 @@ -import { max } from "lodash"; -import { LocationWithCity } from "../../shared/map"; -import { Monster, MonsterForFight } from "../../shared/monsters"; +import { LocationWithCity } from "@shared/map"; +import { Monster, MonsterForFight } from "@shared/monsters"; import { BackToTown } from "./components/button"; export function renderOnlyMonsterSelector(monsters: Monster[] | MonsterForFight[], activeMonsterId: number = 0, location?: LocationWithCity): string { diff --git a/src/server/views/player-bar.ts b/src/server/views/player-bar.ts index 560a71b..aa56799 100644 --- a/src/server/views/player-bar.ts +++ b/src/server/views/player-bar.ts @@ -1,4 +1,4 @@ -import { expToLevel, maxHp, maxVigor, Player } from "../../shared/player"; +import { expToLevel, maxHp, maxVigor, Player } from "@shared/player"; import { ProgressBar } from "./components/progress-bar"; function displayLoginSignupForm(): string { diff --git a/src/server/views/profile.ts b/src/server/views/profile.ts index e6a1c0c..27e2b13 100644 --- a/src/server/views/profile.ts +++ b/src/server/views/profile.ts @@ -1,5 +1,5 @@ -import { EquippedItemDetails } from "../../shared/equipped"; -import { expToLevel, maxHp, maxVigor, Player, StatDef, StatDisplay, totalDefence } from "../../shared/player"; +import { EquippedItemDetails } from "@shared/equipped"; +import { expToLevel, maxHp, maxVigor, Player, StatDef, StatDisplay, totalDefence } from "@shared/player"; function statPointIncreaser(stat: StatDisplay) { return ``; diff --git a/src/server/views/repair.ts b/src/server/views/repair.ts index 9ba994b..fafc28d 100644 --- a/src/server/views/repair.ts +++ b/src/server/views/repair.ts @@ -1,8 +1,8 @@ import { capitalize } from "lodash"; -import { Player } from "../../shared/player"; -import { repairCost } from "../../shared/inventory"; -import { LocationWithCity } from "../../shared/map"; -import { EquippedItemDetails } from "../../shared/equipped"; +import { Player } from "@shared/player"; +import { repairCost } from "@shared/inventory"; +import { LocationWithCity } from "@shared/map"; +import { EquippedItemDetails } from "@shared/equipped"; import { ProgressBar } from "./components/progress-bar"; import * as City from './components/city'; import { BackToTown } from "./components/button"; @@ -17,7 +17,7 @@ function renderStatBoost(name: string, val: number | string): string { function renderRequirement(name: string, val: number | string, currentVal?: number): string { let colorIndicator = ''; - if(currentVal) { + if(currentVal !== undefined && typeof val === 'number') { colorIndicator = currentVal >= val ? 'success' : 'error'; } return `${name}: ${val.toLocaleString()}`; diff --git a/src/server/views/skills.ts b/src/server/views/skills.ts index 8b585f2..941767a 100644 --- a/src/server/views/skills.ts +++ b/src/server/views/skills.ts @@ -1,4 +1,4 @@ -import { Skill, Skills } from "../../shared/skills"; +import { Skill, Skills } from "@shared/skills"; export function renderSkills(skills: Skill[]): string { let html = ` diff --git a/src/server/views/stores.ts b/src/server/views/stores.ts index 8147f96..29c9709 100644 --- a/src/server/views/stores.ts +++ b/src/server/views/stores.ts @@ -1,9 +1,8 @@ -import { ItemStatBoostAbbr, ShopEquipment } from "../../shared/inventory"; -import { ShopItem, Item } from "../../shared/items"; +import { ItemStatBoostAbbr, ShopEquipment } from "@shared/inventory"; +import { ShopItem, Item } from "@shared/items"; import { capitalize, merge } from "lodash"; -import { Player } from "../../shared/player"; -import { LocationWithCity } from "shared/map"; -import { ProgressBar } from "./components/progress-bar"; +import { Player } from "@shared/player"; +import { LocationWithCity } from "@shared/map"; import { BackToTown } from "./components/button"; import { renderStatBoostWithPlayerIncrease } from "./components/stats"; @@ -29,7 +28,7 @@ function renderStatBoost(name: ItemStatBoostAbbr, val: number | string, title?: if(typeof val === 'number') { valSign = val > 0 ? '+' : '-'; } - return `${name}: ${valSign}${val}`; + return `
${name}: ${valSign}${val}
`; } function renderRequirement(name: string, val: number | string, currentVal?: number): string { @@ -37,7 +36,7 @@ function renderRequirement(name: string, val: number | string, currentVal?: numb if (currentVal && typeof val === 'number') { colorIndicator = currentVal >= val ? 'success' : 'error'; } - return `${name}: ${val.toLocaleString()}`; + return `
${name}: ${val.toLocaleString()}
`; } function renderShopItem(item: (ShopItem & Item), action: (item: (ShopItem & Item)) => string): string { @@ -89,8 +88,9 @@ export function renderEquipmentDetails(item: ShopEquipment, player: Player): str function renderShopEquipment(item: ShopEquipment, action: (item: ShopEquipment) => string, player: Player): string { return `
-
-
${action(item)}
+
+
+
${action(item)}
${renderEquipmentDetails(item, player)}
`; diff --git a/src/server/views/travel.ts b/src/server/views/travel.ts index b5f8256..9fcbb47 100644 --- a/src/server/views/travel.ts +++ b/src/server/views/travel.ts @@ -1,4 +1,4 @@ -import { TravelDTO } from "../../shared/map"; +import { TravelDTO } from "@shared/map"; import { ProgressBar } from './components/progress-bar'; import { ButtonWithBlock } from './components/button'; diff --git a/src/shared/stats.ts b/src/shared/stats.ts index 14ae4fd..c060287 100644 --- a/src/shared/stats.ts +++ b/src/shared/stats.ts @@ -5,4 +5,4 @@ export enum Stat { intelligence = 'intelligence' }; -export type STAT_ABR = 'STR' | 'CON' | 'DEX' | 'INT'; +export type STAT_ABR = 'STR' | 'CON' | 'DEX' | 'INT'; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index fa4cf87..7d2e2b5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,12 +7,18 @@ "removeComments": true, "preserveConstEnums": true, "sourceMap": true, - "baseUrl": "src", + "baseUrl": ".", "outDir": "dist", "emitDecoratorMetadata": true, "experimentalDecorators": true, "resolveJsonModule": true, "typeRoots": ["./src/types"], + "paths": { + "@shared/*": ["src/shared/*"], + "@server/*": ["src/server/*"], + "@client/*": ["src/client/*"], + "@assets/*": ["public/assets/*"] + } }, "include": ["src/server/api.ts"] } diff --git a/webpack.config.js b/webpack.config.js index d55a9dc..d7a8656 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -29,7 +29,13 @@ module.exports = { extensions: [".ts", ".tsx", ".js"], plugins: [ new tsconfigPaths() - ] + ], + alias: { + '@shared': path.resolve(__dirname, 'src/shared/'), + '@server': path.resolve(__dirname, 'src/server/'), + '@client': path.resolve(__dirname, 'src/client/'), + '@assets': path.resolve(__dirname, 'public/assets/') + } }, output: { filename: "bundle.js", @@ -38,5 +44,5 @@ module.exports = { performance: { maxEntrypointSize: 512000, maxAssetSize: 512000 - }, + }, }; -- 2.25.1