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
ce2e85cf
Commit
ce2e85cf
authored
Jan 14, 2023
by
chechunchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rerange code
parent
477ee9b3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
45 deletions
+46
-45
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
+2
-9
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/penetrate.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/penetrate.ts
+44
-36
No files found.
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/mod.ts
View file @
ce2e85cf
...
@@ -13,13 +13,12 @@ import MsgNewPhaseAdapter from "./newPhase";
...
@@ -13,13 +13,12 @@ import MsgNewPhaseAdapter from "./newPhase";
import
MsgHintAdapter
from
"
./hint
"
;
import
MsgHintAdapter
from
"
./hint
"
;
import
MsgSelectIdleCmdAdapter
from
"
./selectIdleCmd
"
;
import
MsgSelectIdleCmdAdapter
from
"
./selectIdleCmd
"
;
import
MsgSelectPlaceAdapter
from
"
./selectPlace
"
;
import
MsgSelectPlaceAdapter
from
"
./selectPlace
"
;
import
MsgMoveAdapter
from
"
./move
"
;
import
MsgSelectCardAdapter
from
"
./selectCard
"
;
import
MsgSelectCardAdapter
from
"
./selectCard
"
;
import
MsgSelectChainAdapter
from
"
./selectChain
"
;
import
MsgSelectChainAdapter
from
"
./selectChain
"
;
import
MsgSelectEffectYnAdapter
from
"
./selectEffectYn
"
;
import
MsgSelectEffectYnAdapter
from
"
./selectEffectYn
"
;
import
MsgSelectPositionAdapter
from
"
./selectPosition
"
;
import
MsgSelectPositionAdapter
from
"
./selectPosition
"
;
import
MsgSelectOptionAdapter
from
"
./selectOption
"
;
import
MsgSelectOptionAdapter
from
"
./selectOption
"
;
import
{
penetrate
}
from
"
./penetrate
"
;
import
PENETRATE
from
"
./penetrate
"
;
/*
/*
* STOC GameMsg
* STOC GameMsg
...
@@ -44,7 +43,7 @@ export default class GameMsgAdapter implements StocAdapter {
...
@@ -44,7 +43,7 @@ export default class GameMsgAdapter implements StocAdapter {
const
gameData
=
exData
.
slice
(
1
);
const
gameData
=
exData
.
slice
(
1
);
let
gameMsg
:
any
=
new
ygopro
.
StocGameMessage
({}).
toObject
();
let
gameMsg
:
any
=
new
ygopro
.
StocGameMessage
({}).
toObject
();
if
(
!
penetrate
(
func
,
gameMsg
,
gameData
))
{
if
(
!
PENETRATE
.
penetrate
(
func
,
gameMsg
,
gameData
))
{
switch
(
func
)
{
switch
(
func
)
{
case
GAME_MSG
.
MSG_START
:
{
case
GAME_MSG
.
MSG_START
:
{
gameMsg
.
start
=
MsgStartAdapter
(
gameData
);
gameMsg
.
start
=
MsgStartAdapter
(
gameData
);
...
@@ -81,12 +80,6 @@ export default class GameMsgAdapter implements StocAdapter {
...
@@ -81,12 +80,6 @@ export default class GameMsgAdapter implements StocAdapter {
break
;
break
;
}
}
// case GAME_MSG.MSG_MOVE: {
// // gameMsg.move = MsgMoveAdapter(gameData);
// gameMsg["move"] = MsgMoveAdapter(gameData);
//
// break;
// }
case
GAME_MSG
.
MSG_SELECT_CARD
:
{
case
GAME_MSG
.
MSG_SELECT_CARD
:
{
gameMsg
.
select_card
=
MsgSelectCardAdapter
(
gameData
);
gameMsg
.
select_card
=
MsgSelectCardAdapter
(
gameData
);
...
...
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/penetrate.ts
View file @
ce2e85cf
...
@@ -7,13 +7,13 @@ import { ygopro } from "../../../idl/ocgcore";
...
@@ -7,13 +7,13 @@ import { ygopro } from "../../../idl/ocgcore";
type
Constructor
<
T
=
any
>
=
new
(...
args
:
any
[])
=>
T
;
type
Constructor
<
T
=
any
>
=
new
(...
args
:
any
[])
=>
T
;
const
PenetrateConfig
=
_objToMap
(
PenetrateData
);
const
PenetrateConfig
=
_objToMap
(
PenetrateData
);
const
r
eadFieldHandlerMap
:
Map
<
string
,
readFieldHandler
>
=
new
Map
([
const
R
eadFieldHandlerMap
:
Map
<
string
,
readFieldHandler
>
=
new
Map
([
[
"
uint8
"
,
((
reader
)
=>
reader
.
readUint8
())
as
readFieldHandler
],
[
"
uint8
"
,
((
reader
)
=>
reader
.
readUint8
())
as
readFieldHandler
],
[
"
uint16
"
,
(
reader
)
=>
reader
.
readUint16
()],
[
"
uint16
"
,
(
reader
)
=>
reader
.
readUint16
()],
[
"
uint32
"
,
(
reader
)
=>
reader
.
readUint32
()],
[
"
uint32
"
,
(
reader
)
=>
reader
.
readUint32
()],
[
"
CardLocation
"
,
(
reader
)
=>
reader
.
readCardLocation
()],
[
"
CardLocation
"
,
(
reader
)
=>
reader
.
readCardLocation
()],
]);
]);
const
m
sgConstructorMap
:
Map
<
string
,
Constructor
>
=
new
Map
([
const
M
sgConstructorMap
:
Map
<
string
,
Constructor
>
=
new
Map
([
[
"
move
"
,
ygopro
.
StocGameMessage
.
MsgMove
],
[
"
move
"
,
ygopro
.
StocGameMessage
.
MsgMove
],
]);
]);
...
@@ -29,27 +29,51 @@ interface readFieldHandler {
...
@@ -29,27 +29,51 @@ interface readFieldHandler {
(
reader
:
BufferReader
):
any
;
(
reader
:
BufferReader
):
any
;
}
}
export
function
penetrate
(
class
PenetrateManager
{
msgKey
:
number
,
config
:
Map
<
string
,
penetrateType
>
;
gameMsg
:
any
,
readFieldHandlerMap
:
Map
<
string
,
readFieldHandler
>
=
ReadFieldHandlerMap
;
gameData
:
Uint8Array
msgConstructorMap
:
Map
<
string
,
Constructor
>
=
MsgConstructorMap
;
):
boolean
{
const
config
=
PenetrateConfig
.
get
(
msgKey
.
toString
());
constructor
(
config
:
any
)
{
const
reader
=
new
BufferReader
(
gameData
,
true
);
this
.
config
=
_objToMap
(
config
);
}
if
(
config
)
{
const
protoType
=
config
.
protoType
;
private
readField
(
reader
:
BufferReader
,
fieldType
:
string
):
any
{
const
fields
=
config
.
fields
;
const
handler
=
this
.
readFieldHandlerMap
.
get
(
fieldType
);
let
object
:
any
=
{};
if
(
handler
)
{
for
(
let
field
of
fields
)
{
return
handler
(
reader
);
object
[
field
.
fieldName
]
=
readField
(
reader
,
field
.
fieldType
);
}
}
return
undefined
;
}
gameMsg
[
protoType
]
=
constructMsg
(
protoType
,
object
);
private
constructMsg
(
protoType
:
string
,
object
:
any
):
any
{
const
constructor
=
this
.
msgConstructorMap
.
get
(
protoType
);
if
(
constructor
)
{
return
new
constructor
(
object
);
}
return
undefined
;
}
}
return
config
?
true
:
false
;
penetrate
(
msgKey
:
number
,
gameMsg
:
any
,
gameData
:
Uint8Array
):
boolean
{
const
config
=
this
.
config
.
get
(
msgKey
.
toString
());
const
reader
=
new
BufferReader
(
gameData
,
true
);
if
(
config
)
{
const
protoType
=
config
.
protoType
;
const
fields
=
config
.
fields
;
let
object
:
any
=
{};
for
(
let
field
of
fields
)
{
object
[
field
.
fieldName
]
=
this
.
readField
(
reader
,
field
.
fieldType
);
}
gameMsg
[
protoType
]
=
this
.
constructMsg
(
protoType
,
object
);
}
return
config
?
true
:
false
;
}
}
}
function
_objToMap
(
obj
:
any
):
Map
<
string
,
penetrateType
>
{
function
_objToMap
(
obj
:
any
):
Map
<
string
,
penetrateType
>
{
...
@@ -62,20 +86,4 @@ function _objToMap(obj: any): Map<string, penetrateType> {
...
@@ -62,20 +86,4 @@ function _objToMap(obj: any): Map<string, penetrateType> {
return
map
;
return
map
;
}
}
function
readField
(
reader
:
BufferReader
,
fieldType
:
string
):
any
{
export
default
new
PenetrateManager
(
PenetrateConfig
);
const
handler
=
readFieldHandlerMap
.
get
(
fieldType
);
if
(
handler
)
{
return
handler
(
reader
);
}
return
undefined
;
}
function
constructMsg
(
protoType
:
string
,
object
:
any
):
any
|
undefined
{
const
constructor
=
msgConstructorMap
.
get
(
protoType
);
if
(
constructor
)
{
return
new
constructor
(
object
);
}
return
undefined
;
}
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