Skip to content

Commit

Permalink
fix(left_buyzone_with): changes payload to match entity triggered eve…
Browse files Browse the repository at this point in the history
…nt type
  • Loading branch information
fredrikj31 committed Dec 1, 2023
1 parent 7337ca8 commit 98fee4c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
14 changes: 6 additions & 8 deletions src/parsers/left-buyzone-with.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { Entity, entityRe, parseEntity } from "../entities";

export type LeftBuyzoneWithEventPayload = {
entity: Entity;
items: string[];
kind: string;
value: string[];
};

export type LeftBuyzoneWithEvent = IBaseEvent<"left_buyzone_with", LeftBuyzoneWithEventPayload>;
Expand All @@ -14,16 +15,13 @@ export type LeftBuyzoneWithEvent = IBaseEvent<"left_buyzone_with", LeftBuyzoneWi
export const leftBuyzoneWithParser = defineParser<LeftBuyzoneWithEvent>({
type: "left_buyzone_with",

patterns: [concatPattern`^(?<entity>${entityRe}) left buyzone with (?<items>\\[.*\\])$`],
patterns: [concatPattern`^(?<entity>${entityRe}) left buyzone with (?<value>\\[.*\\])$`],

parse({
entity,

items,
}) {
parse({ entity, kind = "left_buyzone_with", value }) {
return {
entity: parseEntity(entity),
items: items.trim().replaceAll("[", "").replaceAll("]", "").split(" ").slice(1, -1),
kind,
value: value.trim().replaceAll("[", "").replaceAll("]", "").split(" ").slice(1, -1),
};
},
});
3 changes: 2 additions & 1 deletion tests/left_buyzone_with.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ describe("left buyzone with", (): void => {

team: counterTerroristTeam,
},
items: ["weapon_knife_butterfly", "weapon_usp_silencer", "kevlar(100)"],
kind: "left_buyzone_with",
value: ["weapon_knife_butterfly", "weapon_usp_silencer", "kevlar(100)"],
});
});
});

0 comments on commit 98fee4c

Please sign in to comment.