Skip to content

Commit

Permalink
improving FieldAbilities docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
jjppof committed Oct 9, 2023
1 parent 66fc74b commit 43a45ad
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 18 deletions.
2 changes: 1 addition & 1 deletion base/field_abilities/AvoidFieldPsynergy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class AvoidFieldPsynergy extends FieldAbilities {
}
}
async init() {
this.field_psynergy_window.close();
this.close_field_psynergy_window();

await this.stop_casting(false);

Expand Down
2 changes: 1 addition & 1 deletion base/field_abilities/DouseFieldPsynergy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class DouseFieldPsynergy extends FieldAbilities {
}

async init() {
this.field_psynergy_window.close();
this.close_field_psynergy_window();

this.init_cloud();
await this.move_cloud_out();
Expand Down
34 changes: 28 additions & 6 deletions base/field_abilities/FieldAbilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,40 @@ import {degree360} from "../magic_numbers";

/**
* Defines and manages the usage of field psynergy.
* Classes that inherit this one, are expected to at least:
* - call FieldAbilities.set_bootstrap_method on construction;
* - call FieldAbilities.close_field_psynergy_window in an appropriate time.
* - call FieldAbilities.stop_casting and FieldAbilities.return_to_idle_anim possbily on cast finish.
* - implement FieldAbilities.update abstract method, even if empty.
*
* This class already do initial checks, search for target, init casting aura and colorize the map automatically.
*/
export abstract class FieldAbilities {
private static readonly DEFAULT_RANGE = 12;

/** The Phaser.Game object. */
protected game: Phaser.Game;
/** The GoldenSun object. */
protected data: GoldenSun;
/** The controllable char that's casting this psynergy. */
protected controllable_char: ControllableChar;
/** The target object of this psynergy. Might not be necessary depending on the psynergy. */
protected target_object: InteractableObjects | NPC;
/** If called, the casting aura is destroyed. */
protected stop_casting: (reset_casting_psy_flag?: boolean, reset_map_tint?: boolean) => Promise<void>;
/** The direction that the controllable char is casting thie psynergy. */
protected cast_direction: number;
/** Resets the map to default colors. */
protected reset_map: () => void;

private field_psynergy_window: FieldPsynergyWindow;
private ability_key_name: string;
private target_max_range: number | ((target: FieldAbilities["target_object"]) => number);
private action_key_name: string;
private need_target: boolean;
private colorize_map: boolean;
private bootstrap_method: Function;
private cast_finisher: Function;
protected controllable_char: ControllableChar;
protected target_object: InteractableObjects | NPC;
protected stop_casting: (reset_casting_psy_flag?: boolean, reset_map_tint?: boolean) => Promise<void>;
protected field_psynergy_window: FieldPsynergyWindow;
protected cast_direction: number;
protected reset_map: () => void;
private field_color: number;
private field_intensity: number;
private works_on_disabled_target: boolean;
Expand Down Expand Up @@ -270,6 +285,13 @@ export abstract class FieldAbilities {
}
}

/**
* Closes the field psynergy window that shows its name.
*/
protected close_field_psynergy_window() {
this.field_psynergy_window.close();
}

/**
* Initializes the psynergy cast. This is called after initial checks.
* @param caster_key_name the key name of the main char caster.
Expand Down
2 changes: 1 addition & 1 deletion base/field_abilities/FrostFieldPsynergy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class FrostFieldPsynergy extends FieldAbilities {
/*Begins the snowflake effects
Upon finishing, triggers the pillar's growth*/
init_snowflakes() {
this.field_psynergy_window.close();
this.close_field_psynergy_window();
this.data.audio.play_se("misc/ice_hitting", () => {
this.data.audio.play_se("misc/ice_hitting");
});
Expand Down
2 changes: 1 addition & 1 deletion base/field_abilities/GrowthFieldPsynergy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class GrowthFieldPsynergy extends FieldAbilities {
}

init_bubbles() {
this.field_psynergy_window.close();
this.close_field_psynergy_window();
const reproduce = (reproduction_counter: number) => {
if (reproduction_counter === 0) return;
this.data.audio.play_se("psynergy/6", undefined, 0.1);
Expand Down
2 changes: 1 addition & 1 deletion base/field_abilities/LashFieldPsynergy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class LashFieldPsynergy extends FieldAbilities {
}

init_hand() {
this.field_psynergy_window.close();
this.close_field_psynergy_window();
const sprite_key = this._hand_sprite_base.getSpriteKey(LashFieldPsynergy.LASH_HAND_KEY_NAME);
this._hand_sprite = this.game.add.sprite(0, 0, sprite_key);
this.data.overlayer_group.add(this._hand_sprite);
Expand Down
2 changes: 1 addition & 1 deletion base/field_abilities/LiftFieldPsynergy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export class LiftFieldPsynergy extends FieldAbilities {
}

async init() {
this.field_psynergy_window.close();
this.close_field_psynergy_window();

if (this.target_object) {
if (this.target_object.psynergies_info?.lift?.destination_y_pos) {
Expand Down
2 changes: 1 addition & 1 deletion base/field_abilities/MindReadFieldPsynergy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class MindReadFieldPsynergy extends FieldAbilities {
}

async init() {
this.field_psynergy_window.close();
this.close_field_psynergy_window();
this.set_controls();

this.cast_char_anim_promise = this.return_to_idle_anim();
Expand Down
2 changes: 1 addition & 1 deletion base/field_abilities/MoveFieldPsynergy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ export class MoveFieldPsynergy extends FieldAbilities {
this.set_emitter();
this.set_final_emitter();
this.set_hand();
this.field_psynergy_window.close();
this.close_field_psynergy_window();
this.translate_hand();
this.start_emitter();
}
Expand Down
2 changes: 1 addition & 1 deletion base/field_abilities/PoundFieldPsynergy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class PoundFieldPsynergy extends FieldAbilities {
update() {}

init_hand() {
this.field_psynergy_window.close();
this.close_field_psynergy_window();
this.data.overlayer_group.add(this.hand_sprite);
this.data.overlayer_group.bringToTop(this.hand_sprite);
this.hand_sprite.visible = true;
Expand Down
2 changes: 1 addition & 1 deletion base/field_abilities/RetreatFieldPsynergy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class RetreatFieldPsynergy extends FieldAbilities {
}

async init() {
this.field_psynergy_window.close();
this.close_field_psynergy_window();

await this.controllable_char.face_direction(directions.down);
this.controllable_char.play(base_actions.GRANT);
Expand Down
2 changes: 1 addition & 1 deletion base/field_abilities/RevealFieldPsynergy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class RevealFieldPsynergy extends FieldAbilities {
}

show_wave() {
this.field_psynergy_window.close();
this.close_field_psynergy_window();

if (this.controllable_char.on_reveal) {
this.finish(true);
Expand Down
2 changes: 1 addition & 1 deletion base/field_abilities/WhirlwindFieldPsynergy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class WhirlwindFieldPsynergy extends FieldAbilities {
}

init() {
this.field_psynergy_window.close();
this.close_field_psynergy_window();
const sprite_key = this._whirlwind_sprite_base.getSpriteKey(WhirlwindFieldPsynergy.ABILITY_KEY_NAME);
this._whirlwind_sprite = this.game.add.sprite(0, 0, sprite_key);
this.data.overlayer_group.add(this._whirlwind_sprite);
Expand Down

0 comments on commit 43a45ad

Please sign in to comment.