@reldens/game-data-generator 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -29,6 +29,7 @@ class AttributesPerLevel extends GameDataGenerator
|
|
|
29
29
|
// optional:
|
|
30
30
|
this.setBaseAsInitialLevel = sc.get(options, 'setBaseAsInitialLevel', false);
|
|
31
31
|
this.maxLevel = sc.get(options, 'maxLevel', 100);
|
|
32
|
+
this.typeScaleFactorRandom = sc.get(options, 'typeScaleFactorRandom', Math.random());
|
|
32
33
|
this.scaleDivisor = sc.get(options, 'scaleDivisor', 10);
|
|
33
34
|
this.levelDivisor = sc.get(options, 'levelDivisor', 10);
|
|
34
35
|
this.jsonFileName = sc.get(options, 'jsonFileName', 'attributes-per-level-'+this.currentDate+'.json');
|
|
@@ -41,35 +42,38 @@ class AttributesPerLevel extends GameDataGenerator
|
|
|
41
42
|
if(!this.isReady){
|
|
42
43
|
return false;
|
|
43
44
|
}
|
|
44
|
-
// define scale factors for each
|
|
45
|
-
for
|
|
45
|
+
// define scale factors for each type:
|
|
46
|
+
for(let variationType of Object.keys(this.typesVariations)){
|
|
46
47
|
let factor = this.typesVariations[variationType];
|
|
47
|
-
this.typeScaleFactors[variationType] =
|
|
48
|
+
this.typeScaleFactors[variationType] = this.typeScaleFactorRandom * (factor.max - factor.min) + factor.min;
|
|
48
49
|
}
|
|
49
50
|
await this.fileHandler.createFolder(this.generateFolderPath);
|
|
50
51
|
await this.fileHandler.writeFile(
|
|
51
52
|
this.fileHandler.joinPaths(this.generateFolderPath, this.jsonFileName),
|
|
52
|
-
JSON.stringify(
|
|
53
|
+
JSON.stringify({
|
|
54
|
+
statsByVariation: this.generateAttributesData(),
|
|
55
|
+
typeScaleFactorRandom: this.typeScaleFactorRandom
|
|
56
|
+
})
|
|
53
57
|
);
|
|
54
58
|
Logger.info('Data saved! Check the "generated" folder.');
|
|
55
59
|
}
|
|
56
60
|
|
|
57
|
-
|
|
61
|
+
generateAttributesData()
|
|
58
62
|
{
|
|
59
|
-
for
|
|
60
|
-
this.variations[
|
|
61
|
-
this.
|
|
63
|
+
for(let variationType of Object.keys(this.typesVariations)){
|
|
64
|
+
this.variations[variationType] = {};
|
|
65
|
+
this.generateVariation(variationType);
|
|
62
66
|
}
|
|
63
67
|
return this.variations;
|
|
64
68
|
}
|
|
65
69
|
|
|
66
|
-
|
|
70
|
+
generateVariation(variationType)
|
|
67
71
|
{
|
|
68
72
|
let typesKeys = Object.keys(this.typeTemplates);
|
|
69
|
-
for
|
|
70
|
-
this.variations[
|
|
73
|
+
for(let level = 1; level <= this.maxLevel; level ++){
|
|
74
|
+
this.variations[variationType][level] = {};
|
|
71
75
|
for (let typeKey of typesKeys) {
|
|
72
|
-
this.variations[
|
|
76
|
+
this.variations[variationType][level][typeKey] = this.applyTemplate(typeKey, level, variationType);
|
|
73
77
|
}
|
|
74
78
|
}
|
|
75
79
|
}
|