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
love_飞影
Neos
Commits
7365a6b2
Commit
7365a6b2
authored
May 27, 2023
by
timel
Committed by
Chunchi Che
May 28, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: eventbus
parent
a65180b6
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
21 additions
and
23 deletions
+21
-23
src/env.d.ts
src/env.d.ts
+3
-0
src/infra/eventbus.ts
src/infra/eventbus.ts
+10
-0
src/infra/index.ts
src/infra/index.ts
+1
-0
src/main.tsx
src/main.tsx
+0
-4
src/service/duel/draw.ts
src/service/duel/draw.ts
+1
-2
src/service/duel/move.ts
src/service/duel/move.ts
+4
-7
src/ui/Duel/NewPlayMat/Card/index.tsx
src/ui/Duel/NewPlayMat/Card/index.tsx
+1
-2
src/ui/Duel/NewPlayMat/Card/springs/toHand.ts
src/ui/Duel/NewPlayMat/Card/springs/toHand.ts
+1
-1
src/ui/Duel/NewPlayMat/Card/springs/types.ts
src/ui/Duel/NewPlayMat/Card/springs/types.ts
+0
-4
src/ui/Duel/NewPlayMat/utils/eventbus.ts
src/ui/Duel/NewPlayMat/utils/eventbus.ts
+0
-3
No files found.
src/env.d.ts
View file @
7365a6b2
...
@@ -17,4 +17,7 @@ import { EventEmitter } from "eventemitter3";
...
@@ -17,4 +17,7 @@ import { EventEmitter } from "eventemitter3";
declare
global
{
declare
global
{
var
eventBus
:
EventEmitter
;
var
eventBus
:
EventEmitter
;
var
myExtraDeckCodes
:
number
[];
var
myExtraDeckCodes
:
number
[];
export
enum
Report
{
Move
=
"
move
"
,
}
}
}
src/infra/eventbus.ts
0 → 100644
View file @
7365a6b2
import
{
EventEmitter
}
from
"
eventemitter3
"
;
window
.
eventBus
=
new
EventEmitter
();
enum
Report
{
Move
=
"
move
"
,
}
// @ts-ignore
window
.
Report
=
Report
;
src/infra/index.ts
View file @
7365a6b2
...
@@ -2,3 +2,4 @@
...
@@ -2,3 +2,4 @@
export
*
from
"
./sleep
"
;
export
*
from
"
./sleep
"
;
export
*
from
"
./stream
"
;
export
*
from
"
./stream
"
;
export
*
from
"
./eventbus
"
;
src/main.tsx
View file @
7365a6b2
...
@@ -27,10 +27,6 @@ import { BrowserRouter } from "react-router-dom";
...
@@ -27,10 +27,6 @@ import { BrowserRouter } from "react-router-dom";
import
Neos
from
"
./ui/Neos
"
;
import
Neos
from
"
./ui/Neos
"
;
import
{
EventEmitter
}
from
"
eventemitter3
"
;
window
.
eventBus
=
new
EventEmitter
();
const
root
=
ReactDOM
.
createRoot
(
const
root
=
ReactDOM
.
createRoot
(
document
.
getElementById
(
"
root
"
)
as
HTMLElement
document
.
getElementById
(
"
root
"
)
as
HTMLElement
);
);
...
...
src/service/duel/draw.ts
View file @
7365a6b2
...
@@ -2,7 +2,6 @@ import { sleep } from "@/infra";
...
@@ -2,7 +2,6 @@ import { sleep } from "@/infra";
import
{
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
fetchCard
,
ygopro
}
from
"
@/api
"
;
import
{
fetchEsHintMeta
,
matStore
,
cardStore
}
from
"
@/stores
"
;
import
{
fetchEsHintMeta
,
matStore
,
cardStore
}
from
"
@/stores
"
;
import
{
zip
}
from
"
@/ui/Duel/utils
"
;
import
{
zip
}
from
"
@/ui/Duel/utils
"
;
import
{
ReportEnum
}
from
"
@/ui/Duel/NewPlayMat/Card/springs/types
"
;
export
default
async
(
draw
:
ygopro
.
StocGameMessage
.
MsgDraw
)
=>
{
export
default
async
(
draw
:
ygopro
.
StocGameMessage
.
MsgDraw
)
=>
{
fetchEsHintMeta
({
originMsg
:
"
玩家抽卡时
"
});
fetchEsHintMeta
({
originMsg
:
"
玩家抽卡时
"
});
...
@@ -40,5 +39,5 @@ export default async (draw: ygopro.StocGameMessage.MsgDraw) => {
...
@@ -40,5 +39,5 @@ export default async (draw: ygopro.StocGameMessage.MsgDraw) => {
// 抽卡动画
// 抽卡动画
cardStore
cardStore
.
at
(
ygopro
.
CardZone
.
HAND
,
draw
.
player
)
.
at
(
ygopro
.
CardZone
.
HAND
,
draw
.
player
)
.
forEach
((
card
)
=>
eventBus
.
emit
(
Report
Enum
.
Move
,
card
.
uuid
));
.
forEach
((
card
)
=>
eventBus
.
emit
(
Report
.
Move
,
card
.
uuid
));
};
};
src/service/duel/move.ts
View file @
7365a6b2
...
@@ -7,7 +7,6 @@ import { useConfig } from "@/config";
...
@@ -7,7 +7,6 @@ import { useConfig } from "@/config";
import
{
sleep
}
from
"
@/infra
"
;
import
{
sleep
}
from
"
@/infra
"
;
import
{
REASON_MATERIAL
}
from
"
../../common
"
;
import
{
REASON_MATERIAL
}
from
"
../../common
"
;
import
{
ReportEnum
}
from
"
@/ui/Duel/NewPlayMat/Card/springs/types
"
;
const
{
matStore
}
=
store
;
const
{
matStore
}
=
store
;
const
NeosConfig
=
useConfig
();
const
NeosConfig
=
useConfig
();
...
@@ -187,9 +186,9 @@ export default async (move: MsgMove) => {
...
@@ -187,9 +186,9 @@ export default async (move: MsgMove) => {
console
.
warn
(
"
overlay
"
,
from
.
overlay_sequence
,
to
.
overlay_sequence
);
console
.
warn
(
"
overlay
"
,
from
.
overlay_sequence
,
to
.
overlay_sequence
);
})();
})();
// 处理token
let
target
:
CardType
;
let
target
:
CardType
;
// 处理token
if
(
fromZone
===
TZONE
)
{
if
(
fromZone
===
TZONE
)
{
// 召唤 token
// 召唤 token
target
=
cardStore
.
at
(
TZONE
,
from
.
controler
)[
0
];
// 必有,随便取一个没用到的token
target
=
cardStore
.
at
(
TZONE
,
from
.
controler
)[
0
];
// 必有,随便取一个没用到的token
...
@@ -202,6 +201,7 @@ export default async (move: MsgMove) => {
...
@@ -202,6 +201,7 @@ export default async (move: MsgMove) => {
target
=
cardStore
.
at
(
fromZone
,
from
.
controler
,
from
.
sequence
);
target
=
cardStore
.
at
(
fromZone
,
from
.
controler
,
from
.
sequence
);
}
}
// 超量
if
(
toZone
===
OVERLAY
)
{
if
(
toZone
===
OVERLAY
)
{
// 准备超量召唤,超量素材入栈
// 准备超量召唤,超量素材入栈
if
(
reason
==
REASON_MATERIAL
)
overlayStack
.
push
(
target
);
if
(
reason
==
REASON_MATERIAL
)
overlayStack
.
push
(
target
);
...
@@ -231,14 +231,11 @@ export default async (move: MsgMove) => {
...
@@ -231,14 +231,11 @@ export default async (move: MsgMove) => {
target
.
position
=
to
.
position
;
target
.
position
=
to
.
position
;
// 维护完了之后,开始动画
// 维护完了之后,开始动画
eventBus
.
emit
(
Report
Enum
.
Move
,
target
.
uuid
);
eventBus
.
emit
(
Report
.
Move
,
target
.
uuid
);
// 如果from或者to是手卡,那么需要刷新除了这张卡之外,这个玩家的所有手卡
// 如果from或者to是手卡,那么需要刷新除了这张卡之外,这个玩家的所有手卡
if
([
fromZone
,
toZone
].
includes
(
HAND
))
{
if
([
fromZone
,
toZone
].
includes
(
HAND
))
{
cardStore
.
at
(
HAND
,
target
.
controller
).
forEach
((
card
)
=>
{
cardStore
.
at
(
HAND
,
target
.
controller
).
forEach
((
card
)
=>
{
if
(
card
.
uuid
!==
target
.
uuid
)
{
if
(
card
.
uuid
!==
target
.
uuid
)
eventBus
.
emit
(
Report
.
Move
,
card
.
uuid
);
console
.
log
(
"
refresh hand
"
,
card
.
uuid
);
eventBus
.
emit
(
ReportEnum
.
Move
,
card
.
uuid
);
}
});
});
}
}
...
...
src/ui/Duel/NewPlayMat/Card/index.tsx
View file @
7365a6b2
...
@@ -6,7 +6,6 @@ import { useSpring, animated, to } from "@react-spring/web";
...
@@ -6,7 +6,6 @@ import { useSpring, animated, to } from "@react-spring/web";
import
{
ygopro
}
from
"
@/api
"
;
import
{
ygopro
}
from
"
@/api
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
useConfig
}
from
"
@/config
"
;
import
{
moveToDeck
,
moveToGround
,
moveToHand
,
moveToOutside
}
from
"
./springs
"
;
import
{
moveToDeck
,
moveToGround
,
moveToHand
,
moveToOutside
}
from
"
./springs
"
;
import
{
ReportEnum
}
from
"
./springs/types
"
;
import
{
interactTypeToString
}
from
"
../../utils
"
;
import
{
interactTypeToString
}
from
"
../../utils
"
;
import
classnames
from
"
classnames
"
;
import
classnames
from
"
classnames
"
;
...
@@ -57,7 +56,7 @@ export const Card: FC<{ idx: number }> = React.memo(({ idx }) => {
...
@@ -57,7 +56,7 @@ export const Card: FC<{ idx: number }> = React.memo(({ idx }) => {
const
[
highlight
,
setHighlight
]
=
useState
(
false
);
const
[
highlight
,
setHighlight
]
=
useState
(
false
);
const
[
shadowOpacity
,
setShadowOpacity
]
=
useState
(
0
);
const
[
shadowOpacity
,
setShadowOpacity
]
=
useState
(
0
);
eventBus
.
on
(
Report
Enum
.
Move
,
(
uuid
)
=>
{
eventBus
.
on
(
Report
.
Move
,
(
uuid
)
=>
{
if
(
uuid
===
state
.
uuid
)
reload
(
state
.
zone
);
if
(
uuid
===
state
.
uuid
)
reload
(
state
.
zone
);
});
});
...
...
src/ui/Duel/NewPlayMat/Card/springs/toHand.ts
View file @
7365a6b2
import
{
isMe
,
type
CardType
,
cardStore
}
from
"
@/stores
"
;
import
{
isMe
,
type
CardType
,
cardStore
}
from
"
@/stores
"
;
import
{
SpringApi
,
ReportEnum
}
from
"
./types
"
;
import
{
SpringApi
}
from
"
./types
"
;
import
{
matConfig
}
from
"
../../utils
"
;
import
{
matConfig
}
from
"
../../utils
"
;
import
{
ygopro
}
from
"
@/api
"
;
import
{
ygopro
}
from
"
@/api
"
;
import
{
easings
}
from
"
@react-spring/web
"
;
import
{
easings
}
from
"
@react-spring/web
"
;
...
...
src/ui/Duel/NewPlayMat/Card/springs/types.ts
View file @
7365a6b2
...
@@ -10,7 +10,3 @@ export type SpringApi = SpringRef<{
...
@@ -10,7 +10,3 @@ export type SpringApi = SpringRef<{
zIndex
:
number
;
zIndex
:
number
;
height
:
number
;
height
:
number
;
}
>
;
}
>
;
export
enum
ReportEnum
{
Move
=
"
move
"
,
}
src/ui/Duel/NewPlayMat/utils/eventbus.ts
deleted
100644 → 0
View file @
a65180b6
// import { EventEmitter } from "eventemitter3";
// window.eventBus = new EventEmitter();
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