pf2e-sage-stats 0.3.3 → 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 +56 -7
- package/dist/app.js +116 -16
- package/dist/index.js +5 -3
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,9 +758,32 @@ export type TrackerCommand = {
|
|
|
732
758
|
command: 'blank';
|
|
733
759
|
} | {
|
|
734
760
|
command: 'foe';
|
|
735
|
-
name
|
|
736
|
-
alias
|
|
737
|
-
hp
|
|
761
|
+
name: string;
|
|
762
|
+
alias: string;
|
|
763
|
+
hp: number;
|
|
764
|
+
} | {
|
|
765
|
+
command: 'friend';
|
|
766
|
+
name: string;
|
|
767
|
+
alias: string;
|
|
768
|
+
hp: number;
|
|
769
|
+
} | {
|
|
770
|
+
command: 'child';
|
|
771
|
+
tag: string;
|
|
772
|
+
name: string;
|
|
773
|
+
alias: string;
|
|
774
|
+
hp: number;
|
|
775
|
+
} | {
|
|
776
|
+
command: 'name';
|
|
777
|
+
tag: string;
|
|
778
|
+
name: string;
|
|
779
|
+
} | {
|
|
780
|
+
command: 'alias';
|
|
781
|
+
tag: string;
|
|
782
|
+
alias: string;
|
|
783
|
+
} | {
|
|
784
|
+
command: 'hp';
|
|
785
|
+
tag: string;
|
|
786
|
+
hp: number;
|
|
738
787
|
} | {
|
|
739
788
|
command: 'heal';
|
|
740
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
|
-
|
|
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.
|
|
706
|
+
if (tracker.map) {
|
|
705
707
|
lines.unshift('');
|
|
706
|
-
lines.unshift(`[**${((_a = tracker.
|
|
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,8 +746,23 @@ const trackerCommands = [{
|
|
|
726
746
|
regex: /^\s*blank/i,
|
|
727
747
|
map: () => ({ command: 'blank' }),
|
|
728
748
|
}, {
|
|
729
|
-
regex: /^\s*foe
|
|
730
|
-
map: (match) => ({ command: 'foe', name: match[
|
|
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) }); },
|
|
754
|
+
}, {
|
|
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) }); },
|
|
757
|
+
}, {
|
|
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] }); },
|
|
760
|
+
}, {
|
|
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) }),
|
|
731
766
|
}, {
|
|
732
767
|
regex: /^\s*heal/i,
|
|
733
768
|
map: () => ({ command: 'heal' }),
|
|
@@ -770,6 +805,12 @@ const trackerCommands = [{
|
|
|
770
805
|
}, {
|
|
771
806
|
regex: /^\s*([^\s="+-]+)\s*=?"([^"]*)"/,
|
|
772
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 : '' }); },
|
|
773
814
|
}, {
|
|
774
815
|
regex: /^\s*([^\s="+-]+)\s*\+"([^"]*)"/,
|
|
775
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 : '' }); },
|
|
@@ -777,14 +818,14 @@ const trackerCommands = [{
|
|
|
777
818
|
regex: /^\s*([^\s="+-]+)\s*-"([^"]*)"/,
|
|
778
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 : '' }); },
|
|
779
820
|
}, {
|
|
780
|
-
regex: /^\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*\+\+"([^"]*)"/,
|
|
781
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 : '' }); },
|
|
782
826
|
}, {
|
|
783
|
-
regex: /^\s*(
|
|
827
|
+
regex: /^\s*(\S+)\s+[sS]?\s*--"([^"]*)"/,
|
|
784
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 : '' }); },
|
|
785
|
-
}, {
|
|
786
|
-
regex: /^\s*(\S+)\s+[sS]?\s*=?"([^"]*)"/,
|
|
787
|
-
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 : '' }); },
|
|
788
829
|
}, {
|
|
789
830
|
regex: /^\s*(\S+)\s+[sS]?\s*\+"([^"]*)"/,
|
|
790
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 : '' }); },
|
|
@@ -792,11 +833,20 @@ const trackerCommands = [{
|
|
|
792
833
|
regex: /^\s*(\S+)\s+[sS]?\s*-"([^"]*)"/,
|
|
793
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 : '' }); },
|
|
794
835
|
}, {
|
|
795
|
-
regex: /^\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+)/,
|
|
796
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 : '' }); },
|
|
797
841
|
}, {
|
|
798
|
-
regex: /^\s*(
|
|
842
|
+
regex: /^\s*([^\s=+-]+)\s*--(\S+)/,
|
|
799
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 : '' }); },
|
|
800
850
|
}, {
|
|
801
851
|
regex: /^\s*(\S+)\s+[cC]/,
|
|
802
852
|
map: (match) => { var _a; return ({ command: 'check', tag: (_a = match[1]) !== null && _a !== void 0 ? _a : '' }); },
|
|
@@ -1014,6 +1064,56 @@ const applyTrackerCommand = (tracker, action) => {
|
|
|
1014
1064
|
case 'foe':
|
|
1015
1065
|
tracker.chars.push(exports.charSchema.parse({ foe: true, name: action.name, alias: action.alias, maxhp: action.hp, hp: action.hp }));
|
|
1016
1066
|
return tracker;
|
|
1067
|
+
case 'friend':
|
|
1068
|
+
tracker.chars.push(exports.charSchema.parse({ foe: false, name: action.name, alias: action.alias, maxhp: action.hp, hp: action.hp }));
|
|
1069
|
+
return tracker;
|
|
1070
|
+
case 'child': {
|
|
1071
|
+
const item = findCharacter(tracker, action.tag);
|
|
1072
|
+
if (item) {
|
|
1073
|
+
item.children.push(childSchema.parse({ name: action.name, alias: action.alias, maxhp: action.hp, hp: action.hp }));
|
|
1074
|
+
}
|
|
1075
|
+
return tracker;
|
|
1076
|
+
}
|
|
1077
|
+
case 'name': {
|
|
1078
|
+
const item = findCharacterOrChild(tracker, action.tag);
|
|
1079
|
+
if (item) {
|
|
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;
|
|
1096
|
+
}
|
|
1097
|
+
return tracker;
|
|
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;
|
|
1017
1117
|
default:
|
|
1018
1118
|
return unexpectedTrackerCommand(action);
|
|
1019
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('-
|
|
143
|
-
.option('-
|
|
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,
|
|
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
|
}
|