Commit 958dc3d7 authored by Chunchi Che's avatar Chunchi Che

range rust-src

parent dc12d558
Pipeline #20712 passed with stages
in 15 minutes and 3 seconds
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,
}
}
//! 一些`ocg raw buffer`到`neos-protobuf message`的转换逻辑
//!
//! TODO: neos与ygopro交互设计介绍
mod damage;
pub use damage::*;
......@@ -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,
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment