Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
N
Neos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Neos
Commits
1fb2bf76
Commit
1fb2bf76
authored
Apr 27, 2024
by
love_飞影
Committed by
Chunchi Che
May 19, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: fix MR comment
parent
15484bb6
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
26 deletions
+39
-26
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/damage.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/damage.ts
+0
-3
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/win.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/win.ts
+0
-8
src/infra/audio/core/context.ts
src/infra/audio/core/context.ts
+25
-7
src/infra/audio/music/index.ts
src/infra/audio/music/index.ts
+6
-2
src/service/duel/win.ts
src/service/duel/win.ts
+7
-0
src/service/room/chat.ts
src/service/room/chat.ts
+0
-2
src/service/room/errorMsg.ts
src/service/room/errorMsg.ts
+1
-4
No files found.
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/damage.ts
View file @
1fb2bf76
import
{
ocgDamageAdapter
}
from
"
rust-src
"
;
import
{
AudioActionType
,
playEffect
}
from
"
@/infra/audio
"
;
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
/*
...
...
@@ -11,7 +9,6 @@ import { ygopro } from "../../../idl/ocgcore";
* @param value - 减少的Hp数值
* */
export
default
(
data
:
Uint8Array
)
=>
{
playEffect
(
AudioActionType
.
SOUND_DAMAGE
);
const
damage
=
ocgDamageAdapter
(
data
);
return
new
ygopro
.
StocGameMessage
.
MsgUpdateHp
(
damage
);
...
...
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/win.ts
View file @
1fb2bf76
...
...
@@ -2,8 +2,6 @@ import { BufferReader } from "rust-src";
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
MsgWin
=
ygopro
.
StocGameMessage
.
MsgWin
;
import
{
AudioActionType
,
changeScene
}
from
"
@/infra/audio
"
;
import
{
matStore
}
from
"
@/stores
"
;
/*
* Msg Win
...
...
@@ -16,12 +14,6 @@ export default (data: Uint8Array) => {
const
win_player
=
reader
.
readUint8
();
const
reason
=
reader
.
readUint8
();
// 双打需要改这里判断
if
(
matStore
.
isMe
(
win_player
))
{
changeScene
(
AudioActionType
.
BGM_WIN
);
}
else
{
changeScene
(
AudioActionType
.
BGM_LOSE
);
}
return
new
MsgWin
({
win_player
,
...
...
src/infra/audio/core/context.ts
View file @
1fb2bf76
...
...
@@ -18,13 +18,10 @@ export class NeosAudioContext extends EventEmitter<AudioScheduledSourceNodeEvent
return
this
.
_isClosed
;
}
public
async
play
(
audio
:
ArrayBuffer
)
{
const
source
=
this
.
_musicAudioContext
.
createBufferSource
();
const
buffer
=
await
this
.
_musicAudioContext
.
decodeAudioData
(
audio
);
source
.
buffer
=
buffer
;
source
.
connect
(
this
.
_gainNode
).
connect
(
this
.
_musicAudioContext
.
destination
);
source
.
start
();
/**
* 触发自动播放
*/
private
_triggerAutoPlay
()
{
if
(
this
.
state
===
"
suspended
"
)
{
const
autoPlay
=
()
=>
{
document
.
removeEventListener
(
"
click
"
,
autoPlay
);
...
...
@@ -32,6 +29,12 @@ export class NeosAudioContext extends EventEmitter<AudioScheduledSourceNodeEvent
};
document
.
addEventListener
(
"
click
"
,
autoPlay
);
}
}
/**
* 监听未启播
*/
private
_observerPlayState
(
source
:
AudioBufferSourceNode
)
{
// 50ms 未启播,说明播放失败了,重新尝试播放
const
timeout
=
setTimeout
(
async
()
=>
{
if
(
source
.
loop
)
return
;
...
...
@@ -51,6 +54,21 @@ export class NeosAudioContext extends EventEmitter<AudioScheduledSourceNodeEvent
source
.
addEventListener
(
"
ended
"
,
Ended
);
}
/**
* 播放音频
* @param audio 音频数据
*/
public
async
play
(
audio
:
ArrayBuffer
)
{
const
source
=
this
.
_musicAudioContext
.
createBufferSource
();
const
buffer
=
await
this
.
_musicAudioContext
.
decodeAudioData
(
audio
);
source
.
buffer
=
buffer
;
source
.
connect
(
this
.
_gainNode
).
connect
(
this
.
_musicAudioContext
.
destination
);
source
.
start
();
this
.
_triggerAutoPlay
();
this
.
_observerPlayState
(
source
);
}
public
async
resume
()
{
if
(
this
.
state
!==
"
suspended
"
)
return
;
return
this
.
_musicAudioContext
.
resume
();
...
...
src/infra/audio/music/index.ts
View file @
1fb2bf76
...
...
@@ -34,5 +34,9 @@ export function changeScene(scene: AudioActionType) {
}
// 初始化音频设置
audioContextManger
.
updateMusicVolume
(
settingStore
.
audio
.
musicVolume
);
audioContextManger
.
enableBGM
=
settingStore
.
audio
.
enableMusic
??
false
;
function
initAudioSetting
()
{
audioContextManger
.
updateMusicVolume
(
settingStore
.
audio
.
musicVolume
);
audioContextManger
.
enableBGM
=
settingStore
.
audio
.
enableMusic
??
false
;
}
initAudioSetting
();
src/service/duel/win.ts
View file @
1fb2bf76
...
...
@@ -2,6 +2,7 @@ import { fetchStrings, Region, ygopro } from "@/api";
import
{
matStore
}
from
"
@/stores
"
;
import
{
displayEndModal
}
from
"
@/ui/Duel/Message
"
;
import
MsgWin
=
ygopro
.
StocGameMessage
.
MsgWin
;
import
{
AudioActionType
,
changeScene
}
from
"
@/infra/audio
"
;
export
default
async
(
win
:
MsgWin
)
=>
{
const
{
win_player
,
reason
}
=
win
;
...
...
@@ -10,4 +11,10 @@ export default async (win: MsgWin) => {
matStore
.
isMe
(
win_player
),
fetchStrings
(
Region
.
Victory
,
`0x
${
reason
.
toString
(
16
)}
`
),
);
if
(
matStore
.
isMe
(
win_player
))
{
changeScene
(
AudioActionType
.
BGM_WIN
);
}
else
{
changeScene
(
AudioActionType
.
BGM_LOSE
);
}
};
src/service/room/chat.ts
View file @
1fb2bf76
import
{
ygopro
}
from
"
@/api
"
;
import
{
AudioActionType
,
playEffect
}
from
"
@/infra/audio
"
;
import
{
chatStore
}
from
"
@/stores
"
;
export
default
function
handleChat
(
pb
:
ygopro
.
YgoStocMsg
)
{
playEffect
(
AudioActionType
.
SOUND_CHAT
);
const
chat
=
pb
.
stoc_chat
;
chatStore
.
message
=
chat
.
msg
;
chatStore
.
sender
=
chat
.
player
;
...
...
src/service/room/errorMsg.ts
View file @
1fb2bf76
...
...
@@ -17,14 +17,13 @@ const DECKERROR_NOTAVAIL = 0x9;
export
default
async
function
handleErrorMsg
(
errorMsg
:
ygopro
.
StocErrorMsg
)
{
const
{
error_type
,
error_code
}
=
errorMsg
;
playEffect
(
AudioActionType
.
SOUND_INFO
);
switch
(
error_type
)
{
case
ErrorType
.
JOINERROR
:
{
playEffect
(
AudioActionType
.
SOUND_INFO
);
roomStore
.
errorMsg
=
fetchStrings
(
Region
.
System
,
1403
+
error_code
);
break
;
}
case
ErrorType
.
DECKERROR
:
{
playEffect
(
AudioActionType
.
SOUND_INFO
);
const
flag
=
error_code
>>
28
;
const
code
=
error_code
&
0xfffffff
;
const
card
=
fetchCard
(
code
);
...
...
@@ -81,12 +80,10 @@ export default async function handleErrorMsg(errorMsg: ygopro.StocErrorMsg) {
break
;
}
case
ErrorType
.
SIDEERROR
:
{
playEffect
(
AudioActionType
.
SOUND_INFO
);
roomStore
.
errorMsg
=
"
更换副卡组失败,请检查卡片张数是否一致。
"
;
break
;
}
case
ErrorType
.
VERSIONERROR
:
{
playEffect
(
AudioActionType
.
SOUND_INFO
);
roomStore
.
errorMsg
=
"
版本不匹配,请联系技术人员解决
"
;
break
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment