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
958dc3d7
Commit
958dc3d7
authored
Mar 15, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
range rust-src
parent
dc12d558
Pipeline
#20712
passed with stages
in 15 minutes and 3 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
31 deletions
+39
-31
rust-src/src/adapters/damage.rs
rust-src/src/adapters/damage.rs
+30
-0
rust-src/src/adapters/mod.rs
rust-src/src/adapters/mod.rs
+7
-0
rust-src/src/lib.rs
rust-src/src/lib.rs
+2
-31
No files found.
rust-src/src/adapters/damage.rs
0 → 100644
View file @
958dc3d7
use
wasm_bindgen
::
prelude
::
wasm_bindgen
;
use
std
::
convert
::
TryInto
;
#[wasm_bindgen]
pub
struct
MsgUpdateHp
{
pub
player
:
Option
<
u8
>
,
pub
type_
:
Option
<
u8
>
,
pub
value
:
Option
<
i32
>
,
}
#[repr(u8)]
enum
ActionType
{
_
Unknown
=
0
,
Damage
=
1
,
_
Recover
=
2
,
}
#[wasm_bindgen]
pub
fn
ocgDamageAdapter
(
data
:
js_sys
::
Uint8Array
)
->
MsgUpdateHp
{
let
data
=
data
.to_vec
();
let
player
=
data
[
0
];
let
value
=
data
[
1
..
5
]
.try_into
()
.map
(
i32
::
from_le_bytes
)
.ok
();
MsgUpdateHp
{
player
:
Some
(
player
),
type_
:
Some
(
ActionType
::
Damage
as
u8
),
value
,
}
}
rust-src/src/adapters/mod.rs
0 → 100644
View file @
958dc3d7
//! 一些`ocg raw buffer`到`neos-protobuf message`的转换逻辑
//!
//! TODO: neos与ygopro交互设计介绍
mod
damage
;
pub
use
damage
::
*
;
rust-src/src/lib.rs
View file @
958dc3d7
...
...
@@ -2,42 +2,13 @@
mod
buffer
;
mod
utils
;
use
std
::
convert
::
TryInto
;
use
wasm_bindgen
::
prelude
::
wasm_bindgen
;
mod
adapters
;
pub
use
utils
::
set_panic_hook
;
pub
use
adapters
::
*
;
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature
=
"wee_alloc"
)]
#[global_allocator]
static
ALLOC
:
wee_alloc
::
WeeAlloc
=
wee_alloc
::
WeeAlloc
::
INIT
;
#[wasm_bindgen]
pub
struct
MsgUpdateHp
{
pub
player
:
Option
<
u8
>
,
pub
type_
:
Option
<
u8
>
,
pub
value
:
Option
<
i32
>
,
}
#[repr(u8)]
enum
ActionType
{
_
Unknown
=
0
,
Damage
=
1
,
_
Recover
=
2
,
}
#[wasm_bindgen]
pub
fn
ocgDamageAdapter
(
data
:
js_sys
::
Uint8Array
)
->
MsgUpdateHp
{
let
data
=
data
.to_vec
();
let
player
=
data
[
0
];
let
value
=
data
[
1
..
5
]
.try_into
()
.map
(
i32
::
from_le_bytes
)
.ok
();
MsgUpdateHp
{
player
:
Some
(
player
),
type_
:
Some
(
ActionType
::
Damage
as
u8
),
value
,
}
}
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