mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-06-27 14:44:16 +00:00
format codebase with prettier
This commit is contained in:
@@ -5,62 +5,71 @@ import { consolex } from "../Consolex";
|
||||
import { TileRef } from "../game/GameMap";
|
||||
|
||||
export class ShellExecution implements Execution {
|
||||
private active = true;
|
||||
private pathFinder: PathFinder;
|
||||
private shell: Unit;
|
||||
|
||||
private active = true
|
||||
private pathFinder: PathFinder
|
||||
private shell: Unit
|
||||
constructor(
|
||||
private spawn: TileRef,
|
||||
private _owner: Player,
|
||||
private ownerUnit: Unit,
|
||||
private target: Unit,
|
||||
) {}
|
||||
|
||||
constructor(private spawn: TileRef, private _owner: Player, private ownerUnit: Unit, private target: Unit) {
|
||||
init(mg: Game, ticks: number): void {
|
||||
this.pathFinder = PathFinder.Mini(mg, 2000, true, 10);
|
||||
}
|
||||
|
||||
tick(ticks: number): void {
|
||||
if (this.shell == null) {
|
||||
this.shell = this._owner.buildUnit(UnitType.Shell, 0, this.spawn);
|
||||
}
|
||||
if (!this.shell.isActive()) {
|
||||
this.active = false;
|
||||
return;
|
||||
}
|
||||
if (
|
||||
!this.target.isActive() ||
|
||||
!this.ownerUnit.isActive() ||
|
||||
this.target.owner() == this.shell.owner()
|
||||
) {
|
||||
this.shell.delete(false);
|
||||
this.active = false;
|
||||
return;
|
||||
}
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const result = this.pathFinder.nextTile(
|
||||
this.shell.tile(),
|
||||
this.target.tile(),
|
||||
3,
|
||||
);
|
||||
switch (result.type) {
|
||||
case PathFindResultType.Completed:
|
||||
this.active = false;
|
||||
this.target.modifyHealth(-this.shell.info().damage);
|
||||
this.shell.delete(false);
|
||||
return;
|
||||
case PathFindResultType.NextTile:
|
||||
this.shell.move(result.tile);
|
||||
break;
|
||||
case PathFindResultType.Pending:
|
||||
return;
|
||||
case PathFindResultType.PathNotFound:
|
||||
consolex.log(`Shell ${this.shell} could not find target`);
|
||||
this.active = false;
|
||||
this.shell.delete(false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init(mg: Game, ticks: number): void {
|
||||
this.pathFinder = PathFinder.Mini(mg, 2000, true, 10)
|
||||
}
|
||||
|
||||
tick(ticks: number): void {
|
||||
if (this.shell == null) {
|
||||
this.shell = this._owner.buildUnit(UnitType.Shell, 0, this.spawn)
|
||||
}
|
||||
if (!this.shell.isActive()) {
|
||||
this.active = false
|
||||
return
|
||||
}
|
||||
if (!this.target.isActive() || !this.ownerUnit.isActive() || this.target.owner() == this.shell.owner()) {
|
||||
this.shell.delete(false)
|
||||
this.active = false
|
||||
return
|
||||
}
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const result = this.pathFinder.nextTile(this.shell.tile(), this.target.tile(), 3)
|
||||
switch (result.type) {
|
||||
case PathFindResultType.Completed:
|
||||
this.active = false
|
||||
this.target.modifyHealth(-this.shell.info().damage)
|
||||
this.shell.delete(false)
|
||||
return
|
||||
case PathFindResultType.NextTile:
|
||||
this.shell.move(result.tile)
|
||||
break
|
||||
case PathFindResultType.Pending:
|
||||
return
|
||||
case PathFindResultType.PathNotFound:
|
||||
consolex.log(`Shell ${this.shell} could not find target`)
|
||||
this.active = false
|
||||
this.shell.delete(false)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
owner(): Player {
|
||||
return null
|
||||
}
|
||||
isActive(): boolean {
|
||||
return this.active
|
||||
}
|
||||
activeDuringSpawnPhase(): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
owner(): Player {
|
||||
return null;
|
||||
}
|
||||
isActive(): boolean {
|
||||
return this.active;
|
||||
}
|
||||
activeDuringSpawnPhase(): boolean {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user