pf2e-sage-stats 0.4.0 → 0.4.1

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.
package/dist/app.d.ts CHANGED
@@ -568,8 +568,10 @@ export declare const charSchema: zod.ZodObject<{
568
568
  export type CharSchema = zod.infer<typeof charSchema>;
569
569
  export declare const trackerSchema: zod.ZodObject<{
570
570
  title: zod.ZodOptional<zod.ZodString>;
571
+ mapText: zod.ZodOptional<zod.ZodString>;
571
572
  map: zod.ZodOptional<zod.ZodString>;
572
- mapURL: zod.ZodOptional<zod.ZodString>;
573
+ roundText: zod.ZodOptional<zod.ZodString>;
574
+ round: zod.ZodOptional<zod.ZodString>;
573
575
  description: zod.ZodOptional<zod.ZodString>;
574
576
  chars: zod.ZodArray<zod.ZodObject<{
575
577
  init: zod.ZodDefault<zod.ZodNumber>;
@@ -673,7 +675,9 @@ export declare const trackerSchema: zod.ZodObject<{
673
675
  title?: string | undefined;
674
676
  description?: string | undefined;
675
677
  map?: string | undefined;
676
- mapURL?: string | undefined;
678
+ mapText?: string | undefined;
679
+ roundText?: string | undefined;
680
+ round?: string | undefined;
677
681
  }, {
678
682
  chars: {
679
683
  hp?: number | undefined;
@@ -699,7 +703,9 @@ export declare const trackerSchema: zod.ZodObject<{
699
703
  title?: string | undefined;
700
704
  description?: string | undefined;
701
705
  map?: string | undefined;
702
- mapURL?: string | undefined;
706
+ mapText?: string | undefined;
707
+ roundText?: string | undefined;
708
+ round?: string | undefined;
703
709
  }>;
704
710
  export type Tracker = zod.infer<typeof trackerSchema>;
705
711
  export declare const flatMap: Record<string, string>;
@@ -716,12 +722,32 @@ export declare const formatTable: (table: string, season: string, scenario: stri
716
722
  export declare const formatHP: (arg: string) => string;
717
723
  export declare const newtracker: (status: string, desc: {
718
724
  title?: string;
725
+ mapText?: string;
719
726
  map?: string;
720
- mapURL?: string;
727
+ roundText?: string;
728
+ round?: string;
721
729
  description?: string;
722
730
  }) => Tracker;
723
731
  export declare const formatTracker: (tracker: Tracker) => string;
724
732
  export type TrackerCommand = {
733
+ command: 'title';
734
+ title: string;
735
+ } | {
736
+ command: 'mapText';
737
+ mapText: string;
738
+ } | {
739
+ command: 'map';
740
+ map: string;
741
+ } | {
742
+ command: 'roundText';
743
+ roundText: string;
744
+ } | {
745
+ command: 'round';
746
+ round: string;
747
+ } | {
748
+ command: 'desc';
749
+ description: string;
750
+ } | {
725
751
  command: 'block';
726
752
  index: number;
727
753
  } | {
@@ -732,26 +758,32 @@ export type TrackerCommand = {
732
758
  command: 'blank';
733
759
  } | {
734
760
  command: 'foe';
735
- name?: string;
736
- alias?: string;
737
- hp?: number;
761
+ name: string;
762
+ alias: string;
763
+ hp: number;
738
764
  } | {
739
765
  command: 'friend';
740
- name?: string;
741
- alias?: string;
742
- hp?: number;
766
+ name: string;
767
+ alias: string;
768
+ hp: number;
743
769
  } | {
744
- command: 'update';
770
+ command: 'child';
745
771
  tag: string;
746
- name?: string;
747
- alias?: string;
748
- hp?: number;
772
+ name: string;
773
+ alias: string;
774
+ hp: number;
749
775
  } | {
750
- command: 'child';
776
+ command: 'name';
777
+ tag: string;
778
+ name: string;
779
+ } | {
780
+ command: 'alias';
781
+ tag: string;
782
+ alias: string;
783
+ } | {
784
+ command: 'hp';
751
785
  tag: string;
752
- name?: string;
753
- alias?: string;
754
- hp?: number;
786
+ hp: number;
755
787
  } | {
756
788
  command: 'heal';
757
789
  } | {
package/dist/app.js CHANGED
@@ -201,8 +201,10 @@ exports.charSchema = zod_1.default.object({
201
201
  });
202
202
  exports.trackerSchema = zod_1.default.object({
203
203
  title: zod_1.default.string().optional(),
204
+ mapText: zod_1.default.string().optional(),
204
205
  map: zod_1.default.string().optional(),
205
- mapURL: zod_1.default.string().optional(),
206
+ roundText: zod_1.default.string().optional(),
207
+ round: zod_1.default.string().optional(),
206
208
  description: zod_1.default.string().optional(),
207
209
  chars: zod_1.default.array(exports.charSchema),
208
210
  });
@@ -645,11 +647,11 @@ const newtracker = (status, desc) => {
645
647
  }
646
648
  tracker.push(char);
647
649
  }
648
- return { ...desc, chars: tracker };
650
+ return exports.trackerSchema.parse({ ...desc, chars: tracker });
649
651
  };
650
652
  exports.newtracker = newtracker;
651
653
  const formatTracker = (tracker) => {
652
- var _a;
654
+ var _a, _b;
653
655
  const aliasSpace = (t) => (t.alias.length > 0 ? 0 : 5);
654
656
  const nameLengthWithAlias = (t) => t.name.length - aliasSpace(t);
655
657
  const nameLength = tracker.chars.reduce((p, c) => {
@@ -701,19 +703,37 @@ const formatTracker = (tracker) => {
701
703
  lines.unshift('');
702
704
  lines.unshift(`${tracker.description}`);
703
705
  }
704
- if (tracker.mapURL) {
706
+ if (tracker.map) {
705
707
  lines.unshift('');
706
- lines.unshift(`[**${((_a = tracker.map) !== null && _a !== void 0 ? _a : 'Map').toUpperCase()}**](${tracker.mapURL})`);
708
+ lines.unshift(`[**${((_a = tracker.mapText) !== null && _a !== void 0 ? _a : 'Map').toUpperCase()}**](${tracker.map})`);
707
709
  }
708
- if (tracker.title) {
710
+ if (tracker.title || tracker.round) {
709
711
  lines.unshift('');
710
- lines.unshift(`## ${tracker.title}`);
712
+ lines.unshift(`## ${tracker.title} ${tracker.round && `${(_b = tracker.roundText) !== null && _b !== void 0 ? _b : 'Round'} ${tracker.round}`}`);
711
713
  }
712
714
  lines.push(':spacer:');
713
715
  return lines.join('\n');
714
716
  };
715
717
  exports.formatTracker = formatTracker;
716
718
  const trackerCommands = [{
719
+ regex: /^\s*title\s+(?:([^"]+)|"([^"]*)")/i,
720
+ map: (match) => { var _a; return ({ command: 'title', title: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }); },
721
+ }, {
722
+ regex: /^\s*mapText\s+(?:([^"]+)|"([^"]*)")/i,
723
+ map: (match) => { var _a; return ({ command: 'mapText', mapText: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }); },
724
+ }, {
725
+ regex: /^\s*map\s+(?:([^"]+)|"([^"]*)")/i,
726
+ map: (match) => { var _a; return ({ command: 'map', map: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }); },
727
+ }, {
728
+ regex: /^\s*roundText\s+(?:([^"]+)|"([^"]*)")/i,
729
+ map: (match) => { var _a; return ({ command: 'roundText', roundText: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }); },
730
+ }, {
731
+ regex: /^\s*round\s+(?:([^"]+)|"([^"]*)")/i,
732
+ map: (match) => { var _a; return ({ command: 'round', round: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }); },
733
+ }, {
734
+ regex: /^\s*desc\s+(?:([^"]+)|"([^"]*)")/i,
735
+ map: (match) => { var _a; return ({ command: 'desc', description: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }); },
736
+ }, {
717
737
  regex: /^\s*[bB]\s*(\d+)/,
718
738
  map: (match) => { var _a; return ({ command: 'block', index: parseInt((_a = match[1]) !== null && _a !== void 0 ? _a : '', 10) }); },
719
739
  }, {
@@ -726,17 +746,23 @@ const trackerCommands = [{
726
746
  regex: /^\s*blank/i,
727
747
  map: () => ({ command: 'blank' }),
728
748
  }, {
729
- regex: /^\s*foe(\s+(\S+))?(\s+(\S+))?(\s+(\d+))?/i,
730
- map: (match) => ({ command: 'foe', name: match[2], alias: match[4], hp: match[6] ? parseInt(match[6], 10) : undefined }),
749
+ regex: /^\s*foe\s+(?:([^"]+)|"([^"]*)")\s+(\S+)\s+(\d+)/i,
750
+ map: (match) => { var _a; return ({ command: 'foe', name: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2], alias: match[3], hp: parseInt(match[4], 10) }); },
751
+ }, {
752
+ regex: /^\s*friend\s+(?:([^"]+)|"([^"]*)")\s+(\S+)\s+(\d+)/i,
753
+ map: (match) => { var _a; return ({ command: 'friend', name: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2], alias: match[3], hp: parseInt(match[4], 10) }); },
731
754
  }, {
732
- regex: /^\s*friend(\s+(\S+))?(\s+(\S+))?(\s+(\d+))?/i,
733
- map: (match) => ({ command: 'friend', name: match[2], alias: match[4], hp: match[6] ? parseInt(match[6], 10) : undefined }),
755
+ regex: /^\s*child\s+(\S+)\s+(?:([^"]+)|"([^"]*)")\s+(\S+)\s+(\d+)/i,
756
+ map: (match) => { var _a; return ({ command: 'child', tag: match[1], name: (_a = match[2]) !== null && _a !== void 0 ? _a : match[3], alias: match[4], hp: parseInt(match[5], 10) }); },
734
757
  }, {
735
- regex: /^\s*child\s+(\S+)(\s+(\S+))?(\s+(\S+))?(\s+(\d+))?/i,
736
- map: (match) => ({ command: 'child', tag: match[1], name: match[3], alias: match[5], hp: match[7] ? parseInt(match[7], 10) : undefined }),
758
+ regex: /^\s*name\s+(\S+)\s+(?:([^"]+)|"([^"]*)")/i,
759
+ map: (match) => { var _a; return ({ command: 'name', tag: match[1], name: (_a = match[2]) !== null && _a !== void 0 ? _a : match[3] }); },
737
760
  }, {
738
- regex: /^\s*update\s+(\S+)(\s+(\S+))?(\s+(\S+))?(\s+(\d+))?/i,
739
- map: (match) => ({ command: 'update', tag: match[1], name: match[3], alias: match[5], hp: match[7] ? parseInt(match[7], 10) : undefined }),
761
+ regex: /^\s*alias\s+(\S+)\s+(\S+)/i,
762
+ map: (match) => ({ command: 'alias', tag: match[1], alias: match[2] }),
763
+ }, {
764
+ regex: /^\s*hp\s+(\S+)\s+(\d+)/i,
765
+ map: (match) => ({ command: 'hp', tag: match[1], hp: parseInt(match[2], 10) }),
740
766
  }, {
741
767
  regex: /^\s*heal/i,
742
768
  map: () => ({ command: 'heal' }),
@@ -779,6 +805,12 @@ const trackerCommands = [{
779
805
  }, {
780
806
  regex: /^\s*([^\s="+-]+)\s*=?"([^"]*)"/,
781
807
  map: (match) => { var _a, _b; return ({ command: 'set-conditions', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '', value: (_b = match[2]) !== null && _b !== void 0 ? _b : '' }); },
808
+ }, {
809
+ regex: /^\s*([^\s="+-]+)\s*\+\+"([^"]*)"/,
810
+ map: (match) => { var _a, _b; return ({ command: 'inc-conditions', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '', value: (_b = match[2]) !== null && _b !== void 0 ? _b : '' }); },
811
+ }, {
812
+ regex: /^\s*([^\s="+-]+)\s*--"([^"]*)"/,
813
+ map: (match) => { var _a, _b; return ({ command: 'dec-conditions', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '', value: (_b = match[2]) !== null && _b !== void 0 ? _b : '' }); },
782
814
  }, {
783
815
  regex: /^\s*([^\s="+-]+)\s*\+"([^"]*)"/,
784
816
  map: (match) => { var _a, _b; return ({ command: 'add-conditions', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '', value: (_b = match[2]) !== null && _b !== void 0 ? _b : '' }); },
@@ -786,14 +818,14 @@ const trackerCommands = [{
786
818
  regex: /^\s*([^\s="+-]+)\s*-"([^"]*)"/,
787
819
  map: (match) => { var _a, _b; return ({ command: 'rem-conditions', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '', value: (_b = match[2]) !== null && _b !== void 0 ? _b : '' }); },
788
820
  }, {
789
- regex: /^\s*([^\s="+-]+)\s*\+\+"([^"]*)"/,
821
+ regex: /^\s*(\S+)\s+[sS]?\s*=?"([^"]*)"/,
822
+ map: (match) => { var _a, _b; return ({ command: 'set-conditions', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '', value: (_b = match[2]) !== null && _b !== void 0 ? _b : '' }); },
823
+ }, {
824
+ regex: /^\s*(\S+)\s+[sS]?\s*\+\+"([^"]*)"/,
790
825
  map: (match) => { var _a, _b; return ({ command: 'inc-conditions', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '', value: (_b = match[2]) !== null && _b !== void 0 ? _b : '' }); },
791
826
  }, {
792
- regex: /^\s*([^\s="+-]+)\s*--"([^"]*)"/,
827
+ regex: /^\s*(\S+)\s+[sS]?\s*--"([^"]*)"/,
793
828
  map: (match) => { var _a, _b; return ({ command: 'dec-conditions', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '', value: (_b = match[2]) !== null && _b !== void 0 ? _b : '' }); },
794
- }, {
795
- regex: /^\s*(\S+)\s+[sS]?\s*=?"([^"]*)"/,
796
- map: (match) => { var _a, _b; return ({ command: 'set-conditions', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '', value: (_b = match[2]) !== null && _b !== void 0 ? _b : '' }); },
797
829
  }, {
798
830
  regex: /^\s*(\S+)\s+[sS]?\s*\+"([^"]*)"/,
799
831
  map: (match) => { var _a, _b; return ({ command: 'add-conditions', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '', value: (_b = match[2]) !== null && _b !== void 0 ? _b : '' }); },
@@ -801,11 +833,20 @@ const trackerCommands = [{
801
833
  regex: /^\s*(\S+)\s+[sS]?\s*-"([^"]*)"/,
802
834
  map: (match) => { var _a, _b; return ({ command: 'rem-conditions', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '', value: (_b = match[2]) !== null && _b !== void 0 ? _b : '' }); },
803
835
  }, {
804
- regex: /^\s*(\S+)\s+[sS]?\s*\+\+"([^"]*)"/,
836
+ regex: /^\s*([^\s=+-]+)\s*=(\S+)/,
837
+ map: (match) => { var _a, _b; return ({ command: 'set-conditions', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '', value: (_b = match[2]) !== null && _b !== void 0 ? _b : '' }); },
838
+ }, {
839
+ regex: /^\s*([^\s=+-]+)\s*\+\+(\S+)/,
805
840
  map: (match) => { var _a, _b; return ({ command: 'inc-conditions', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '', value: (_b = match[2]) !== null && _b !== void 0 ? _b : '' }); },
806
841
  }, {
807
- regex: /^\s*(\S+)\s+[sS]?\s*--"([^"]*)"/,
842
+ regex: /^\s*([^\s=+-]+)\s*--(\S+)/,
808
843
  map: (match) => { var _a, _b; return ({ command: 'dec-conditions', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '', value: (_b = match[2]) !== null && _b !== void 0 ? _b : '' }); },
844
+ }, {
845
+ regex: /^\s*([^\s=+-]+)\s*\+(\S+)/,
846
+ map: (match) => { var _a, _b; return ({ command: 'add-conditions', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '', value: (_b = match[2]) !== null && _b !== void 0 ? _b : '' }); },
847
+ }, {
848
+ regex: /^\s*([^\s=+-]+)\s*-(\S+)/,
849
+ map: (match) => { var _a, _b; return ({ command: 'rem-conditions', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '', value: (_b = match[2]) !== null && _b !== void 0 ? _b : '' }); },
809
850
  }, {
810
851
  regex: /^\s*(\S+)\s+[cC]/,
811
852
  map: (match) => { var _a; return ({ command: 'check', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '' }); },
@@ -1033,22 +1074,46 @@ const applyTrackerCommand = (tracker, action) => {
1033
1074
  }
1034
1075
  return tracker;
1035
1076
  }
1036
- case 'update': {
1077
+ case 'name': {
1037
1078
  const item = findCharacterOrChild(tracker, action.tag);
1038
1079
  if (item) {
1039
- if (action.name) {
1040
- item.name = action.name;
1041
- }
1042
- if (action.alias) {
1043
- item.alias = action.alias;
1044
- }
1045
- if (action.hp) {
1046
- item.maxhp = action.hp;
1047
- item.hp = action.hp;
1048
- }
1080
+ item.name = action.name;
1081
+ }
1082
+ return tracker;
1083
+ }
1084
+ case 'alias': {
1085
+ const item = findCharacterOrChild(tracker, action.tag);
1086
+ if (item) {
1087
+ item.alias = action.alias;
1088
+ }
1089
+ return tracker;
1090
+ }
1091
+ case 'hp': {
1092
+ const item = findCharacterOrChild(tracker, action.tag);
1093
+ if (item) {
1094
+ item.maxhp = action.hp;
1095
+ item.hp = action.hp;
1049
1096
  }
1050
1097
  return tracker;
1051
1098
  }
1099
+ case 'title':
1100
+ tracker.title = action.title;
1101
+ return tracker;
1102
+ case 'mapText':
1103
+ tracker.mapText = action.mapText;
1104
+ return tracker;
1105
+ case 'map':
1106
+ tracker.map = action.map;
1107
+ return tracker;
1108
+ case 'roundText':
1109
+ tracker.roundText = action.roundText;
1110
+ return tracker;
1111
+ case 'round':
1112
+ tracker.round = action.round;
1113
+ return tracker;
1114
+ case 'desc':
1115
+ tracker.description = action.description;
1116
+ return tracker;
1052
1117
  default:
1053
1118
  return unexpectedTrackerCommand(action);
1054
1119
  }
package/dist/index.js CHANGED
@@ -139,12 +139,14 @@ program.command('newtracker')
139
139
  .argument('<file>', 'input text file')
140
140
  .option('-o, --output <file>', 'output file name')
141
141
  .option('-t, --title <string>', 'tracker title')
142
- .option('-m, --map <string>', 'tracker map name')
143
- .option('-u, --mapURL <string>', 'tracker map url')
142
+ .option('-n, --mapText <string>', 'tracker map name')
143
+ .option('-m, --map <string>', 'tracker map url')
144
+ .option('-s, --roundText <string>', 'tracker round name')
145
+ .option('-r, --round <string>', 'tracker round')
144
146
  .option('-d, --description <string>', 'tracker description')
145
147
  .action(async (argument, option) => {
146
148
  const file = await promises_1.default.readFile(argument, { encoding: 'utf-8' });
147
- const tracker = (0, app_1.newtracker)(file, { title: option.title, map: option.map, mapURL: option.mapURL, description: option.description });
149
+ const tracker = (0, app_1.newtracker)(file, { title: option.title, mapText: option.mapText, map: option.map, roundText: option.roundText, round: option.round, description: option.description });
148
150
  if (option.output) {
149
151
  await promises_1.default.writeFile(option.output, JSON.stringify(tracker, undefined, 2), { encoding: 'utf-8' });
150
152
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pf2e-sage-stats",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "An RPG Sage's .tsv stat generation tool",
5
5
  "author": "ikariott@gmail.com",
6
6
  "license": "MIT",