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
21e11058
Commit
21e11058
authored
Mar 13, 2023
by
Chunchi Che
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle damage msg in rust-src
parent
95b51bd0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
19 deletions
+25
-19
rust-src/Cargo.lock
rust-src/Cargo.lock
+1
-0
rust-src/Cargo.toml
rust-src/Cargo.toml
+2
-1
rust-src/src/buffer.rs
rust-src/src/buffer.rs
+1
-0
rust-src/src/lib.rs
rust-src/src/lib.rs
+18
-5
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/damage.ts
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/damage.ts
+3
-10
src/ui/Neos.tsx
src/ui/Neos.tsx
+0
-3
No files found.
rust-src/Cargo.lock
View file @
21e11058
...
@@ -89,6 +89,7 @@ name = "rust-src"
...
@@ -89,6 +89,7 @@ name = "rust-src"
version = "0.1.0"
version = "0.1.0"
dependencies = [
dependencies = [
"console_error_panic_hook",
"console_error_panic_hook",
"js-sys",
"wasm-bindgen",
"wasm-bindgen",
"wasm-bindgen-test",
"wasm-bindgen-test",
"wee_alloc",
"wee_alloc",
...
...
rust-src/Cargo.toml
View file @
21e11058
...
@@ -10,10 +10,11 @@ crate-type = ["cdylib", "rlib"]
...
@@ -10,10 +10,11 @@ crate-type = ["cdylib", "rlib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
[features]
default
=
["console_error_panic_hook"]
default
=
[
"console_error_panic_hook"
,
"wee_alloc"
]
[dependencies]
[dependencies]
wasm-bindgen
=
"0.2.63"
wasm-bindgen
=
"0.2.63"
js-sys
=
"0.3.61"
console_error_panic_hook
=
{
version
=
"0.1.6"
,
optional
=
true
}
console_error_panic_hook
=
{
version
=
"0.1.6"
,
optional
=
true
}
wee_alloc
=
{
version
=
"0.4.5"
,
optional
=
true
}
wee_alloc
=
{
version
=
"0.4.5"
,
optional
=
true
}
...
...
rust-src/src/buffer.rs
0 → 100644
View file @
21e11058
// TODO
rust-src/src/lib.rs
View file @
21e11058
#![allow(non_snake_case)]
mod
buffer
;
mod
utils
;
mod
utils
;
use
wasm_bindgen
::
prelude
::
*
;
use
std
::
convert
::
TryInto
;
use
wasm_bindgen
::
prelude
::
wasm_bindgen
;
pub
use
utils
::
set_panic_hook
;
pub
use
utils
::
set_panic_hook
;
...
@@ -11,11 +15,20 @@ pub use utils::set_panic_hook;
...
@@ -11,11 +15,20 @@ pub use utils::set_panic_hook;
static
ALLOC
:
wee_alloc
::
WeeAlloc
=
wee_alloc
::
WeeAlloc
::
INIT
;
static
ALLOC
:
wee_alloc
::
WeeAlloc
=
wee_alloc
::
WeeAlloc
::
INIT
;
#[wasm_bindgen]
#[wasm_bindgen]
extern
"C"
{
pub
struct
MsgUpdateHp
{
fn
alert
(
s
:
&
str
);
pub
player
:
Option
<
u8
>
,
pub
value
:
Option
<
i32
>
,
}
}
#[wasm_bindgen]
#[wasm_bindgen]
pub
fn
greet
()
{
pub
fn
ocgDamageAdapter
(
data
:
js_sys
::
Uint8Array
)
->
MsgUpdateHp
{
alert
(
"Hello, {{project-name}}!"
);
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
),
value
,
}
}
}
src/api/ocgcore/ocgAdapter/stoc/stocGameMsg/damage.ts
View file @
21e11058
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
{
ygopro
}
from
"
../../../idl/ocgcore
"
;
import
{
BufferReader
}
from
"
../../bufferIO
"
;
import
{
ocgDamageAdapter
}
from
"
rust-src
"
;
/*
/*
* Msg Damage
* Msg Damage
...
@@ -8,14 +8,7 @@ import { BufferReader } from "../../bufferIO";
...
@@ -8,14 +8,7 @@ import { BufferReader } from "../../bufferIO";
* @param value - 减少的Hp数值
* @param value - 减少的Hp数值
* */
* */
export
default
(
data
:
Uint8Array
)
=>
{
export
default
(
data
:
Uint8Array
)
=>
{
const
reader
=
new
BufferReader
(
data
,
true
);
const
damage
=
ocgDamageAdapter
(
data
);
const
player
=
reader
.
readUint8
();
return
new
ygopro
.
StocGameMessage
.
MsgUpdateHp
(
damage
);
const
value
=
reader
.
readInt32
();
return
new
ygopro
.
StocGameMessage
.
MsgUpdateHp
({
player
,
type_
:
ygopro
.
StocGameMessage
.
MsgUpdateHp
.
ActionType
.
DAMAGE
,
value
,
});
};
};
src/ui/Neos.tsx
View file @
21e11058
import
React
,
{
Suspense
}
from
"
react
"
;
import
React
,
{
Suspense
}
from
"
react
"
;
import
{
Routes
,
Route
}
from
"
react-router-dom
"
;
import
{
Routes
,
Route
}
from
"
react-router-dom
"
;
import
LazyLoad
,
{
Loading
}
from
"
./LazyLoad
"
;
import
LazyLoad
,
{
Loading
}
from
"
./LazyLoad
"
;
import
{
greet
}
from
"
rust-src
"
;
const
Login
=
React
.
lazy
(()
=>
import
(
"
./Login
"
));
const
Login
=
React
.
lazy
(()
=>
import
(
"
./Login
"
));
const
WaitRoom
=
React
.
lazy
(()
=>
import
(
"
./WaitRoom
"
));
const
WaitRoom
=
React
.
lazy
(()
=>
import
(
"
./WaitRoom
"
));
...
@@ -9,8 +8,6 @@ const Mora = React.lazy(() => import("./Mora"));
...
@@ -9,8 +8,6 @@ const Mora = React.lazy(() => import("./Mora"));
const
NeosDuel
=
React
.
lazy
(()
=>
import
(
"
./Duel/main
"
));
const
NeosDuel
=
React
.
lazy
(()
=>
import
(
"
./Duel/main
"
));
export
default
function
()
{
export
default
function
()
{
greet
();
return
(
return
(
<
Routes
>
<
Routes
>
<
Route
path=
"/"
element=
{
<
LazyLoad
lazy=
{
<
Login
/>
}
/>
}
/>
<
Route
path=
"/"
element=
{
<
LazyLoad
lazy=
{
<
Login
/>
}
/>
}
/>
...
...
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