pf2e-sage-stats 0.4.3 → 0.4.5
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 +3 -3
- package/dist/app.js +66 -89
- package/package.json +1 -1
package/dist/app.d.ts
CHANGED
|
@@ -761,18 +761,18 @@ export type TrackerCommand = {
|
|
|
761
761
|
} | {
|
|
762
762
|
command: 'foe';
|
|
763
763
|
name: string;
|
|
764
|
-
alias
|
|
764
|
+
alias?: string;
|
|
765
765
|
hp: number;
|
|
766
766
|
} | {
|
|
767
767
|
command: 'friend';
|
|
768
768
|
name: string;
|
|
769
|
-
alias
|
|
769
|
+
alias?: string;
|
|
770
770
|
hp: number;
|
|
771
771
|
} | {
|
|
772
772
|
command: 'child';
|
|
773
773
|
tag: string;
|
|
774
774
|
name: string;
|
|
775
|
-
alias
|
|
775
|
+
alias?: string;
|
|
776
776
|
hp: number;
|
|
777
777
|
} | {
|
|
778
778
|
command: 'name';
|
package/dist/app.js
CHANGED
|
@@ -656,11 +656,12 @@ const formatTracker = (tracker) => {
|
|
|
656
656
|
var _a, _b;
|
|
657
657
|
const aliasSpace = (t) => (t.alias.length > 0 ? 0 : 5);
|
|
658
658
|
const nameLengthWithAlias = (t) => t.name.length - aliasSpace(t);
|
|
659
|
-
const
|
|
659
|
+
const chars = [...tracker.chars];
|
|
660
|
+
const nameLength = chars.reduce((p, c) => {
|
|
660
661
|
const length = c.children.reduce((pp, cc) => pp > nameLengthWithAlias(cc) ? pp : nameLengthWithAlias(cc), nameLengthWithAlias(c));
|
|
661
662
|
return p > length ? p : length;
|
|
662
663
|
}, 0);
|
|
663
|
-
const hpLength =
|
|
664
|
+
const hpLength = chars.reduce((p, c) => {
|
|
664
665
|
const hpLength = c.maxhp.toString().length + 1 + c.hp.toString().length + (c.temphp > 1 ? c.temphp.toString().length + 1 : 0);
|
|
665
666
|
const length = c.children.reduce((pp, cc) => {
|
|
666
667
|
const hhpLength = cc.maxhp.toString().length + 1 + cc.hp.toString().length + (cc.temphp > 1 ? cc.temphp.toString().length + 1 : 0);
|
|
@@ -681,9 +682,9 @@ const formatTracker = (tracker) => {
|
|
|
681
682
|
':limping:',
|
|
682
683
|
':dying:',
|
|
683
684
|
].reverse();
|
|
684
|
-
const lines =
|
|
685
|
+
const lines = chars.sort((a, b) => (a.init === b.init) ? (b.foe ? 1 : 0) - (a.foe ? 1 : 0) : b.init - a.init).flatMap((char, index) => {
|
|
685
686
|
const ls = [];
|
|
686
|
-
if (
|
|
687
|
+
if (chars[index - 1] && chars[index - 1].foe !== char.foe) {
|
|
687
688
|
ls.push('');
|
|
688
689
|
}
|
|
689
690
|
const hp = !char.foe && char.hp > 0 ? (`${char.hp}${char.temphp > 0 ? `+${char.temphp}` : ''}/${char.maxhp}`.padStart(hpLength)) : char.hp > 0 ? (`-${char.maxhp - char.hp}${char.temphp > 0 ? `+${char.temphp}` : ''}`.padStart(hpLength)) : (`${char.hp}${char.temphp > 0 ? `+${char.temphp}` : ''}`.padStart(hpLength));
|
|
@@ -723,187 +724,163 @@ const formatTracker = (tracker) => {
|
|
|
723
724
|
exports.formatTracker = formatTracker;
|
|
724
725
|
const trackerCommands = [{
|
|
725
726
|
regex: /^\s*title\s+(?:([^"\s]+)|"([^"]*)")/i,
|
|
726
|
-
map: (match) => { var _a; return
|
|
727
|
+
map: (match) => { var _a; return [{ command: 'title', title: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }]; },
|
|
727
728
|
}, {
|
|
728
729
|
regex: /^\s*map-text\s+(?:([^"\s]+)|"([^"]*)")/i,
|
|
729
|
-
map: (match) => { var _a; return
|
|
730
|
+
map: (match) => { var _a; return [{ command: 'map-text', mapText: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }]; },
|
|
730
731
|
}, {
|
|
731
732
|
regex: /^\s*map\s+(?:([^"\s]+)|"([^"]*)")/i,
|
|
732
|
-
map: (match) => { var _a; return
|
|
733
|
+
map: (match) => { var _a; return [{ command: 'map', map: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }]; },
|
|
733
734
|
}, {
|
|
734
735
|
regex: /^\s*round-text\s+(?:([^"\s]+)|"([^"]*)")/i,
|
|
735
|
-
map: (match) => { var _a; return
|
|
736
|
+
map: (match) => { var _a; return [{ command: 'round-text', roundText: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }]; },
|
|
736
737
|
}, {
|
|
737
738
|
regex: /^\s*round\s+(?:([^"\s]+)|"([^"]*)")/i,
|
|
738
|
-
map: (match) => { var _a; return
|
|
739
|
+
map: (match) => { var _a; return [{ command: 'round', round: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }]; },
|
|
739
740
|
}, {
|
|
740
741
|
regex: /^\s*(?:desc|description)\s+(?:([^"\s]+)|"([^"]*)")/i,
|
|
741
|
-
map: (match) => { var _a; return
|
|
742
|
+
map: (match) => { var _a; return [{ command: 'desc', description: (_a = match[1]) !== null && _a !== void 0 ? _a : match[2] }]; },
|
|
742
743
|
}, {
|
|
743
744
|
regex: /^\s*(?:b|block)\s*(\d+)/i,
|
|
744
|
-
map: (match) => {
|
|
745
|
+
map: (match) => [{ command: 'block', index: parseInt(match[1], 10) }],
|
|
745
746
|
}, {
|
|
746
747
|
regex: /^\s*reset/i,
|
|
747
|
-
map: () =>
|
|
748
|
+
map: () => [{ command: 'reset' }],
|
|
748
749
|
}, {
|
|
749
750
|
regex: /^\s*purge/i,
|
|
750
|
-
map: () =>
|
|
751
|
+
map: () => [{ command: 'purge' }],
|
|
751
752
|
}, {
|
|
752
753
|
regex: /^\s*(?:blank|blanc|clear)/i,
|
|
753
|
-
map: () =>
|
|
754
|
+
map: () => [{ command: 'blank' }],
|
|
754
755
|
}, {
|
|
755
756
|
regex: /^\s*expire/i,
|
|
756
|
-
map: () =>
|
|
757
|
+
map: () => [{ command: 'expire' }],
|
|
757
758
|
}, {
|
|
758
|
-
regex: /^\s*foe\s+(?:([^"\s]+)|"([^"]*)")
|
|
759
|
-
map: (match) => { var _a; return
|
|
759
|
+
regex: /^\s*foe\s+(?:([^"\s]+)|"([^"]*)")(?:\s+(\S+))?\s+(\d+)/i,
|
|
760
|
+
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) }]; },
|
|
760
761
|
}, {
|
|
761
|
-
regex: /^\s*friend\s+(?:([^"\s]+)|"([^"]*)")
|
|
762
|
-
map: (match) => { var _a; return
|
|
762
|
+
regex: /^\s*friend\s+(?:([^"\s]+)|"([^"]*)")(?:\s+(\S+))?\s+(\d+)/i,
|
|
763
|
+
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) }]; },
|
|
763
764
|
}, {
|
|
764
|
-
regex: /^\s*child\s+(\S+)\s+(?:([^"\s]+)|"([^"]*)")
|
|
765
|
-
map: (match) => { var _a; return
|
|
765
|
+
regex: /^\s*child\s+(\S+)\s+(?:([^"\s]+)|"([^"]*)")(?:\s+(\S+))?\s+(\d+)/i,
|
|
766
|
+
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) }]; },
|
|
766
767
|
}, {
|
|
767
768
|
regex: /^\s*name\s+(\S+)\s+(?:([^"\s]+)|"([^"]*)")/i,
|
|
768
|
-
map: (match) => { var _a; return
|
|
769
|
+
map: (match) => { var _a; return [{ command: 'name', tag: match[1], name: (_a = match[2]) !== null && _a !== void 0 ? _a : match[3] }]; },
|
|
769
770
|
}, {
|
|
770
771
|
regex: /^\s*alias\s+(\S+)\s+(\S+)/i,
|
|
771
|
-
map: (match) =>
|
|
772
|
+
map: (match) => [{ command: 'alias', tag: match[1], alias: match[2] }],
|
|
772
773
|
}, {
|
|
773
774
|
regex: /^\s*hp\s+(\S+)\s+(\d+)/i,
|
|
774
|
-
map: (match) =>
|
|
775
|
+
map: (match) => [{ command: 'hp', tag: match[1], hp: parseInt(match[2], 10) }],
|
|
775
776
|
}, {
|
|
776
777
|
regex: /^\s*heal/i,
|
|
777
|
-
map: () =>
|
|
778
|
+
map: () => [{ command: 'heal' }],
|
|
778
779
|
}, {
|
|
779
780
|
regex: /^\s*exit/i,
|
|
780
|
-
map: () =>
|
|
781
|
+
map: () => [{ command: 'exit' }],
|
|
781
782
|
}, {
|
|
782
783
|
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
|
-
},
|
|
784
|
+
map: (match) => [{ command: 'mod-hp', tag: match[1], value: parseInt(match[2], 10) }],
|
|
789
785
|
}, {
|
|
790
786
|
regex: /^\s*([^\s="+-]+)(?:\s+|\s*=)(\d+)/,
|
|
791
|
-
map: (match) => {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
return { command: 'set-hp', tag, value: parseInt(raw, 10) };
|
|
796
|
-
},
|
|
787
|
+
map: (match) => [{ command: 'set-hp', tag: match[1], value: parseInt(match[2], 10) }],
|
|
788
|
+
}, {
|
|
789
|
+
regex: /^\s*(?:t|temp)((?:\s+([^\s="+-]+)(?:\s+|\s*=)(\d+))+)/i,
|
|
790
|
+
map: (match) => { var _a; return (_a = [...match[1].matchAll(/\s+([^\s="+-]+)(?:\s+|\s*=)(\d+)/g)].map((sub) => ({ command: 'set-thp', tag: sub[1], value: parseInt(sub[2], 10) }))) !== null && _a !== void 0 ? _a : []; },
|
|
797
791
|
}, {
|
|
798
792
|
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
|
-
},
|
|
793
|
+
map: (match) => [{ command: 'mod-thp', tag: match[1], value: parseInt(match[2], 10) }],
|
|
805
794
|
}, {
|
|
806
795
|
regex: /^\s*([^\s="+-]+)\s+[tT]\s*=?(\d+)/,
|
|
807
|
-
map: (match) => {
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
return { command: 'set-thp', tag, value: parseInt(raw, 10) };
|
|
812
|
-
},
|
|
796
|
+
map: (match) => [{ command: 'set-thp', tag: match[1], value: parseInt(match[2], 10) }],
|
|
797
|
+
}, {
|
|
798
|
+
regex: /^\s*(?:i|init)((?:\s+([^\s="+-]+)(?:\s+|\s*=)(\d+))+)/i,
|
|
799
|
+
map: (match) => { var _a; return (_a = [...match[1].matchAll(/\s+([^\s="+-]+)(?:\s+|\s*=)(\d+)/g)].map((sub) => ({ command: 'set-init', tag: sub[1], value: parseInt(sub[2], 10) }))) !== null && _a !== void 0 ? _a : []; },
|
|
813
800
|
}, {
|
|
814
801
|
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
|
-
},
|
|
802
|
+
map: (match) => [{ command: 'mod-init', tag: match[1], value: parseInt(match[2], 10) }],
|
|
821
803
|
}, {
|
|
822
804
|
regex: /^\s*([^\s="+-]+)\s+[iI]\s*=?(\d+)/,
|
|
823
|
-
map: (match) => {
|
|
824
|
-
var _a, _b;
|
|
825
|
-
const tag = (_a = match[1]) !== null && _a !== void 0 ? _a : '';
|
|
826
|
-
const raw = (_b = match[2]) !== null && _b !== void 0 ? _b : '';
|
|
827
|
-
return { command: 'set-init', tag, value: parseInt(raw, 10) };
|
|
828
|
-
},
|
|
805
|
+
map: (match) => [{ command: 'set-init', tag: match[1], value: parseInt(match[2], 10) }],
|
|
829
806
|
}, {
|
|
830
807
|
regex: /^\s*([^\s="+-]+)\s*=?"([^"]*)"/,
|
|
831
|
-
map: (match) => {
|
|
808
|
+
map: (match) => [{ command: 'set-conditions', tag: match[1], value: match[2] }],
|
|
832
809
|
}, {
|
|
833
810
|
regex: /^\s*([^\s="+-]+)\s*\+\+"([^"]*)"/,
|
|
834
|
-
map: (match) => {
|
|
811
|
+
map: (match) => [{ command: 'inc-conditions', tag: match[1], value: match[2] }],
|
|
835
812
|
}, {
|
|
836
813
|
regex: /^\s*([^\s="+-]+)\s*--"([^"]*)"/,
|
|
837
|
-
map: (match) => {
|
|
814
|
+
map: (match) => [{ command: 'dec-conditions', tag: match[1], value: match[2] }],
|
|
838
815
|
}, {
|
|
839
816
|
regex: /^\s*([^\s="+-]+)\s*\+"([^"]*)"/,
|
|
840
|
-
map: (match) => {
|
|
817
|
+
map: (match) => [{ command: 'add-conditions', tag: match[1], value: match[2] }],
|
|
841
818
|
}, {
|
|
842
819
|
regex: /^\s*([^\s="+-]+)\s*-"([^"]*)"/,
|
|
843
|
-
map: (match) => {
|
|
820
|
+
map: (match) => [{ command: 'rem-conditions', tag: match[1], value: match[2] }],
|
|
844
821
|
}, {
|
|
845
822
|
regex: /^\s*([^\s="+-]+)\s+[sS]\s*=?"([^"]*)"/,
|
|
846
|
-
map: (match) => {
|
|
823
|
+
map: (match) => [{ command: 'set-conditions', tag: match[1], value: match[2] }],
|
|
847
824
|
}, {
|
|
848
825
|
regex: /^\s*([^\s="+-]+)\s+[sS]?\s*\+\+"([^"]*)"/,
|
|
849
|
-
map: (match) => {
|
|
826
|
+
map: (match) => [{ command: 'inc-conditions', tag: match[1], value: match[2] }],
|
|
850
827
|
}, {
|
|
851
828
|
regex: /^\s*([^\s="+-]+)\s+[sS]?\s*--"([^"]*)"/,
|
|
852
|
-
map: (match) => {
|
|
829
|
+
map: (match) => [{ command: 'dec-conditions', tag: match[1], value: match[2] }],
|
|
853
830
|
}, {
|
|
854
831
|
regex: /^\s*([^\s="+-]+)\s+[sS]?\s*\+"([^"]*)"/,
|
|
855
|
-
map: (match) => {
|
|
832
|
+
map: (match) => [{ command: 'add-conditions', tag: match[1], value: match[2] }],
|
|
856
833
|
}, {
|
|
857
834
|
regex: /^\s*([^\s="+-]+)\s+[sS]?\s*-"([^"]*)"/,
|
|
858
|
-
map: (match) => {
|
|
835
|
+
map: (match) => [{ command: 'rem-conditions', tag: match[1], value: match[2] }],
|
|
859
836
|
}, {
|
|
860
837
|
regex: /^\s*([^\s="+-]+)\s*=(\S+)/,
|
|
861
|
-
map: (match) => {
|
|
838
|
+
map: (match) => [{ command: 'set-conditions', tag: match[1], value: match[2] }],
|
|
862
839
|
}, {
|
|
863
840
|
regex: /^\s*([^\s="+-]+)\s*\+\+(\S+)/,
|
|
864
|
-
map: (match) => {
|
|
841
|
+
map: (match) => [{ command: 'inc-conditions', tag: match[1], value: match[2] }],
|
|
865
842
|
}, {
|
|
866
843
|
regex: /^\s*([^\s="+-]+)\s*--(\S+)/,
|
|
867
|
-
map: (match) => {
|
|
844
|
+
map: (match) => [{ command: 'dec-conditions', tag: match[1], value: match[2] }],
|
|
868
845
|
}, {
|
|
869
846
|
regex: /^\s*([^\s="+-]+)\s*\+(\S+)/,
|
|
870
|
-
map: (match) => {
|
|
847
|
+
map: (match) => [{ command: 'add-conditions', tag: match[1], value: match[2] }],
|
|
871
848
|
}, {
|
|
872
849
|
regex: /^\s*([^\s="+-]+)\s*-(\S+)/,
|
|
873
|
-
map: (match) => {
|
|
850
|
+
map: (match) => [{ command: 'rem-conditions', tag: match[1], value: match[2] }],
|
|
874
851
|
}, {
|
|
875
852
|
regex: /^\s*([^\s="+-]+)\s+[sS]\s*=(\S+)/,
|
|
876
|
-
map: (match) => {
|
|
853
|
+
map: (match) => [{ command: 'set-conditions', tag: match[1], value: match[2] }],
|
|
877
854
|
}, {
|
|
878
855
|
regex: /^\s*([^\s="+-]+)\s+[sS]\s*\+\+(\S+)/,
|
|
879
|
-
map: (match) => {
|
|
856
|
+
map: (match) => [{ command: 'inc-conditions', tag: match[1], value: match[2] }],
|
|
880
857
|
}, {
|
|
881
858
|
regex: /^\s*([^\s="+-]+)\s+[sS]\s*--(\S+)/,
|
|
882
|
-
map: (match) => {
|
|
859
|
+
map: (match) => [{ command: 'dec-conditions', tag: match[1], value: match[2] }],
|
|
883
860
|
}, {
|
|
884
861
|
regex: /^\s*([^\s="+-]+)\s+[sS]\s*\+(\S+)/,
|
|
885
|
-
map: (match) => {
|
|
862
|
+
map: (match) => [{ command: 'add-conditions', tag: match[1], value: match[2] }],
|
|
886
863
|
}, {
|
|
887
864
|
regex: /^\s*([^\s="+-]+)\s+[sS]\s*-(\S+)/,
|
|
888
|
-
map: (match) => {
|
|
865
|
+
map: (match) => [{ command: 'rem-conditions', tag: match[1], value: match[2] }],
|
|
889
866
|
}, {
|
|
890
867
|
regex: /^\s*(\S+)\s+[cC]/,
|
|
891
|
-
map: (match) => {
|
|
868
|
+
map: (match) => [{ command: 'check', tag: match[1] }],
|
|
892
869
|
}, {
|
|
893
870
|
regex: /^\s*(\S+)\s+[aA]/,
|
|
894
|
-
map: (match) => {
|
|
871
|
+
map: (match) => [{ command: 'arrow', tag: match[1] }],
|
|
895
872
|
}, {
|
|
896
873
|
regex: /^\s*(\S+)\s+[eE]/,
|
|
897
|
-
map: (match) => {
|
|
874
|
+
map: (match) => [{ command: 'empty', tag: match[1] }],
|
|
898
875
|
}, {
|
|
899
876
|
regex: /^\s*(\S+)\s+[xX]/,
|
|
900
|
-
map: (match) => {
|
|
877
|
+
map: (match) => [{ command: 'cross', tag: match[1] }],
|
|
901
878
|
}, {
|
|
902
879
|
regex: /^\s*(\S+)\s+[dD]/,
|
|
903
|
-
map: (match) => {
|
|
880
|
+
map: (match) => [{ command: 'delete', tag: match[1] }],
|
|
904
881
|
}, {
|
|
905
882
|
regex: /^\s*(\S+)\s+[wW]/,
|
|
906
|
-
map: (match) => {
|
|
883
|
+
map: (match) => [{ command: 'wait', tag: match[1] }],
|
|
907
884
|
}];
|
|
908
885
|
const parseTrackerCommands = (line) => {
|
|
909
886
|
const actions = [];
|
|
@@ -917,7 +894,7 @@ const parseTrackerCommands = (line) => {
|
|
|
917
894
|
if (!match) {
|
|
918
895
|
break;
|
|
919
896
|
}
|
|
920
|
-
actions.push(command.map(match));
|
|
897
|
+
actions.push(...command.map(match));
|
|
921
898
|
input = input.slice(match[0].length);
|
|
922
899
|
}
|
|
923
900
|
return actions;
|