pf2e-sage-stats 0.4.0 → 0.4.2

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: 'map-text';
737
+ mapText: string;
738
+ } | {
739
+ command: 'map';
740
+ map: string;
741
+ } | {
742
+ command: 'round-text';
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,41 @@ 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([
713
+ '##',
714
+ ...(tracker.title ? [tracker.title] : []),
715
+ ...(tracker.round ? [`${(_b = tracker.roundText) !== null && _b !== void 0 ? _b : 'Round'} ${tracker.round}`] : [])
716
+ ].join(' '));
711
717
  }
712
718
  lines.push(':spacer:');
713
719
  return lines.join('\n');
714
720
  };
715
721
  exports.formatTracker = formatTracker;
716
722
  const trackerCommands = [{
723
+ regex: /^\s*title\s+(?:([^"\s]+)|"([^"]*)")/i,
724
+ map: (match) => { var _a; return ({ command: 'title', title: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }); },
725
+ }, {
726
+ regex: /^\s*map-text\s+(?:([^"\s]+)|"([^"]*)")/i,
727
+ map: (match) => { var _a; return ({ command: 'map-text', mapText: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }); },
728
+ }, {
729
+ regex: /^\s*map\s+(?:([^"\s]+)|"([^"]*)")/i,
730
+ map: (match) => { var _a; return ({ command: 'map', map: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }); },
731
+ }, {
732
+ regex: /^\s*round-text\s+(?:([^"\s]+)|"([^"]*)")/i,
733
+ map: (match) => { var _a; return ({ command: 'round-text', roundText: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }); },
734
+ }, {
735
+ regex: /^\s*round\s+(?:([^"\s]+)|"([^"]*)")/i,
736
+ map: (match) => { var _a; return ({ command: 'round', round: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }); },
737
+ }, {
738
+ regex: /^\s*desc\s+(?:([^"\s]+)|"([^"]*)")/i,
739
+ map: (match) => { var _a; return ({ command: 'desc', description: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }); },
740
+ }, {
717
741
  regex: /^\s*[bB]\s*(\d+)/,
718
742
  map: (match) => { var _a; return ({ command: 'block', index: parseInt((_a = match[1]) !== null && _a !== void 0 ? _a : '', 10) }); },
719
743
  }, {
@@ -726,17 +750,23 @@ const trackerCommands = [{
726
750
  regex: /^\s*blank/i,
727
751
  map: () => ({ command: 'blank' }),
728
752
  }, {
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 }),
753
+ regex: /^\s*foe\s+(?:([^"\s]+)|"([^"]*)")\s+(\S+)\s+(\d+)/i,
754
+ 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) }); },
755
+ }, {
756
+ regex: /^\s*friend\s+(?:([^"\s]+)|"([^"]*)")\s+(\S+)\s+(\d+)/i,
757
+ 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
758
  }, {
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 }),
759
+ regex: /^\s*child\s+(\S+)\s+(?:([^"\s]+)|"([^"]*)")\s+(\S+)\s+(\d+)/i,
760
+ 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
761
  }, {
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 }),
762
+ regex: /^\s*name\s+(\S+)\s+(?:([^"\s]+)|"([^"]*)")/i,
763
+ map: (match) => { var _a; return ({ command: 'name', tag: match[1], name: (_a = match[2]) !== null && _a !== void 0 ? _a : match[3] }); },
737
764
  }, {
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 }),
765
+ regex: /^\s*alias\s+(\S+)\s+(\S+)/i,
766
+ map: (match) => ({ command: 'alias', tag: match[1], alias: match[2] }),
767
+ }, {
768
+ regex: /^\s*hp\s+(\S+)\s+(\d+)/i,
769
+ map: (match) => ({ command: 'hp', tag: match[1], hp: parseInt(match[2], 10) }),
740
770
  }, {
741
771
  regex: /^\s*heal/i,
742
772
  map: () => ({ command: 'heal' }),
@@ -779,6 +809,12 @@ const trackerCommands = [{
779
809
  }, {
780
810
  regex: /^\s*([^\s="+-]+)\s*=?"([^"]*)"/,
781
811
  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 : '' }); },
812
+ }, {
813
+ regex: /^\s*([^\s="+-]+)\s*\+\+"([^"]*)"/,
814
+ 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 : '' }); },
815
+ }, {
816
+ regex: /^\s*([^\s="+-]+)\s*--"([^"]*)"/,
817
+ 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
818
  }, {
783
819
  regex: /^\s*([^\s="+-]+)\s*\+"([^"]*)"/,
784
820
  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 +822,14 @@ const trackerCommands = [{
786
822
  regex: /^\s*([^\s="+-]+)\s*-"([^"]*)"/,
787
823
  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
824
  }, {
789
- regex: /^\s*([^\s="+-]+)\s*\+\+"([^"]*)"/,
825
+ regex: /^\s*(\S+)\s+[sS]?\s*=?"([^"]*)"/,
826
+ 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 : '' }); },
827
+ }, {
828
+ regex: /^\s*(\S+)\s+[sS]?\s*\+\+"([^"]*)"/,
790
829
  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
830
  }, {
792
- regex: /^\s*([^\s="+-]+)\s*--"([^"]*)"/,
831
+ regex: /^\s*(\S+)\s+[sS]?\s*--"([^"]*)"/,
793
832
  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
833
  }, {
798
834
  regex: /^\s*(\S+)\s+[sS]?\s*\+"([^"]*)"/,
799
835
  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 +837,20 @@ const trackerCommands = [{
801
837
  regex: /^\s*(\S+)\s+[sS]?\s*-"([^"]*)"/,
802
838
  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
839
  }, {
804
- regex: /^\s*(\S+)\s+[sS]?\s*\+\+"([^"]*)"/,
840
+ regex: /^\s*([^\s=+-]+)\s*=(\S+)/,
841
+ 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 : '' }); },
842
+ }, {
843
+ regex: /^\s*([^\s=+-]+)\s*\+\+(\S+)/,
805
844
  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
845
  }, {
807
- regex: /^\s*(\S+)\s+[sS]?\s*--"([^"]*)"/,
846
+ regex: /^\s*([^\s=+-]+)\s*--(\S+)/,
808
847
  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 : '' }); },
848
+ }, {
849
+ regex: /^\s*([^\s=+-]+)\s*\+(\S+)/,
850
+ 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 : '' }); },
851
+ }, {
852
+ regex: /^\s*([^\s=+-]+)\s*-(\S+)/,
853
+ 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
854
  }, {
810
855
  regex: /^\s*(\S+)\s+[cC]/,
811
856
  map: (match) => { var _a; return ({ command: 'check', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '' }); },
@@ -1033,22 +1078,46 @@ const applyTrackerCommand = (tracker, action) => {
1033
1078
  }
1034
1079
  return tracker;
1035
1080
  }
1036
- case 'update': {
1081
+ case 'name': {
1037
1082
  const item = findCharacterOrChild(tracker, action.tag);
1038
1083
  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
- }
1084
+ item.name = action.name;
1085
+ }
1086
+ return tracker;
1087
+ }
1088
+ case 'alias': {
1089
+ const item = findCharacterOrChild(tracker, action.tag);
1090
+ if (item) {
1091
+ item.alias = action.alias;
1092
+ }
1093
+ return tracker;
1094
+ }
1095
+ case 'hp': {
1096
+ const item = findCharacterOrChild(tracker, action.tag);
1097
+ if (item) {
1098
+ item.maxhp = action.hp;
1099
+ item.hp = action.hp;
1049
1100
  }
1050
1101
  return tracker;
1051
1102
  }
1103
+ case 'title':
1104
+ tracker.title = action.title;
1105
+ return tracker;
1106
+ case 'map-text':
1107
+ tracker.mapText = action.mapText;
1108
+ return tracker;
1109
+ case 'map':
1110
+ tracker.map = action.map;
1111
+ return tracker;
1112
+ case 'round-text':
1113
+ tracker.roundText = action.roundText;
1114
+ return tracker;
1115
+ case 'round':
1116
+ tracker.round = action.round;
1117
+ return tracker;
1118
+ case 'desc':
1119
+ tracker.description = action.description;
1120
+ return tracker;
1052
1121
  default:
1053
1122
  return unexpectedTrackerCommand(action);
1054
1123
  }
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.2",
4
4
  "description": "An RPG Sage's .tsv stat generation tool",
5
5
  "author": "ikariott@gmail.com",
6
6
  "license": "MIT",