Skip to content

Commit

Permalink
key cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rsek committed Sep 27, 2022
1 parent 9dd839b commit f95c861
Show file tree
Hide file tree
Showing 25 changed files with 8,521 additions and 8,514 deletions.
2 changes: 1 addition & 1 deletion _master-data/Starforged/Encounters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Source:
Authors:
- Shawn Tomkin
Title: "ironsworn: starforged rulebook"
Title: "Ironsworn: Starforged rulebook"
License: https://creativecommons.org/licenses/by-nc-sa/4.0/
Date: "050622"
Encounters:
Expand Down
2 changes: 1 addition & 1 deletion dataforged-tools/src/builders/assets/AssetBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class AssetBuilder extends SourceInheritorBuilder implements Asset {
if (yaml.Abilities.length !== 3) {
throw badJsonError(this.constructor, yaml.Abilities, `Asset ${this.$id} doesn't have 3 abilities!`);
} else {
this.Abilities = yaml.Abilities.map((abilityJson, index) => new AssetAbilityBuilder(abilityJson, `${this.$id}/Abilities/${index + 1}`, game, this)) as [AssetAbilityBuilder, AssetAbilityBuilder, AssetAbilityBuilder];
this.Abilities = yaml.Abilities.map((abilityJson, index) => new AssetAbilityBuilder(abilityJson, formatId((index + 1).toString(),this.$id, "Abilities"), game, this)) as [AssetAbilityBuilder, AssetAbilityBuilder, AssetAbilityBuilder];
}

_.merge(this, replaceInAllStrings(this, Replacement.Asset, this.$id));
Expand Down
4 changes: 2 additions & 2 deletions dataforged-tools/src/builders/assets/AssetTypeBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class AssetTypeBuilder extends SourceInheritorBuilder implements AssetTyp
Title: Title;
Aliases?: string[] | undefined;
Description: string;
Assets: Asset[];
Assets: {[key:string]: Asset};
Display: Display;
Usage: AssetUsage;
constructor(yaml: YamlAssetType, fragment: string, game: Game, rootSource: Source) {
Expand All @@ -31,7 +31,7 @@ export class AssetTypeBuilder extends SourceInheritorBuilder implements AssetTyp
usage.Shared = false;
}
this.Usage = usage;
this.Assets = _.map(yaml.Assets,asset => new AssetBuilder(asset, game, this, rootSource));
this.Assets = _.mapValues(yaml.Assets,asset => new AssetBuilder(asset, game, this, rootSource));
}
}

3 changes: 2 additions & 1 deletion dataforged-tools/src/builders/common/RollTemplateBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { HasId, RollTemplate, YamlRollTemplate } from "@schema";
import { formatId } from "@utils";

/**
* @internal
Expand All @@ -9,7 +10,7 @@ export class RollTemplateBuilder implements RollTemplate {
Summary?: string | undefined;
Description?: string | undefined;
constructor(yaml: YamlRollTemplate, parent: HasId) {
this.$id = `${parent.$id}/Roll_template`;
this.$id = formatId("roll template", parent.$id);
this.Result = yaml.Result;
this.Summary = yaml.Summary;
this.Description = yaml.Description;
Expand Down
2 changes: 1 addition & 1 deletion dataforged-tools/src/builders/moves/MoveBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class MoveBuilder extends SourceInheritorBuilder implements Move {
this.Oracles = yaml.Oracles;


this.Outcomes = yaml.Outcomes ? new OutcomesBuilder(yaml.Outcomes, `${this.$id}/Outcomes`) : undefined;
this.Outcomes = yaml.Outcomes ? new OutcomesBuilder(yaml.Outcomes, formatId("Outcomes",this.$id)) : undefined;
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { CustomStatBuilder } from "@builders";
import type { CustomStat, MoveTrigger , MoveTriggerOptionAction, MoveTriggerOptionBase, MoveTriggerOptionProgress, ProgressTypeIronsworn, ProgressTypeStarforged, RollableStat, YamlMoveTriggerOptionAction as yaml, YamlMoveTriggerOptionProgress } from "@schema";
import { Replacement, RollMethod, RollType } from "@schema";
import { formatId } from "@utils";

/**
* @internal
Expand All @@ -13,7 +14,7 @@ export abstract class MoveTriggerOptionBuilder implements MoveTriggerOptionBase
Using: (RollableStat | ProgressTypeStarforged|ProgressTypeIronsworn)[];
"Custom stat"?: CustomStat | undefined;
constructor(yaml: yaml|YamlMoveTriggerOptionProgress, parent: MoveTrigger, index: number) {
this.$id = `${parent.$id}/Options/${index+1}`;
this.$id = formatId( (index+1).toString(), parent.$id, "Options");
this.Text = yaml.Text;
this["Roll type"] = yaml["Roll type"] ?? RollType.Action;
this.Method = yaml.Method ?? RollMethod.Any;
Expand Down
5 changes: 3 additions & 2 deletions dataforged-tools/src/builders/oracles/TableColumnBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { TableColumnType } from "@schema";
import type { OracleTable, TableColumnRoll, TableColumnText } from "@schema";
import { formatId } from "@utils";

/**
* @internal
Expand All @@ -11,7 +12,7 @@ export class TableColumnTextBuilder implements TableColumnText {
["Content"]: TableColumnText["Content"];
Key: TableColumnText["Key"];
constructor(parentID: string, content: OracleTable["$id"], index: number, label: string = "Result", key: TableColumnText["Key"] = "Result") {
this.$id = `${parentID}/Columns/${index+1}`;
this.$id = formatId((index+1).toString(),parentID, "columns");
this.Label = label;
this["Content"] = content;
this.Key = key;
Expand All @@ -27,7 +28,7 @@ export class TableColumnRollBuilder implements TableColumnRoll {
Label: string;
["Content"]: TableColumnRoll["Content"];
constructor(parentID: string, content: OracleTable["$id"], index: number, label: string = "Roll") {
this.$id = `${parentID}/Columns/${index+1}`;
this.$id = formatId((index+1).toString(),parentID, "columns");
this.Label = label;
this["Content"] = content;
}
Expand Down
Loading

0 comments on commit f95c861

Please sign in to comment.