Skip to content

Commit

Permalink
update:(ScriptBase) add IS_SCRIPTBASE static
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieuLivebardon authored and LorenzoMarnat committed Jun 14, 2023
1 parent 5b99e91 commit d1ab204
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/shared/src/Game/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const Context = class {
for (const key in object) {
const value = object[key];

if (value.prototype instanceof ScriptBase) {
if (value.IS_SCRIPTBASE) {
if (result[value.ID_SCRIPT])
throw new Error('no unique id ' + value.ID_SCRIPT);
result[value.ID_SCRIPT] = value;
Expand Down Expand Up @@ -693,8 +693,13 @@ const ScriptBase = class {
onCommand(type, data) {}

static get ID_SCRIPT() {
console.error(this.name);
throw new Error('this is abstract class you should override ID_SCRIPT');
}

static get IS_SCRIPTBASE() {
return true;
}
};

module.exports = {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/Game/ScriptTemplate/AbstractMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ module.exports = class AbstractMap extends ScriptBase {
}

static get ID_SCRIPT() {
return 'abstract_map_id';
return 'map_id';
}
};

0 comments on commit d1ab204

Please sign in to comment.