Fix issue with research_sync plugin (#502)

* fix type issues on loading technologies and broadcasting progress

* Distinguish Technology and TechnologySync type
This commit is contained in:
Luciole authored and GitHub committed 2023-08-26 16:35:39 +02:00
1 parent 36ced0d3ba
commit 1afbbe04e1
3 files changed
+26 -19

No files matched your search

+6 -6
View File
@@ -88,7 +88,7 @@ export class FinishedEvent {
}
}
export class Technology {
export class TechnologySync {
constructor(
public name: string,
public level: number,
@@ -107,7 +107,7 @@ export class Technology {
return [this.name, this.level, this.progress, this.researched];
}
static fromJSON(json: Static<typeof Technology.jsonSchema>): Technology {
static fromJSON(json: Static<typeof TechnologySync.jsonSchema>): TechnologySync {
return new this(json[0], json[1], json[2], json[3]);
}
}
@@ -120,18 +120,18 @@ export class SyncTechnologiesRequest {
static plugin = "research_sync" as const;
constructor(
public technologies: Technology[]
public technologies: TechnologySync[]
) {
}
static jsonSchema = Type.Array(Technology.jsonSchema);
static jsonSchema = Type.Array(TechnologySync.jsonSchema);
toJSON() {
return this.technologies;
}
static fromJSON(json: Static<typeof SyncTechnologiesRequest.jsonSchema>): SyncTechnologiesRequest {
return new this(json.map(e => Technology.fromJSON(e)));
return new this(json.map(e => TechnologySync.fromJSON(e)));
}
static Response = lib.jsonArray(Technology);
static Response = lib.jsonArray(TechnologySync);
}