Skip to content

Commit

Permalink
move game and map to features
Browse files Browse the repository at this point in the history
  • Loading branch information
Greegko committed Jun 10, 2023
1 parent 66ea51b commit b80ff19
Show file tree
Hide file tree
Showing 65 changed files with 71 additions and 38 deletions.
1 change: 1 addition & 0 deletions packages/core/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from "./store";
export * from "./command";
export * from "./event";
export * from "./game-state";
export * from "./interfaces";
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { Turn } from "@core";

export interface GeneralGameStoreState {
turn: Turn;
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from "./turn";
export * from "./general-game-store-state";
export * from "./game-command";
5 changes: 5 additions & 0 deletions packages/core/src/features/game/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": "../../../tsconfig-base.json",
"include": ["**/*.ts"],
"references": [{ "path": "../../core" }, { "path": "../activity" }]
}
2 changes: 2 additions & 0 deletions packages/core/src/features/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ export * from "./unit";
export * from "./battle";
export * from "./party";
export * from "./activity";
export * from "./map";
export * from "./game";
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { injectable } from "inversify";
import { append, evolve, find, values } from "rambda";

import { EventSystem } from "@core";
import { EventSystem, Turn } from "@core";

import { EffectStatic } from "@models";
import { Turn } from "@modules/game";

import { Map, MapEvent, MapID, MapLocation, MapLocationID, MapLocationType, MapSize } from "./interfaces";
import { MapLocationStore } from "./map-location-store";
Expand Down
File renamed without changes.
12 changes: 12 additions & 0 deletions packages/core/src/features/map/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../../../tsconfig-base.json",
"include": ["**/*.ts"],
"references": [
{ "path": "../../core" },
{ "path": "../../models" },
{ "path": "../activity" },
{ "path": "../party" },
{ "path": "../game" },
{ "path": "../battle" }
]
}
9 changes: 9 additions & 0 deletions packages/core/src/features/map/types/feature-game.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import "@features/game";

import { MapID } from "../interfaces";

declare module "@features/game" {
export interface GeneralGameStoreState {
worldMapId: MapID;
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import "@core";

import { Map, MapID, MapLocation, MapLocationID } from "../interfaces";

declare module "@core" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./game-state";
export * from "./command";
export * from "./event";
export * from "./feature-game";
9 changes: 8 additions & 1 deletion packages/core/src/features/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{
"extends": "../../tsconfig-base.json",
"include": ["./index.ts"],
"references": [{ "path": "./unit" }, { "path": "./battle" }, { "path": "./party" }, { "path": "./activity" }]
"references": [
{ "path": "./unit" },
{ "path": "./battle" },
{ "path": "./party" },
{ "path": "./activity" },
{ "path": "./game" },
{ "path": "./map" }
]
}
2 changes: 1 addition & 1 deletion packages/core/src/features/unit/interfaces/unit-command.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ItemID } from "@models";

import { UnitID } from ".";
import { UnitID } from "./unit-base";

export enum UnitCommand {
EquipItem = "unit/equip-item",
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/game/create-game-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import { GameInstance } from "./interfaces";
export type CreateGameInstance = (config?: GameConfig) => GameInstance;

const coreModules = [
modules.gameModule,
modules.mapModule,
modules.villageModule,
modules.villageBuildingsModule,
modules.debugModule,
modules.shopModule,
modules.optionsModule,
features.gameModule,
features.mapModule,
features.activityModule,
features.partyModule,
features.battleModule,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/game/game-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { injectable } from "inversify";

import { Command, CommandSystem, Event, EventSystem, GameState } from "@core";

import { GameCommand, GameStore } from "@modules/game";
import { GameCommand, GameStore } from "@features/game";

@injectable()
export class GameController {
Expand Down

This file was deleted.

2 changes: 0 additions & 2 deletions packages/core/src/modules/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import "@core-types";

export * from "./game";
export * from "./village";
export * from "./map";
export * from "./debug";
export * from "./shop";
export * from "./options";
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MapID } from "@modules/map";
import { MapID } from "@features/map";

export type PortalID = string;
export type PortalState = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { injectable } from "inversify";
import { commandHandler } from "@core";

import { ActivityManager } from "@features/activity";
import { MapLocationStore, MapLocationType, MapService, MapSize, PartyMapService } from "@features/map";
import { DungeonKey, EffectStatic } from "@models";
import { MapLocationStore, MapLocationType, MapService, MapSize, PartyMapService } from "@modules/map";
import { PortalActivity, VillageStashService, VillageStore } from "@modules/village";

import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MapLocationID } from "@features/map";
import { PartyID } from "@features/party";
import { ItemID } from "@models";
import { MapLocationID } from "@modules/map";

export enum PortalCommand {
OpenPortal = "portal/open-portal",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/modules/village/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Dependencies
import "@features/battle";
import "@features/map";

export * from "./village-store";
export * from "./village-stash-service";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MapLocationID } from "@features/map";
import { UnitID } from "@features/unit";
import { ItemStash, ResourceStash } from "@models";
import { MapLocationID } from "@modules/map";
import { ShopID } from "@modules/shop";

export type VillageStash = ItemStash & ResourceStash;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/modules/village/village-command-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { append, find, head, values, whereEq } from "rambda";
import { commandHandler } from "@core";

import { ActivityManager, ActivityStore } from "@features/activity";
import { GameCommand, GeneralGameStore } from "@features/game";
import { MapLocationType, MapService, MapSize, PartyMapService } from "@features/map";
import { PartyActivityManager, PartyOwner, PartyService } from "@features/party";
import { UnitStore, isAlive } from "@features/unit";
import { Resource } from "@models";
import { GameCommand, GeneralGameStore } from "@modules/game";
import { MapLocationType, MapService, MapSize, PartyMapService } from "@modules/map";

import { VillageActivity, VillageBuilding, VillageCommand, VillageCommandHealPartyArgs } from "./interfaces";
import { heroFactory, newBuildingCost, newHeroCost } from "./lib";
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/modules/village/village-event-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { complement, prop } from "rambda";
import { ModuleConfig, ModuleConfigToken, eventHandler } from "@core";

import { BattleEvent, BattleFinishedActivityArgs } from "@features/battle";
import { MapEvent, PartyEventArrivedToLocationArgs } from "@features/map";
import { PartyID, PartyService } from "@features/party";
import { isAlive } from "@features/unit";
import { MapEvent, PartyEventArrivedToLocationArgs } from "@modules/map";

import { VillageConfig } from "./interfaces";
import { calculateLoot, calculateXpGain } from "./lib";
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/activities/manager.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ActivityType } from "@features/activity";
import { MapActivity } from "@modules/map";
import { MapActivity } from "@features/map";
import { VillageActivity } from "@modules/village";

import { createState, test } from "../utils";
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/activities/world/explore.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { values } from "rambda";

import { MapActivity, MapLocationType } from "@modules/map";
import { MapActivity, MapLocationType } from "@features/map";

import { createState, test } from "../../utils";

Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/activities/world/travel.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ActivityType } from "@features/activity";
import { MapActivity } from "@modules/map";
import { MapActivity } from "@features/map";

import { createState, stashFactory, test } from "../../utils";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MapLocationType } from "@modules/map";
import { MapLocationType } from "@features/map";
import { PortalCommand } from "@modules/village";

import { createState, test } from "../../../utils";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MapLocationType } from "@modules/map";
import { MapLocationType } from "@features/map";
import { PortalActivity, PortalCommand } from "@modules/village";

import { createState, test } from "../../../utils";
Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/commands/map/battle.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BattleActivityType } from "@features/battle";
import { MapCommand } from "@features/map";
import { PartyOwner } from "@features/party";
import { MapCommand } from "@modules/map";

import { createState, test } from "../../utils";

Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/commands/map/explore.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MapActivity, MapCommand } from "@modules/map";
import { MapActivity, MapCommand } from "@features/map";

import { createState, test } from "../../utils";

Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/commands/map/travel.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MapActivity, MapCommand } from "@modules/map";
import { MapActivity, MapCommand } from "@features/map";

import { createState, test } from "../../utils";

Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/event-handlers/map/new-location.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MapEvent } from "@features/map";
import { EffectType, MiscEffectType } from "@models";
import { MapEvent } from "@modules/map";

import { createState, test } from "../../utils";

Expand Down
4 changes: 2 additions & 2 deletions packages/core/tests/utils/create-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { GameState } from "@core";

import { Activity, ActivityID } from "@features/activity";
import { BattleID, BattleStoreState } from "@features/battle";
import { GeneralGameStoreState } from "@features/game";
import { Map, MapID, MapLocation, MapLocationID, MapLocationType } from "@features/map";
import { Party, PartyID } from "@features/party";
import { Unit, UnitID } from "@features/unit";
import { GeneralGameStoreState } from "@modules/game";
import { Map, MapID, MapLocation, MapLocationID, MapLocationType } from "@modules/map";
import { OptionID, OptionState } from "@modules/options";
import { ShopID, ShopState } from "@modules/shop";
import { VillageState } from "@modules/village";
Expand Down
4 changes: 2 additions & 2 deletions packages/core/tests/utils/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Chance } from "chance";

import { Activity, ActivityType } from "@features/activity";
import { BattleStoreState } from "@features/battle";
import { GeneralGameStoreState } from "@features/game";
import { Map, MapLocation, MapLocationType, MapSize } from "@features/map";
import { Party, PartyOwner } from "@features/party";
import { Unit, UnitType } from "@features/unit";
import { Armor, ItemStash, ItemType, ResourceStash, Rune, Shield, Weapon } from "@models";
import { GeneralGameStoreState } from "@modules/game";
import { Map, MapLocation, MapLocationType, MapSize } from "@modules/map";
import { OptionState } from "@modules/options";
import { ShopState } from "@modules/shop";
import { VillageState } from "@modules/village";
Expand Down

0 comments on commit b80ff19

Please sign in to comment.