diff --git a/.vscode/launch.json b/.vscode/launch.json index 1fd0639..4bd377c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,9 +13,9 @@ "request": "launch", "name": "Debug AVA test file in Core", "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/ava", - "runtimeArgs": ["${file}", "--config", "./ava.config-debug.mjs", "--file-line", "${lineNumber}"], + "runtimeArgs": ["${file}", "--config", "../ava.config-debug.mjs", "--file-line", "${lineNumber}"], "outputCapture": "std", - "cwd": "${workspaceFolder}/packages/core-test", + "cwd": "${workspaceFolder}/packages/core/tests", "skipFiles": ["/**/*.js"], "console": "integratedTerminal", "internalConsoleOptions": "neverOpen" diff --git a/package-lock.json b/package-lock.json index 465510d..9317873 100644 --- a/package-lock.json +++ b/package-lock.json @@ -417,10 +417,6 @@ "resolved": "packages/core", "link": true }, - "node_modules/@rpg-village/core-test": { - "resolved": "packages/core-test", - "link": true - }, "node_modules/@rpg-village/web": { "resolved": "packages/web", "link": true @@ -8110,17 +8106,23 @@ "rambda": "7.5.0", "reflect-metadata": "0.1.13", "shortid": "2.2.16", + "ts-node": "10.9.1", "ts-patch": "3.0.0-beta3", "typescript": "5.0.4", "typescript-transform-paths": "3.4.6" }, "devDependencies": { - "@types/shortid": "0.0.29" + "@types/chance": "1.1.3", + "@types/node": "20.1.0", + "@types/shortid": "0.0.29", + "ava": "5.2.0", + "chance": "1.1.11" } }, "packages/core-test": { "name": "@rpg-village/core-test", "version": "1.0.0", + "extraneous": true, "dependencies": { "@rpg-village/core": "1.0.0", "rambda": "7.5.0", @@ -8821,29 +8823,21 @@ "@rpg-village/core": { "version": "file:packages/core", "requires": { + "@types/chance": "1.1.3", + "@types/node": "20.1.0", "@types/shortid": "0.0.29", + "ava": "5.2.0", + "chance": "1.1.11", "inversify": "6.0.1", "rambda": "7.5.0", "reflect-metadata": "0.1.13", "shortid": "2.2.16", + "ts-node": "10.9.1", "ts-patch": "3.0.0-beta3", "typescript": "5.0.4", "typescript-transform-paths": "3.4.6" } }, - "@rpg-village/core-test": { - "version": "file:packages/core-test", - "requires": { - "@rpg-village/core": "1.0.0", - "@types/chance": "1.1.3", - "@types/node": "20.1.0", - "ava": "5.2.0", - "chance": "1.1.11", - "rambda": "7.5.0", - "ts-node": "10.9.1", - "typescript": "5.0.4" - } - }, "@rpg-village/web": { "version": "file:packages/web", "requires": { diff --git a/package.json b/package.json index e080179..e78cc10 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "build": "npm run build:core && npm run build:web", "build:core": "npm run build --prefix packages/core", "build:web": "npm run build --prefix packages/web", - "test:core": "npm run test:watch --prefix packages/core-test", + "test:core": "npm run test:watch --prefix packages/core", "prepare": "for P in packages/*/; do (cd $P && npm run prepare); done" }, "private": true, diff --git a/packages/core-test/.prettierrc b/packages/core-test/.prettierrc deleted file mode 100644 index 495c33f..0000000 --- a/packages/core-test/.prettierrc +++ /dev/null @@ -1,9 +0,0 @@ -{ - "trailingComma": "all", - "printWidth": 120, - "arrowParens": "avoid", - "importOrder": ["ava", "", "^@rpg-village/core", "^[./]"], - "importOrderSeparation": true, - "importOrderParserPlugins": ["typescript", "decorators-legacy"], - "importOrderSortSpecifiers": true -} diff --git a/packages/core-test/ava.config.mjs b/packages/core-test/ava.config.mjs deleted file mode 100644 index af45b3f..0000000 --- a/packages/core-test/ava.config.mjs +++ /dev/null @@ -1,4 +0,0 @@ -export default { - ignoredByWatcher: ["tests"], - files: ["dist/**/*.test.js"], -}; diff --git a/packages/core-test/package.json b/packages/core-test/package.json deleted file mode 100644 index ce609f9..0000000 --- a/packages/core-test/package.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "name": "@rpg-village/core-test", - "version": "1.0.0", - "scripts": { - "build": "tsc", - "build:watch": "tsc --watch", - "test": "ava", - "test:watch": "concurrently 'tsc --watch' 'ava --watch' --default-input-target 1", - "prepare": "true" - }, - "dependencies": { - "rambda": "7.5.0", - "@rpg-village/core": "1.0.0", - "typescript": "5.0.4", - "ts-node": "10.9.1" - }, - "devDependencies": { - "@types/chance": "1.1.3", - "@types/node": "20.1.0", - "ava": "5.2.0", - "chance": "1.1.11" - } -} diff --git a/packages/core-test/tests/commands/buildings/rune-workshop/dismantle-rune.test.ts b/packages/core-test/tests/commands/buildings/rune-workshop/dismantle-rune.test.ts deleted file mode 100644 index e1a004f..0000000 --- a/packages/core-test/tests/commands/buildings/rune-workshop/dismantle-rune.test.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { ItemType, RuneWorkshopCommand } from "@rpg-village/core"; - -import { createState, test } from "../../../utils"; - -test("should empower rune with soul", { - initState: createState(({ village }) => [village({ stash: { resource: { soul: 5 }, items: [{ id: 'rune', itemType: ItemType.Rune, soul: 2 }] } })]), - commands: [ - { - command: RuneWorkshopCommand.DismantleRune, - args: { - runeId: 'rune' - } - }, - ], - expectedState: { village: { stash: { resource: { soul: 7 }, items: [] } } }, -}); diff --git a/packages/core-test/tests/commands/buildings/rune-workshop/empower-rune.test.ts b/packages/core-test/tests/commands/buildings/rune-workshop/empower-rune.test.ts deleted file mode 100644 index cd9c6cb..0000000 --- a/packages/core-test/tests/commands/buildings/rune-workshop/empower-rune.test.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { ItemType, RuneWorkshopCommand } from "@rpg-village/core"; - -import { createState, test } from "../../../utils"; - -test("should empower rune with soul", { - initState: createState(({ village }) => [village({ stash: { resource: { soul: 5 }, items: [{ id: 'rune', itemType: ItemType.Rune, soul: 1 }] } })]), - commands: [ - { - command: RuneWorkshopCommand.EmpowerRune, - args: { - runeId: 'rune', - soul: 1 - } - }, - ], - expectedState: { village: { stash: { resource: { soul: 4 }, items: [{ id: 'rune', itemType: ItemType.Rune, soul: 2 }] } } }, -}); diff --git a/packages/core-test/tsconfig.json b/packages/core-test/tsconfig.json deleted file mode 100644 index 79073cf..0000000 --- a/packages/core-test/tsconfig.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "compilerOptions": { - "baseUrl": "./", - "target": "esnext", - "module": "commonjs", - "moduleResolution": "node", - "sourceMap": true, - "outDir": "./dist" - } -} diff --git a/packages/core-test/ava.config-debug.mjs b/packages/core/ava.config-debug.mjs similarity index 90% rename from packages/core-test/ava.config-debug.mjs rename to packages/core/ava.config-debug.mjs index 8c615ef..1f6cefa 100644 --- a/packages/core-test/ava.config-debug.mjs +++ b/packages/core/ava.config-debug.mjs @@ -2,8 +2,8 @@ import * as fs from "fs"; const defaultSettings = { extensions: ["ts"], - timeout: "100m", - require: ["ts-node/register"], + timeout: "5s", + require: ["ts-node/register", "reflect-metadata"], }; const extraSettings = {}; diff --git a/packages/core/ava.config.mjs b/packages/core/ava.config.mjs new file mode 100644 index 0000000..7c7ce89 --- /dev/null +++ b/packages/core/ava.config.mjs @@ -0,0 +1,5 @@ +export default { + ignoredByWatcher: ["tests/**/*", "src/**/*"], + require: "reflect-metadata", + files: ["dist/**/*.test.js"], +}; diff --git a/packages/core/package.json b/packages/core/package.json index 3bbcd2e..000d9c4 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -4,6 +4,9 @@ "scripts": { "build": "tsc -b ./tsconfig-public-api.json", "build:watch": "tsc -b ./tsconfig-public-api.json --watch", + "build:test": "tsc -b ./tests/tsconfig.json --watch", + "test": "ava", + "test:watch": "ava --watch", "prepare": "ts-patch install -s" }, "dependencies": { @@ -13,10 +16,15 @@ "shortid": "2.2.16", "ts-patch": "3.0.0-beta3", "typescript": "5.0.4", - "typescript-transform-paths": "3.4.6" + "typescript-transform-paths": "3.4.6", + "ts-node": "10.9.1" }, "devDependencies": { - "@types/shortid": "0.0.29" + "@types/chance": "1.1.3", + "@types/shortid": "0.0.29", + "@types/node": "20.1.0", + "ava": "5.2.0", + "chance": "1.1.11" }, "types": "dist/public-api.d.ts", "main": "dist/public-api.js" diff --git a/packages/core/src/modules/map/index.ts b/packages/core/src/modules/map/index.ts index 68605cf..f277130 100644 --- a/packages/core/src/modules/map/index.ts +++ b/packages/core/src/modules/map/index.ts @@ -2,5 +2,5 @@ export * from "./interfaces"; export * from "./map-service"; export * from "./map-store"; export * from "./types"; -export * from "./map-module"; export * from "./party-map-service"; +export * from "./map-module"; diff --git a/packages/core-test/tests/activities/battle.test.ts b/packages/core/tests/activities/battle.test.ts similarity index 96% rename from packages/core-test/tests/activities/battle.test.ts rename to packages/core/tests/activities/battle.test.ts index 42fb9fb..aa1de5f 100644 --- a/packages/core-test/tests/activities/battle.test.ts +++ b/packages/core/tests/activities/battle.test.ts @@ -1,12 +1,7 @@ -import { - AttackEffectType, - BattleActivityType, - EffectType, - ItemType, - RuneAttackEffectType, - UnitType, - VillageConfig, -} from "@rpg-village/core"; +import { UnitType } from "@features/unit"; +import { AttackEffectType, EffectType, ItemType, RuneAttackEffectType } from "@models"; +import { BattleActivityType } from "@modules/battle"; +import { VillageConfig } from "@modules/village"; import { createState, test } from "../utils"; import { equipmentFactory, runeFactory } from "../utils/factories"; diff --git a/packages/core-test/tests/activities/buildings/training-field/train.test.ts b/packages/core/tests/activities/buildings/training-field/train.test.ts similarity index 93% rename from packages/core-test/tests/activities/buildings/training-field/train.test.ts rename to packages/core/tests/activities/buildings/training-field/train.test.ts index 28f5535..e5cfef4 100644 --- a/packages/core-test/tests/activities/buildings/training-field/train.test.ts +++ b/packages/core/tests/activities/buildings/training-field/train.test.ts @@ -1,4 +1,4 @@ -import { TrainingFieldActivity } from "@rpg-village/core"; +import { TrainingFieldActivity } from "@modules/village"; import { createState, test } from "../../../utils"; diff --git a/packages/core-test/tests/activities/manager.test.ts b/packages/core/tests/activities/manager.test.ts similarity index 90% rename from packages/core-test/tests/activities/manager.test.ts rename to packages/core/tests/activities/manager.test.ts index 1123031..c47bfaa 100644 --- a/packages/core-test/tests/activities/manager.test.ts +++ b/packages/core/tests/activities/manager.test.ts @@ -1,4 +1,6 @@ -import { ActivityType, MapActivity, VillageActivity } from "@rpg-village/core"; +import { ActivityType } from "@modules/activity"; +import { MapActivity } from "@modules/map"; +import { VillageActivity } from "@modules/village"; import { createState, test } from "../utils"; diff --git a/packages/core-test/tests/activities/village/build.test.ts b/packages/core/tests/activities/village/build.test.ts similarity index 57% rename from packages/core-test/tests/activities/village/build.test.ts rename to packages/core/tests/activities/village/build.test.ts index 1a1b0fb..b618980 100644 --- a/packages/core-test/tests/activities/village/build.test.ts +++ b/packages/core/tests/activities/village/build.test.ts @@ -1,18 +1,20 @@ -import { VillageActivity, VillageCommand } from "@rpg-village/core"; +import { VillageActivity, VillageCommand } from "@modules/village"; import { test } from "../../utils"; test("should start a build activity when gold is enough", { initState: { village: { stash: { resource: { gold: 100 } }, trainingField: 0 } }, commands: [VillageCommand.BuildTrainingField], - expectedState: (state, t) => t.withRandomId(state.activities, { name: VillageActivity.Build, startArgs: { targetBuilding: 'trainingField' } }), + expectedState: (state, t) => + t.withRandomId(state.activities, { name: VillageActivity.Build, startArgs: { targetBuilding: "trainingField" } }), }); test("should block the second command for building", { initState: { village: { stash: { resource: { gold: 1000 } }, trainingField: 0 } }, commands: [VillageCommand.BuildTrainingField, VillageCommand.BuildTrainingField], expectedState: [ - (state, t) => t.withRandomId(state.activities, { name: VillageActivity.Build, startArgs: { targetBuilding: 'trainingField' } }), - (state, t) => t.deepEqual(state.village, { stash: { resource: { gold: 900 } }, trainingField: 0 }) - ] + (state, t) => + t.withRandomId(state.activities, { name: VillageActivity.Build, startArgs: { targetBuilding: "trainingField" } }), + (state, t) => t.deepEqual(state.village, { stash: { resource: { gold: 900 } }, trainingField: 0 }), + ], }); diff --git a/packages/core-test/tests/activities/village/gather-resource-from-portal.test.ts b/packages/core/tests/activities/village/gather-resource-from-portal.test.ts similarity index 89% rename from packages/core-test/tests/activities/village/gather-resource-from-portal.test.ts rename to packages/core/tests/activities/village/gather-resource-from-portal.test.ts index 7e2aa0e..7bb5b58 100644 --- a/packages/core-test/tests/activities/village/gather-resource-from-portal.test.ts +++ b/packages/core/tests/activities/village/gather-resource-from-portal.test.ts @@ -1,4 +1,4 @@ -import { PortalActivity } from "@rpg-village/core"; +import { PortalActivity } from "@modules/village"; import { createState, test } from "../../utils"; diff --git a/packages/core-test/tests/activities/world/explore.test.ts b/packages/core/tests/activities/world/explore.test.ts similarity index 97% rename from packages/core-test/tests/activities/world/explore.test.ts rename to packages/core/tests/activities/world/explore.test.ts index 0959770..9819133 100644 --- a/packages/core-test/tests/activities/world/explore.test.ts +++ b/packages/core/tests/activities/world/explore.test.ts @@ -1,6 +1,6 @@ import { values } from "rambda"; -import { MapActivity, MapLocationType } from "@rpg-village/core"; +import { MapActivity, MapLocationType } from "@modules/map"; import { createState, test } from "../../utils"; diff --git a/packages/core-test/tests/activities/world/travel.test.ts b/packages/core/tests/activities/world/travel.test.ts similarity index 93% rename from packages/core-test/tests/activities/world/travel.test.ts rename to packages/core/tests/activities/world/travel.test.ts index 5fb4e48..8b1d33a 100644 --- a/packages/core-test/tests/activities/world/travel.test.ts +++ b/packages/core/tests/activities/world/travel.test.ts @@ -1,4 +1,5 @@ -import { ActivityType, MapActivity } from "@rpg-village/core"; +import { ActivityType } from "@modules/activity"; +import { MapActivity } from "@modules/map"; import { createState, stashFactory, test } from "../../utils"; diff --git a/packages/core-test/tests/commands/buildings/blacksmith/create-item.test.ts b/packages/core/tests/commands/buildings/blacksmith/create-item.test.ts similarity index 89% rename from packages/core-test/tests/commands/buildings/blacksmith/create-item.test.ts rename to packages/core/tests/commands/buildings/blacksmith/create-item.test.ts index 523ba49..4e8bb40 100644 --- a/packages/core-test/tests/commands/buildings/blacksmith/create-item.test.ts +++ b/packages/core/tests/commands/buildings/blacksmith/create-item.test.ts @@ -1,4 +1,5 @@ -import { BlacksmithCommand, ItemType } from "@rpg-village/core"; +import { ItemType } from "@models"; +import { BlacksmithCommand } from "@modules/village"; import { createState, test } from "../../../utils"; diff --git a/packages/core-test/tests/commands/buildings/blacksmith/upgrade-item.test.ts b/packages/core/tests/commands/buildings/blacksmith/upgrade-item.test.ts similarity index 95% rename from packages/core-test/tests/commands/buildings/blacksmith/upgrade-item.test.ts rename to packages/core/tests/commands/buildings/blacksmith/upgrade-item.test.ts index fd0f5a6..0f52d07 100644 --- a/packages/core-test/tests/commands/buildings/blacksmith/upgrade-item.test.ts +++ b/packages/core/tests/commands/buildings/blacksmith/upgrade-item.test.ts @@ -1,4 +1,5 @@ -import { AttackEffectType, BlacksmithCommand, EffectType, EquipmentSlot, StashLocation } from "@rpg-village/core"; +import { AttackEffectType, EffectType, EquipmentSlot } from "@models"; +import { BlacksmithCommand, StashLocation } from "@modules/village"; import { createState, test } from "../../../utils"; diff --git a/packages/core-test/tests/commands/buildings/portals/enter-portal.test.ts b/packages/core/tests/commands/buildings/portals/enter-portal.test.ts similarity index 84% rename from packages/core-test/tests/commands/buildings/portals/enter-portal.test.ts rename to packages/core/tests/commands/buildings/portals/enter-portal.test.ts index d861f91..f4097d8 100644 --- a/packages/core-test/tests/commands/buildings/portals/enter-portal.test.ts +++ b/packages/core/tests/commands/buildings/portals/enter-portal.test.ts @@ -1,4 +1,5 @@ -import { MapLocationType, PortalCommand } from "@rpg-village/core"; +import { MapLocationType } from "@modules/map"; +import { PortalCommand } from "@modules/village"; import { createState, test } from "../../../utils"; diff --git a/packages/core-test/tests/commands/buildings/portals/leave-portal.test.ts b/packages/core/tests/commands/buildings/portals/leave-portal.test.ts similarity index 94% rename from packages/core-test/tests/commands/buildings/portals/leave-portal.test.ts rename to packages/core/tests/commands/buildings/portals/leave-portal.test.ts index 530f226..2fa485b 100644 --- a/packages/core-test/tests/commands/buildings/portals/leave-portal.test.ts +++ b/packages/core/tests/commands/buildings/portals/leave-portal.test.ts @@ -1,4 +1,5 @@ -import { MapLocationType, PortalActivity, PortalCommand } from "@rpg-village/core"; +import { MapLocationType } from "@modules/map"; +import { PortalActivity, PortalCommand } from "@modules/village"; import { createState, test } from "../../../utils"; diff --git a/packages/core-test/tests/commands/buildings/portals/open-portal.test.ts b/packages/core/tests/commands/buildings/portals/open-portal.test.ts similarity index 93% rename from packages/core-test/tests/commands/buildings/portals/open-portal.test.ts rename to packages/core/tests/commands/buildings/portals/open-portal.test.ts index 0ad3588..93a0eea 100644 --- a/packages/core-test/tests/commands/buildings/portals/open-portal.test.ts +++ b/packages/core/tests/commands/buildings/portals/open-portal.test.ts @@ -1,6 +1,7 @@ import { values } from "rambda"; -import { AttackEffectType, EffectType, ItemType, PortalCommand } from "@rpg-village/core"; +import { AttackEffectType, EffectType, ItemType } from "@models"; +import { PortalCommand } from "@modules/village"; import { createState, test } from "../../../utils"; diff --git a/packages/core-test/tests/commands/buildings/rune-workshop/create-rune.test.ts b/packages/core/tests/commands/buildings/rune-workshop/create-rune.test.ts similarity index 87% rename from packages/core-test/tests/commands/buildings/rune-workshop/create-rune.test.ts rename to packages/core/tests/commands/buildings/rune-workshop/create-rune.test.ts index 448f6c2..53f5e97 100644 --- a/packages/core-test/tests/commands/buildings/rune-workshop/create-rune.test.ts +++ b/packages/core/tests/commands/buildings/rune-workshop/create-rune.test.ts @@ -1,4 +1,5 @@ -import { ItemType, RuneWorkshopCommand } from "@rpg-village/core"; +import { ItemType } from "@models"; +import { RuneWorkshopCommand } from "@modules/village"; import { createState, test } from "../../../utils"; diff --git a/packages/core/tests/commands/buildings/rune-workshop/dismantle-rune.test.ts b/packages/core/tests/commands/buildings/rune-workshop/dismantle-rune.test.ts new file mode 100644 index 0000000..98bda4d --- /dev/null +++ b/packages/core/tests/commands/buildings/rune-workshop/dismantle-rune.test.ts @@ -0,0 +1,19 @@ +import { ItemType } from "@models"; +import { RuneWorkshopCommand } from "@modules/village"; + +import { createState, test } from "../../../utils"; + +test("should empower rune with soul", { + initState: createState(({ village }) => [ + village({ stash: { resource: { soul: 5 }, items: [{ id: "rune", itemType: ItemType.Rune, soul: 2 }] } }), + ]), + commands: [ + { + command: RuneWorkshopCommand.DismantleRune, + args: { + runeId: "rune", + }, + }, + ], + expectedState: { village: { stash: { resource: { soul: 7 }, items: [] } } }, +}); diff --git a/packages/core/tests/commands/buildings/rune-workshop/empower-rune.test.ts b/packages/core/tests/commands/buildings/rune-workshop/empower-rune.test.ts new file mode 100644 index 0000000..67eb92f --- /dev/null +++ b/packages/core/tests/commands/buildings/rune-workshop/empower-rune.test.ts @@ -0,0 +1,22 @@ +import { ItemType } from "@models"; +import { RuneWorkshopCommand } from "@modules/village"; + +import { createState, test } from "../../../utils"; + +test("should empower rune with soul", { + initState: createState(({ village }) => [ + village({ stash: { resource: { soul: 5 }, items: [{ id: "rune", itemType: ItemType.Rune, soul: 1 }] } }), + ]), + commands: [ + { + command: RuneWorkshopCommand.EmpowerRune, + args: { + runeId: "rune", + soul: 1, + }, + }, + ], + expectedState: { + village: { stash: { resource: { soul: 4 }, items: [{ id: "rune", itemType: ItemType.Rune, soul: 2 }] } }, + }, +}); diff --git a/packages/core-test/tests/commands/buildings/rune-workshop/forge-dungeon-key.test.ts b/packages/core/tests/commands/buildings/rune-workshop/forge-dungeon-key.test.ts similarity index 88% rename from packages/core-test/tests/commands/buildings/rune-workshop/forge-dungeon-key.test.ts rename to packages/core/tests/commands/buildings/rune-workshop/forge-dungeon-key.test.ts index cf64a66..39d1b8c 100644 --- a/packages/core-test/tests/commands/buildings/rune-workshop/forge-dungeon-key.test.ts +++ b/packages/core/tests/commands/buildings/rune-workshop/forge-dungeon-key.test.ts @@ -1,4 +1,5 @@ -import { ItemType, RuneWorkshopCommand } from "@rpg-village/core"; +import { ItemType } from "@models"; +import { RuneWorkshopCommand } from "@modules/village"; import { createState, test } from "../../../utils"; diff --git a/packages/core-test/tests/commands/map/battle.test.ts b/packages/core/tests/commands/map/battle.test.ts similarity index 84% rename from packages/core-test/tests/commands/map/battle.test.ts rename to packages/core/tests/commands/map/battle.test.ts index 51fbf2a..8b213b6 100644 --- a/packages/core-test/tests/commands/map/battle.test.ts +++ b/packages/core/tests/commands/map/battle.test.ts @@ -1,4 +1,6 @@ -import { BattleActivityType, MapCommand, PartyOwner } from "@rpg-village/core"; +import { BattleActivityType } from "@modules/battle"; +import { MapCommand } from "@modules/map"; +import { PartyOwner } from "@modules/party"; import { createState, test } from "../../utils"; diff --git a/packages/core-test/tests/commands/map/explore.test.ts b/packages/core/tests/commands/map/explore.test.ts similarity index 97% rename from packages/core-test/tests/commands/map/explore.test.ts rename to packages/core/tests/commands/map/explore.test.ts index 138a902..93e427f 100644 --- a/packages/core-test/tests/commands/map/explore.test.ts +++ b/packages/core/tests/commands/map/explore.test.ts @@ -1,4 +1,4 @@ -import { MapActivity, MapCommand } from "@rpg-village/core"; +import { MapActivity, MapCommand } from "@modules/map"; import { createState, test } from "../../utils"; diff --git a/packages/core-test/tests/commands/map/travel.test.ts b/packages/core/tests/commands/map/travel.test.ts similarity index 93% rename from packages/core-test/tests/commands/map/travel.test.ts rename to packages/core/tests/commands/map/travel.test.ts index 0dd3597..9eac3a3 100644 --- a/packages/core-test/tests/commands/map/travel.test.ts +++ b/packages/core/tests/commands/map/travel.test.ts @@ -1,4 +1,4 @@ -import { MapActivity, MapCommand } from "@rpg-village/core"; +import { MapActivity, MapCommand } from "@modules/map"; import { createState, test } from "../../utils"; diff --git a/packages/core-test/tests/commands/options/choose-option.test.ts b/packages/core/tests/commands/options/choose-option.test.ts similarity index 94% rename from packages/core-test/tests/commands/options/choose-option.test.ts rename to packages/core/tests/commands/options/choose-option.test.ts index 11a05bc..6aed3d0 100644 --- a/packages/core-test/tests/commands/options/choose-option.test.ts +++ b/packages/core/tests/commands/options/choose-option.test.ts @@ -1,4 +1,4 @@ -import { OptionCommand } from "@rpg-village/core"; +import { OptionCommand } from "@modules/options"; import { createState, test } from "../../utils"; diff --git a/packages/core-test/tests/commands/shop/buy-item.test.ts b/packages/core/tests/commands/shop/buy-item.test.ts similarity index 97% rename from packages/core-test/tests/commands/shop/buy-item.test.ts rename to packages/core/tests/commands/shop/buy-item.test.ts index 376da79..5780119 100644 --- a/packages/core-test/tests/commands/shop/buy-item.test.ts +++ b/packages/core/tests/commands/shop/buy-item.test.ts @@ -1,4 +1,4 @@ -import { ShopCommand } from "@rpg-village/core"; +import { ShopCommand } from "@modules/shop"; import { createState, test } from "../../utils"; diff --git a/packages/core-test/tests/commands/unit/equip.test.ts b/packages/core/tests/commands/unit/equip.test.ts similarity index 95% rename from packages/core-test/tests/commands/unit/equip.test.ts rename to packages/core/tests/commands/unit/equip.test.ts index 009faea..d4f7c44 100644 --- a/packages/core-test/tests/commands/unit/equip.test.ts +++ b/packages/core/tests/commands/unit/equip.test.ts @@ -1,4 +1,5 @@ -import { EquipmentSlot, ItemType, UnitCommand } from "@rpg-village/core"; +import { UnitCommand } from "@features/unit"; +import { EquipmentSlot, ItemType } from "@models"; import { test } from "../../utils"; diff --git a/packages/core-test/tests/commands/unit/unequip.test.ts b/packages/core/tests/commands/unit/unequip.test.ts similarity index 83% rename from packages/core-test/tests/commands/unit/unequip.test.ts rename to packages/core/tests/commands/unit/unequip.test.ts index 5802b3b..db44846 100644 --- a/packages/core-test/tests/commands/unit/unequip.test.ts +++ b/packages/core/tests/commands/unit/unequip.test.ts @@ -1,4 +1,5 @@ -import { EquipmentSlot, StashLocation, UnitCommand } from "@rpg-village/core"; +import { UnitCommand } from "@features/unit"; +import { EquipmentSlot } from "@models"; import { test } from "../../utils"; @@ -32,7 +33,7 @@ test("should add un-equiped item to the unit stash", { commands: [ { command: UnitCommand.UnequipItem, - args: { unitId: "test-hero-id", itemId: "test-item-id", stash: StashLocation.Unit }, + args: { unitId: "test-hero-id", itemId: "test-item-id" }, }, ], expectedState: { diff --git a/packages/core-test/tests/commands/village/build-blacksmith.test.ts b/packages/core/tests/commands/village/build-blacksmith.test.ts similarity index 67% rename from packages/core-test/tests/commands/village/build-blacksmith.test.ts rename to packages/core/tests/commands/village/build-blacksmith.test.ts index 17b2074..17e514e 100644 --- a/packages/core-test/tests/commands/village/build-blacksmith.test.ts +++ b/packages/core/tests/commands/village/build-blacksmith.test.ts @@ -1,4 +1,4 @@ -import { VillageActivity, VillageCommand } from "@rpg-village/core"; +import { VillageActivity, VillageCommand } from "@modules/village"; import { test } from "../../utils"; @@ -9,7 +9,8 @@ const initState = { test("should start building activity with blacksmith", { initState, commands: [VillageCommand.BuildBlacksmith], - expectedState: (state, t) => t.withRandomId(state.activities, { name: VillageActivity.Build, startArgs: { targetBuilding: 'blacksmith' } }), + expectedState: (state, t) => + t.withRandomId(state.activities, { name: VillageActivity.Build, startArgs: { targetBuilding: "blacksmith" } }), }); test("should reduce the village resouce by the blacksmith cost", { diff --git a/packages/core-test/tests/commands/village/build-house.test.ts b/packages/core/tests/commands/village/build-house.test.ts similarity index 66% rename from packages/core-test/tests/commands/village/build-house.test.ts rename to packages/core/tests/commands/village/build-house.test.ts index aa5dea0..71dc7bb 100644 --- a/packages/core-test/tests/commands/village/build-house.test.ts +++ b/packages/core/tests/commands/village/build-house.test.ts @@ -1,4 +1,4 @@ -import { VillageActivity, VillageCommand } from "@rpg-village/core"; +import { VillageActivity, VillageCommand } from "@modules/village"; import { test } from "../../utils"; @@ -9,7 +9,8 @@ const initState = { test("should start a building acitivity for houses", { initState, commands: [VillageCommand.BuildHouse], - expectedState: (state, t) => t.withRandomId(state.activities, { name: VillageActivity.Build, startArgs: { targetBuilding: 'houses' } }), + expectedState: (state, t) => + t.withRandomId(state.activities, { name: VillageActivity.Build, startArgs: { targetBuilding: "houses" } }), }); test("should reduce the village resouce by the house cost", { diff --git a/packages/core-test/tests/commands/village/build-portals.test.ts b/packages/core/tests/commands/village/build-portals.test.ts similarity index 68% rename from packages/core-test/tests/commands/village/build-portals.test.ts rename to packages/core/tests/commands/village/build-portals.test.ts index 7a074d1..8d92db4 100644 --- a/packages/core-test/tests/commands/village/build-portals.test.ts +++ b/packages/core/tests/commands/village/build-portals.test.ts @@ -1,4 +1,4 @@ -import { VillageActivity, VillageCommand } from "@rpg-village/core"; +import { VillageActivity, VillageCommand } from "@modules/village"; import { test } from "../../utils"; @@ -9,7 +9,8 @@ const initState = { test("should start a building activity with portals", { initState, commands: [VillageCommand.BuildPortalSummonerStone], - expectedState: (state, t) => t.withRandomId(state.activities, { name: VillageActivity.Build, startArgs: { targetBuilding: 'portals' } }), + expectedState: (state, t) => + t.withRandomId(state.activities, { name: VillageActivity.Build, startArgs: { targetBuilding: "portals" } }), }); test("should reduce the village resouce by the portals cost", { diff --git a/packages/core-test/tests/commands/village/build-rune-workshop.test.ts b/packages/core/tests/commands/village/build-rune-workshop.test.ts similarity index 67% rename from packages/core-test/tests/commands/village/build-rune-workshop.test.ts rename to packages/core/tests/commands/village/build-rune-workshop.test.ts index 8ef48e6..3b2dc18 100644 --- a/packages/core-test/tests/commands/village/build-rune-workshop.test.ts +++ b/packages/core/tests/commands/village/build-rune-workshop.test.ts @@ -1,4 +1,4 @@ -import { VillageActivity, VillageCommand } from "@rpg-village/core"; +import { VillageActivity, VillageCommand } from "@modules/village"; import { test } from "../../utils"; @@ -9,7 +9,8 @@ const initState = { test("should start a build activity runeWorkshop", { initState, commands: [VillageCommand.BuildRuneWorkshop], - expectedState: (state, t) => t.withRandomId(state.activities, { name: VillageActivity.Build, startArgs: { targetBuilding: 'runeWorkshop' } }), + expectedState: (state, t) => + t.withRandomId(state.activities, { name: VillageActivity.Build, startArgs: { targetBuilding: "runeWorkshop" } }), }); test("should reduce the village resouce by the runeWorkshop cost", { diff --git a/packages/core-test/tests/commands/village/build-training-field.test.ts b/packages/core/tests/commands/village/build-training-field.test.ts similarity index 66% rename from packages/core-test/tests/commands/village/build-training-field.test.ts rename to packages/core/tests/commands/village/build-training-field.test.ts index 70df2e7..1df9503 100644 --- a/packages/core-test/tests/commands/village/build-training-field.test.ts +++ b/packages/core/tests/commands/village/build-training-field.test.ts @@ -1,4 +1,4 @@ -import { VillageActivity, VillageCommand } from "@rpg-village/core"; +import { VillageActivity, VillageCommand } from "@modules/village"; import { test } from "../../utils"; @@ -9,7 +9,8 @@ const initState = { test("should build a trainingField", { initState, commands: [VillageCommand.BuildTrainingField], - expectedState: (state, t) => t.withRandomId(state.activities, { name: VillageActivity.Build, startArgs: { targetBuilding: 'trainingField' } }), + expectedState: (state, t) => + t.withRandomId(state.activities, { name: VillageActivity.Build, startArgs: { targetBuilding: "trainingField" } }), }); test("should reduce the village resouce by the trainingField cost", { diff --git a/packages/core-test/tests/commands/village/hirehero.test.ts b/packages/core/tests/commands/village/hirehero.test.ts similarity index 94% rename from packages/core-test/tests/commands/village/hirehero.test.ts rename to packages/core/tests/commands/village/hirehero.test.ts index 182b80f..e896fad 100644 --- a/packages/core-test/tests/commands/village/hirehero.test.ts +++ b/packages/core/tests/commands/village/hirehero.test.ts @@ -1,4 +1,4 @@ -import { VillageCommand } from "@rpg-village/core"; +import { VillageCommand } from "@modules/village"; import { test } from "../../utils"; diff --git a/packages/core-test/tests/event-handlers/map/new-location.ts b/packages/core/tests/event-handlers/map/new-location.ts similarity index 90% rename from packages/core-test/tests/event-handlers/map/new-location.ts rename to packages/core/tests/event-handlers/map/new-location.ts index 327f747..8010db6 100644 --- a/packages/core-test/tests/event-handlers/map/new-location.ts +++ b/packages/core/tests/event-handlers/map/new-location.ts @@ -1,4 +1,5 @@ -import { EffectType, MapEvent, MiscEffectType } from "@rpg-village/core"; +import { EffectType, MiscEffectType } from "@models"; +import { MapEvent } from "@modules/map"; import { createState, test } from "../../utils"; diff --git a/packages/core-test/tests/game-module.test.ts b/packages/core/tests/game-module.test.ts similarity index 91% rename from packages/core-test/tests/game-module.test.ts rename to packages/core/tests/game-module.test.ts index 0a084c6..1f6c950 100644 --- a/packages/core-test/tests/game-module.test.ts +++ b/packages/core/tests/game-module.test.ts @@ -1,6 +1,6 @@ import test from "ava"; -import { GameState } from "@rpg-village/core"; +import { GameState } from "@core"; import { gameFactory } from "./utils/game-factory"; diff --git a/packages/core/tests/tsconfig.json b/packages/core/tests/tsconfig.json new file mode 100644 index 0000000..91c6ab9 --- /dev/null +++ b/packages/core/tests/tsconfig.json @@ -0,0 +1,34 @@ +{ + "compilerOptions": { + "baseUrl": "./", + "target": "esnext", + "module": "commonjs", + "composite": true, + "moduleResolution": "node", + "sourceMap": true, + "outDir": "../dist/tests", + "rootDir": "../dist/tests", + "paths": { + "@core": ["../dist/core"], + "@game": ["../dist/game"], + "@models": ["../dist/models"], + // "@modules": ["../dist/modules"], + "@modules/*": ["../dist/modules/*"], + "@features": ["../dist/features"], + "@features/*": ["../dist/features/*"] + }, + "plugins": [ + { "transform": "typescript-transform-paths" }, + { "transform": "typescript-transform-paths", "afterDeclarations": true } + ] + }, + "include": ["**/*"], + "references": [ + { "path": "../src/core" }, + { "path": "../src/features" }, + { "path": "../src/lib" }, + { "path": "../src/models" }, + { "path": "../src/modules" }, + { "path": "../src/game" } + ] +} diff --git a/packages/core-test/tests/utils/create-state.ts b/packages/core/tests/utils/create-state.ts similarity index 87% rename from packages/core-test/tests/utils/create-state.ts rename to packages/core/tests/utils/create-state.ts index 031fa3c..abed805 100644 --- a/packages/core-test/tests/utils/create-state.ts +++ b/packages/core/tests/utils/create-state.ts @@ -1,26 +1,14 @@ -import { - Activity, - ActivityID, - BattleID, - BattleStoreState, - GameState, - GeneralGameStoreState, - Map, - MapID, - MapLocation, - MapLocationID, - MapLocationType, - MapSize, - OptionID, - OptionState, - Party, - PartyID, - ShopID, - ShopState, - Unit, - UnitID, - VillageState, -} from "@rpg-village/core"; +import { GameState } from "@core"; + +import { Unit, UnitID } from "@features/unit"; +import { Activity, ActivityID } from "@modules/activity"; +import { BattleID, BattleStoreState } from "@modules/battle"; +import { GeneralGameStoreState } from "@modules/game"; +import { Map, MapID, MapLocation, MapLocationID, MapLocationType } from "@modules/map"; +import { OptionID, OptionState } from "@modules/options"; +import { Party, PartyID } from "@modules/party"; +import { ShopID, ShopState } from "@modules/shop"; +import { VillageState } from "@modules/village"; import { activityFactory, diff --git a/packages/core-test/tests/utils/custom-assertions.ts b/packages/core/tests/utils/custom-assertions.ts similarity index 100% rename from packages/core-test/tests/utils/custom-assertions.ts rename to packages/core/tests/utils/custom-assertions.ts diff --git a/packages/core-test/tests/utils/factories.ts b/packages/core/tests/utils/factories.ts similarity index 86% rename from packages/core-test/tests/utils/factories.ts rename to packages/core/tests/utils/factories.ts index 6fcc2e1..1371ad5 100644 --- a/packages/core-test/tests/utils/factories.ts +++ b/packages/core/tests/utils/factories.ts @@ -1,30 +1,15 @@ import { Chance } from "chance"; -import { - Activity, - ActivityType, - Armor, - BattleStoreState, - GeneralGameStoreState, - ItemStash, - ItemType, - Map, - MapLocation, - MapLocationType, - MapSize, - OptionState, - Party, - PartyActivity, - PartyOwner, - ResourceStash, - Rune, - Shield, - ShopState, - Unit, - UnitType, - VillageState, - Weapon, -} from "@rpg-village/core"; +import { Unit, UnitType } from "@features/unit"; +import { Armor, ItemStash, ItemType, ResourceStash, Rune, Shield, Weapon } from "@models"; +import { Activity, ActivityType } from "@modules/activity"; +import { BattleStoreState } from "@modules/battle"; +import { GeneralGameStoreState } from "@modules/game"; +import { Map, MapLocation, MapLocationType, MapSize } from "@modules/map"; +import { OptionState } from "@modules/options"; +import { Party, PartyOwner } from "@modules/party"; +import { ShopState } from "@modules/shop"; +import { VillageState } from "@modules/village"; const chance = Chance(); diff --git a/packages/core-test/tests/utils/game-factory.ts b/packages/core/tests/utils/game-factory.ts similarity index 75% rename from packages/core-test/tests/utils/game-factory.ts rename to packages/core/tests/utils/game-factory.ts index 687df6e..9ed086d 100644 --- a/packages/core-test/tests/utils/game-factory.ts +++ b/packages/core/tests/utils/game-factory.ts @@ -1,4 +1,5 @@ -import { GameState, ModuleConfig, createGameInstance } from "@rpg-village/core"; +import { GameState, ModuleConfig } from "@core"; +import { createGameInstance } from "@game"; interface GameFactory { state: Partial; diff --git a/packages/core-test/tests/utils/index.ts b/packages/core/tests/utils/index.ts similarity index 100% rename from packages/core-test/tests/utils/index.ts rename to packages/core/tests/utils/index.ts diff --git a/packages/core-test/tests/utils/partial-deep.ts b/packages/core/tests/utils/partial-deep.ts similarity index 100% rename from packages/core-test/tests/utils/partial-deep.ts rename to packages/core/tests/utils/partial-deep.ts diff --git a/packages/core-test/tests/utils/test.ts b/packages/core/tests/utils/test.ts similarity index 94% rename from packages/core-test/tests/utils/test.ts rename to packages/core/tests/utils/test.ts index 8c310ce..f5c3086 100644 --- a/packages/core-test/tests/utils/test.ts +++ b/packages/core/tests/utils/test.ts @@ -1,9 +1,9 @@ import * as ava from "ava"; - +import * as util from "node:util"; import { argv } from "process"; -import * as util from "util"; -import { Command, Event, GameConfig, GameState } from "@rpg-village/core"; +import { Command, Event, GameState } from "@core"; +import { GameConfig } from "@game"; import { ExecutionTestContext, lengthAssertionFactory, withRandomIDAssertionFactory } from "./custom-assertions"; import { gameFactory } from "./game-factory"; diff --git a/packages/core/tsconfig-public-api.json b/packages/core/tsconfig-public-api.json index 8e623ea..f2264f8 100644 --- a/packages/core/tsconfig-public-api.json +++ b/packages/core/tsconfig-public-api.json @@ -2,7 +2,7 @@ "extends": "./tsconfig-base.json", "files": ["./src/public-api.ts"], "compilerOptions": { - "outDir": "./dist/public-api" + "outDir": "./dist" }, "references": [ { "path": "./src/core" },