@@ -34,7 +34,7 @@ pub async fn init(
34
34
from_game ( game)
35
35
}
36
36
37
- #[ wasm_bindgen]
37
+ #[ wasm_bindgen( js_name = move ) ]
38
38
pub fn execute_move ( game : JsValue , move_data : JsValue , player : JsValue ) -> JsValue {
39
39
let game = get_game ( game) ;
40
40
let action = serde_wasm_bindgen:: from_value ( move_data) . expect ( "move should be of type action" ) ;
@@ -56,16 +56,16 @@ pub fn scores(game: JsValue) -> JsValue {
56
56
serde_wasm_bindgen:: to_value ( & scores) . expect ( "scores should be serializable" )
57
57
}
58
58
59
- #[ wasm_bindgen]
59
+ #[ wasm_bindgen( js_name = "dropPlayer" ) ]
60
60
pub async fn drop_player ( game : JsValue , player : JsValue ) -> JsValue {
61
61
let game = get_game ( game) ;
62
62
let player_index = player. as_f64 ( ) . expect ( "player index should be a number" ) as usize ;
63
63
let game = game_api:: drop_player ( game, player_index) ;
64
64
from_game ( game)
65
65
}
66
66
67
- #[ wasm_bindgen]
68
- pub async fn current_player ( game : JsValue ) -> JsValue {
67
+ #[ wasm_bindgen( js_name = "currentPlayer" ) ]
68
+ pub fn current_player ( game : JsValue ) -> JsValue {
69
69
let game = get_game ( game) ;
70
70
let player_index = game_api:: current_player ( & game) ;
71
71
match player_index {
@@ -74,22 +74,22 @@ pub async fn current_player(game: JsValue) -> JsValue {
74
74
}
75
75
}
76
76
77
- #[ wasm_bindgen]
78
- pub async fn log_length ( game : JsValue ) -> JsValue {
77
+ #[ wasm_bindgen( js_name = "logLength" ) ]
78
+ pub fn log_length ( game : JsValue ) -> JsValue {
79
79
let game = get_game ( game) ;
80
80
let log_length = game_api:: log_length ( & game) ;
81
81
JsValue :: from_f64 ( log_length as f64 )
82
82
}
83
83
84
- #[ wasm_bindgen]
85
- pub async fn log_slice ( game : JsValue , options : JsValue ) -> JsValue {
84
+ #[ wasm_bindgen( js_name = "logSlice" ) ]
85
+ pub fn log_slice ( game : JsValue , options : JsValue ) -> JsValue {
86
86
let game = get_game ( game) ;
87
87
let options = serde_wasm_bindgen:: from_value ( options) . expect ( "options should be serializable" ) ;
88
88
let log = game_api:: log_slice ( & game, & options) ;
89
89
serde_wasm_bindgen:: to_value ( & log) . expect ( "log should be serializable" )
90
90
}
91
91
92
- #[ wasm_bindgen]
92
+ #[ wasm_bindgen( js_name = "setPlayerMetaData" ) ]
93
93
pub fn set_player_meta_data ( game : JsValue , player_index : JsValue , meta_data : JsValue ) -> JsValue {
94
94
let game = get_game ( game) ;
95
95
let player_index = player_index
@@ -109,7 +109,7 @@ pub fn rankings(game: JsValue) -> JsValue {
109
109
serde_wasm_bindgen:: to_value ( & rankings) . expect ( "rankings should be serializable" )
110
110
}
111
111
112
- #[ wasm_bindgen]
112
+ #[ wasm_bindgen( js_name = "roundNumber" ) ]
113
113
pub fn round_number ( game : JsValue ) -> JsValue {
114
114
let game = get_game ( game) ;
115
115
let round = game_api:: round ( & game) ;
@@ -126,7 +126,7 @@ pub fn factions(game: JsValue) -> JsValue {
126
126
serde_wasm_bindgen:: to_value ( & factions) . expect ( "faction list should be serializable" )
127
127
}
128
128
129
- #[ wasm_bindgen]
129
+ #[ wasm_bindgen( js_name = "stripSecret" ) ]
130
130
pub fn strip_secret ( game : JsValue , player : JsValue ) -> JsValue {
131
131
let game = get_game ( game) ;
132
132
let player_index = player. as_f64 ( ) . map ( |player_index| player_index as usize ) ;
0 commit comments