@zwa73/utils 1.0.46 → 1.0.49

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.
@@ -0,0 +1,223 @@
1
+ import { UtilFunc } from "../UtilFunctions";
2
+ import { ComposedClassMult, ComposedPartClass, ComposedPartClassMult, FixedLengthTuple, FuncPropNames } from "../UtilInterfaces";
3
+
4
+ const compKeys = ["getData","getA"] as const;
5
+
6
+ class A {
7
+ abc=223;
8
+ /**A的getData */
9
+ getData(){
10
+ return this.abc
11
+ }
12
+ /**获取A */
13
+ getA(){
14
+ return this;
15
+ }
16
+ }
17
+ class C {
18
+ abc=3333;
19
+ /**A的getData */
20
+ resetData(){
21
+ return this.abc
22
+ }
23
+ /**获取C */
24
+ getC(){
25
+ return this;
26
+ }
27
+ /**获取C */
28
+ private getC1(){
29
+ return this;
30
+ }
31
+ }
32
+ class B{
33
+ private _bc:BComp;
34
+ private constructor(){
35
+ const tb:B = this;
36
+ this._bc = UtilFunc.composePartClass(tb, new A(), ...compKeys);
37
+ }
38
+ static init(){
39
+ return new B()._bc;
40
+ }
41
+ /**B的getData */
42
+ getData1(){return "BGetdata"}
43
+ getTest(){return this._bc.getData()}
44
+ }
45
+ type BComp = ComposedPartClass<B, A, typeof compKeys[number]>;
46
+ const BComp = {
47
+ init(){
48
+ return B.init();
49
+ }
50
+ }
51
+
52
+ let c:BComp = BComp.init();
53
+ console.log(1);
54
+ let d = c.getData();//?
55
+ c.getA
56
+ c.getData1();//?
57
+ c.getTest();//?
58
+
59
+ // 使用示例
60
+ type R3 = ComposedPartClassMult<B, A, "getData"|"getA", C>
61
+ let r3:R3 = null as any;
62
+
63
+
64
+
65
+ class Monster{
66
+ constructor(a:number){}
67
+ monfunc(){
68
+ return "mon"
69
+ }
70
+ }
71
+ class Monster1{
72
+ constructor(a:number){}
73
+ m1num=123;
74
+ monfunc1(){
75
+ return "mon1"
76
+ }
77
+ }
78
+ type OtherMonster = ComposedClassMult<{
79
+ om:string
80
+ mon:Monster
81
+ },[Monster,Monster1]>
82
+ const OtherMonster = {
83
+ init():OtherMonster{
84
+ let mon = new Monster(123);
85
+ let mon1 = new Monster1(223);
86
+ let om = {
87
+ om:"123",mon
88
+ }
89
+ return UtilFunc.composeClass(om,mon,mon1);
90
+ }
91
+ }
92
+
93
+ let om = OtherMonster.init();//?
94
+ om.monfunc();//?
95
+ om.monfunc1();//?
96
+ om.m1num//?
97
+
98
+ type ExtData = {
99
+ 攻击 : number;
100
+ 生命 : number;
101
+ 防御 : number;
102
+ 暴击 : number;
103
+ 暴击伤害 : number;
104
+ 攻击加成 : number;
105
+ 生命加成 : number;
106
+ 防御加成 : number;
107
+ };
108
+ const BASE_MAX = { 攻击: 24, 生命: 54, 防御: 16, 暴击: 5, 暴击伤害: 5, 攻击加成: 3.8, 生命加成: 3.8, 防御加成: 3.8 }
109
+ const 精调前 = [
110
+ { 攻击 : 17, 生命: 0 , 防御: 0 , 暴击: 0 , 暴击伤害: 3.5 , 攻击加成: 3.0, 生命加成: 0, 防御加成: 3.4 } , // 霰弹 专用消焰器
111
+ { 攻击 : 19, 生命: 0 , 防御: 0 , 暴击: 4.5 , 暴击伤害: 4.5 , 攻击加成: 3.4, 生命加成: 0, 防御加成: 0 } , // 霰弹 专用消音器
112
+ { 攻击 : 21, 生命: 0 , 防御: 10 , 暴击: 0 , 暴击伤害: 0 , 攻击加成: 3.8, 生命加成: 0, 防御加成: 3.0 } , // 机枪 重型制退器
113
+ { 攻击 : 17, 生命: 48 , 防御: 14 , 暴击: 0 , 暴击伤害: 0 , 攻击加成: 2.6, 生命加成: 0, 防御加成: 0 } , // 冲锋 消焰器攻击头
114
+ { 攻击 : 23, 生命: 0 , 防御: 0 , 暴击: 5 , 暴击伤害: 0 , 攻击加成: 3.4, 生命加成: 0, 防御加成: 0 } , // 狙击 异位打击 快拆战术手电
115
+ { 攻击 : 17, 生命: 53 , 防御: 0 , 暴击: 0 , 暴击伤害: 0 , 攻击加成: 3.4, 生命加成: 0, 防御加成: 0 } , // 霰弹 减伤支援 钢化铆钉
116
+ { 攻击 : 21, 生命: 0 , 防御: 0 , 暴击: 3.5 , 暴击伤害: 0 , 攻击加成: 3.0, 生命加成: 0, 防御加成: 0 } , // 冲锋 异位打击 内瞄式红点
117
+ { 攻击 : 17, 生命: 0 , 防御: 3.8, 暴击: 0 , 暴击伤害: 0 , 攻击加成: 2.6, 生命加成: 0, 防御加成: 0 } , // 机枪 双重对策 镭射插件
118
+ { 攻击 : 19, 生命: 38 , 防御: 0 , 暴击: 0 , 暴击伤害: 0 , 攻击加成: 3.4, 生命加成: 0, 防御加成: 0 } , // 机枪 双重对策 折叠脚架
119
+ ] as const;
120
+ const 精调后 = [
121
+ { 攻击 : 26, 生命: 0 , 防御: 0 , 暴击: 0 , 暴击伤害: 8.1 , 攻击加成: 7.5, 生命加成: 0, 防御加成: 5.8 } , // 霰弹 专用消焰器
122
+ { 攻击 : 31, 生命: 0 , 防御: 0 , 暴击: 10.4, 暴击伤害: 10.4, 攻击加成: 7.5, 生命加成: 0, 防御加成: 0 } , // 霰弹 专用消音器
123
+ { 攻击 : 49, 生命: 0 , 防御: 17 , 暴击: 0 , 暴击伤害: 0 , 攻击加成: 7.6, 生命加成: 0, 防御加成: 6.9 } , // 机枪 重型制退器
124
+ { 攻击 : 46, 生命: 116, 防御: 27 , 暴击: 0 , 暴击伤害: 0 , 攻击加成: 5.0, 生命加成: 0, 防御加成: 0 } , // 冲锋 消焰器攻击头
125
+ { 攻击 : 42, 生命: 0 , 防御: 0 , 暴击: 11.5, 暴击伤害: 0 , 攻击加成: 6.8, 生命加成: 0, 防御加成: 0 } , // 狙击 异位打击 快拆战术
126
+ { 攻击 : 34, 生命: 101, 防御: 0 , 暴击: 0 , 暴击伤害: 0 , 攻击加成: 6.5, 生命加成: 0, 防御加成: 0 } , // 霰弹 减伤支援 钢化铆钉
127
+ { 攻击 : 38, 生命: 0 , 防御: 0 , 暴击: 8.4 , 暴击伤害: 0 , 攻击加成: 4.8, 生命加成: 0, 防御加成: 0 } , // 冲锋 异位打击 内瞄式红
128
+ { 攻击 : 43, 生命: 0 , 防御: 8.0, 暴击: 0 , 暴击伤害: 0 , 攻击加成: 7.3, 生命加成: 0, 防御加成: 0 } , // 机枪 双重对策 镭射插件
129
+ { 攻击 : 42, 生命: 54 , 防御: 0 , 暴击: 0 , 暴击伤害: 0 , 攻击加成: 6.2, 生命加成: 0, 防御加成: 0 } , // 机枪 双重对策 折叠脚架
130
+ ] as const;
131
+ const Pointify = (ed:ExtData)=>
132
+ UtilFunc.mapObject(ed,(k,v)=> v ? v / BASE_MAX[k] : 0 );
133
+ const Sump = (ed:ExtData)=> Object.values(ed).reduce((r,v)=>r+v);
134
+ const pipeFunc = UtilFunc.pipeline(Pointify,Sump);
135
+ const Display = (list:number[])=>list.reduce((r,v)=>`${r}\t${v.toFixed(2)}`,"").trim();
136
+ const pre = 精调前.map((v)=>pipeFunc(v));
137
+ const aft = 精调后.map((v)=>pipeFunc(v));
138
+ const div = pre.map((dv,i)=>aft[i]/dv);
139
+ Display(pre)//?
140
+ Display(aft)//?
141
+ Display(div)//?
142
+
143
+
144
+ interface obja {
145
+ a: number;
146
+ }
147
+ // 定义一个函数,它将作为构造函数
148
+ function MyObject() {
149
+ // @ts-ignore
150
+ this.a = 123;
151
+ }
152
+
153
+
154
+ let asloop = [
155
+ {
156
+ type:"effect_of_condition",
157
+ id:"loop",
158
+ effect:[
159
+ {if:{math:["i",">","0"]},
160
+ then:[
161
+ {u_message:"hello world"},
162
+ {math:["i","-=","1"]},
163
+ {run_eocs:"loop"},
164
+ ]}
165
+ ]
166
+ },
167
+ {
168
+ type:"effect_of_condition",
169
+ id:"main",
170
+ effect:[
171
+ {math:["i","=","10"]},
172
+ {run_eocs:"loop"}
173
+ ]
174
+ }
175
+ ]
176
+ let asaloop = [
177
+ {
178
+ type:"effect_of_condition",
179
+ id:"loop",
180
+ effect:[
181
+ {u_message:"hello world"}
182
+ ]
183
+ },
184
+ {
185
+ type:"effect_of_condition",
186
+ id:"main",
187
+ effect:[
188
+ {
189
+ run_eoc_with:"efl",
190
+ variables:{
191
+ i:"0",
192
+ length:"10",
193
+ eoc:"loop"
194
+ }
195
+ }
196
+ ]
197
+ }
198
+ ]
199
+
200
+
201
+ const testa = {
202
+ _a: 123
203
+ }
204
+ Object.defineProperty(testa, 'a', {
205
+ get: () =>1,
206
+ set: function(value) {
207
+ console.log('Set:', value);
208
+ },
209
+ enumerable: true
210
+ });
211
+ Object.defineProperty(testa, 'c', {
212
+ value: 123,
213
+ writable: true,
214
+ enumerable: true,
215
+ configurable: true
216
+ });
217
+ testa.constructor.prototype//?
218
+ testa//?
219
+ let testkeys:any = [];
220
+ for(let k in testa)
221
+ testkeys.push(k)
222
+ testkeys//?
223
+
@@ -0,0 +1,40 @@
1
+ import * as fs from "fs";
2
+ import * as path from "path";
3
+ import { globSync } from "glob";
4
+ import { UtilFT } from "../UtilFileTools";
5
+
6
+ // 将字符串转换为十六进制
7
+ function stringToHex(str:string) {
8
+ const buf = Buffer.from(str, 'utf8');
9
+ return buf.toString('hex');
10
+ }
11
+
12
+ // 将十六进制转换为字符串
13
+ function hexToString(hex:string) {
14
+ const buf = Buffer.from(hex, 'hex');
15
+ return buf.toString('utf8');
16
+ }
17
+
18
+ // 示例
19
+ let str = "Hello World";
20
+ let hex = "0B0000002D";
21
+
22
+ console.log(stringToHex(str)); // 输出字符串对应的十六进制
23
+ console.log(hexToString(hex)); // 输出十六进制对应的字符串
24
+ hexToString("556E6974794653")//?
25
+ /**
26
+ 首先我有一个文件夹./in
27
+ 我在里面存放了一些整合加密的二进制文件,文件名符合正则/.*\.bk/
28
+ 我需要你帮我写解密程序,将其解密并分离为单独的文件,接下来我告诉你解密方式:
29
+ 读取文件后,我们先用split(hexToString(hex))对文本进行分割成多块,然后在每一块找到第二个"UnityFS",
30
+ 再从第二个UnityFS的开头截取到每一块的末尾
31
+ 我举一个例子,假设我们有一段分割完成的文本块 "112233 UnityFS sasasd UnityFS我需要的内容"
32
+ 那么它截取完成之后应该是"UnityFS我需要的内容"
33
+ 最后,我们在将所有截取完成的文本块作为文件输出到./out/{filename}
34
+ 文件名就是 {原文件名+块编号.bs}
35
+ 开始写吧
36
+ **/
37
+ path.parse("123.bs").name;//?
38
+
39
+ let filepath = "F:\\Sosarciel\\SosarcielCore\\NodeJs\\utils\\src"
40
+ UtilFT.fileSearchGlob(`${filepath}/**/*.ts`,"**/test/**/*.ts");//?
package/tsconfig.json CHANGED
@@ -7,6 +7,8 @@
7
7
  "outDir": "./dist",
8
8
  "declaration": true,
9
9
  "baseUrl": ".",
10
+ "emitDecoratorMetadata": true,
11
+ "experimentalDecorators": true,
10
12
  "paths": {
11
13
  "@/*": ["./*"],
12
14
  "DataController": ["./src/DataController"],