getMapProperty

This commit is contained in:
_Bastler
2021-11-24 14:32:45 +01:00
parent bc7d9a96fe
commit 16a73d4de6
5 changed files with 66 additions and 16 deletions
+13
View File
@@ -0,0 +1,13 @@
import * as tg from "generic-type-guard";
export const isGetPropertyEvent = new tg.IsInterface()
.withProperties({
layerName: tg.isString,
propertyName: tg.isString,
propertyValue: tg.isUnion(tg.isString, tg.isUnion(tg.isNumber, tg.isUnion(tg.isBoolean, tg.isUndefined))),
})
.get();
/**
* A message sent from the iFrame to the game to change the value of the property of the layer
*/
export type GetPropertyEvent = tg.GuardedType<typeof isGetPropertyEvent>;
+5
View File
@@ -30,6 +30,7 @@ import type {
import { isMessageReferenceEvent, isTriggerActionMessageEvent } from "./ui/TriggerActionMessageEvent";
import type { MenuRegisterEvent, UnregisterMenuEvent } from "./ui/MenuRegisterEvent";
import type { ChangeLayerEvent } from "./ChangeLayerEvent";
import { isGetPropertyEvent } from "./GetPropertyEvent";
export interface TypedMessageEvent<T> extends MessageEvent {
data: T;
@@ -103,6 +104,10 @@ export const iframeQueryMapTypeGuards = {
query: tg.isUndefined,
answer: isGameStateEvent,
},
getProperty: {
query: isGetPropertyEvent,
answer: isGetPropertyEvent,
},
getMapData: {
query: tg.isUndefined,
answer: isMapDataEvent,