typed-adventureland
Version:
Strong TypeScript declarations for the game AdventureLand
192 lines (191 loc) • 4.69 kB
TypeScript
import { HitData } from "./character-event";
import { ApiResponse } from "./game-event-api-response";
import { ItemInfo, TradeItemInfo } from "./items";
import { TypedEventEmitter } from "./TypedEventEmitter";
import { ItemKey } from "./types/GTypes/items";
import { MapKey } from "./types/GTypes/maps";
import { NpcKey } from "./types/GTypes/npcs";
export type GameWithEventsFunctions = Pick<TypedEventEmitter<GameEvents>, "on" | "once" | "off"> & {
all(callback?: (name: any, data: any) => void): void;
};
export interface GameHitEvent {
source: string;
/** monster id or character name, perhaps NPC name? */
actor: string;
/** monster id or character name, perhaps NPC name? */
target: string;
damage?: number;
/** projectile id */
pid?: string;
heal?: number;
crit?: boolean;
kill?: boolean;
evade?: boolean;
miss?: boolean;
/**
* Outrunning the projectile
*/
avoid?: boolean;
/**
* Whether the attack poisoned the target
*/
poison?: boolean;
/**
* Whether the attack freezed the target
*/
freeze?: boolean;
/**
* Whether the attack stunned the target
*/
stun?: boolean;
/** Reflected damage */
reflect?: number;
/**
* Returned damage
*/
dreturn?: number;
trigger?: string;
condition?: string;
sneak?: boolean;
stacked?: string[];
mobbing?: number;
unintentional?: boolean;
aoe?: boolean;
}
export interface ActionEvent {
source: string;
/** monster id or character name, perhaps NPC name? */
actor: string;
/** monster id or character name, perhaps NPC name? */
target: string;
projectile?: string;
/** Arrival in ms */
eta?: number;
/** projectile id */
pid?: string;
ray?: string;
instant?: boolean;
}
/**
* Item bought from an NPC
*/
export interface GameBuyEvent {
type: "+$";
id: NpcKey;
/** character name */
name: string;
item: ItemInfo;
event: "buy";
}
export interface GameSellEvent {
type: "-$";
id: NpcKey;
/** character name */
name: string;
item: ItemInfo;
num: number;
event: "sell";
}
/**
* Item bought from Ponty aka secondhand
*/
export interface GamePontyBuy {
/** Character who triggered the event */
name: string;
item: {
name: ItemKey;
level: number;
rid: string;
q: number;
cash?: boolean;
};
}
/** Item bought from Lost and Found */
export interface GameLostAndFoundBuy {
/** Character who triggered the event */
name: string;
item: {
name: ItemKey;
level: number;
rid: string;
q: number;
};
}
export interface GameEvents {
level_up: {
/** Character name */
name: string;
level: number;
};
event: {
/** snowman, pinkgoo, wabbit, franky, grinch */
name: string;
map?: MapKey;
x?: number;
y?: number;
};
shutdown: {
/**
* Server shutdown in 20 seconds
*/
seconds: number;
};
item_sent: {
sender: string;
receiver: string;
item: ItemInfo;
};
gold_sent: {
sender: string;
receiver: string;
gold: number;
};
cx_sent: {
sender: string;
receiver: string;
cx: string;
};
api_response: ApiResponse;
/** Item bought from Ponty */
sbuy: {
/** Character who triggered the event */
name: string;
item: ItemInfo;
};
/** Item bought from Lost and Found */
fbuy: {
/** Character who triggered the event */
name: string;
item: {
name: ItemKey;
level: number;
rid: string;
q: number;
};
};
death: {
/** Character Name or Monster ID */
id: string;
/** Luck taken into account when looting */
luckm: number;
/** Contribution distribution for cooperative monsters */
points?: Record<string, number>;
};
mluck: {
/** Character Name */
name: string;
item: ItemInfo;
/** Inventory slot */
num: number;
};
trade: {
/** Character Name */
seller: string;
/** Character Name */
buyer: string;
item: TradeItemInfo;
slot: string;
};
hit: HitData;
}
export * from "./game-event-api-response";