Resolve circular dependency
This commit is contained in:
parent
89164bf83d
commit
dc63079081
6 changed files with 130 additions and 127 deletions
|
|
@ -4,9 +4,11 @@ import {
|
|||
Attack,
|
||||
attackPunch,
|
||||
attacks,
|
||||
type IAttack,
|
||||
} from "./structures/attacks.js";
|
||||
import {
|
||||
npcBecky,
|
||||
npcs,
|
||||
type IAttack,
|
||||
type IEntity,
|
||||
type INPC,
|
||||
type INPCData,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import type { MatrixClient } from "matrix-js-sdk";
|
||||
import type {
|
||||
Attack,
|
||||
IEntity,
|
||||
INPC,
|
||||
IPlayer,
|
||||
|
|
@ -9,6 +8,7 @@ import type {
|
|||
import { locationFarlands } from "./structures/locations.js";
|
||||
import { getAttack, getMaxHealth, getNpcData, isPlayer } from "./entity.js";
|
||||
import { sleep } from "matrix-js-sdk/lib/utils.js";
|
||||
import type { Attack } from "./structures/attacks.js";
|
||||
|
||||
const fightEntity = async (
|
||||
client: MatrixClient,
|
||||
|
|
|
|||
115
src/services/game/structures/attacks.ts
Normal file
115
src/services/game/structures/attacks.ts
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
import { DamageType } from "./damageTypes.js";
|
||||
|
||||
export interface IAttack {
|
||||
id: Attack;
|
||||
damageType: DamageType;
|
||||
damageMultiplier: number;
|
||||
messages: string[];
|
||||
messagesDead: string[];
|
||||
messagesOverpower: string[];
|
||||
}
|
||||
|
||||
export enum Attack {
|
||||
PUNCH = "PUNCH",
|
||||
CUT = "CUT",
|
||||
STAB = "STAB",
|
||||
KICK = "KICK",
|
||||
STOMP = "STOMP",
|
||||
SIT = "SIT",
|
||||
RIP = "RIP",
|
||||
}
|
||||
|
||||
export const attackPunch: IAttack = {
|
||||
id: Attack.PUNCH,
|
||||
damageType: DamageType.PHYSICAL,
|
||||
damageMultiplier: 0.5,
|
||||
messages: ["ATTACKER punches DEFENDER"],
|
||||
messagesDead: [
|
||||
"ATTACKER punches DEFENDER to death",
|
||||
"ATTACKER beats DEFENDER to death",
|
||||
],
|
||||
messagesOverpower: ["ATTACKER punches DEFENDER into mush"],
|
||||
};
|
||||
|
||||
export const attackCut: IAttack = {
|
||||
id: Attack.CUT,
|
||||
damageType: DamageType.PHYSICAL,
|
||||
damageMultiplier: 1,
|
||||
messages: ["ATTACKER cuts DEFENDER"],
|
||||
messagesDead: [
|
||||
"ATTACKER cuts DEFENDER in half",
|
||||
"ATTACKER cuts DEFENDER's head off",
|
||||
"ATTACKER cuts DEFENDER, instantly killing them",
|
||||
],
|
||||
messagesOverpower: ["ATTACKER cuts DEFENDER in half"],
|
||||
};
|
||||
|
||||
export const attackStab: IAttack = {
|
||||
id: Attack.STAB,
|
||||
damageType: DamageType.PHYSICAL,
|
||||
damageMultiplier: 1.5,
|
||||
messages: ["ATTACKER stabs DEFENDER"],
|
||||
messagesDead: [
|
||||
"ATTACKER stabs DEFENDER to death",
|
||||
"ATTACKER stabs DEFENDER, instantly killing them",
|
||||
],
|
||||
messagesOverpower: ["ATTACKER stabs DEFENDER, instantly killing them"],
|
||||
};
|
||||
|
||||
export const attackKick: IAttack = {
|
||||
id: Attack.KICK,
|
||||
damageType: DamageType.PHYSICAL,
|
||||
damageMultiplier: 0.75,
|
||||
messages: [
|
||||
"ATTACKER kick DEFENDER",
|
||||
"ATTACKER kick DEFENDER in their face",
|
||||
],
|
||||
messagesDead: ["ATTACKER kicks DEFENDER to death"],
|
||||
messagesOverpower: ["ATTACKER kicks DEFENDER into mush"],
|
||||
};
|
||||
|
||||
export const attackStomp: IAttack = {
|
||||
id: Attack.STOMP,
|
||||
damageType: DamageType.PHYSICAL,
|
||||
damageMultiplier: 0.75,
|
||||
messages: [
|
||||
"ATTACKER stomps DEFENDER",
|
||||
"ATTACKER stomps DEFENDER in their face",
|
||||
],
|
||||
messagesDead: ["ATTACKER stomps DEFENDER to death"],
|
||||
messagesOverpower: [
|
||||
"ATTACKER stomps DEFENDER into mush",
|
||||
"DEFENDER explodes after ATTACKER stomps them into bloody mush",
|
||||
],
|
||||
};
|
||||
|
||||
export const attackSit: IAttack = {
|
||||
id: Attack.SIT,
|
||||
damageType: DamageType.PHYSICAL,
|
||||
damageMultiplier: 0.65,
|
||||
messages: ["ATTACKER sits on DEFENDER"],
|
||||
messagesDead: ["ATTACKER sits on DEFENDER and crushes them to death"],
|
||||
messagesOverpower: [
|
||||
"ATTACKER sits on DEFENDER and crushes them into mush and goo",
|
||||
"DEFENDER explodes after ATTACKER sits on them with their full weight",
|
||||
],
|
||||
};
|
||||
|
||||
export const attackRip: IAttack = {
|
||||
id: Attack.RIP,
|
||||
damageType: DamageType.PHYSICAL,
|
||||
damageMultiplier: 0.3,
|
||||
messages: ["ATTACKER tries to rip DEFENDER's limbs off"],
|
||||
messagesDead: ["ATTACKER rips DEFENDER's head off"],
|
||||
messagesOverpower: ["ATTACKER effortlessly rips DEFENDER's body in half"],
|
||||
};
|
||||
|
||||
export const attacks = [
|
||||
attackPunch,
|
||||
attackCut,
|
||||
attackStab,
|
||||
attackKick,
|
||||
attackStomp,
|
||||
attackSit,
|
||||
attackRip,
|
||||
];
|
||||
8
src/services/game/structures/damageTypes.ts
Normal file
8
src/services/game/structures/damageTypes.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
export enum DamageType {
|
||||
PHYSICAL = "PHYSICAL",
|
||||
ELEMENTAL = "ELEMENTAL",
|
||||
ARCANE = "ARCANE",
|
||||
PSYCHIC = "PSYCHIC",
|
||||
POISON = "POISON",
|
||||
RADIATION = "RADIATION",
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import { Location } from "./locations.js";
|
||||
import { Race } from "./races.js";
|
||||
import type { IInventory } from "../types.js";
|
||||
import { DamageType } from "./items.js";
|
||||
import { Attack } from "./attacks.js";
|
||||
|
||||
export interface IEntity {
|
||||
name: string;
|
||||
|
|
@ -52,120 +52,6 @@ export enum NpcType {
|
|||
AGGRESIVE = "AGGRESIVE",
|
||||
}
|
||||
|
||||
export interface IAttack {
|
||||
id: Attack;
|
||||
damageType: DamageType;
|
||||
damageMultiplier: number;
|
||||
messages: string[];
|
||||
messagesDead: string[];
|
||||
messagesOverpower: string[];
|
||||
}
|
||||
|
||||
export enum Attack {
|
||||
PUNCH = "PUNCH",
|
||||
CUT = "CUT",
|
||||
STAB = "STAB",
|
||||
KICK = "KICK",
|
||||
STOMP = "STOMP",
|
||||
SIT = "SIT",
|
||||
RIP = "RIP",
|
||||
}
|
||||
|
||||
export const attackPunch: IAttack = {
|
||||
id: Attack.PUNCH,
|
||||
damageType: DamageType.PHYSICAL,
|
||||
damageMultiplier: 0.5,
|
||||
messages: ["ATTACKER punches DEFENDER"],
|
||||
messagesDead: [
|
||||
"ATTACKER punches DEFENDER to death",
|
||||
"ATTACKER beats DEFENDER to death",
|
||||
],
|
||||
messagesOverpower: ["ATTACKER punches DEFENDER into mush"],
|
||||
};
|
||||
|
||||
export const attackCut: IAttack = {
|
||||
id: Attack.CUT,
|
||||
damageType: DamageType.PHYSICAL,
|
||||
damageMultiplier: 1,
|
||||
messages: ["ATTACKER cuts DEFENDER"],
|
||||
messagesDead: [
|
||||
"ATTACKER cuts DEFENDER in half",
|
||||
"ATTACKER cuts DEFENDER's head off",
|
||||
"ATTACKER cuts DEFENDER, instantly killing them",
|
||||
],
|
||||
messagesOverpower: ["ATTACKER cuts DEFENDER in half"],
|
||||
};
|
||||
|
||||
export const attackStab: IAttack = {
|
||||
id: Attack.STAB,
|
||||
damageType: DamageType.PHYSICAL,
|
||||
damageMultiplier: 1.5,
|
||||
messages: ["ATTACKER stabs DEFENDER"],
|
||||
messagesDead: [
|
||||
"ATTACKER stabs DEFENDER to death",
|
||||
"ATTACKER stabs DEFENDER, instantly killing them",
|
||||
],
|
||||
messagesOverpower: ["ATTACKER stabs DEFENDER, instantly killing them"],
|
||||
};
|
||||
|
||||
export const attackKick: IAttack = {
|
||||
id: Attack.KICK,
|
||||
damageType: DamageType.PHYSICAL,
|
||||
damageMultiplier: 0.75,
|
||||
messages: [
|
||||
"ATTACKER kick DEFENDER",
|
||||
"ATTACKER kick DEFENDER in their face",
|
||||
],
|
||||
messagesDead: ["ATTACKER kicks DEFENDER to death"],
|
||||
messagesOverpower: ["ATTACKER kicks DEFENDER into mush"],
|
||||
};
|
||||
|
||||
export const attackStomp: IAttack = {
|
||||
id: Attack.STOMP,
|
||||
damageType: DamageType.PHYSICAL,
|
||||
damageMultiplier: 0.75,
|
||||
messages: [
|
||||
"ATTACKER stomps DEFENDER",
|
||||
"ATTACKER stomps DEFENDER in their face",
|
||||
],
|
||||
messagesDead: ["ATTACKER stomps DEFENDER to death"],
|
||||
messagesOverpower: [
|
||||
"ATTACKER stomps DEFENDER into mush",
|
||||
"DEFENDER explodes after ATTACKER stomps them into bloody mush",
|
||||
],
|
||||
};
|
||||
|
||||
export const attackSit: IAttack = {
|
||||
id: Attack.SIT,
|
||||
damageType: DamageType.PHYSICAL,
|
||||
damageMultiplier: 0.65,
|
||||
messages: ["ATTACKER sits on DEFENDER"],
|
||||
messagesDead: ["ATTACKER sits on DEFENDER and crushes them to death"],
|
||||
messagesOverpower: [
|
||||
"ATTACKER sits on DEFENDER and crushes them into mush and goo",
|
||||
"DEFENDER explodes after ATTACKER sits on them with their full weight",
|
||||
],
|
||||
};
|
||||
|
||||
export const attackRip: IAttack = {
|
||||
id: Attack.RIP,
|
||||
damageType: DamageType.PHYSICAL,
|
||||
damageMultiplier: 0.3,
|
||||
messages: ["ATTACKER tries to rip DEFENDER's limbs off"],
|
||||
messagesDead: ["ATTACKER rips DEFENDER's head off"],
|
||||
messagesOverpower: ["ATTACKER effortlessly rips DEFENDER's body in half"],
|
||||
};
|
||||
|
||||
export const attacks = [
|
||||
attackPunch,
|
||||
attackCut,
|
||||
attackStab,
|
||||
attackKick,
|
||||
attackStomp,
|
||||
attackSit,
|
||||
attackRip,
|
||||
];
|
||||
|
||||
export const npcBecky: INPC = {
|
||||
id: NPC.BECKY,
|
||||
name: "Becky",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { Attack } from "./entities.js";
|
||||
import { Attack } from "./attacks.js";
|
||||
import { DamageType } from "./damageTypes.js";
|
||||
import { Rarity } from "./rarities.js";
|
||||
|
||||
export interface IItem {
|
||||
|
|
@ -31,15 +32,6 @@ export enum ItemType {
|
|||
BOOTS = "BOOTS",
|
||||
}
|
||||
|
||||
export enum DamageType {
|
||||
PHYSICAL = "PHYSICAL",
|
||||
ELEMENTAL = "ELEMENTAL",
|
||||
ARCANE = "ARCANE",
|
||||
PSYCHIC = "PSYCHIC",
|
||||
POISON = "POISON",
|
||||
RADIATION = "RADIATION",
|
||||
}
|
||||
|
||||
export enum Ability {
|
||||
TELEPORT = "TELEPORT",
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue