maidraw 0.4.3 → 0.4.4

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.
@@ -67,7 +67,7 @@
67
67
  {
68
68
  "type": "image",
69
69
  "x": 980,
70
- "y": 260,
70
+ "y": 220,
71
71
  "width": 600,
72
72
  "height": 566,
73
73
  "path": "../../common/prism/jp/chara.png"
@@ -91,7 +91,7 @@
91
91
  {
92
92
  "type": "score-grid",
93
93
  "x": 40,
94
- "y": 470,
94
+ "y": 440,
95
95
  "horizontalSize": 5,
96
96
  "verticalSize": 3,
97
97
  "region": "new",
@@ -114,7 +114,7 @@
114
114
  {
115
115
  "type": "score-grid",
116
116
  "x": 40,
117
- "y": 1075,
117
+ "y": 1015,
118
118
  "horizontalSize": 5,
119
119
  "verticalSize": 7,
120
120
  "region": "old",
@@ -144,8 +144,8 @@
144
144
  "type": "text",
145
145
  "size": 32,
146
146
  "x": 60,
147
- "y": 415,
148
- "borderColor": "#000000",
147
+ "y": 2280,
148
+ "borderColor": "#226180",
149
149
  "align": "left",
150
150
  "content": "Generated by saltbot |"
151
151
  },
@@ -153,10 +153,37 @@
153
153
  "type": "text",
154
154
  "size": 28,
155
155
  "x": 445,
156
- "y": 385,
157
- "borderColor": "#000000",
156
+ "y": 2260,
157
+ "borderColor": "#226180",
158
158
  "align": "left",
159
- "content": "maimaidx.cab/invite\nmaimaidx.cab/discord"
159
+ "content": "maimai.cab/invite\nmaimai.cab/discord"
160
+ },
161
+ {
162
+ "type": "text",
163
+ "size": 24,
164
+ "x": 50,
165
+ "y": 390,
166
+ "borderColor": "#226180",
167
+ "align": "left",
168
+ "content": "NEW\nOLD"
169
+ },
170
+ {
171
+ "type": "text",
172
+ "size": 24,
173
+ "x": 115,
174
+ "y": 390,
175
+ "borderColor": "#226180",
176
+ "align": "left",
177
+ "content": "scores average: {newScoreRatingAvg}.\nscores average: {oldScoreRatingAvg}."
178
+ },
179
+ {
180
+ "type": "text",
181
+ "size": 24,
182
+ "x": 370,
183
+ "y": 390,
184
+ "borderColor": "#226180",
185
+ "align": "left",
186
+ "content": "{newScoreMilestone}\n{oldScoreMilestone}"
160
187
  }
161
188
  ]
162
189
  }
@@ -3,9 +3,6 @@ import ScoreTrackerAdapter from "./lib";
3
3
  import { LXNS } from "./lib/lxns";
4
4
  import { KamaiTachi } from "./lib/kamaiTachi";
5
5
  import { DivingFish } from "./lib/divingFish";
6
- export { LXNS } from "./lib/lxns";
7
- export { KamaiTachi } from "./lib/kamaiTachi";
8
- export { DivingFish } from "./lib/divingFish";
9
6
  export declare class Best50 {
10
7
  static LXNS: typeof LXNS;
11
8
  static KamaiTachi: typeof KamaiTachi;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.Best50 = exports.DivingFish = exports.KamaiTachi = exports.LXNS = void 0;
6
+ exports.Best50 = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
8
  const upath_1 = __importDefault(require("upath"));
9
9
  const type_1 = require("../../type");
@@ -15,12 +15,7 @@ const chart_1 = require("../chart");
15
15
  const lxns_1 = require("./lib/lxns");
16
16
  const kamaiTachi_1 = require("./lib/kamaiTachi");
17
17
  const divingFish_1 = require("./lib/divingFish");
18
- var lxns_2 = require("./lib/lxns");
19
- Object.defineProperty(exports, "LXNS", { enumerable: true, get: function () { return lxns_2.LXNS; } });
20
- var kamaiTachi_2 = require("./lib/kamaiTachi");
21
- Object.defineProperty(exports, "KamaiTachi", { enumerable: true, get: function () { return kamaiTachi_2.KamaiTachi; } });
22
- var divingFish_2 = require("./lib/divingFish");
23
- Object.defineProperty(exports, "DivingFish", { enumerable: true, get: function () { return divingFish_2.DivingFish; } });
18
+ const string_template_1 = __importDefault(require("string-template"));
24
19
  class HalfFullWidthConvert {
25
20
  static charsets = {
26
21
  latin: { halfRE: /[!-~]/g, fullRE: /[!-~]/g, delta: 0xfee0 },
@@ -703,11 +698,11 @@ class Best50 {
703
698
  }
704
699
  /* End Username Draw*/
705
700
  }
706
- static async drawTextModule(ctx, theme, element) {
707
- let infiniteWideLines = element.content.split("\n");
701
+ static async drawTextModule(ctx, theme, element, variables = {}) {
702
+ let naiveLines = (0, string_template_1.default)(element.content, variables).split("\n");
708
703
  let lines = [];
709
704
  if (element.linebreak) {
710
- for (let originalContent of infiniteWideLines) {
705
+ for (let originalContent of naiveLines) {
711
706
  while (originalContent.length) {
712
707
  const line = this.findMaxFitString(ctx, originalContent, element.width || Infinity, "");
713
708
  originalContent = originalContent.replace(line, "").trim();
@@ -716,13 +711,13 @@ class Best50 {
716
711
  }
717
712
  }
718
713
  else {
719
- for (const originalContent of infiniteWideLines) {
714
+ for (const originalContent of naiveLines) {
720
715
  lines.push(this.findMaxFitString(ctx, originalContent, element.width || Infinity));
721
716
  }
722
717
  }
723
718
  for (let i = 0; i < lines.length; ++i) {
724
719
  const line = lines[i];
725
- this.drawText(ctx, line, element.x, element.y + i * element.size * 1.3, element.size, element.size / 6, element.width || Infinity, element.align, element.color || "#FFFFFF", element.borderColor
720
+ this.drawText(ctx, line, element.x, element.y + i * element.size * 1.3, element.size, element.size / 3.5, element.width || Infinity, element.align, element.color || "#FFFFFF", element.borderColor
726
721
  ? element.borderColor
727
722
  : color_1.default.rgb(element.color || "#FFFFFF")
728
723
  .darken(0.3)
@@ -781,7 +776,326 @@ class Best50 {
781
776
  break;
782
777
  }
783
778
  case "text": {
784
- await this.drawTextModule(ctx, currentTheme, element);
779
+ function getRatingBase(scores) {
780
+ return (scores
781
+ .map((v) => v.dxRating)
782
+ .sort((a, b) => a - b)[0] || 0);
783
+ }
784
+ function getRatingAvg(scores) {
785
+ return (scores
786
+ .map((v) => v.dxRating)
787
+ .reduce((sum, v) => (sum += v)) /
788
+ scores.length);
789
+ }
790
+ function getMilestone(scores) {
791
+ const MILESTONES_SSSP = {
792
+ "15.0": 337,
793
+ "14.9": 335,
794
+ "14.8": 333,
795
+ "14.7": 330,
796
+ "14.6": 328,
797
+ "14.5": 326,
798
+ "14.4": 324,
799
+ "14.3": 321,
800
+ "14.2": 319,
801
+ "14.1": 317,
802
+ "14.0": 315,
803
+ "13.9": 312,
804
+ "13.8": 310,
805
+ "13.7": 308,
806
+ "13.6": 306,
807
+ "13.5": 303,
808
+ "13.4": 301,
809
+ "13.3": 299,
810
+ "13.2": 297,
811
+ "13.1": 294,
812
+ "13.0": 292,
813
+ "12.9": 290,
814
+ "12.8": 288,
815
+ "12.7": 285,
816
+ "12.6": 283,
817
+ "12.5": 281,
818
+ "12.4": 279,
819
+ "12.3": 276,
820
+ "12.2": 274,
821
+ "12.1": 272,
822
+ "12.0": 270,
823
+ "11.9": 267,
824
+ "11.8": 265,
825
+ "11.7": 263,
826
+ "11.6": 261,
827
+ "11.5": 258,
828
+ "11.4": 256,
829
+ "11.3": 254,
830
+ "11.2": 252,
831
+ "11.1": 249,
832
+ "11.0": 247,
833
+ "10.9": 245,
834
+ "10.8": 243,
835
+ "10.7": 240,
836
+ "10.6": 238,
837
+ "10.5": 236,
838
+ "10.4": 234,
839
+ "10.3": 231,
840
+ "10.2": 229,
841
+ "10.1": 227,
842
+ "10.0": 225,
843
+ "9.9": 222,
844
+ "9.8": 220,
845
+ "9.7": 218,
846
+ "9.6": 216,
847
+ "9.5": 213,
848
+ "9.4": 211,
849
+ "9.3": 209,
850
+ "9.2": 207,
851
+ "9.1": 204,
852
+ "9.0": 202,
853
+ "8.9": 200,
854
+ "8.8": 198,
855
+ "8.7": 195,
856
+ "8.6": 193,
857
+ "8.5": 191,
858
+ "8.4": 189,
859
+ "8.3": 186,
860
+ "8.2": 184,
861
+ "8.1": 182,
862
+ "8.0": 180,
863
+ "7.9": 177,
864
+ "7.8": 175,
865
+ "7.7": 173,
866
+ "7.6": 171,
867
+ "7.5": 168,
868
+ "7.4": 166,
869
+ "7.3": 164,
870
+ "7.2": 162,
871
+ "7.1": 159,
872
+ "7.0": 157,
873
+ "6.9": 155,
874
+ "6.8": 153,
875
+ "6.7": 150,
876
+ "6.6": 148,
877
+ "6.5": 146,
878
+ "6.4": 144,
879
+ "6.3": 141,
880
+ "6.2": 139,
881
+ "6.1": 137,
882
+ "6.0": 135,
883
+ "5.9": 132,
884
+ "5.8": 130,
885
+ "5.7": 128,
886
+ "5.6": 126,
887
+ "5.5": 123,
888
+ "5.4": 121,
889
+ "5.3": 119,
890
+ "5.2": 117,
891
+ "5.1": 114,
892
+ "5.0": 112,
893
+ "4.9": 110,
894
+ "4.8": 108,
895
+ "4.7": 105,
896
+ "4.6": 103,
897
+ "4.5": 101,
898
+ "4.4": 99,
899
+ "4.3": 96,
900
+ "4.2": 94,
901
+ "4.1": 92,
902
+ "4.0": 90,
903
+ "3.9": 87,
904
+ "3.8": 85,
905
+ "3.7": 83,
906
+ "3.6": 81,
907
+ "3.5": 78,
908
+ "3.4": 76,
909
+ "3.3": 74,
910
+ "3.2": 72,
911
+ "3.1": 69,
912
+ "3.0": 67,
913
+ "2.9": 65,
914
+ "2.8": 63,
915
+ "2.7": 60,
916
+ "2.6": 58,
917
+ "2.5": 56,
918
+ "2.4": 54,
919
+ "2.3": 51,
920
+ "2.2": 49,
921
+ "2.1": 47,
922
+ "2.0": 45,
923
+ "1.9": 42,
924
+ "1.8": 40,
925
+ "1.7": 38,
926
+ "1.6": 36,
927
+ "1.5": 33,
928
+ "1.4": 31,
929
+ "1.3": 29,
930
+ "1.2": 27,
931
+ "1.1": 24,
932
+ "1.0": 22,
933
+ };
934
+ const MILESTONES_SSS = {
935
+ "15.0": 324,
936
+ "14.9": 321,
937
+ "14.8": 319,
938
+ "14.7": 317,
939
+ "14.6": 315,
940
+ "14.5": 313,
941
+ "14.4": 311,
942
+ "14.3": 308,
943
+ "14.2": 306,
944
+ "14.1": 304,
945
+ "14.0": 302,
946
+ "13.9": 300,
947
+ "13.8": 298,
948
+ "13.7": 295,
949
+ "13.6": 293,
950
+ "13.5": 291,
951
+ "13.4": 289,
952
+ "13.3": 287,
953
+ "13.2": 285,
954
+ "13.1": 282,
955
+ "13.0": 280,
956
+ "12.9": 278,
957
+ "12.8": 276,
958
+ "12.7": 274,
959
+ "12.6": 272,
960
+ "12.5": 270,
961
+ "12.4": 267,
962
+ "12.3": 265,
963
+ "12.2": 263,
964
+ "12.1": 261,
965
+ "12.0": 259,
966
+ "11.9": 257,
967
+ "11.8": 254,
968
+ "11.7": 252,
969
+ "11.6": 250,
970
+ "11.5": 248,
971
+ "11.4": 246,
972
+ "11.3": 244,
973
+ "11.2": 241,
974
+ "11.1": 239,
975
+ "11.0": 237,
976
+ "10.9": 235,
977
+ "10.8": 233,
978
+ "10.7": 231,
979
+ "10.6": 228,
980
+ "10.5": 226,
981
+ "10.4": 224,
982
+ "10.3": 222,
983
+ "10.2": 220,
984
+ "10.1": 218,
985
+ "10.0": 216,
986
+ "9.9": 213,
987
+ "9.8": 211,
988
+ "9.7": 209,
989
+ "9.6": 207,
990
+ "9.5": 205,
991
+ "9.4": 203,
992
+ "9.3": 200,
993
+ "9.2": 198,
994
+ "9.1": 196,
995
+ "9.0": 194,
996
+ "8.9": 192,
997
+ "8.8": 190,
998
+ "8.7": 187,
999
+ "8.6": 185,
1000
+ "8.5": 183,
1001
+ "8.4": 181,
1002
+ "8.3": 179,
1003
+ "8.2": 177,
1004
+ "8.1": 174,
1005
+ "8.0": 172,
1006
+ "7.9": 170,
1007
+ "7.8": 168,
1008
+ "7.7": 166,
1009
+ "7.6": 164,
1010
+ "7.5": 162,
1011
+ "7.4": 159,
1012
+ "7.3": 157,
1013
+ "7.2": 155,
1014
+ "7.1": 153,
1015
+ "7.0": 151,
1016
+ "6.9": 149,
1017
+ "6.8": 146,
1018
+ "6.7": 144,
1019
+ "6.6": 142,
1020
+ "6.5": 140,
1021
+ "6.4": 138,
1022
+ "6.3": 136,
1023
+ "6.2": 133,
1024
+ "6.1": 131,
1025
+ "6.0": 129,
1026
+ "5.9": 127,
1027
+ "5.8": 125,
1028
+ "5.7": 123,
1029
+ "5.6": 120,
1030
+ "5.5": 118,
1031
+ "5.4": 116,
1032
+ "5.3": 114,
1033
+ "5.2": 112,
1034
+ "5.1": 110,
1035
+ "5.0": 108,
1036
+ "4.9": 105,
1037
+ "4.8": 103,
1038
+ "4.7": 101,
1039
+ "4.6": 99,
1040
+ "4.5": 97,
1041
+ "4.4": 95,
1042
+ "4.3": 92,
1043
+ "4.2": 90,
1044
+ "4.1": 88,
1045
+ "4.0": 86,
1046
+ "3.9": 84,
1047
+ "3.8": 82,
1048
+ "3.7": 79,
1049
+ "3.6": 77,
1050
+ "3.5": 75,
1051
+ "3.4": 73,
1052
+ "3.3": 71,
1053
+ "3.2": 69,
1054
+ "3.1": 66,
1055
+ "3.0": 64,
1056
+ "2.9": 62,
1057
+ "2.8": 60,
1058
+ "2.7": 58,
1059
+ "2.6": 56,
1060
+ "2.5": 54,
1061
+ "2.4": 51,
1062
+ "2.3": 49,
1063
+ "2.2": 47,
1064
+ "2.1": 45,
1065
+ "2.0": 43,
1066
+ "1.9": 41,
1067
+ "1.8": 38,
1068
+ "1.7": 36,
1069
+ "1.6": 34,
1070
+ "1.5": 32,
1071
+ "1.4": 30,
1072
+ "1.3": 28,
1073
+ "1.2": 25,
1074
+ "1.1": 23,
1075
+ "1.0": 21,
1076
+ };
1077
+ const base = getRatingBase(scores);
1078
+ const sssTarget = Object.entries(MILESTONES_SSS).find(([_, rating]) => base >= rating)?.[0];
1079
+ const ssspTarget = Object.entries(MILESTONES_SSSP).find(([_, rating]) => base >= rating)?.[0];
1080
+ if (sssTarget && ssspTarget)
1081
+ return `Next rating boost: lv. ${(parseFloat(ssspTarget) + 0.1).toFixed(1)} SSS+/${(parseFloat(sssTarget) + 0.1).toFixed(1)} SSS`;
1082
+ else if (sssTarget)
1083
+ return `Next rating boost: lv. ${(parseFloat(sssTarget) + 0.1).toFixed(1)} SSS`;
1084
+ else if (ssspTarget)
1085
+ return `Next rating boost: lv. ${(parseFloat(ssspTarget) + 0.1).toFixed(1)} SSS`;
1086
+ else
1087
+ return "Good job!";
1088
+ }
1089
+ await this.drawTextModule(ctx, currentTheme, element, {
1090
+ username: HalfFullWidthConvert.toFullWidth(name),
1091
+ rating: rating.toFixed(0),
1092
+ newScoreRatingAvg: getRatingAvg(newScores).toFixed(0),
1093
+ oldScoreRatingAvg: getRatingAvg(oldScores).toFixed(0),
1094
+ newScoreRatingBase: getRatingBase(newScores).toFixed(0),
1095
+ oldScoreRatingBase: getRatingBase(oldScores).toFixed(0),
1096
+ newScoreMilestone: getMilestone(newScores),
1097
+ oldScoreMilestone: getMilestone(oldScores),
1098
+ });
785
1099
  break;
786
1100
  }
787
1101
  }