diff --git a/src/services/game/entity.ts b/src/services/game/entity.ts index e464fd1..d435366 100644 --- a/src/services/game/entity.ts +++ b/src/services/game/entity.ts @@ -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, diff --git a/src/services/game/game.ts b/src/services/game/game.ts index 7f70916..851b351 100644 --- a/src/services/game/game.ts +++ b/src/services/game/game.ts @@ -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, diff --git a/src/services/game/structures/attacks.ts b/src/services/game/structures/attacks.ts new file mode 100644 index 0000000..50b6cef --- /dev/null +++ b/src/services/game/structures/attacks.ts @@ -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, +]; diff --git a/src/services/game/structures/damageTypes.ts b/src/services/game/structures/damageTypes.ts new file mode 100644 index 0000000..006153c --- /dev/null +++ b/src/services/game/structures/damageTypes.ts @@ -0,0 +1,8 @@ +export enum DamageType { + PHYSICAL = "PHYSICAL", + ELEMENTAL = "ELEMENTAL", + ARCANE = "ARCANE", + PSYCHIC = "PSYCHIC", + POISON = "POISON", + RADIATION = "RADIATION", +} diff --git a/src/services/game/structures/entities.ts b/src/services/game/structures/entities.ts index afe2ef0..5d24658 100644 --- a/src/services/game/structures/entities.ts +++ b/src/services/game/structures/entities.ts @@ -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", diff --git a/src/services/game/structures/items.ts b/src/services/game/structures/items.ts index 72c0ba1..0cfaed3 100644 --- a/src/services/game/structures/items.ts +++ b/src/services/game/structures/items.ts @@ -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", }