/
雀魂Mod_Plus.user.js
7293 lines (7041 loc) · 508 KB
/
雀魂Mod_Plus.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name 雀魂Mod_Plus
// @name:zh-TW 雀魂Mod_Plus
// @name:zh-HK 雀魂Mod_Plus
// @name:en MajsoulMod_Plus
// @name:ja 雀魂Mod_Plus
// @namespace https://github.com/Avenshy
// @version 0.11.38
// @description 雀魂解锁全角色、皮肤、装扮等,支持全部服务器。
// @description:zh-TW 雀魂解鎖全角色、皮膚、裝扮等,支持全部伺服器。
// @description:zh-HK 雀魂解鎖全角色、皮膚、裝扮等,支持全部服務器。
// @description:en A majsoul mod that unlocks all characters, skins, decorations, etc. and supports all servers.
// @description:ja A majsoul mod that unlocks all characters, skins, decorations, etc. and supports all servers.
// @author Avenshy
// @iconURL https://www.maj-soul.com/homepage/character/1/yiji_0.png
// @homepageURL https://github.com/Avenshy/majsoul_mod_plus
// @supportURL https://github.com/Avenshy/majsoul_mod_plus/issues
// @match https://game.maj-soul.com/1/
// @match https://game.maj-soul.net/1/
// @match https://game.mahjongsoul.com/
// @match https://game.mahjongsoul.com/index.html
// @match https://mahjongsoul.game.yo-star.com/
// @require https://greasyfork.org/scripts/447701-javascript-blowfish/code/javascript-blowfish.js?version=1069157
// @require https://greasyfork.org/scripts/447737-majsoul-mod-plus/code/majsoul_mod_plus.js?version=1130702
// @require https://unpkg.com/[email protected]/dist/js/bootstrap.bundle.min.js
// @resource bootstrap https://unpkg.com/[email protected]/dist/css/bootstrap.min.css
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_info
// @grant unsafeWindow
// @grant GM_xmlhttpRequest
// @grant GM_registerMenuCommand
// @grant GM_addStyle
// @grant GM_getResourceText
// @connect localhost
// @license GPL-3.0
// ==/UserScript==
// 无需在此调整任何设置!正常游戏即可!
// 无需在此调整任何设置!正常游戏即可!
// 无需在此调整任何设置!正常游戏即可!
// ID可以F12打开控制台查询。
// 所有物品 cfg.item_definition.item.map_
// 所有角色 cfg.item_definition.character.map_
// 所有皮肤 cfg.item_definition.skin.map_
// 所有称号 cfg.item_definition.title.map_
class MajsoulModPlus {
constructor() {
this.settings = { // 第一次使用的默认设置
character: 200001, // 当前角色
characters: { 0: 400101 }, // 各角色使用的皮肤
star_chars: [], // 星标角色
commonViewList: [
[],
[],
[],
[],
[]
], // 保存装扮
loadingCG: [], // 加载插画CG
using_commonview_index: 0, // 使用装扮页
title: 600021, // 称号
nickname: '',
setAuto: {
isSetAuto: false, // 开关,是否在开局后自动设置指定状态
setAutoLiPai: true, // 自动理牌
setAutoHule: true, // 自动和了
setAutoNoFulu: false, // 不吃碰杠
setAutoMoQie: false // 自动摸切
},
setbianjietishi: false, // 强制打开便捷提示
setItems: {
setAllItems: true, // 开关,是否获得全部道具
ignoreItems: [], // 不需要获得的道具id
ignoreEvent: true // 不获得活动道具,编号一般为309XXX
},
randomBotSkin: false, // 开关,是否随机电脑皮肤
randomPlayerDefSkin: false, // 开关,是否随机那些只有默认皮肤的玩家的皮肤
version: '', // 上次运行的版本,用于显示更新日志
isReadme: false, // 是否已阅读readme
sendGame: false, // 开关,是否发送游戏对局(如发送至mahjong-helper)
sendGameURL: 'https://localhost:12121/', // 接收游戏对局的URL
setPaipuChar: true, // 开关,对查看牌谱生效
showServer: true, // 开关,显示玩家所在服务器
antiCensorship: true, // 开关,反屏蔽名称与文本审查
antiKickout: true // 开关,屏蔽挂机检测踢出游戏
}
}
loadSettings() {
var temp = {};
try {
let value = GM_getValue('majsoul_mod_plus', '');
if (value != '') {
if (value.charAt(0) == '{' && value.charAt(value.length - 1) == '}') {
temp = JSON.parse(GM_getValue('majsoul_mod_plus', '{}'));
} else {
let bf = new Blowfish(secret_key);
temp = JSON.parse(bf.trimZeros(bf.decrypt(bf.base64Decode(value.replace(/-/g, '=')))));
}
} else {
firstRun = true;
}
} catch (error) {
console.log('[雀魂mod_plus] 读取配置出错,自动切换到cookie模式');
let ca = document.cookie.split(";");
for (let element of ca) {
element = element.trim();
if (element.indexOf('majsoul_mod_plus=') == 0) {
value = decodeURIComponent(element.substring("majsoul_mod_plus=".length, element.length));
if (value.charAt(0) == '{' && value.charAt(value.length - 1) == '}') {
temp = JSON.parse(value);
break
} else {
let bf = new Blowfish(secret_key);
temp = JSON.parse(bf.trimZeros(bf.decrypt(bf.base64Decode(value.replace(/-/g, '=')))));
break
}
}
}
}
for (var key in temp) {
if (this.settings[key] != undefined) {
this.settings[key] = temp[key];
}
}
this.saveSettings(true);
}
saveSettings(isFirstRun) {
let bf = new Blowfish(secret_key);
let value = bf.base64Encode(bf.encrypt(JSON.stringify(this.settings))).replace(/=/g, '-')
try {
GM_setValue('majsoul_mod_plus', value);
} catch (error) {
var d = new Date();
d.setTime(d.getTime() + (360 * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toGMTString();
document.cookie = "majsoul_mod_plus=" + encodeURIComponent(value) + "; " + expires;
}
if (isFirstRun) {
console.log('[雀魂mod_plus] 配置已读取:')
console.log(this)
console.warn('[雀魂mod_plus] ' + secret_key);
} else {
console.log('[雀魂mod_plus] 配置已保存:');
console.log(this)
console.warn('[雀魂mod_plus] ' + secret_key);
}
}
}
let secret_key;
let fake_data = {};
! function () {
var MMP = new MajsoulModPlus;
let bf = new Blowfish("majsoul_mod_plus");
secret_key = bf.trimZeros(bf.decrypt(bf.base64Decode(tips.replace(/-/g, '='))));
if (typeof unsafeWindow !== "undefined") {
unsafeWindow.MMP = MMP;
} else {
console.log("unsafeWindow API not available. Try to inject into window.MMP");
window.MMP = MMP;
}
MMP.loadSettings();
}();
// 取称号id
function getAvatar_id() {
for (let item of MMP.settings.commonViewList[MMP.settings.using_commonview_index]) {
if (item.slot == 5) {
return item.item_id;
}
}
return 305501;
}
// 设置便捷提示
function setAuto() {
// 自动理牌
view.DesktopMgr.Inst.auto_liqi = MMP.settings.setAuto.setAutoLiPai;
view.DesktopMgr.Inst.setAutoLiPai(MMP.settings.setAuto.setAutoLiPai);
uiscript.UI_DesktopInfo.Inst.refreshFuncBtnShow(uiscript.UI_DesktopInfo.Inst._container_fun.getChildByName("btn_autolipai"), MMP.settings.setAuto.setAutoLiPai);
//Laya.LocalStorage.setItem("autolipai", MMP.settings.setAuto.setAutoLiPai ? "true" : "false");
// 自动和牌
view.DesktopMgr.Inst.auto_hule = MMP.settings.setAuto.setAutoHule;
view.DesktopMgr.Inst.setAutoHule(MMP.settings.setAuto.setAutoHule);
uiscript.UI_DesktopInfo.Inst.refreshFuncBtnShow(uiscript.UI_DesktopInfo.Inst._container_fun.getChildByName("btn_autohu"), MMP.settings.setAuto.setAutoHule);
// 不吃碰杠
view.DesktopMgr.Inst.auto_nofulu = MMP.settings.setAuto.setAutoNoFulu;
view.DesktopMgr.Inst.setAutoNoFulu(MMP.settings.setAuto.setAutoNoFulu);
uiscript.UI_DesktopInfo.Inst.refreshFuncBtnShow(uiscript.UI_DesktopInfo.Inst._container_fun.getChildByName("btn_autonoming"), MMP.settings.setAuto.setAutoNoFulu);
// 自动摸切
view.DesktopMgr.Inst.auto_moqie = MMP.settings.setAuto.setAutoMoQie;
view.DesktopMgr.Inst.setAutoMoQie(MMP.settings.setAuto.setAutoMoQie);
uiscript.UI_DesktopInfo.Inst.refreshFuncBtnShow(uiscript.UI_DesktopInfo.Inst._container_fun.getChildByName("btn_automoqie"), MMP.settings.setAuto.setAutoMoQie);
}
// 油猴API测试
function testAPI() {
let apis = ['GM_setValue', 'GM_getValue', 'GM_info', 'unsafeWindow', 'GM_xmlhttpRequest', 'GM_registerMenuCommand', 'GM_addStyle', 'GM_getResourceText'];
let result = { 'apis': {}, 'clear': true };
for (func of apis) {
try {
if (typeof eval(func) !== "undefined") {
result['apis'][func] = true;
} else {
result['apis'][func] = false;
result['clear'] = false;
}
} catch {
result['apis'][func] = false;
result['clear'] = false;
}
}
return result
}
! function majsoul_mod_plus() {
try {
// Hack 开启报番型,作者 aoarashi1988,Handle修改
! function () {
const arrBackup = cfg.voice.sound.groups_;
if (!arrBackup || arrBackup.length === 0) {
throw new Error();
}
Object.entries(cfg.voice.sound.groups_).forEach(
([soundID, soundGroup]) => {
soundGroup.forEach((soundObject, index) => {
soundObject.level_limit = 0;
soundObject.bond_limit = 0;
});
});
}
();
// 设置全部道具
!function (G) {
var F;
!function (G) {
G[G.none = 0] = 'none',
G[G['daoju'] = 1] = 'daoju',
G[G.gift = 2] = 'gift',
G[G['fudai'] = 3] = 'fudai',
G[G.view = 5] = 'view';
}
(F = G['EItemCategory'] || (G['EItemCategory'] = {}));
var v = function (v) {
function z() {
var G = v.call(this, new ui['lobby']['bagUI']()) || this;
return G['container_top'] = null,
G['container_content'] = null,
G['locking'] = !1,
G.tabs = [],
G['page_item'] = null,
G['page_gift'] = null,
G['page_skin'] = null,
G['page_cg'] = null,
G['select_index'] = 0,
z.Inst = G,
G;
}
return __extends(z, v),
z.init = function () {
var G = this;
app['NetAgent']['AddListener2Lobby']('NotifyAccountUpdate', Laya['Handler']['create'](this, function (F) {
var v = F['update'];
v && v.bag && (G['update_data'](v.bag['update_items']), G['update_daily_gain_data'](v.bag));
}, null, !1)),
// START
GameMgr.Inst['use_fetch_info'] ||
this['fetch']();
// END
},
z['fetch'] = function () {
var F = this;
this['_item_map'] = {},
this['_daily_gain_record'] = {},
app['NetAgent']['sendReq2Lobby']('Lobby', 'fetchBagInfo', {}, function (v, z) {
if (v || z['error'])
G['UIMgr'].Inst['showNetReqError']('fetchBagInfo', v, z);
else {
app.Log.log('背包信息:' + JSON['stringify'](z));
var h = z.bag;
if (h) {
if (MMP.settings.setItems.setAllItems) {
//设置全部道具
var items = cfg.item_definition.item.map_;
for (var id in items) {
if (MMP.settings.setItems.ignoreItems.includes(Number(id)) || (MMP.settings.setItems.ignoreEvent ? (id.slice(0, 3) == '309' ? true : false) : false)) {
for (let item of h["items"]) {
if (item.item_id == id) {
cfg.item_definition.item.get(item.item_id);
F._item_map[item.item_id] = {
item_id: item.item_id,
count: item.stack,
category: items[item.item_id].category
};
break;
}
}
} else {
cfg.item_definition.item.get(id);
F._item_map[id] = {
item_id: id,
count: 1,
category: items[id].category
}; //获取物品列表并添加
}
}
} else {
if (h['items'])
for (var P = 0; P < h['items']['length']; P++) {
var C = h['items'][P]['item_id'],
M = h['items'][P]['stack'],
U = cfg['item_definition'].item.get(C);
U && (F['_item_map'][C] = {
item_id: C,
count: M,
category: U['category']
}, 1 == U['category'] && 3 == U.type && app['NetAgent']['sendReq2Lobby']('Lobby', 'openAllRewardItem', {
item_id: C
}, function () { }));
}
if (h['daily_gain_record'])
for (var y = h['daily_gain_record'], P = 0; P < y['length']; P++) {
var S = y[P]['limit_source_id'];
F['_daily_gain_record'][S] = {};
var N = y[P]['record_time'];
F['_daily_gain_record'][S]['record_time'] = N;
var O = y[P]['records'];
if (O)
for (var W = 0; W < O['length']; W++)
F['_daily_gain_record'][S][O[W]['item_id']] = O[W]['count'];
}
}
}
}
});
},
z['onFetchSuccess'] = function (G) {
this['_item_map'] = {},
this['_daily_gain_record'] = {};
var F = G['bag_info'];
if (F) {
var v = F.bag;
if (v) {
if (MMP.settings.setItems.setAllItems) {
//设置全部道具
var items = cfg.item_definition.item.map_;
for (var id in items) {
if (MMP.settings.setItems.ignoreItems.includes(Number(id)) || (MMP.settings.setItems.ignoreEvent ? (id.slice(0, 3) == '309' ? true : false) : false)) {
for (let item of v["items"]) {
if (item.item_id == id) {
cfg.item_definition.item.get(item.item_id);
this._item_map[item.item_id] = {
item_id: item.item_id,
count: item.stack,
category: items[item.item_id].category
};
break;
}
}
} else {
cfg.item_definition.item.get(id);
this._item_map[id] = {
item_id: id,
count: 1,
category: items[id].category
}; //获取物品列表并添加
}
}
} else {
if (v['items'])
for (var z = 0; z < v['items']['length']; z++) {
var h = v['items'][z]['item_id'],
P = v['items'][z]['stack'],
C = cfg['item_definition'].item.get(h);
C && (this['_item_map'][h] = {
item_id: h,
count: P,
category: C['category']
}, 1 == C['category'] && 3 == C.type && app['NetAgent']['sendReq2Lobby']('Lobby', 'openAllRewardItem', {
item_id: h
}, function () { }));
}
if (v['daily_gain_record'])
for (var M = v['daily_gain_record'], z = 0; z < M['length']; z++) {
var U = M[z]['limit_source_id'];
this['_daily_gain_record'][U] = {};
var y = M[z]['record_time'];
this['_daily_gain_record'][U]['record_time'] = y;
var S = M[z]['records'];
if (S)
for (var N = 0; N < S['length']; N++)
this['_daily_gain_record'][U][S[N]['item_id']] = S[N]['count'];
}
}
}
}
},
z['find_item'] = function (G) {
var F = this['_item_map'][G];
return F ? {
item_id: F['item_id'],
category: F['category'],
count: F['count']
}
: null;
},
z['get_item_count'] = function (G) {
var F = this['find_item'](G);
if (F)
return F['count'];
if ('100001' == G) {
for (var v = 0, z = 0, h = GameMgr.Inst['free_diamonds']; z < h['length']; z++) {
var P = h[z];
GameMgr.Inst['account_numerical_resource'][P] && (v += GameMgr.Inst['account_numerical_resource'][P]);
}
for (var C = 0, M = GameMgr.Inst['paid_diamonds']; C < M['length']; C++) {
var P = M[C];
GameMgr.Inst['account_numerical_resource'][P] && (v += GameMgr.Inst['account_numerical_resource'][P]);
}
return v;
}
if ('100004' == G) {
for (var U = 0, y = 0, S = GameMgr.Inst['free_pifuquans']; y < S['length']; y++) {
var P = S[y];
GameMgr.Inst['account_numerical_resource'][P] && (U += GameMgr.Inst['account_numerical_resource'][P]);
}
for (var N = 0, O = GameMgr.Inst['paid_pifuquans']; N < O['length']; N++) {
var P = O[N];
GameMgr.Inst['account_numerical_resource'][P] && (U += GameMgr.Inst['account_numerical_resource'][P]);
}
return U;
}
return '100002' == G ? GameMgr.Inst['account_data'].gold : 0;
},
z['find_items_by_category'] = function (G, F) {
var v = [];
for (var z in this['_item_map'])
this['_item_map'][z]['category'] == G && this['_item_map'][z]['count'] && v.push({
item_id: this['_item_map'][z]['item_id'],
category: this['_item_map'][z]['category'],
count: this['_item_map'][z]['count']
});
return F && v.sort(function (G, v) {
return cfg['item_definition'].item.get(G['item_id'])[F] - cfg['item_definition'].item.get(v['item_id'])[F];
}),
v;
},
z['update_data'] = function (F) {
for (var v = 0; v < F['length']; v++) {
var z = F[v]['item_id'],
h = F[v]['stack'];
if (h > 0) {
this['_item_map']['hasOwnProperty'](z['toString']()) ? this['_item_map'][z]['count'] = h : this['_item_map'][z] = {
item_id: z,
count: h,
category: cfg['item_definition'].item.get(z)['category']
};
var P = cfg['item_definition'].item.get(z);
1 == P['category'] && 3 == P.type && app['NetAgent']['sendReq2Lobby']('Lobby', 'openAllRewardItem', {
item_id: z
}, function () { }),
5 == P['category'] && (this['new_bag_item_ids'].push(z), this['new_zhuangban_item_ids'][z] = 1),
8 != P['category'] || P['item_expire'] || this['new_cg_ids'].push(z);
} else if (this['_item_map']['hasOwnProperty'](z['toString']())) {
var C = cfg['item_definition'].item.get(z);
C && 5 == C['category'] && G['UI_Sushe']['on_view_remove'](z),
this['_item_map'][z] = 0,
delete this['_item_map'][z];
}
}
this.Inst && this.Inst['when_data_change']();
for (var v = 0; v < F['length']; v++) {
var z = F[v]['item_id'];
if (this['_item_listener']['hasOwnProperty'](z['toString']()))
for (var M = this['_item_listener'][z], U = 0; U < M['length']; U++)
M[U].run();
}
for (var v = 0; v < this['_all_item_listener']['length']; v++)
this['_all_item_listener'][v].run();
},
z['update_daily_gain_data'] = function (G) {
var F = G['update_daily_gain_record'];
if (F)
for (var v = 0; v < F['length']; v++) {
var z = F[v]['limit_source_id'];
this['_daily_gain_record'][z] || (this['_daily_gain_record'][z] = {});
var h = F[v]['record_time'];
this['_daily_gain_record'][z]['record_time'] = h;
var P = F[v]['records'];
if (P)
for (var C = 0; C < P['length']; C++)
this['_daily_gain_record'][z][P[C]['item_id']] = P[C]['count'];
}
},
z['get_item_daily_record'] = function (G, F) {
return this['_daily_gain_record'][G] ? this['_daily_gain_record'][G]['record_time'] ? game['Tools']['isPassedRefreshTimeServer'](this['_daily_gain_record'][G]['record_time']) ? this['_daily_gain_record'][G][F] ? this['_daily_gain_record'][G][F] : 0 : 0 : 0 : 0;
},
z['add_item_listener'] = function (G, F) {
this['_item_listener']['hasOwnProperty'](G['toString']()) || (this['_item_listener'][G] = []),
this['_item_listener'][G].push(F);
},
z['remove_item_listener'] = function (G, F) {
var v = this['_item_listener'][G];
if (v)
for (var z = 0; z < v['length']; z++)
if (v[z] === F) {
v[z] = v[v['length'] - 1],
v.pop();
break;
}
},
z['add_all_item_listener'] = function (G) {
this['_all_item_listener'].push(G);
},
z['remove_all_item_listener'] = function (G) {
for (var F = this['_all_item_listener'], v = 0; v < F['length']; v++)
if (F[v] === G) {
F[v] = F[F['length'] - 1],
F.pop();
break;
}
},
z['removeAllBagNew'] = function () {
this['new_bag_item_ids'] = [];
},
z['removeAllCGNew'] = function () {
this['new_cg_ids'] = [];
},
z['removeZhuangBanNew'] = function (G) {
for (var F = 0, v = G; F < v['length']; F++) {
var z = v[F];
delete this['new_zhuangban_item_ids'][z];
}
},
z['checkItemEnough'] = function (G) {
for (var F = G['split'](','), v = 0, h = F; v < h['length']; v++) {
var P = h[v];
if (P) {
var C = P['split']('-');
if (z['get_item_count'](Number(C[0])) < Number(C[1]))
return !1;
}
}
return !0;
},
z['prototype']['have_red_point'] = function () {
return this['page_cg']['have_redpoint']();
},
z['prototype']['onCreate'] = function () {
var F = this;
this['container_top'] = this.me['getChildByName']('top'),
this['container_top']['getChildByName']('btn_back')['clickHandler'] = Laya['Handler']['create'](this, function () {
F['locking'] || F.hide(Laya['Handler']['create'](F, function () {
return F['closeHandler'] ? (F['closeHandler'].run(), F['closeHandler'] = null, void 0) : (G['UI_Lobby'].Inst['enable'] = !0, void 0);
}));
}, null, !1),
this['container_content'] = this.me['getChildByName']('content');
for (var v = function (G) {
z.tabs.push(z['container_content']['getChildByName']('tabs')['getChildByName']('btn' + G)),
z.tabs[G]['clickHandler'] = Laya['Handler']['create'](z, function () {
F['select_index'] != G && F['on_change_tab'](G);
}, null, !1);
}, z = this, h = 0; 5 > h; h++)
v(h);
this['page_item'] = new G['UI_Bag_PageItem'](this['container_content']['getChildByName']('page_items')),
this['page_gift'] = new G['UI_Bag_PageGift'](this['container_content']['getChildByName']('page_gift')),
this['page_skin'] = new G['UI_Bag_PageSkin'](this['container_content']['getChildByName']('page_skin')),
this['page_cg'] = new G['UI_Bag_PageCG'](this['container_content']['getChildByName']('page_cg'));
},
z['prototype'].show = function (F, v) {
var z = this;
void 0 === F && (F = 0),
void 0 === v && (v = null),
this['enable'] = !0,
this['locking'] = !0,
this['closeHandler'] = v,
G['UIBase']['anim_alpha_in'](this['container_top'], {
y: -30
}, 200),
G['UIBase']['anim_alpha_in'](this['container_content'], {
y: 30
}, 200),
Laya['timer'].once(300, this, function () {
z['locking'] = !1;
}),
this['on_change_tab'](F),
this['refreshRedpoint'](),
game['Scene_Lobby'].Inst['change_bg']('indoor', !1);
},
z['prototype']['onSkinYuLanBack'] = function () {
var F = this;
this['enable'] = !0,
this['locking'] = !0,
G['UIBase']['anim_alpha_in'](this['container_top'], {
y: -30
}, 200),
G['UIBase']['anim_alpha_in'](this['container_content'], {
y: 30
}, 200),
Laya['timer'].once(300, this, function () {
F['locking'] = !1;
}),
this['page_skin'].me['visible'] = !0,
this['refreshRedpoint'](),
game['Scene_Lobby'].Inst['change_bg']('indoor', !1);
},
z['prototype'].hide = function (F) {
var v = this;
this['locking'] = !0,
G['UIBase']['anim_alpha_out'](this['container_top'], {
y: -30
}, 200),
G['UIBase']['anim_alpha_out'](this['container_content'], {
y: 30
}, 200),
Laya['timer'].once(300, this, function () {
v['locking'] = !1,
v['enable'] = !1,
F && F.run();
});
},
z['prototype']['onDisable'] = function () {
this['page_skin']['close'](),
this['page_item']['close'](),
this['page_gift']['close'](),
this['page_cg']['close']();
},
z['prototype']['on_change_tab'] = function (G) {
this['select_index'] = G;
for (var v = 0; v < this.tabs['length']; v++)
this.tabs[v].skin = game['Tools']['localUISrc'](G == v ? 'myres/shop/tab_choose.png' : 'myres/shop/tab_unchoose.png'), this.tabs[v]['getChildAt'](0)['color'] = G == v ? '#d9b263' : '#8cb65f';
switch (this['page_item']['close'](), this['page_gift']['close'](), this['page_skin'].me['visible'] = !1, this['page_cg']['close'](), G) {
case 0:
this['page_item'].show(F['daoju']);
break;
case 1:
this['page_gift'].show();
break;
case 2:
this['page_item'].show(F.view);
break;
case 3:
this['page_skin'].show();
break;
case 4:
this['page_cg'].show();
}
},
z['prototype']['when_data_change'] = function () {
this['page_item'].me['visible'] && this['page_item']['when_update_data'](),
this['page_gift'].me['visible'] && this['page_gift']['when_update_data']();
},
z['prototype']['on_cg_change'] = function () {
this['page_cg']['when_update_data']();
},
z['prototype']['refreshRedpoint'] = function () {
this.tabs[4]['getChildByName']('redpoint')['visible'] = this['page_cg']['have_redpoint']();
},
z['_item_map'] = {},
z['_item_listener'] = {},
z['_all_item_listener'] = [],
z['_daily_gain_record'] = {},
z['new_bag_item_ids'] = [],
z['new_zhuangban_item_ids'] = {},
z['new_cg_ids'] = [],
z.Inst = null,
z;
}
(G['UIBase']);
G['UI_Bag'] = v;
}
(uiscript || (uiscript = {}));
// 修改牌桌上角色
!function (G) {
var F = function () {
function F() {
var F = this;
this.urls = [],
this['link_index'] = -1,
this['connect_state'] = G['EConnectState'].none,
this['reconnect_count'] = 0,
this['reconnect_span'] = [500, 1000, 3000, 6000, 10000, 15000],
this['playerreconnect'] = !1,
this['lasterrortime'] = 0,
this['load_over'] = !1,
this['loaded_player_count'] = 0,
this['real_player_count'] = 0,
this['is_ob'] = !1,
this['ob_token'] = '',
this['lb_index'] = 0,
this['_report_reconnect_count'] = 0,
this['_connect_start_time'] = 0,
app['NetAgent']['AddListener2MJ']('NotifyPlayerLoadGameReady', Laya['Handler']['create'](this, function (G) {
app.Log.log('NotifyPlayerLoadGameReady: ' + JSON['stringify'](G)),
F['loaded_player_count'] = G['ready_id_list']['length'],
F['load_over'] && uiscript['UI_Loading'].Inst['enable'] && uiscript['UI_Loading'].Inst['showLoadCount'](F['loaded_player_count'], F['real_player_count']);
}));
}
return Object['defineProperty'](F, 'Inst', {
get: function () {
return null == this['_Inst'] ? this['_Inst'] = new F() : this['_Inst'];
},
enumerable: !1,
configurable: !0
}),
F['prototype']['OpenConnect'] = function (F, v, z, h) {
var P = this;
uiscript['UI_Loading'].Inst.show('enter_mj'),
G['Scene_Lobby'].Inst && G['Scene_Lobby'].Inst['active'] && (G['Scene_Lobby'].Inst['active'] = !1),
G['Scene_Huiye'].Inst && G['Scene_Huiye'].Inst['active'] && (G['Scene_Huiye'].Inst['active'] = !1),
this['Close'](),
view['BgmListMgr']['stopBgm'](),
this['is_ob'] = !1,
Laya['timer'].once(500, this, function () {
P.url = '',
P['token'] = F,
P['game_uuid'] = v,
P['server_location'] = z,
GameMgr.Inst['ingame'] = !0,
GameMgr.Inst['mj_server_location'] = z,
GameMgr.Inst['mj_game_token'] = F,
GameMgr.Inst['mj_game_uuid'] = v,
P['playerreconnect'] = h,
P['_setState'](G['EConnectState']['tryconnect']),
P['load_over'] = !1,
P['loaded_player_count'] = 0,
P['real_player_count'] = 0,
P['lb_index'] = 0,
P['_fetch_gateway'](0);
}),
Laya['timer'].loop(300000, this, this['reportInfo']);
},
F['prototype']['reportInfo'] = function () {
this['connect_state'] == G['EConnectState']['connecting'] && GameMgr.Inst['postNewInfo2Server']('network_route', {
client_type: 'web',
route_type: 'game',
route_index: G['LobbyNetMgr']['root_id_lst'][G['LobbyNetMgr'].Inst['choosed_index']],
route_delay: Math.min(10000, Math['round'](app['NetAgent']['mj_network_delay'])),
connection_time: Math['round'](Date.now() - this['_connect_start_time']),
reconnect_count: this['_report_reconnect_count']
});
},
F['prototype']['Close'] = function () {
this['load_over'] = !1,
app.Log.log('MJNetMgr close'),
this['_setState'](G['EConnectState'].none),
app['NetAgent']['Close2MJ'](),
this.url = '',
Laya['timer']['clear'](this, this['reportInfo']);
},
F['prototype']['_OnConnent'] = function (F) {
app.Log.log('MJNetMgr _OnConnent event:' + F),
F == Laya['Event']['CLOSE'] || F == Laya['Event']['ERROR'] ? Laya['timer']['currTimer'] - this['lasterrortime'] > 100 && (this['lasterrortime'] = Laya['timer']['currTimer'], this['connect_state'] == G['EConnectState']['tryconnect'] ? this['_try_to_linknext']() : this['connect_state'] == G['EConnectState']['connecting'] ? view['DesktopMgr'].Inst['active'] ? (view['DesktopMgr'].Inst['duringReconnect'] = !0, this['_setState'](G['EConnectState']['reconnecting']), this['reconnect_count'] = 0, this['_Reconnect']()) : (this['_setState'](G['EConnectState']['disconnect']), uiscript['UIMgr'].Inst['ShowErrorInfo'](G['Tools']['strOfLocalization'](2008)), G['Scene_MJ'].Inst['ForceOut']()) : this['connect_state'] == G['EConnectState']['reconnecting'] && this['_Reconnect']()) : F == Laya['Event'].OPEN && (this['_connect_start_time'] = Date.now(), (this['connect_state'] == G['EConnectState']['tryconnect'] || this['connect_state'] == G['EConnectState']['reconnecting']) && ((this['connect_state'] = G['EConnectState']['tryconnect']) ? this['_report_reconnect_count'] = 0 : this['_report_reconnect_count']++, this['_setState'](G['EConnectState']['connecting']), this['is_ob'] ? this['_ConnectSuccessOb']() : this['_ConnectSuccess']()));
},
F['prototype']['_Reconnect'] = function () {
var F = this;
G['LobbyNetMgr'].Inst['connect_state'] == G['EConnectState'].none || G['LobbyNetMgr'].Inst['connect_state'] == G['EConnectState']['disconnect'] ? this['_setState'](G['EConnectState']['disconnect']) : G['LobbyNetMgr'].Inst['connect_state'] == G['EConnectState']['connecting'] && GameMgr.Inst['logined'] ? this['reconnect_count'] >= this['reconnect_span']['length'] ? this['_setState'](G['EConnectState']['disconnect']) : (Laya['timer'].once(this['reconnect_span'][this['reconnect_count']], this, function () {
F['connect_state'] == G['EConnectState']['reconnecting'] && (app.Log.log('MJNetMgr reconnect count:' + F['reconnect_count']), app['NetAgent']['connect2MJ'](F.url, Laya['Handler']['create'](F, F['_OnConnent'], null, !1), 'local' == F['server_location'] ? '/game-gateway' : '/game-gateway-zone'));
}), this['reconnect_count']++) : Laya['timer'].once(1000, this, this['_Reconnect']);
},
F['prototype']['_try_to_linknext'] = function () {
this['link_index']++,
this.url = '',
app.Log.log('mj _try_to_linknext(' + this['link_index'] + ') url.length=' + this.urls['length']),
this['link_index'] < 0 || this['link_index'] >= this.urls['length'] ? G['LobbyNetMgr'].Inst['polling_connect'] ? (this['lb_index']++, this['_fetch_gateway'](0)) : (this['_setState'](G['EConnectState'].none), uiscript['UIMgr'].Inst['ShowErrorInfo'](G['Tools']['strOfLocalization'](59)), this['_SendDebugInfo'](), view['DesktopMgr'].Inst && !view['DesktopMgr'].Inst['active'] && G['Scene_MJ'].Inst['ForceOut']()) : (app['NetAgent']['connect2MJ'](this.urls[this['link_index']].url, Laya['Handler']['create'](this, this['_OnConnent'], null, !1), 'local' == this['server_location'] ? '/game-gateway' : '/game-gateway-zone'), this.url = this.urls[this['link_index']].url);
},
F['prototype']['GetAuthData'] = function () {
return {
account_id: GameMgr.Inst['account_id'],
token: this['token'],
game_uuid: this['game_uuid'],
gift: CryptoJS['HmacSHA256'](this['token'] + GameMgr.Inst['account_id'] + this['game_uuid'], 'damajiang')['toString']()
};
},
F['prototype']['_fetch_gateway'] = function (F) {
var v = this;
if (G['LobbyNetMgr'].Inst['polling_connect'] && this['lb_index'] >= G['LobbyNetMgr'].Inst.urls['length'])
return uiscript['UIMgr'].Inst['ShowErrorInfo'](G['Tools']['strOfLocalization'](59)), this['_SendDebugInfo'](), view['DesktopMgr'].Inst && !view['DesktopMgr'].Inst['active'] && G['Scene_MJ'].Inst['ForceOut'](), this['_setState'](G['EConnectState'].none), void 0;
this.urls = [],
this['link_index'] = -1,
app.Log.log('mj _fetch_gateway retry_count:' + F);
var z = function (z) {
var h = JSON['parse'](z);
if (app.Log.log('mj _fetch_gateway func_success data = ' + z), h['maintenance'])
v['_setState'](G['EConnectState'].none), uiscript['UIMgr'].Inst['ShowErrorInfo'](G['Tools']['strOfLocalization'](2009)), view['DesktopMgr'].Inst && !view['DesktopMgr'].Inst['active'] && G['Scene_MJ'].Inst['ForceOut']();
else if (h['servers'] && h['servers']['length'] > 0) {
for (var P = h['servers'], C = G['Tools']['deal_gateway'](P), M = 0; M < C['length']; M++)
v.urls.push({
name: '___' + M,
url: C[M]
});
v['link_index'] = -1,
v['_try_to_linknext']();
} else
1 > F ? Laya['timer'].once(1000, v, function () {
v['_fetch_gateway'](F + 1);
}) : G['LobbyNetMgr'].Inst['polling_connect'] ? (v['lb_index']++, v['_fetch_gateway'](0)) : (uiscript['UIMgr'].Inst['ShowErrorInfo'](G['Tools']['strOfLocalization'](60)), v['_SendDebugInfo'](), view['DesktopMgr'].Inst && !view['DesktopMgr'].Inst['active'] && G['Scene_MJ'].Inst['ForceOut'](), v['_setState'](G['EConnectState'].none));
},
h = function () {
app.Log.log('mj _fetch_gateway func_error'),
1 > F ? Laya['timer'].once(500, v, function () {
v['_fetch_gateway'](F + 1);
}) : G['LobbyNetMgr'].Inst['polling_connect'] ? (v['lb_index']++, v['_fetch_gateway'](0)) : (uiscript['UIMgr'].Inst['ShowErrorInfo'](G['Tools']['strOfLocalization'](58)), v['_SendDebugInfo'](), view['DesktopMgr'].Inst['active'] || G['Scene_MJ'].Inst['ForceOut'](), v['_setState'](G['EConnectState'].none));
},
P = function (G) {
var F = new Laya['HttpRequest']();
F.once(Laya['Event']['COMPLETE'], v, function (G) {
z(G);
}),
F.once(Laya['Event']['ERROR'], v, function () {
h();
});
var P = [];
P.push('If-Modified-Since'),
P.push('0'),
G += '?service=ws-game-gateway',
G += GameMgr['inHttps'] ? '&protocol=ws&ssl=true' : '&protocol=ws&ssl=false',
G += '&location=' + v['server_location'],
G += '&rv=' + Math['floor'](10000000 * Math['random']()) + Math['floor'](10000000 * Math['random']()),
F.send(G, '', 'get', 'text', P),
app.Log.log('mj _fetch_gateway func_fetch url = ' + G);
};
G['LobbyNetMgr'].Inst['polling_connect'] ? P(G['LobbyNetMgr'].Inst.urls[this['lb_index']]) : P(G['LobbyNetMgr'].Inst['lb_url']);
},
F['prototype']['_setState'] = function (F) {
this['connect_state'] = F,
GameMgr['inRelease'] || null != uiscript['UI_Common'].Inst && (F == G['EConnectState'].none ? uiscript['UI_Common'].Inst['label_net_mj'].text = '' : F == G['EConnectState']['tryconnect'] ? (uiscript['UI_Common'].Inst['label_net_mj'].text = '尝试连接麻将服务器', uiscript['UI_Common'].Inst['label_net_mj']['color'] = '#000000') : F == G['EConnectState']['connecting'] ? (uiscript['UI_Common'].Inst['label_net_mj'].text = '麻将服务器:正常', uiscript['UI_Common'].Inst['label_net_mj']['color'] = '#00ff00') : F == G['EConnectState']['disconnect'] ? (uiscript['UI_Common'].Inst['label_net_mj'].text = '麻将服务器:断开连接', uiscript['UI_Common'].Inst['label_net_mj']['color'] = '#ff0000', uiscript['UI_Disconnect'].Inst && uiscript['UI_Disconnect'].Inst.show()) : F == G['EConnectState']['reconnecting'] && (uiscript['UI_Common'].Inst['label_net_mj'].text = '麻将服务器:正在重连', uiscript['UI_Common'].Inst['label_net_mj']['color'] = '#ff0000', uiscript['UI_Disconnect'].Inst && uiscript['UI_Disconnect'].Inst.show()));
},
F['prototype']['_ConnectSuccess'] = function () {
var F = this;
app.Log.log('MJNetMgr _ConnectSuccess '),
this['load_over'] = !1,
app['NetAgent']['sendReq2MJ']('FastTest', 'authGame', this['GetAuthData'](), function (v, z) {
if (v || z['error'])
uiscript['UIMgr'].Inst['showNetReqError']('authGame', v, z), G['Scene_MJ'].Inst['GameEnd'](), view['BgmListMgr']['PlayLobbyBgm']();
else {
app.Log.log('麻将桌验证通过:' + JSON['stringify'](z)),
uiscript['UI_Loading'].Inst['setProgressVal'](0.1);
// 强制打开便捷提示
if (MMP.settings.setbianjietishi) {
z['game_config']['mode']['detail_rule']['bianjietishi'] = true;
}
// END
var h = [],
P = 0;
view['DesktopMgr']['player_link_state'] = z['state_list'];
var C = G['Tools']['strOfLocalization'](2003),
M = z['game_config'].mode,
U = view['ERuleMode']['Liqi4'];
M.mode < 10 ? (U = view['ERuleMode']['Liqi4'], F['real_player_count'] = 4) : M.mode < 20 && (U = view['ERuleMode']['Liqi3'], F['real_player_count'] = 3);
for (var y = 0; y < F['real_player_count']; y++)
h.push(null);
M['extendinfo'] && (C = G['Tools']['strOfLocalization'](2004)),
M['detail_rule'] && M['detail_rule']['ai_level'] && (1 === M['detail_rule']['ai_level'] && (C = G['Tools']['strOfLocalization'](2003)), 2 === M['detail_rule']['ai_level'] && (C = G['Tools']['strOfLocalization'](2004)));
for (var S = G['GameUtility']['get_default_ai_skin'](), N = G['GameUtility']['get_default_ai_character'](), y = 0; y < z['seat_list']['length']; y++) {
var O = z['seat_list'][y];
if (0 == O) {
h[y] = {
nickname: C,
avatar_id: S,
level: {
id: '10101'
},
level3: {
id: '20101'
},
character: {
charid: N,
level: 0,
exp: 0,
views: [],
skin: S,
is_upgraded: !1
}
};
//随机化电脑皮肤
if (MMP.settings.randomBotSkin == true) {
let all_keys = Object.keys(cfg.item_definition.skin.map_);
let rand_skin_id = parseInt(Math.random() * all_keys.length, 10);
let skin = cfg.item_definition.skin.map_[all_keys[rand_skin_id]];
// 修复皮肤错误导致无法进入游戏的bug
if (skin.id != 400000 && skin.id != 400001) {
h[y].avatar_id = skin.id;
h[y].character.charid = skin.character_id;
h[y].character.skin = skin.id;
}
}
if (MMP.settings.showServer == true) {
h[y].nickname = '[BOT]' + h[y].nickname;
}
} else {
P++;
for (var W = 0; W < z['players']['length']; W++)
if (z['players'][W]['account_id'] == O) {
h[y] = z['players'][W];
//修改牌桌上人物头像及皮肤
if (h[y].account_id == GameMgr.Inst.account_id) {
for (let item of uiscript.UI_Sushe.characters) {
if (item['charid'] == uiscript.UI_Sushe.main_character_id) {
h[y].character = item;
}
}
h[y].avatar_id = uiscript.UI_Sushe.main_chara_info.skin;
h[y].views = uiscript.UI_Sushe.commonViewList[uiscript.UI_Sushe.using_commonview_index];
h[y].avatar_frame = GameMgr.Inst.account_data.avatar_frame;
h[y].title = GameMgr.Inst.account_data.title;
if (MMP.settings.nickname != '') {
h[y].nickname = MMP.settings.nickname;
}
} else if (MMP.settings.randomPlayerDefSkin && (h[y].avatar_id == 400101 || h[y].avatar_id == 400201)) {
//玩家如果用了默认皮肤也随机换
let all_keys = Object.keys(cfg.item_definition.skin.map_);
let rand_skin_id = parseInt(Math.random() * all_keys.length, 10);
let skin = cfg.item_definition.skin.map_[all_keys[rand_skin_id]];
// 修复皮肤错误导致无法进入游戏的bug
if (skin.id != 400000 && skin.id != 400001) {
h[y].avatar_id = skin.id;
h[y].character.charid = skin.character_id;
h[y].character.skin = skin.id;
}
}
if (MMP.settings.showServer == true) {
let server = game.Tools.get_zone_id(h[y].account_id);
if (server == 1) {
h[y].nickname = '[CN]' + h[y].nickname;
} else if (server == 2) {
h[y].nickname = '[JP]' + h[y].nickname;
} else if (server == 3) {
h[y].nickname = '[EN]' + h[y].nickname;
} else {
h[y].nickname = '[??]' + h[y].nickname;
}
}
// END
break;
}
}
}
for (var y = 0; y < F['real_player_count']; y++)
null == h[y] && (h[y] = {
account: 0,
nickname: G['Tools']['strOfLocalization'](2010),
avatar_id: S,
level: {
id: '10101'
},
level3: {
id: '20101'
},
character: {
charid: N,
level: 0,
exp: 0,
views: [],
skin: S,
is_upgraded: !1
}
});
F['loaded_player_count'] = z['ready_id_list']['length'],
F['_AuthSuccess'](h, z['is_game_start'], z['game_config']['toJSON']());
}
});
},
F['prototype']['_AuthSuccess'] = function (F, v, z) {
var h = this;
view['DesktopMgr'].Inst && view['DesktopMgr'].Inst['active'] ? (this['load_over'] = !0, Laya['timer'].once(500, this, function () {
app.Log.log('重连信息1 round_id:' + view['DesktopMgr'].Inst['round_id'] + ' step:' + view['DesktopMgr'].Inst['current_step']),
view['DesktopMgr'].Inst['Reset'](),
view['DesktopMgr'].Inst['duringReconnect'] = !0,
uiscript['UI_Loading'].Inst['setProgressVal'](0.2),
app['NetAgent']['sendReq2MJ']('FastTest', 'syncGame', {
round_id: view['DesktopMgr'].Inst['round_id'],