Skip to content

Commit

Permalink
more small stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
shanemadden committed Dec 18, 2023
1 parent 02b5f0f commit 3aecdd4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,23 @@ pub fn resources() -> JsHashMap<IntershardResourceType, u32> {
Game::resources().into()
}

/// Get an [`JsHashMap<RoomName, Room>`] with the rooms visible for the current
/// Get a [`JsHashMap<RoomName, Room>`] with the rooms visible for the current
/// tick.
///
/// [Screeps documentation](https://docs.screeps.com/api/#Game.rooms)
pub fn rooms() -> JsHashMap<RoomName, Room> {
Game::rooms().into()
}

/// Get an [`JsHashMap<String, StructureSpawn>`] with all of your spawns, which
/// Get a [`JsHashMap<String, StructureSpawn>`] with all of your spawns, which
/// has spawn names as keys.
///
/// [Screeps documentation](https://docs.screeps.com/api/#Game.spawns)
pub fn spawns() -> JsHashMap<String, StructureSpawn> {
Game::spawns().into()
}

/// Get an [`JsHashMap<RawObjectId, StructureObject>`] with all of your owned
/// Get a [`JsHashMap<RawObjectId, StructureObject>`] with all of your owned
/// structures.
///
/// [Screeps documentation](https://docs.screeps.com/api/#Game.spawns)
Expand Down Expand Up @@ -205,8 +205,10 @@ pub fn get_object_by_id_erased(id: &RawObjectId) -> Option<RoomObject> {
Game::get_object_by_id(&js_str)
}

/// Send an email message to yourself with a given message. Set a group
/// interval to only send messages every `group_interval` minutes.
/// Send an email message to yourself with a given message.
///
/// Set a `group_interval` with a limit, in minutes, on how frequently emails
/// are allowed to be sent.
///
/// [Screeps documentation](https://docs.screeps.com/api/#Game.notify)
pub fn notify(message: &str, group_interval: Option<u32>) {
Expand Down
2 changes: 2 additions & 0 deletions src/js_collections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ pub trait JsCollectionFromValue {
fn from_value(val: JsValue) -> Self;
}

/// Container holding a reference to an [`Object`] in JavaScript as well as
/// expected types for both the keys and values.
pub struct JsHashMap<K, V> {
map: Object,
_phantom: PhantomData<(K, V)>,
Expand Down

0 comments on commit 3aecdd4

Please sign in to comment.