yareio_sys/structure/
star.rs

1//! Provides access to stars.
2
3use crate::structure::{Structure, StructureID};
4use crate::{prelude::*, CanFrom};
5use js_sys::Object;
6use std::convert::TryFrom;
7use wasm_bindgen::prelude::*;
8
9// Star
10#[wasm_bindgen]
11extern "C" {
12    /// The ID of a [`Star`].
13    #[wasm_bindgen(extends = StructureID, typescript_type = "StarID")]
14    #[derive(Clone, Debug, PartialEq, Eq)]
15    pub type StarID;
16
17    /// A star.
18    ///
19    /// [Yare.io Documentation](https://yare.io/documentation#doc_star)
20    #[wasm_bindgen(extends = Structure, typescript_type = "Star")]
21    #[derive(Clone, Debug, PartialEq, Eq)]
22    pub type Star;
23
24    #[wasm_bindgen(method, getter)]
25    pub fn id(this: &Star) -> StarID;
26
27    #[wasm_bindgen(method, getter)]
28    pub fn active_in(this: &Star) -> u32;
29
30    #[wasm_bindgen(method, getter)]
31    pub fn active_at(this: &Star) -> u32;
32}
33
34impl CanFrom<Structure> for Star {
35    #[inline]
36    fn can_from(value: &Structure) -> bool {
37        value.structure_type().to_str() == "star"
38    }
39}
40
41try_can_from!(impl TryFrom<Structure>, Error = Structure for Star);
42
43// `stars`
44#[wasm_bindgen]
45extern "C" {
46    #[wasm_bindgen(extends = Object, typescript_type = "(typeof stars)")]
47    #[derive(Clone, Debug)]
48    pub type Stars;
49
50    #[wasm_bindgen(js_name = "stars")]
51    static _stars: Stars;
52}
53
54impl TryGetByID<EntityID, Star> for Stars {}
55impl TryGetByID<StructureID, Star> for Stars {}
56impl EnumerateByID<StarID, Star> for Stars {}
57impl GetByID<StarID, Star> for Stars {}
58
59/// `stars`. Use the [`GetByID`] trait to retrieve individual stars.
60///
61/// [Yare.io Documentation](https://yare.io/documentation#doc_star)
62#[inline(always)]
63pub fn stars() -> &'static Stars {
64    &_stars
65}
66
67// `star_zxq`
68#[wasm_bindgen]
69extern "C" {
70    #[wasm_bindgen(js_name = "star_zxq")]
71    static _star_zxq: Star;
72}
73
74/// `star_zxq` ([player 1](crate::players::Players::p1)'s star).
75///
76/// [Yare.io Documentation](https://yare.io/documentation#doc_intro)
77#[inline(always)]
78pub fn star_zxq() -> &'static Star {
79    &_star_zxq
80}
81
82// `star_a1c`
83#[wasm_bindgen]
84extern "C" {
85    #[wasm_bindgen(js_name = "star_a1c")]
86    static _star_a1c: Star;
87}
88
89/// `star_a1c` ([player 2](crate::players::Players::p1)'s star).
90///
91/// [Yare.io Documentation](https://yare.io/documentation#doc_intro)
92#[inline(always)]
93pub fn star_a1c() -> &'static Star {
94    &_star_a1c
95}
96
97// `star_p89`
98#[wasm_bindgen]
99extern "C" {
100    #[wasm_bindgen(js_name = "star_p89")]
101    static _star_p89: Star;
102}
103
104/// `star_p89` (the outpost's star).
105///
106/// [Yare.io Documentation](https://yare.io/documentation#doc_intro)
107#[inline(always)]
108pub fn star_p89() -> &'static Star {
109    &_star_p89
110}