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
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
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
BBeretta
Neos
Commits
80edb50d
Commit
80edb50d
authored
May 09, 2023
by
chechunchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
optimize setTimeout
parent
012d2682
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
219 additions
and
212 deletions
+219
-212
src/service/duel/gameMsg.ts
src/service/duel/gameMsg.ts
+218
-211
src/service/duel/timeLimit.ts
src/service/duel/timeLimit.ts
+1
-1
No files found.
src/service/duel/gameMsg.ts
View file @
80edb50d
...
...
@@ -55,216 +55,223 @@ const ActiveList = [
"
select_yes_no
"
,
];
export
default
function
handleGameMsg
(
pb
:
ygopro
.
YgoStocMsg
)
{
const
msg
=
pb
.
stoc_game_msg
;
if
(
ActiveList
.
includes
(
msg
.
gameMsg
))
{
matStore
.
waiting
=
false
;
}
switch
(
msg
.
gameMsg
)
{
case
"
start
"
:
{
onMsgStart
(
msg
.
start
);
break
;
}
case
"
draw
"
:
{
onMsgDraw
(
msg
.
draw
);
break
;
}
case
"
new_turn
"
:
{
onMsgNewTurn
(
msg
.
new_turn
);
break
;
}
case
"
new_phase
"
:
{
onMsgNewPhase
(
msg
.
new_phase
);
break
;
}
case
"
hint
"
:
{
onMsgHint
(
msg
.
hint
);
break
;
}
case
"
select_idle_cmd
"
:
{
onMsgSelectIdleCmd
(
msg
.
select_idle_cmd
);
break
;
}
case
"
select_place
"
:
{
onMsgSelectPlace
(
msg
.
select_place
);
break
;
}
case
"
move
"
:
{
onMsgMove
(
msg
.
move
);
break
;
}
case
"
select_card
"
:
{
onMsgSelectCard
(
msg
.
select_card
);
break
;
}
case
"
select_chain
"
:
{
onMsgSelectChain
(
msg
.
select_chain
);
break
;
}
case
"
select_effect_yn
"
:
{
onMsgSelectEffectYn
(
msg
.
select_effect_yn
);
break
;
}
case
"
select_position
"
:
{
onMsgSelectPosition
(
msg
.
select_position
);
break
;
}
case
"
select_option
"
:
{
onMsgSelectOption
(
msg
.
select_option
);
break
;
}
case
"
shuffle_hand
"
:
{
onMsgShuffleHand
(
msg
.
shuffle_hand
);
break
;
}
case
"
select_battle_cmd
"
:
{
onMsgSelectBattleCmd
(
msg
.
select_battle_cmd
);
break
;
}
case
"
pos_change
"
:
{
onMsgPosChange
(
msg
.
pos_change
);
break
;
}
case
"
select_unselect_card
"
:
{
onMsgSelectUnselectCard
(
msg
.
select_unselect_card
);
break
;
}
case
"
select_yes_no
"
:
{
onMsgSelectYesNo
(
msg
.
select_yes_no
);
break
;
}
case
"
update_hp
"
:
{
onMsgUpdateHp
(
msg
.
update_hp
);
break
;
}
case
"
win
"
:
{
onMsgWin
(
msg
.
win
);
break
;
}
case
"
wait
"
:
{
onMsgWait
(
msg
.
wait
);
break
;
}
case
"
update_data
"
:
{
onMsgUpdateData
(
msg
.
update_data
);
break
;
}
case
"
reload_field
"
:
{
onMsgReloadField
(
msg
.
reload_field
);
break
;
}
case
"
select_sum
"
:
{
onMsgSelectSum
(
msg
.
select_sum
);
break
;
}
case
"
select_tribute
"
:
{
onMsgSelectTribute
(
msg
.
select_tribute
);
break
;
}
case
"
update_counter
"
:
{
onMsgUpdateCounter
(
msg
.
update_counter
);
break
;
}
case
"
select_counter
"
:
{
onMsgSelectCounter
(
msg
.
select_counter
);
break
;
}
case
"
sort_card
"
:
{
onMsgSortCard
(
msg
.
sort_card
);
break
;
}
case
"
set
"
:
{
onMsgSet
(
msg
.
set
);
break
;
}
case
"
swap
"
:
{
onMsgSwap
(
msg
.
swap
);
break
;
}
case
"
attack
"
:
{
onMsgAttack
(
msg
.
attack
);
const
TIME_GAP
=
200
;
break
;
}
case
"
attack_disable
"
:
{
onMsgAttackDisable
(
msg
.
attack_disable
);
break
;
}
case
"
chaining
"
:
{
onMsgChaining
(
msg
.
chaining
);
break
;
}
case
"
summoning
"
:
{
onMsgSummoning
(
msg
.
summoning
);
break
;
}
case
"
summoned
"
:
{
onMsgSummoned
(
msg
.
summoned
);
break
;
}
case
"
flip_summoning
"
:
{
onMsgFlipSummoning
(
msg
.
flip_summoning
);
break
;
}
case
"
flip_summoned
"
:
{
onMsgFilpSummoned
(
msg
.
flip_summoned
);
break
;
}
case
"
sp_summoning
"
:
{
onMsgSpSummoning
(
msg
.
sp_summoning
);
break
;
}
case
"
sp_summoned
"
:
{
onMsgSpSummoned
(
msg
.
sp_summoned
);
break
;
}
case
"
unimplemented
"
:
{
onUnimplemented
(
msg
.
unimplemented
);
break
;
}
default
:
{
break
;
}
}
export
default
function
handleGameMsg
(
pb
:
ygopro
.
YgoStocMsg
)
{
// 防止MSG更新太频繁,做下控频
//
// TODO: 细化需要控频的MSG
setTimeout
(()
=>
{
const
msg
=
pb
.
stoc_game_msg
;
if
(
ActiveList
.
includes
(
msg
.
gameMsg
))
{
matStore
.
waiting
=
false
;
}
switch
(
msg
.
gameMsg
)
{
case
"
start
"
:
{
onMsgStart
(
msg
.
start
);
break
;
}
case
"
draw
"
:
{
onMsgDraw
(
msg
.
draw
);
break
;
}
case
"
new_turn
"
:
{
onMsgNewTurn
(
msg
.
new_turn
);
break
;
}
case
"
new_phase
"
:
{
onMsgNewPhase
(
msg
.
new_phase
);
break
;
}
case
"
hint
"
:
{
onMsgHint
(
msg
.
hint
);
break
;
}
case
"
select_idle_cmd
"
:
{
onMsgSelectIdleCmd
(
msg
.
select_idle_cmd
);
break
;
}
case
"
select_place
"
:
{
onMsgSelectPlace
(
msg
.
select_place
);
break
;
}
case
"
move
"
:
{
onMsgMove
(
msg
.
move
);
break
;
}
case
"
select_card
"
:
{
onMsgSelectCard
(
msg
.
select_card
);
break
;
}
case
"
select_chain
"
:
{
onMsgSelectChain
(
msg
.
select_chain
);
break
;
}
case
"
select_effect_yn
"
:
{
onMsgSelectEffectYn
(
msg
.
select_effect_yn
);
break
;
}
case
"
select_position
"
:
{
onMsgSelectPosition
(
msg
.
select_position
);
break
;
}
case
"
select_option
"
:
{
onMsgSelectOption
(
msg
.
select_option
);
break
;
}
case
"
shuffle_hand
"
:
{
onMsgShuffleHand
(
msg
.
shuffle_hand
);
break
;
}
case
"
select_battle_cmd
"
:
{
onMsgSelectBattleCmd
(
msg
.
select_battle_cmd
);
break
;
}
case
"
pos_change
"
:
{
onMsgPosChange
(
msg
.
pos_change
);
break
;
}
case
"
select_unselect_card
"
:
{
onMsgSelectUnselectCard
(
msg
.
select_unselect_card
);
break
;
}
case
"
select_yes_no
"
:
{
onMsgSelectYesNo
(
msg
.
select_yes_no
);
break
;
}
case
"
update_hp
"
:
{
onMsgUpdateHp
(
msg
.
update_hp
);
break
;
}
case
"
win
"
:
{
onMsgWin
(
msg
.
win
);
break
;
}
case
"
wait
"
:
{
onMsgWait
(
msg
.
wait
);
break
;
}
case
"
update_data
"
:
{
onMsgUpdateData
(
msg
.
update_data
);
break
;
}
case
"
reload_field
"
:
{
onMsgReloadField
(
msg
.
reload_field
);
break
;
}
case
"
select_sum
"
:
{
onMsgSelectSum
(
msg
.
select_sum
);
break
;
}
case
"
select_tribute
"
:
{
onMsgSelectTribute
(
msg
.
select_tribute
);
break
;
}
case
"
update_counter
"
:
{
onMsgUpdateCounter
(
msg
.
update_counter
);
break
;
}
case
"
select_counter
"
:
{
onMsgSelectCounter
(
msg
.
select_counter
);
break
;
}
case
"
sort_card
"
:
{
onMsgSortCard
(
msg
.
sort_card
);
break
;
}
case
"
set
"
:
{
onMsgSet
(
msg
.
set
);
break
;
}
case
"
swap
"
:
{
onMsgSwap
(
msg
.
swap
);
break
;
}
case
"
attack
"
:
{
onMsgAttack
(
msg
.
attack
);
break
;
}
case
"
attack_disable
"
:
{
onMsgAttackDisable
(
msg
.
attack_disable
);
break
;
}
case
"
chaining
"
:
{
onMsgChaining
(
msg
.
chaining
);
break
;
}
case
"
summoning
"
:
{
onMsgSummoning
(
msg
.
summoning
);
break
;
}
case
"
summoned
"
:
{
onMsgSummoned
(
msg
.
summoned
);
break
;
}
case
"
flip_summoning
"
:
{
onMsgFlipSummoning
(
msg
.
flip_summoning
);
break
;
}
case
"
flip_summoned
"
:
{
onMsgFilpSummoned
(
msg
.
flip_summoned
);
break
;
}
case
"
sp_summoning
"
:
{
onMsgSpSummoning
(
msg
.
sp_summoning
);
break
;
}
case
"
sp_summoned
"
:
{
onMsgSpSummoned
(
msg
.
sp_summoned
);
break
;
}
case
"
unimplemented
"
:
{
onUnimplemented
(
msg
.
unimplemented
);
break
;
}
default
:
{
break
;
}
}
},
TIME_GAP
);
}
src/service/duel/timeLimit.ts
View file @
80edb50d
import
{
sendTimeConfirm
,
ygopro
}
from
"
@/api
"
;
import
{
matStore
}
from
"
@/stores
"
;
const
TIME_GAP
=
1500
;
const
TIME_GAP
=
200
;
// TODO: use config
export
default
function
handleTimeLimit
(
timeLimit
:
ygopro
.
StocTimeLimit
)
{
setTimeout
(()
=>
{
...
...
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