From af830b91a129ce7513a7c5c08f64fdb655b43d51 Mon Sep 17 00:00:00 2001 From: Hendrik Brummermann Date: Tue, 19 Sep 2023 19:43:54 +0200 Subject: [PATCH] debug output --- srcjs/stendhal/EventRegistry.ts | 2 ++ srcjs/stendhal/event/ChatOptionsEvent.ts | 39 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 srcjs/stendhal/event/ChatOptionsEvent.ts diff --git a/srcjs/stendhal/EventRegistry.ts b/srcjs/stendhal/EventRegistry.ts index 058e0b3a699..f2db06316d0 100644 --- a/srcjs/stendhal/EventRegistry.ts +++ b/srcjs/stendhal/EventRegistry.ts @@ -15,6 +15,7 @@ declare var stendhal: any; import { RPEntity } from "./entity/RPEntity"; import { RPObject } from "./entity/RPObject"; +import { ChatOptionsEvent } from "./event/ChatOptionsEvent"; import { ExamineEvent } from "./event/ExamineEvent"; import { GroupChangeEvent } from "./event/GroupChangeEvent"; import { GroupInviteEvent } from "./event/GroupInviteEvent"; @@ -65,6 +66,7 @@ export class EventRegistry { } this.initialized = true; + this.register("chat_options", new ChatOptionsEvent()); this.register("examine", new ExamineEvent()); this.register("group_change_event", new GroupChangeEvent()); this.register("group_invite_event", new GroupInviteEvent()); diff --git a/srcjs/stendhal/event/ChatOptionsEvent.ts b/srcjs/stendhal/event/ChatOptionsEvent.ts new file mode 100644 index 00000000000..45a7f430dfb --- /dev/null +++ b/srcjs/stendhal/event/ChatOptionsEvent.ts @@ -0,0 +1,39 @@ +/*************************************************************************** + * (C) Copyright 2023-2023 - Stendhal * + *************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Affero General Public License as * + * published by the Free Software Foundation; either version 3 of the * + * License, or (at your option) any later version. * + * * + ***************************************************************************/ + +import { RPEvent } from "./RPEvent"; + +declare var marauroa: any + +/** + * shows an image for a detail view + */ +export class ChatOptionsEvent extends RPEvent { + + public npc!: string; + public options!: string; + + public execute(entity: any): void { + if (entity !== marauroa.me) { + return; + } + + let optionsList = this['options'].split("|~|"); + let message = []; + for (let optionListEntry of optionsList) { + let option = optionListEntry.split("|*|"); + message.push(option[1]); + } + + console.log("Chat options for " + this['npc'] + ": " + message.join(", ")); + } + +};