[][src]Trait wasmdome_mech_sdk::MechInstruments

pub trait MechInstruments {
    fn position(&self) -> Point;
fn hull_integrity(&self) -> u32;
fn power(&self) -> u32;
fn primary_range(&self) -> u32;
fn secondary_range(&self) -> u32;
fn last_radar_scan(&self) -> Option<Vec<RadarPing>>;
fn direction_to(&self, target: &Point) -> GridDirection;
fn random_number(&self, min: u32, max: u32) -> u32;
fn world_size(&self) -> GameBoard;
fn register_acc(&self, reg: u32, val: u64) -> MechCommand;
fn register_dec(&self, reg: u32, val: u64) -> MechCommand;
fn register_set(&self, reg: u32, val: RegisterValue) -> MechCommand;
fn register_get(&self, reg: u32) -> Option<&RegisterValue>;
fn request_radar(&self) -> MechCommand;
fn fire_primary(&self, dir: GridDirection) -> MechCommand;
fn fire_secondary(&self, dir: GridDirection) -> MechCommand;
fn move_mech(&self, dir: GridDirection) -> MechCommand; }

The interface through which a mech interacts with the arena. Functions on the mech instruments panel are divided into two categories:

  • Sensor access - These functions are synchronous and the results are accessed immediately within your code. There is no power/action point cost to using these functions.
  • Commands - The mech's handler function must return a vector of commands. The instruments panel has shortcut functions that can be used to generate these commands. Each command has an action point cost associated with it, so take care not to exceed your turn budget

By cleverly and carefully combining the mech sensor functions with the commands it can issue to the arena, your goal is to build a mech that can outsmart, outgun, and outmaneuver its opponents in the wasmdome.

Required methods

fn position(&self) -> Point

Obtains the current position of the mech

fn hull_integrity(&self) -> u32

Queries the hull integrity of the mech in remaining hit / damage points

fn power(&self) -> u32

Returns the number of action points this mech can consume per turn. While this may default to 4, your code should use this value as a maximum in case matches started with different rules include more or less maximum APs

fn primary_range(&self) -> u32

Returns the range (in whole grid units) of the primary weapon. This defaults to 3 but your code should use this if you need to perform calculations based on range

fn secondary_range(&self) -> u32

Returns the range (in whole grid units) of the secondary weapon, which defaults to 6 but your code should use this if you need to perform calculations based on range

fn last_radar_scan(&self) -> Option<Vec<RadarPing>>

Accesses the last radar scan (if any) performed by your mech. If on turn x your mech has a radar request in the command list, then on turn x+1 that scan's results will be available

fn direction_to(&self, target: &Point) -> GridDirection

A handy function that performs the Euclidean calculation for you in order to determine the direction between your mech and a target point

fn random_number(&self, min: u32, max: u32) -> u32

Generate a random number between the min and max values (inclusive)

fn world_size(&self) -> GameBoard

Obtains the dimensions of the arena in which the mech resides

fn register_acc(&self, reg: u32, val: u64) -> MechCommand

Accumulates the value stored in the given register. If the register has not been initialized, the accumulator value supplied will be stored in the register (e.g. the value will be added to 0)

fn register_dec(&self, reg: u32, val: u64) -> MechCommand

Safely decrements (with a floor of 0) the value in the given register

fn register_set(&self, reg: u32, val: RegisterValue) -> MechCommand

Sets the value in the given register. This will overwrite any previously existing value

fn register_get(&self, reg: u32) -> Option<&RegisterValue>

Queries the value (if any) stored in the given register

fn request_radar(&self) -> MechCommand

Generates a radar request command to be processed by the game engine at the end of this turn

fn fire_primary(&self, dir: GridDirection) -> MechCommand

Generates a request to fire the primary weapon

fn fire_secondary(&self, dir: GridDirection) -> MechCommand

Generates a request to fire the secondary weapon

fn move_mech(&self, dir: GridDirection) -> MechCommand

Generates a request to move the mech

Loading content...

Implementors

Loading content...