mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-13 06:14:51 +00:00
Fixed quick chat text injection (#1144)
## Description: https://github.com/openfrontio/OpenFrontIO/issues/1035 Fixes #1035 ## Please complete the following: - [x] I have added screenshots for all UI updates - [x] I process any text displayed to the user through translateText() and I've added it to the en.json file - [x] I have added relevant tests to the test directory - [x] I confirm I have thoroughly tested these changes and take full responsibility for any bugs introduced - [x] I understand that submitting code with bugs that could have been caught through manual testing blocks releases and new features for all contributors ## Please put your Discord username so you can be contacted if a bug or regression is found: .w. --------- Co-authored-by: Scott Anderson <scottanderson@users.noreply.github.com> Co-authored-by: evanpelle <evanpelle@gmail.com>
This commit is contained in:
+1
-1
@@ -287,7 +287,7 @@ export const QuickChatIntentSchema = BaseIntentSchema.extend({
|
||||
type: z.literal("quick_chat"),
|
||||
recipient: ID,
|
||||
quickChatKey: QuickChatKeySchema,
|
||||
variables: z.record(SafeString).optional(),
|
||||
target: ID.optional(),
|
||||
});
|
||||
|
||||
export const MarkDisconnectedIntentSchema = BaseIntentSchema.extend({
|
||||
|
||||
@@ -122,7 +122,7 @@ export class Executor {
|
||||
player,
|
||||
intent.recipient,
|
||||
intent.quickChatKey,
|
||||
intent.variables ?? {},
|
||||
intent.target,
|
||||
);
|
||||
case "mark_disconnected":
|
||||
return new MarkDisconnectedExecution(player, intent.isDisconnected);
|
||||
|
||||
@@ -10,7 +10,7 @@ export class QuickChatExecution implements Execution {
|
||||
private sender: Player,
|
||||
private recipientID: PlayerID,
|
||||
private quickChatKey: string,
|
||||
private variables: Record<string, string>,
|
||||
private target: PlayerID | undefined,
|
||||
) {}
|
||||
|
||||
init(mg: Game, ticks: number): void {
|
||||
@@ -27,12 +27,12 @@ export class QuickChatExecution implements Execution {
|
||||
}
|
||||
|
||||
tick(ticks: number): void {
|
||||
const message = this.getMessageFromKey(this.quickChatKey, this.variables);
|
||||
const message = this.getMessageFromKey(this.quickChatKey);
|
||||
|
||||
this.mg.displayChat(
|
||||
message[1],
|
||||
message[0],
|
||||
this.variables,
|
||||
this.target,
|
||||
this.recipient.id(),
|
||||
true,
|
||||
this.sender.name(),
|
||||
@@ -41,7 +41,7 @@ export class QuickChatExecution implements Execution {
|
||||
this.mg.displayChat(
|
||||
message[1],
|
||||
message[0],
|
||||
this.variables,
|
||||
this.target,
|
||||
this.sender.id(),
|
||||
false,
|
||||
this.recipient.name(),
|
||||
@@ -66,10 +66,7 @@ export class QuickChatExecution implements Execution {
|
||||
return false;
|
||||
}
|
||||
|
||||
private getMessageFromKey(
|
||||
fullKey: string,
|
||||
vars: Record<string, string>,
|
||||
): string[] {
|
||||
private getMessageFromKey(fullKey: string): string[] {
|
||||
const translated = fullKey.split(".");
|
||||
return translated;
|
||||
}
|
||||
|
||||
@@ -606,7 +606,7 @@ export interface Game extends GameMap {
|
||||
displayChat(
|
||||
message: string,
|
||||
category: string,
|
||||
variables: Record<string, string>,
|
||||
target: PlayerID | undefined,
|
||||
playerID: PlayerID | null,
|
||||
isFrom: boolean,
|
||||
recipient: string,
|
||||
|
||||
@@ -630,7 +630,7 @@ export class GameImpl implements Game {
|
||||
displayChat(
|
||||
message: string,
|
||||
category: string,
|
||||
variables: Record<string, string> = {},
|
||||
target: PlayerID | undefined,
|
||||
playerID: PlayerID | null,
|
||||
isFrom: boolean,
|
||||
recipient: string,
|
||||
@@ -643,7 +643,7 @@ export class GameImpl implements Game {
|
||||
type: GameUpdateType.DisplayChatEvent,
|
||||
key: message,
|
||||
category: category,
|
||||
variables: variables,
|
||||
target: target,
|
||||
playerID: id,
|
||||
isFrom,
|
||||
recipient: recipient,
|
||||
|
||||
@@ -172,7 +172,7 @@ export type DisplayChatMessageUpdate = {
|
||||
type: GameUpdateType.DisplayChatEvent;
|
||||
key: string;
|
||||
category: string;
|
||||
variables?: Record<string, string>;
|
||||
target: string | undefined;
|
||||
playerID: number | null;
|
||||
isFrom: boolean;
|
||||
recipient: string;
|
||||
|
||||
Reference in New Issue
Block a user