1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use js_sys::JsString;
use wasm_bindgen::prelude::*;
use crate::{objects::RoomObject, prelude::*};
#[wasm_bindgen]
extern "C" {
/// An reference to a javascript object representing a [`Score`], which
/// appears randomly around the map and adds to your score when stepped on
/// by one of your creeps.
///
/// [Screeps documentation](https://docs-season.screeps.com/api/#Score)
#[wasm_bindgen(extends = RoomObject)]
#[derive(Clone, Debug)]
pub type Score;
#[wasm_bindgen(method, getter = id)]
fn id_internal(this: &Score) -> JsString;
/// The amount of [`Score`] that this object is worth when collected by a
/// creep.
///
/// [Screeps documentation](https://docs-season.screeps.com/api/#Score.score)
#[wasm_bindgen(method, getter)]
pub fn score(this: &Score) -> u32;
/// The number of ticks until the [`Score`] will decay, disappearing
/// completely.
///
/// [Screeps documentation](https://docs-season.screeps.com/api/#Score.ticksToDecay)
#[wasm_bindgen(method, getter = ticksToDecay)]
pub fn ticks_to_decay(this: &Score) -> u32;
}
impl CanDecay for Score {
fn ticks_to_decay(&self) -> u32 {
Self::ticks_to_decay(self)
}
}
impl HasId for Score {
fn js_raw_id(&self) -> JsString {
Self::id_internal(self)
}
}