screeps/game/
shard.rs

1//! Information about the current shard.
2//!
3//! [Screeps documentation](https://docs.screeps.com/api/#Game.shard)
4use js_sys::JsString;
5use wasm_bindgen::prelude::*;
6
7#[wasm_bindgen]
8extern "C" {
9    #[wasm_bindgen(js_name = "shard")]
10    type Shard;
11
12    #[wasm_bindgen(js_namespace = ["Game"], js_class = "shard", static_method_of = Shard, getter, js_name = name)]
13    fn name() -> JsString;
14
15    #[wasm_bindgen(js_namespace = ["Game"], js_class = "shard", static_method_of = Shard, getter, js_name = type)]
16    fn shard_type() -> JsString;
17
18    #[wasm_bindgen(js_namespace = ["Game"], js_class = "shard", static_method_of = Shard, getter, js_name = ptr)]
19    fn ptr() -> bool;
20}
21
22/// Current shard name.
23pub fn name() -> String {
24    Shard::name().into()
25}
26
27/// Shard type. Currently always "normal".
28pub fn shard_type() -> String {
29    Shard::shard_type().into()
30}
31
32/// Flag for if this is a public test server or not.
33pub fn ptr() -> bool {
34    Shard::ptr()
35}