-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update EntityFactory types + compiling errors #42
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,51 @@ | ||
{ | ||
"name": "ranvier", | ||
"description": "MUD game engine", | ||
"homepage": "https://ranviermud.com", | ||
"bugs": "https://github.com/Ranvier-TS/core-ts/issues", | ||
"license": "MIT", | ||
"author": "Shawn Biddle (http://shawnbiddle.com), Sean O'Donohue, Brian Nelson", | ||
"version": "3.1.1", | ||
"repository": "github:ranvier-ts/core-ts", | ||
"engines": { | ||
"node": ">= 12.18.2" | ||
}, | ||
"scripts": { | ||
"test": "nyc --reporter=html --reporter=text --include=src --all mocha --recursive", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"prepare": "npm run build", | ||
"build": "tsc", | ||
"project": "npx tsc -p tsconfig.json", | ||
"watch": "tsc --watch --project tsconfig.json", | ||
"prepublish": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json" | ||
}, | ||
"main": "./dist/cjs/index.js", | ||
"types": "./dist/index.d.ts", | ||
"module": "./dist/esm/index.js", | ||
"directory": [ | ||
"./dist/esm" | ||
], | ||
"dependencies": { | ||
"@types/bcryptjs": "^2.4.2", | ||
"@types/commander": "^2.12.2", | ||
"@types/js-yaml": "^3.12.5", | ||
"@types/uuid": "^8.3.0", | ||
"@types/winston": "^2.4.4", | ||
"@types/ws": "^7.4.5", | ||
"bcryptjs": "^2.4.0", | ||
"js-yaml": "^3.12.0", | ||
"pretty-error": "^2.0.2", | ||
"require-dir": "^1.1.0", | ||
"sty": "", | ||
"uuid": "^3.3.2", | ||
"winston": "^2.4.5", | ||
"wrap-ansi": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^14.14.2", | ||
"coveralls": "^3.0.2", | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.1.0", | ||
"typescript": "^4.4.4" | ||
} | ||
"name": "ranvier", | ||
"description": "MUD game engine", | ||
"homepage": "https://ranviermud.com", | ||
"bugs": "https://github.com/Ranvier-TS/core-ts/issues", | ||
"license": "MIT", | ||
"author": "Shawn Biddle (http://shawnbiddle.com), Sean O'Donohue, Brian Nelson", | ||
"version": "3.1.1", | ||
"repository": "github:ranvier-ts/core-ts", | ||
"engines": { | ||
"node": ">= 12.18.2" | ||
}, | ||
"scripts": { | ||
"test": "nyc --reporter=html --reporter=text --include=src --all mocha --recursive", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"prepare": "npm run build", | ||
"build": "tsc", | ||
"project": "npx tsc -p tsconfig.json", | ||
"watch": "tsc --watch --project tsconfig.json", | ||
"prepublish": "tsc -p tsconfig.json && tsc -p tsconfig-cjs.json" | ||
}, | ||
"main": "./dist/cjs/index.js", | ||
"types": "./dist/index.d.ts", | ||
"module": "./dist/esm/index.js", | ||
"directory": [ | ||
"./dist/esm" | ||
], | ||
"dependencies": { | ||
"@types/bcryptjs": "^2.4.2", | ||
"@types/js-yaml": "^3.12.5", | ||
"@types/uuid": "^8.3.0", | ||
"@types/winston": "^2.4.4", | ||
"@types/ws": "^7.4.5", | ||
"bcryptjs": "^2.4.0", | ||
"commander": "^4.1.0", | ||
"js-yaml": "^3.12.0", | ||
"pretty-error": "^2.0.2", | ||
"require-dir": "^1.1.0", | ||
"sty": "", | ||
"uuid": "^3.3.2", | ||
"winston": "^2.4.5", | ||
"wrap-ansi": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^14.14.2", | ||
"coveralls": "^3.0.2", | ||
"mocha": "^5.2.0", | ||
"nyc": "^13.1.0", | ||
"typescript": "^4.4.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,11 +8,10 @@ import { Command, ICommandDef } from './Command'; | |
import { Config } from './Config'; | ||
import { Data } from './Data'; | ||
import { IEffectDef } from './Effect'; | ||
import { EntityFactoryType } from './EntityFactory'; | ||
import { EntityDefinitionBase, EntityFactory } from './EntityFactory'; | ||
import { EntityLoaderKeys, EntityLoaderRegistry } from './EntityLoaderRegistry'; | ||
import { EntityReference } from './EntityReference'; | ||
import { EventListeners } from './EventManager'; | ||
import { GameEntities, GameEntityDefinition } from './GameEntity'; | ||
import { IGameState } from './GameState'; | ||
import { Helpfile } from './Helpfile'; | ||
import { Logger } from './Logger'; | ||
|
@@ -21,6 +20,7 @@ import { QuestGoal } from './QuestGoal'; | |
import { QuestReward } from './QuestReward'; | ||
import { ISkillOptions, Skill } from './Skill'; | ||
import { SkillType } from './SkillType'; | ||
import { EffectableEntity } from './EffectableEntity'; | ||
|
||
export interface IListenersLoader { | ||
listeners: EventListeners; | ||
|
@@ -301,6 +301,8 @@ export class BundleManager { | |
items: [], | ||
npcs: [], | ||
rooms: [], | ||
entityReference: areaName, | ||
id: areaName, | ||
}; | ||
|
||
const scriptPath = this._getAreaScriptPath(bundle, 'area'); | ||
|
@@ -376,11 +378,14 @@ export class BundleManager { | |
* @param {EntityFactory} factory | ||
* @return {Array<string>} | ||
*/ | ||
async loadEntities( | ||
async loadEntities< | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good use of generics here |
||
TEntity extends EffectableEntity, | ||
TDef extends EntityDefinitionBase | ||
>( | ||
bundle: string, | ||
areaName: string, | ||
type: EntityLoaderKeys, | ||
factory: EntityFactoryType | ||
factory: EntityFactory<TEntity, TDef> | ||
): Promise<string[]> { | ||
const loader = this.loaderRegistry.get(type); | ||
loader.setBundle(bundle); | ||
|
@@ -390,7 +395,7 @@ export class BundleManager { | |
return []; | ||
} | ||
|
||
const entities = (await loader.fetchAll()) as GameEntityDefinition[]; | ||
const entities: TDef[] = await loader.fetchAll(); | ||
if (!entities) { | ||
Logger.warn(`\t\t\t${type} has an invalid value [${entities}]`); | ||
return []; | ||
|
@@ -438,8 +443,11 @@ export class BundleManager { | |
* @param {string} entityRef | ||
* @param {string} scriptPath | ||
*/ | ||
loadEntityScript( | ||
factory: EntityFactoryType, | ||
loadEntityScript< | ||
TEntity extends EffectableEntity, | ||
TDef extends EntityDefinitionBase | ||
>( | ||
factory: EntityFactory<TEntity, TDef>, | ||
entityRef: EntityReference, | ||
scriptPath: string | ||
) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had a compile error from commander in the node_modules. We only use the 'types' in core-ts, so just upgraded to the real package (as the types are just a stub) until the error went away.