Skip to content

Commit

Permalink
v2.0.0 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
kalepail committed Feb 16, 2023
1 parent c723eff commit 0f79aae
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
17 changes: 15 additions & 2 deletions contracts/_game_engine/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ impl GameEngine {
}
}

Ok(())
decrement_fuel(&e, get_shoot_fuel(&e))
}

/// Harvest a fuel pod.
Expand All @@ -117,7 +117,11 @@ impl GameEngine {
}

/// Upgrade the ship to get every fuel cost halfed.
pub fn p_upgrade(e: Env) {
pub fn p_upgrade(e: Env) -> Result<(), Error> {
if e.storage().has(&DataKey::Upgraded) {
return Err(Error::UnknownErr)
}

let curr_shoot_fuel = get_shoot_fuel(&e);
let curr_move_fuel = get_move_fuel(&e);
let curr_turn_fuel = get_turn_fuel(&e);
Expand All @@ -127,13 +131,22 @@ impl GameEngine {
set_turn_fuel(&e, curr_turn_fuel / 2);

decrement_points(&e, 5);

e.storage().set(&DataKey::Upgraded, &true);

Ok(())
}

/// Get the player's position on the grid.
pub fn p_pos(e: Env) -> Point {
get_position(&e)
}

/// Get the player's current direction.
pub fn p_dir(e: Env) -> Direction {
get_direction(&e)
}

/// Get how many points the player has currently collected.
pub fn p_points(e: Env) -> u32 {
get_points(&e)
Expand Down
1 change: 1 addition & 0 deletions contracts/_game_engine/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub enum DataKey {
Expired(Point),
AstDensity,
PodDensity,
Upgraded,
}

#[contracttype]
Expand Down
Binary file modified contracts/game_engine.wasm
Binary file not shown.

0 comments on commit 0f79aae

Please sign in to comment.