pf2e-sage-stats 0.4.2 → 0.4.3
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 +2 -0
- package/dist/app.js +83 -40
- package/package.json +1 -1
package/dist/app.d.ts
CHANGED
package/dist/app.js
CHANGED
|
@@ -622,26 +622,28 @@ const formatHP = (arg) => {
|
|
|
622
622
|
};
|
|
623
623
|
exports.formatHP = formatHP;
|
|
624
624
|
const newtracker = (status, desc) => {
|
|
625
|
-
var _a, _b;
|
|
626
|
-
const regex = /((
|
|
625
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
626
|
+
const regex = /(([^[(\n]+)\s+(?:\[(\S+)\]\s+)?\((\d+)\/(\d+)\s+HP\):[^\S\n]*([^\n]*)(\n>\s*([^[(\n]+)\s+(?:\[(\S+)\]\s+)?\((\d+)\/(\d+)\s+HP\):[^\S\n]*([^\n]*))*)/gm;
|
|
627
627
|
const match = status.match(regex);
|
|
628
628
|
const tracker = zod_1.default.array(exports.charSchema).parse([]);
|
|
629
629
|
for (const m of match !== null && match !== void 0 ? match : []) {
|
|
630
|
-
const mmatch = m.match(
|
|
631
|
-
const cmatch = m.match(/>\s+(\S+)\s
|
|
630
|
+
const mmatch = m.match(/^([^[(\n]+)\s+(?:\[(\S+)\]\s+)?\((\d+)\/(\d+)\s+HP\):[^\S\n]*([^\n]*)/);
|
|
631
|
+
const cmatch = m.match(/>\s*([^[(\n]+)\s+(?:\[(\S+)\]\s+)?\((\d+)\/(\d+)\s+HP\):[^\S\n]*([^\n]*)/g);
|
|
632
632
|
const char = exports.charSchema.parse({
|
|
633
|
-
name: mmatch === null || mmatch === void 0 ? void 0 : mmatch[1],
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
633
|
+
name: (_a = mmatch === null || mmatch === void 0 ? void 0 : mmatch[1]) === null || _a === void 0 ? void 0 : _a.trim(),
|
|
634
|
+
alias: (_b = mmatch === null || mmatch === void 0 ? void 0 : mmatch[2]) === null || _b === void 0 ? void 0 : _b.trim(),
|
|
635
|
+
hp: (_c = mmatch === null || mmatch === void 0 ? void 0 : mmatch[3]) === null || _c === void 0 ? void 0 : _c.trim(),
|
|
636
|
+
maxhp: (_d = mmatch === null || mmatch === void 0 ? void 0 : mmatch[4]) === null || _d === void 0 ? void 0 : _d.trim(),
|
|
637
|
+
conditions: (_e = mmatch === null || mmatch === void 0 ? void 0 : mmatch[5]) === null || _e === void 0 ? void 0 : _e.trim(),
|
|
637
638
|
});
|
|
638
639
|
for (const c of cmatch !== null && cmatch !== void 0 ? cmatch : []) {
|
|
639
|
-
const fmatch = c.match(/>\s+(\S+)\s
|
|
640
|
+
const fmatch = c.match(/>\s*([^[(\n]+)\s+(?:\[(\S+)\]\s+)?\((\d+)\/(\d+)\s+HP\):[^\S\n]*([^\n]*)/);
|
|
640
641
|
const child = childSchema.parse({
|
|
641
|
-
name: fmatch === null || fmatch === void 0 ? void 0 : fmatch[1],
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
642
|
+
name: (_f = fmatch === null || fmatch === void 0 ? void 0 : fmatch[1]) === null || _f === void 0 ? void 0 : _f.trim(),
|
|
643
|
+
alias: (_g = fmatch === null || fmatch === void 0 ? void 0 : fmatch[2]) === null || _g === void 0 ? void 0 : _g.trim(),
|
|
644
|
+
hp: (_h = fmatch === null || fmatch === void 0 ? void 0 : fmatch[3]) === null || _h === void 0 ? void 0 : _h.trim(),
|
|
645
|
+
maxhp: (_j = fmatch === null || fmatch === void 0 ? void 0 : fmatch[4]) === null || _j === void 0 ? void 0 : _j.trim(),
|
|
646
|
+
conditions: (_k = fmatch === null || fmatch === void 0 ? void 0 : fmatch[5]) === null || _k === void 0 ? void 0 : _k.trim(),
|
|
645
647
|
});
|
|
646
648
|
char.children.push(child);
|
|
647
649
|
}
|
|
@@ -735,10 +737,10 @@ const trackerCommands = [{
|
|
|
735
737
|
regex: /^\s*round\s+(?:([^"\s]+)|"([^"]*)")/i,
|
|
736
738
|
map: (match) => { var _a; return ({ command: 'round', round: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }); },
|
|
737
739
|
}, {
|
|
738
|
-
regex: /^\s*desc\s+(?:([^"\s]+)|"([^"]*)")/i,
|
|
740
|
+
regex: /^\s*(?:desc|description)\s+(?:([^"\s]+)|"([^"]*)")/i,
|
|
739
741
|
map: (match) => { var _a; return ({ command: 'desc', description: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }); },
|
|
740
742
|
}, {
|
|
741
|
-
regex: /^\s*
|
|
743
|
+
regex: /^\s*(?:b|block)\s*(\d+)/i,
|
|
742
744
|
map: (match) => { var _a; return ({ command: 'block', index: parseInt((_a = match[1]) !== null && _a !== void 0 ? _a : '', 10) }); },
|
|
743
745
|
}, {
|
|
744
746
|
regex: /^\s*reset/i,
|
|
@@ -747,8 +749,11 @@ const trackerCommands = [{
|
|
|
747
749
|
regex: /^\s*purge/i,
|
|
748
750
|
map: () => ({ command: 'purge' }),
|
|
749
751
|
}, {
|
|
750
|
-
regex: /^\s*blank/i,
|
|
752
|
+
regex: /^\s*(?:blank|blanc|clear)/i,
|
|
751
753
|
map: () => ({ command: 'blank' }),
|
|
754
|
+
}, {
|
|
755
|
+
regex: /^\s*expire/i,
|
|
756
|
+
map: () => ({ command: 'expire' }),
|
|
752
757
|
}, {
|
|
753
758
|
regex: /^\s*foe\s+(?:([^"\s]+)|"([^"]*)")\s+(\S+)\s+(\d+)/i,
|
|
754
759
|
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) }); },
|
|
@@ -774,36 +779,51 @@ const trackerCommands = [{
|
|
|
774
779
|
regex: /^\s*exit/i,
|
|
775
780
|
map: () => ({ command: 'exit' }),
|
|
776
781
|
}, {
|
|
777
|
-
regex: /^\s*([^\
|
|
782
|
+
regex: /^\s*([^\s="+-]+)\s*([+-]\d+)/,
|
|
783
|
+
map: (match) => {
|
|
784
|
+
var _a, _b;
|
|
785
|
+
const tag = (_a = match[1]) !== null && _a !== void 0 ? _a : '';
|
|
786
|
+
const raw = (_b = match[2]) !== null && _b !== void 0 ? _b : '';
|
|
787
|
+
return { command: 'mod-hp', tag, value: parseInt(raw, 10) };
|
|
788
|
+
},
|
|
789
|
+
}, {
|
|
790
|
+
regex: /^\s*([^\s="+-]+)(?:\s+|\s*=)(\d+)/,
|
|
778
791
|
map: (match) => {
|
|
779
792
|
var _a, _b;
|
|
780
793
|
const tag = (_a = match[1]) !== null && _a !== void 0 ? _a : '';
|
|
781
794
|
const raw = (_b = match[2]) !== null && _b !== void 0 ? _b : '';
|
|
782
|
-
if (raw.match(/^[+-]/)) {
|
|
783
|
-
return { command: 'mod-hp', tag, value: parseInt(raw, 10) };
|
|
784
|
-
}
|
|
785
795
|
return { command: 'set-hp', tag, value: parseInt(raw, 10) };
|
|
786
796
|
},
|
|
787
797
|
}, {
|
|
788
|
-
regex: /^\s*(
|
|
798
|
+
regex: /^\s*([^\s="+-]+)\s+[tT]\s*([+-]\d+)/,
|
|
799
|
+
map: (match) => {
|
|
800
|
+
var _a, _b;
|
|
801
|
+
const tag = (_a = match[1]) !== null && _a !== void 0 ? _a : '';
|
|
802
|
+
const raw = (_b = match[2]) !== null && _b !== void 0 ? _b : '';
|
|
803
|
+
return { command: 'mod-thp', tag, value: parseInt(raw, 10) };
|
|
804
|
+
},
|
|
805
|
+
}, {
|
|
806
|
+
regex: /^\s*([^\s="+-]+)\s+[tT]\s*=?(\d+)/,
|
|
789
807
|
map: (match) => {
|
|
790
808
|
var _a, _b;
|
|
791
809
|
const tag = (_a = match[1]) !== null && _a !== void 0 ? _a : '';
|
|
792
810
|
const raw = (_b = match[2]) !== null && _b !== void 0 ? _b : '';
|
|
793
|
-
if (raw.match(/^[+-]/)) {
|
|
794
|
-
return { command: 'mod-thp', tag, value: parseInt(raw, 10) };
|
|
795
|
-
}
|
|
796
811
|
return { command: 'set-thp', tag, value: parseInt(raw, 10) };
|
|
797
812
|
},
|
|
798
813
|
}, {
|
|
799
|
-
regex: /^\s*(
|
|
814
|
+
regex: /^\s*([^\s="+-]+)\s+[iI]\s*([+-]\d+)/,
|
|
815
|
+
map: (match) => {
|
|
816
|
+
var _a, _b;
|
|
817
|
+
const tag = (_a = match[1]) !== null && _a !== void 0 ? _a : '';
|
|
818
|
+
const raw = (_b = match[2]) !== null && _b !== void 0 ? _b : '';
|
|
819
|
+
return { command: 'mod-init', tag, value: parseInt(raw, 10) };
|
|
820
|
+
},
|
|
821
|
+
}, {
|
|
822
|
+
regex: /^\s*([^\s="+-]+)\s+[iI]\s*=?(\d+)/,
|
|
800
823
|
map: (match) => {
|
|
801
824
|
var _a, _b;
|
|
802
825
|
const tag = (_a = match[1]) !== null && _a !== void 0 ? _a : '';
|
|
803
826
|
const raw = (_b = match[2]) !== null && _b !== void 0 ? _b : '';
|
|
804
|
-
if (raw.match(/^[+-]/)) {
|
|
805
|
-
return { command: 'mod-init', tag, value: parseInt(raw, 10) };
|
|
806
|
-
}
|
|
807
827
|
return { command: 'set-init', tag, value: parseInt(raw, 10) };
|
|
808
828
|
},
|
|
809
829
|
}, {
|
|
@@ -822,34 +842,49 @@ const trackerCommands = [{
|
|
|
822
842
|
regex: /^\s*([^\s="+-]+)\s*-"([^"]*)"/,
|
|
823
843
|
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 : '' }); },
|
|
824
844
|
}, {
|
|
825
|
-
regex: /^\s*(
|
|
845
|
+
regex: /^\s*([^\s="+-]+)\s+[sS]\s*=?"([^"]*)"/,
|
|
826
846
|
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
847
|
}, {
|
|
828
|
-
regex: /^\s*(
|
|
848
|
+
regex: /^\s*([^\s="+-]+)\s+[sS]?\s*\+\+"([^"]*)"/,
|
|
829
849
|
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 : '' }); },
|
|
830
850
|
}, {
|
|
831
|
-
regex: /^\s*(
|
|
851
|
+
regex: /^\s*([^\s="+-]+)\s+[sS]?\s*--"([^"]*)"/,
|
|
832
852
|
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 : '' }); },
|
|
833
853
|
}, {
|
|
834
|
-
regex: /^\s*(
|
|
854
|
+
regex: /^\s*([^\s="+-]+)\s+[sS]?\s*\+"([^"]*)"/,
|
|
835
855
|
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 : '' }); },
|
|
836
856
|
}, {
|
|
837
|
-
regex: /^\s*(
|
|
857
|
+
regex: /^\s*([^\s="+-]+)\s+[sS]?\s*-"([^"]*)"/,
|
|
838
858
|
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 : '' }); },
|
|
839
859
|
}, {
|
|
840
|
-
regex: /^\s*([^\s
|
|
860
|
+
regex: /^\s*([^\s="+-]+)\s*=(\S+)/,
|
|
841
861
|
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
862
|
}, {
|
|
843
|
-
regex: /^\s*([^\s
|
|
863
|
+
regex: /^\s*([^\s="+-]+)\s*\+\+(\S+)/,
|
|
844
864
|
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 : '' }); },
|
|
845
865
|
}, {
|
|
846
|
-
regex: /^\s*([^\s
|
|
866
|
+
regex: /^\s*([^\s="+-]+)\s*--(\S+)/,
|
|
847
867
|
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
868
|
}, {
|
|
849
|
-
regex: /^\s*([^\s
|
|
869
|
+
regex: /^\s*([^\s="+-]+)\s*\+(\S+)/,
|
|
850
870
|
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
871
|
}, {
|
|
852
|
-
regex: /^\s*([^\s
|
|
872
|
+
regex: /^\s*([^\s="+-]+)\s*-(\S+)/,
|
|
873
|
+
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 : '' }); },
|
|
874
|
+
}, {
|
|
875
|
+
regex: /^\s*([^\s="+-]+)\s+[sS]\s*=(\S+)/,
|
|
876
|
+
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 : '' }); },
|
|
877
|
+
}, {
|
|
878
|
+
regex: /^\s*([^\s="+-]+)\s+[sS]\s*\+\+(\S+)/,
|
|
879
|
+
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 : '' }); },
|
|
880
|
+
}, {
|
|
881
|
+
regex: /^\s*([^\s="+-]+)\s+[sS]\s*--(\S+)/,
|
|
882
|
+
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 : '' }); },
|
|
883
|
+
}, {
|
|
884
|
+
regex: /^\s*([^\s="+-]+)\s+[sS]\s*\+(\S+)/,
|
|
885
|
+
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 : '' }); },
|
|
886
|
+
}, {
|
|
887
|
+
regex: /^\s*([^\s="+-]+)\s+[sS]\s*-(\S+)/,
|
|
853
888
|
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 : '' }); },
|
|
854
889
|
}, {
|
|
855
890
|
regex: /^\s*(\S+)\s+[cC]/,
|
|
@@ -973,6 +1008,14 @@ const applyTrackerCommand = (tracker, action) => {
|
|
|
973
1008
|
...tracker,
|
|
974
1009
|
chars: tracker.chars.filter((entry) => !entry.foe),
|
|
975
1010
|
};
|
|
1011
|
+
case 'expire':
|
|
1012
|
+
tracker.chars.forEach((char) => {
|
|
1013
|
+
char.temphp = 0;
|
|
1014
|
+
char.children.forEach((child) => {
|
|
1015
|
+
child.temphp = 0;
|
|
1016
|
+
});
|
|
1017
|
+
});
|
|
1018
|
+
return tracker;
|
|
976
1019
|
case 'heal':
|
|
977
1020
|
tracker.chars.forEach((char) => {
|
|
978
1021
|
char.hp = char.maxhp;
|
|
@@ -1029,10 +1072,10 @@ const applyTrackerCommand = (tracker, action) => {
|
|
|
1029
1072
|
updateConditions(tracker, action.tag, (conditions) => conditions.filter((condition) => !condition.includes(action.value.toLowerCase().trim())));
|
|
1030
1073
|
return tracker;
|
|
1031
1074
|
case 'inc-conditions':
|
|
1032
|
-
updateConditions(tracker, action.tag, (conditions) => conditions.map((condition) => (numberedCondition(condition, action.value.toLowerCase().trim(), (label, value) => `${label} ${value + 1}`))));
|
|
1075
|
+
updateConditions(tracker, action.tag, (conditions) => conditions.map((condition) => (numberedCondition(condition, action.value.toLowerCase().trim(), (label, value) => `${label} ${value + 1}`))).filter((c) => c !== null));
|
|
1033
1076
|
return tracker;
|
|
1034
1077
|
case 'dec-conditions':
|
|
1035
|
-
updateConditions(tracker, action.tag, (conditions) => conditions.map((condition) => (numberedCondition(condition, action.value.toLowerCase().trim(), (label, value) => (value > 1 ? `${label} ${value - 1}` :
|
|
1078
|
+
updateConditions(tracker, action.tag, (conditions) => conditions.map((condition) => (numberedCondition(condition, action.value.toLowerCase().trim(), (label, value) => (value > 1 ? `${label} ${value - 1}` : null)))).filter((c) => c !== null));
|
|
1036
1079
|
return tracker;
|
|
1037
1080
|
case 'mod-thp': {
|
|
1038
1081
|
const item = findCharacterOrChild(tracker, action.tag);
|