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
477ee9b3
Commit
477ee9b3
authored
Jan 14, 2023
by
chechunchi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix error
parent
23ff98cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
17 deletions
+34
-17
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/penetrate.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/penetrate.ts
+34
-17
No files found.
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/penetrate.ts
View file @
477ee9b3
...
...
@@ -2,6 +2,20 @@
import
PenetrateData
from
"
./penetrate.json
"
;
import
{
BufferReader
}
from
"
../../bufferIO
"
;
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
type
Constructor
<
T
=
any
>
=
new
(...
args
:
any
[])
=>
T
;
const
PenetrateConfig
=
_objToMap
(
PenetrateData
);
const
readFieldHandlerMap
:
Map
<
string
,
readFieldHandler
>
=
new
Map
([
[
"
uint8
"
,
((
reader
)
=>
reader
.
readUint8
())
as
readFieldHandler
],
[
"
uint16
"
,
(
reader
)
=>
reader
.
readUint16
()],
[
"
uint32
"
,
(
reader
)
=>
reader
.
readUint32
()],
[
"
CardLocation
"
,
(
reader
)
=>
reader
.
readCardLocation
()],
]);
const
msgConstructorMap
:
Map
<
string
,
Constructor
>
=
new
Map
([
[
"
move
"
,
ygopro
.
StocGameMessage
.
MsgMove
],
]);
export
interface
penetrateType
{
protoType
:
string
;
...
...
@@ -11,7 +25,9 @@ export interface penetrateType {
}[];
}
const
PenetrateConfig
=
_objToMap
(
PenetrateData
);
interface
readFieldHandler
{
(
reader
:
BufferReader
):
any
;
}
export
function
penetrate
(
msgKey
:
number
,
...
...
@@ -25,12 +41,12 @@ export function penetrate(
const
protoType
=
config
.
protoType
;
const
fields
=
config
.
fields
;
let
obj
:
any
=
{};
let
obj
ect
:
any
=
{};
for
(
let
field
of
fields
)
{
obj
[
field
.
fieldName
]
=
readField
(
reader
,
field
.
fieldType
);
obj
ect
[
field
.
fieldName
]
=
readField
(
reader
,
field
.
fieldType
);
}
gameMsg
[
protoType
]
=
obj
;
gameMsg
[
protoType
]
=
constructMsg
(
protoType
,
object
)
;
}
return
config
?
true
:
false
;
...
...
@@ -47,18 +63,19 @@ function _objToMap(obj: any): Map<string, penetrateType> {
}
function
readField
(
reader
:
BufferReader
,
fieldType
:
string
):
any
{
switch
(
fieldType
)
{
case
"
uint8
"
:
{
return
reader
.
readUint8
();
}
case
"
uint32
"
:
{
return
reader
.
readUint32
()
;
}
case
"
CardLocation
"
:
{
return
reader
.
readCardLocation
();
}
default
:
{
return
undefined
;
}
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