-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
228 lines (217 loc) · 6.57 KB
/
script.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
// 扩展 BGM,作者 Handle,部分参考 rin93 的源码
if (!!view && !!uiscript) {
const musicDir = 'qqhlddz/'
// 正负得点播放不同 音效
const _showBackup = uiscript.UI_GameEnd.prototype.show
uiscript.UI_GameEnd.prototype.show = function () {
var musicPlayerFlag = false
view.DesktopMgr.Inst.gameEndResult.players.forEach((player, index) => {
if (player.seat == view.DesktopMgr.Inst.seat) {
if (player.total_point >= 0) {
setTimeout(() => {
view.AudioMgr.PlaySound('audio/' + musicDir + 'win', 1)
}, 3000)
musicPlayerFlag = true
} else {
setTimeout(() => {
view.AudioMgr.PlaySound('audio/' + musicDir + 'lose', 1)
}, 3000)
musicPlayerFlag = true
}
}
})
if (!musicPlayerFlag) {
setTimeout(() => {
view.AudioMgr.PlaySound('audio/' + musicDir + 'win', 1)
}, 3000)
}
_showBackup.apply(this, arguments)
}
// 不同 UI 注入不同音乐
const lobbyMusic = musicDir + 'lobby.mp3'
const executeUIs = [['UI_Lobby', 'onEnable', 'lobby.mp3']]
executeUIs.forEach(([scriptKey, funName, fileName]) => {
uiscript[scriptKey].prototype[funName] = (() => {
const functionBackup = uiscript[scriptKey].prototype[funName]
return function () {
view.AudioMgr.PlayMusic(musicDir + fileName, 1, false, true)
return functionBackup.apply(this, arguments)
}
})()
})
let isRefreshPaiLeftHacked = false
let isFastrecord = false
let currentBGM
let thisTurnBGM
let richedCount = 0
let fewPai = false
const richMusicSet = { count: 0, file: '' }
// 对默认音乐进行拒绝
view.AudioMgr.PlayMusic = (() => {
const functionBackup = view.AudioMgr.PlayMusic
let lastTimeMusic = ''
return function (audioDir, ...args) {
// if (audioDir != 'music/game.mp3' && !isFastrecord) {
// console.log(args)
// console.warn('Playing: ' + audioDir)
if (args[2] !== true) {
if (view.BgmListMgr.bgm_lobby_list.includes(audioDir)) {
lastTimeMusic = lobbyMusic
}
return functionBackup.apply(this, [lastTimeMusic, ...args])
} else {
lastTimeMusic = audioDir
}
return functionBackup.apply(this, [audioDir, ...args])
// }
// return null
}
})()
// view.AudioMgr.StopMusic = (() => {
// var funBackup = view.AudioMgr.StopMusic
// return function() {
// return (
// !new Error().stack.split('\n')[3].match(/anonymous/) &&
// funBackup.apply(this, arguments)
// )
// }
// })()
const backupStopmusic = view.AudioMgr.StopMusic
view.AudioMgr.StopMusic = function () {
// console.warn(this)
return backupStopmusic.apply(this, arguments)
}
const paiRemain = (number) => {
return false
// return view.DesktopMgr.Inst.left_tile_count <= number
}
const playMusic = () => {
let fileDir = ''
if (richedCount > 0) {
// 立直
if (richMusicSet.count < richedCount) {
richMusicSet.count = richedCount
fileDir = (() => {
if (richedCount >= 2) {
richedCount = 2
}
let richFile = 'Exciting' + richedCount
return richFile
})()
richMusicSet.file = fileDir
} else {
fileDir = richMusicSet.file
}
} else if (paiRemain(20)) {
if (!fewPai) {
// 余牌少于 20
fileDir =
'few' +
(() => {
return (Math.random() * 5) >> 0
})()
fewPai = fileDir
} else {
fileDir = fewPai
}
}
if (!fileDir) {
currentBGM = thisTurnBGM
} else {
currentBGM = fileDir
}
currentBGM = `${musicDir}${currentBGM}.mp3`
if (!isFastrecord && currentBGM && view.DesktopMgr.Inst.gameing) {
view.AudioMgr.PlayMusic(currentBGM, 0, false, true)
}
}
const newRound = (roundInfo) => {
// 如果是第一局,hack剩余牌数
if (!isRefreshPaiLeftHacked && view.DesktopMgr.Inst) {
isRefreshPaiLeftHacked = true
const functionBackup = view.DesktopMgr.Inst.RefreshPaiLeft
view.DesktopMgr.Inst.RefreshPaiLeft = function (...args) {
if (paiRemain(20)) {
playMusic()
}
return functionBackup.apply(this, args)
}
}
// roundInfo.ju为局数,roundInfo.ben为本场数
thisTurnBGM = 'Normal'
richedCount = 0
fewPai = false
richMusicSet.count = 0
richMusicSet.file = ''
playMusic()
}
view.ViewPlayer.prototype.AddQiPai = (function () {
const functionBackup = view.ViewPlayer.prototype.AddQiPai
return function (r, isRich, y, z) {
if (isRich) {
richedCount++
// if (this.container_qipai.player.seat === view.DesktopMgr.Inst.seat) {
// isMyRich |= true
// } else {
// isMyRich |= false
// }
playMusic()
}
return functionBackup.apply(this, arguments)
}
})()
;['play', 'fastplay', 'record', 'fastrecord'].forEach((key) => {
const functionBackup = view.ActionNewRound[key]
view.ActionNewRound[key] = function (...args) {
isFastrecord = false
if (key === 'fastrecord') {
isFastrecord = true
}
const resultBackup = functionBackup.apply(this, args)
newRound(...args)
return resultBackup
}
})
Object.entries({
Replay: '_refreshBarshow',
Live_Broadcast: '_fastSync',
}).forEach(([key, value]) => {
uiscript['UI_' + key]['prototype'][value] = (() => {
const oldFunction = uiscript['UI_' + key]['prototype'][value]
return function () {
const resultBackup = oldFunction.apply(this, arguments)
if (isFastrecord) {
isFastrecord = false
playMusic()
}
return resultBackup
}
})()
})
// 强制干翻立直BGM,作者Handle
const backupFun = view.DesktopMgr.prototype.initRoom
view.DesktopMgr.prototype.initRoom = function (...args) {
// console.log(args)
try {
const player_datas = args[1]
if (Array.isArray(player_datas)) {
player_datas.forEach((player_data) => {
const views = player_data.views
if (views && views.length) {
if (Array.isArray(views)) {
player_data.views = views.filter((view) => {
const slot = view.slot
const id = view.item_id
return !(slot == game.EView.lizhi_bgm)
})
}
}
})
}
args[1] = player_datas
} catch (e) {
console.warn(e)
}
return backupFun.call(this, ...args)
}
}