Skip to content

Commit

Permalink
removing unnecessary property from speed event
Browse files Browse the repository at this point in the history
  • Loading branch information
jjppof committed Oct 16, 2022
1 parent 28a3a1a commit a99fc43
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
21 changes: 2 additions & 19 deletions base/tile_events/SpeedEvent.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import {directions, get_directions} from "../utils";
import {TileEvent, event_types} from "./TileEvent";

export class SpeedEvent extends TileEvent {
private _speed: number;
private _speed_activate_directions: Set<directions>;
private _force_axis: "x" | "y";
private _on_stairs: boolean;
private _previous_on_stairs: boolean;
Expand All @@ -20,7 +18,6 @@ export class SpeedEvent extends TileEvent {
affected_by_reveal,
key_name: string,
speed: number,
speed_activate_directions,
on_stairs,
force_axis
) {
Expand All @@ -39,28 +36,17 @@ export class SpeedEvent extends TileEvent {
key_name
);
this._speed = speed;
this._speed_activate_directions = new Set();
this._force_axis = force_axis;
this._on_stairs = on_stairs;
this._previous_on_stairs = false;
if (speed_activate_directions === undefined || speed_activate_directions === "all") {
get_directions(true).forEach(d => this._speed_activate_directions.add(d));
} else if (Array.isArray(directions)) {
speed_activate_directions.forEach(d => this._speed_activate_directions.add(directions[d as string]));
} else {
this._speed_activate_directions.add(directions[speed_activate_directions as string]);
}
}

get speed() {
return this._speed;
}

unset() {
if (
this.data.tile_event_manager.event_triggered(this) &&
(!this.check_position() || !this._speed_activate_directions.has(this.data.hero.current_direction))
) {
if (this.data.tile_event_manager.event_triggered(this) && !this.check_position()) {
this.data.tile_event_manager.unset_triggered_event(this);
if (this._force_axis) {
this.data.hero.increase_forced_extra_speed({[this._force_axis]: -this.speed});
Expand All @@ -74,10 +60,7 @@ export class SpeedEvent extends TileEvent {
}

fire() {
if (
!this.data.tile_event_manager.event_triggered(this) &&
this._speed_activate_directions.has(this.data.hero.current_direction)
) {
if (!this.data.tile_event_manager.event_triggered(this)) {
this.data.tile_event_manager.set_triggered_event(this);
if (this._force_axis) {
this.data.hero.increase_forced_extra_speed({[this._force_axis]: this.speed});
Expand Down
1 change: 0 additions & 1 deletion base/tile_events/TileEventManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ export class TileEventManager {
info.affected_by_reveal,
info.key_name,
info.speed,
info.speed_activate_directions,
info.on_stairs,
info.force_axis
);
Expand Down

0 comments on commit a99fc43

Please sign in to comment.