screeps/game/
gpl.rs

1//! Global Power Level information.
2//!
3//! [Screeps documentation](http://docs.screeps.com/api/#Game.gpl)
4use wasm_bindgen::prelude::*;
5
6#[wasm_bindgen]
7extern "C" {
8    #[wasm_bindgen(js_name = "gpl")]
9    type Gpl;
10
11    #[wasm_bindgen(js_namespace = ["Game"], js_class = "gpl", static_method_of = Gpl, getter, js_name = level)]
12    fn level() -> u32;
13
14    #[wasm_bindgen(js_namespace = ["Game"], js_class = "gpl", static_method_of = Gpl, getter, js_name = progress)]
15    fn progress() -> f64;
16
17    #[wasm_bindgen(js_namespace = ["Game"], js_class = "gpl", static_method_of = Gpl, getter, js_name = progressTotal)]
18    fn progress_total() -> f64;
19}
20
21/// Your current Global Power Level, which determines power creep
22/// development.
23pub fn level() -> u32 {
24    Gpl::level()
25}
26
27/// Your progress toward the next Global Power Level.
28pub fn progress() -> f64 {
29    Gpl::progress()
30}
31
32/// Total progress needed to reach the next Global Power Level.
33pub fn progress_total() -> f64 {
34    Gpl::progress_total()
35}