Skip to content

Commit 95dfc2d

Browse files
committed
fixed all the linting stuffmerged lint results
2 parents 52d3d45 + 34c594d commit 95dfc2d

File tree

8 files changed

+73
-64
lines changed

8 files changed

+73
-64
lines changed

src/game-engine/world/action/magic-on-npc.action.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Npc } from '../actor/npc/npc';
88
/**
99
* Defines a button action hook.
1010
*/
11-
export interface Magic_On_NPCActionHook extends ActionHook<Magic_On_NPCAction, magic_on_npcActionHandler> {
11+
export interface Magic_On_NPCActionHook extends ActionHook<Magic_On_NPCAction, magic_on_npcActionHandler> {
1212
// The npc world id that was clicked on after choosing the spell
1313
npcworldId?: number;
1414
// The IDs of the UI widgets that the buttons are on.
@@ -23,15 +23,15 @@ export interface Magic_On_NPCActionHook extends ActionHook<Magic_On_NPCAction, m
2323
/**
2424
* The button action hook handler function to be called when the hook's conditions are met.
2525
*/
26-
export type magic_on_npcActionHandler = (buttonAction: Magic_On_NPCAction) => void | Promise<void>;
26+
export type magic_on_npcActionHandler = (buttonAction: Magic_On_NPCAction) => void | Promise<void>;
2727

2828

2929
/**
3030
* Details about a button action being performed.
3131
*/
32-
export interface Magic_On_NPCAction {
32+
export interface Magic_On_NPCAction {
3333
// The npc world id that was clicked on after choosing the spell
34-
npc: Npc;
34+
npc: Npc;
3535
// The player performing the action.
3636
player: Player;
3737
// The ID of the UI widget that the button is on.
@@ -48,11 +48,11 @@ export interface Magic_On_NPCAction {
4848
* @param widgetId
4949
* @param buttonId
5050
*/
51-
const buttonActionPipe = (npc:Npc, player: Player, widgetId: number, buttonId: number): RunnableHooks<Magic_On_NPCAction> => {
51+
const buttonActionPipe = (npc:Npc, player: Player, widgetId: number, buttonId: number): RunnableHooks<Magic_On_NPCAction> => {
5252
//console.info(`pew pew you use magic on ${npc.name}!`);
5353

5454
// Find all object action plugins that reference this location object
55-
const matchingHooks = getActionHooks<Magic_On_NPCActionHook>('magic_on_npc');
55+
const matchingHooks = getActionHooks<Magic_On_NPCActionHook>('magic_on_npc');
5656

5757

5858
return {

src/game-engine/world/actor/actor.ts

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,25 @@ export abstract class Actor {
4141

4242
public pathfinding: Pathfinding = new Pathfinding(this);
4343
public lastMovementPosition: Position;
44+
// #region Behaviors and Combat flags/checks
45+
public inCombat: boolean = false;
46+
public meleeDistance: number = 1;
47+
public Behaviors: Behavior[] = [];
48+
public isDead: boolean = false;
49+
public combatTargets: Actor[] = [];
50+
public hitPoints = this.skills.hitpoints.level * 4;
51+
public maxHitPoints = this.skills.hitpoints.level * 4;
52+
public get highestCombatSkill(): Skill {
53+
const attack = this.skills.getLevel('attack');
54+
const magic = this.skills.getLevel('magic');
55+
const ranged = this.skills.getLevel('ranged');
56+
57+
if (ranged > magic && ranged > ranged) return ranged;
58+
else if (magic > attack && magic > ranged) return magic;
59+
else return attack;
60+
}
61+
62+
// #endregion
4463

4564
protected randomMovementInterval;
4665

@@ -65,9 +84,9 @@ export abstract class Actor {
6584
}
6685

6786
public damage(amount: number, damageType: DamageType = DamageType.DAMAGE) {
68-
let armorReduction = 0;
69-
let spellDamageReduction = 0;
70-
let poisonReistance = 0;
87+
const armorReduction = 0;
88+
const spellDamageReduction = 0;
89+
const poisonReistance = 0;
7190
amount -= armorReduction;
7291
this.hitPoints -= amount;
7392
this.skills.setHitpoints(this.hitPoints);
@@ -78,6 +97,8 @@ export abstract class Actor {
7897
this.playAnimation(this.getBlockAnimation());
7998
}
8099

100+
101+
81102
//public damage(amount: number, damageType: DamageType = DamageType.DAMAGE): 'alive' | 'dead' {
82103
// let remainingHitpoints: number = this.skills.hitpoints.level - amount;
83104
// const maximumHitpoints: number = this.skills.hitpoints.levelForExp;
@@ -567,23 +588,5 @@ export abstract class Actor {
567588
};
568589
}
569590

570-
// #region Behaviors and Combat flags/checks
571-
public inCombat: boolean = false;
572-
public meleeDistance: number = 1;
573-
public Behaviors: Behavior[] = new Array();
574-
public isDead: boolean = false;
575-
public combatTargets: Actor[] = new Array();
576-
public hitPoints = this.skills.hitpoints.level * 4;
577-
public maxHitPoints = this.skills.hitpoints.level * 4;
578-
public get highestCombatSkill(): Skill {
579-
let attack = this.skills.getLevel('attack');
580-
let magic = this.skills.getLevel('magic');
581-
let ranged = this.skills.getLevel('ranged');
582-
583-
if (ranged > magic && ranged > ranged) return ranged;
584-
else if (magic > attack && magic > ranged) return magic;
585-
else return attack;
586-
}
587591

588-
// #endregion
589592
}

src/game-engine/world/actor/behaviors/auto-attack.behavior.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,23 @@ import { Npc } from '../npc/npc';
99
import { Player } from '../player/player';
1010

1111
export class AutoAttackBehavior extends Behavior {
12-
private _combatPulse;
12+
1313
Type = BehaviorType.Combat;
14-
Name = "auto-attack-combat";
15-
//seconds
14+
Name = 'auto-attack-combat';
15+
16+
private _combatPulse;
1617
private _CoolDown: number = 3;
1718
private _lastAttack = new Date();
1819
private _player: Player;
20+
1921
//this should be called when combat starts
2022
public async init(me: Actor, them: Actor): Promise<void> {
2123
this.Me = me;
2224
this.Them = them;
2325
this._player = (me as Player);
2426
console.log('all set to auto attack!');
2527
(this.Them as Npc).npcEvents.on('death', (npc) => this._player.onNpcKill);
26-
super.init(me, them);
28+
await super.init(me, them);
2729
}
2830

2931
public async tick() {
@@ -61,7 +63,7 @@ export class AutoAttackBehavior extends Behavior {
6163
public async doAttack(): Promise<void> {
6264
return new Promise<void>(resolve => {
6365
//do attack stuff
64-
let _damage = this.Me.skills.strength.level;
66+
const _damage = this.Me.skills.strength.level;
6567
console.log(`you attack ${(this.Them as Npc).name} for ${_damage} damage! (after the CD)`);
6668
this.Them.damage(_damage);
6769
if (this.Them.hitPoints <= 0) {

src/game-engine/world/actor/behaviors/melee-combat.behavior.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { Player } from '../player/player';
99
import { Npc } from '../npc/npc';
1010

1111
export class MeleeCombatBehavior extends Behavior {
12-
private _combatPulse;
12+
1313
Type = BehaviorType.Combat;
14-
Name = "basic-melee-combat";
14+
Name = 'basic-melee-combat';
1515
//seconds
1616
private _CoolDown: number = 4;
1717
private _lastAttack = new Date();
@@ -20,7 +20,7 @@ export class MeleeCombatBehavior extends Behavior {
2020
public async init(me: Actor, them: Actor): Promise<void> {
2121
this.Me = me;
2222
this.Them = them;
23-
super.init(me, them);
23+
await super.init(me, them);
2424
}
2525

2626
public async tick() {
@@ -54,7 +54,7 @@ export class MeleeCombatBehavior extends Behavior {
5454
if (!this.Me.isDead) super.tick();
5555
resolve();
5656
}
57-
57+
5858

5959
});
6060
}
@@ -63,7 +63,7 @@ export class MeleeCombatBehavior extends Behavior {
6363
//do attack stuff
6464
this.Me.playAnimation(this.Me.getAttackAnimation());
6565

66-
let _damage = this.Me.skills.strength.level;
66+
const _damage = this.Me.skills.strength.level;
6767
console.log(`${(this.Me as Npc).name} attacks ${(this.Them as Player).username} for ${_damage} damage! (after the CD)`);
6868
(this.Me as Npc).npcEvents.emit('damage', _damage);
6969
this.Them.damage(_damage);

src/game-engine/world/actor/npc/npc.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export class Npc extends Actor {
4040
stand?: number;
4141
};
4242
public instanceId: string = null;
43+
//ToDo: this should either be calculated by the level or from a config
44+
public experienceValue: number = 10;
45+
public npcEvents: EventEmitter = new EventEmitter();
46+
4347

4448
private _name: string;
4549
private _combatLevel: number;
@@ -49,8 +53,7 @@ export class Npc extends Actor {
4953
private npcSpawn: NpcSpawn;
5054
private _initialized: boolean = false;
5155

52-
//ToDo: this should either be calcualted by teh level or from a config
53-
public experienceValue: number = 10;
56+
5457

5558
public constructor(npcDetails: NpcDetails | number, npcSpawn: NpcSpawn, instanceId: string = null) {
5659
super();
@@ -122,27 +125,27 @@ export class Npc extends Actor {
122125
}
123126

124127
//This is useful so that we can tie into things like "spell casts" or events, or traps, etc to finish quests or whatever
125-
public npcEvents: EventEmitter = new EventEmitter();
128+
126129
public async processDeath(assailant: Actor): Promise<void> {
127-
const deathPosition = this.position;
130+
return new Promise<void>(resolve => {
131+
const deathPosition = this.position;
128132

129-
let deathAnim: number = animationIds.death;
130-
deathAnim = findNpc(this.id)?.combatAnimations?.death || animationIds.death
131-
133+
let deathAnim: number = animationIds.death;
134+
deathAnim = findNpc(this.id)?.combatAnimations?.death || animationIds.death
132135

133-
//ToDo: all this is broken
134-
try {
135-
136-
this.playAnimation(deathAnim);
137-
world.playLocationSound(deathPosition, soundIds.npc.human.maleDeath, 5);
138-
let instance = world.globalInstance;
139-
instance.spawnWorldItem(itemIds.bones, deathPosition,
140-
{ owner: assailant instanceof Player ? assailant : undefined, expires: 300 });
141-
}
142-
catch (err) {
143-
logger.debug(err);
144-
}
145136

137+
//ToDo: all this is broken
138+
try {
139+
140+
this.playAnimation(deathAnim);
141+
world.playLocationSound(deathPosition, soundIds.npc.human.maleDeath, 5);
142+
world.globalInstance.spawnWorldItem(itemIds.bones, deathPosition,
143+
{ owner: assailant instanceof Player ? assailant : undefined, expires: 300 });
144+
}
145+
catch (err) {
146+
logger.debug(err);
147+
}
148+
});
146149

147150
}
148151
public getAttackAnimation(): number {
@@ -172,7 +175,7 @@ export class Npc extends Actor {
172175
}
173176

174177
public async tick(): Promise<void> {
175-
for (var i = 0; i < this.Behaviors.length; i++) {
178+
for (let i = 0; i < this.Behaviors.length; i++) {
176179
this.Behaviors[i].tick();
177180
}
178181
return new Promise<void>(resolve => {

src/game-engine/world/actor/player/player.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ export class Player extends Actor {
127127
public friendsList: string[] = [];
128128
public ignoreList: string[] = [];
129129
public cutscene: Cutscene = null;
130+
public playerEvents: EventEmitter = new EventEmitter();
131+
130132

131133
private readonly _socket: Socket;
132134
private readonly _inCipher: Isaac;
@@ -400,7 +402,7 @@ export class Player extends Actor {
400402
}
401403

402404
public async tick(): Promise<void> {
403-
for (var i = 0; i < this.Behaviors.length; i++) {
405+
for (let i = 0; i < this.Behaviors.length; i++) {
404406
this.Behaviors[i].tick();
405407
}
406408
return new Promise<void>(resolve => {
@@ -991,7 +993,6 @@ export class Player extends Actor {
991993
this.savedMetadata.npcTransformation = npc;
992994
this.updateFlags.appearanceUpdateRequired = true;
993995
}
994-
public playerEvents: EventEmitter = new EventEmitter();
995996

996997
/**
997998
* Returns the morphed NPC details for a specific player based on his client settings

src/plugins/buttons/magic-attack.plugin.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ const buttonIds: number[] = [
1515
];
1616

1717
function attack_target(player: Player, elapsedTicks: number): boolean {
18-
logger.info('attacking?');
18+
logger.info('attacking?');
1919
return true;
2020
}
2121

22-
const spells = ['Wind Strike','Confuse', 'Water Strike','unknown?', 'Earth Strike'];
23-
export const activate = (task: TaskExecutor<Magic_On_NPCAction>, elapsedTicks: number = 0) => {
22+
const spells = ['Wind Strike','Confuse', 'Water Strike','unknown?', 'Earth Strike'];
23+
export const activate = (task: TaskExecutor<Magic_On_NPCAction>, elapsedTicks: number = 0) => {
2424
const {
2525
npc,
2626
player,
@@ -42,6 +42,6 @@ export default {
4242
activate,
4343
interval: 0
4444
}
45-
} as Magic_On_NPCActionHook
45+
} as Magic_On_NPCActionHook
4646

4747
};

src/plugins/combat/combat.plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const activate = async (task: TaskExecutor<NpcInteractionAction>, elapsed
3232
await combatBehavior.init(player, npc);
3333
player.inCombat = true;
3434
});
35-
task.stop();
35+
await task.stop();
3636
};
3737

3838

0 commit comments

Comments
 (0)