correction from code review
This commit is contained in:
parent
d4bc999c54
commit
a5cb93541a
10 changed files with 58 additions and 161 deletions
|
@ -1,26 +1,13 @@
|
|||
import * as tg from "generic-type-guard";
|
||||
|
||||
/*export const isPositionState = new tg.IsInterface().withProperties({
|
||||
x: tg.isNumber,
|
||||
y: tg.isNumber
|
||||
}).get()
|
||||
export const isPlayerState = new tg.IsInterface()
|
||||
.withStringIndexSignature(
|
||||
new tg.IsInterface().withProperties({
|
||||
position: isPositionState,
|
||||
pusherId: tg.isUnion(tg.isNumber, tg.isUndefined)
|
||||
}).get()
|
||||
).get()
|
||||
|
||||
export type PlayerStateObject = tg.GuardedType<typeof isPlayerState>;*/
|
||||
|
||||
export const isGameStateEvent =
|
||||
new tg.IsInterface().withProperties({
|
||||
roomId: tg.isString,
|
||||
mapUrl: tg.isString,
|
||||
nickname: tg.isUnion(tg.isString, tg.isNull),
|
||||
uuid: tg.isUnion(tg.isString, tg.isUndefined),
|
||||
startLayerName: tg.isUnion(tg.isString, tg.isNull)
|
||||
roomId: tg.isString,
|
||||
mapUrl: tg.isString,
|
||||
nickname: tg.isUnion(tg.isString, tg.isNull),
|
||||
uuid: tg.isUnion(tg.isString, tg.isUndefined),
|
||||
startLayerName: tg.isUnion(tg.isString, tg.isNull),
|
||||
tags : tg.isArray(tg.isString),
|
||||
}).get();
|
||||
/**
|
||||
* A message sent from the game to the iFrame when the gameState is got by the script
|
||||
|
|
|
@ -4,7 +4,7 @@ import * as tg from "generic-type-guard";
|
|||
|
||||
export const isHasPlayerMovedEvent =
|
||||
new tg.IsInterface().withProperties({
|
||||
direction: tg.isString,
|
||||
direction: tg.isElementOf('right', 'left', 'up', 'down'),
|
||||
moving: tg.isBoolean,
|
||||
x: tg.isNumber,
|
||||
y: tg.isNumber
|
||||
|
|
|
@ -15,8 +15,6 @@ import type { UserInputChatEvent } from './UserInputChatEvent';
|
|||
import type { DataLayerEvent } from "./DataLayerEvent";
|
||||
import type { LayerEvent } from './LayerEvent';
|
||||
import type { SetPropertyEvent } from "./setPropertyEvent";
|
||||
import type { TagEvent } from "./TagEvent";
|
||||
import type { TilesetEvent } from "./TilesetEvent";
|
||||
|
||||
export interface TypedMessageEvent<T> extends MessageEvent {
|
||||
data: T
|
||||
|
@ -24,7 +22,6 @@ export interface TypedMessageEvent<T> extends MessageEvent {
|
|||
|
||||
export type IframeEventMap = {
|
||||
getState: GameStateEvent,
|
||||
// updateTile: UpdateTileEvent
|
||||
registerMenuCommand: MenuItemRegisterEvent
|
||||
chat: ChatEvent,
|
||||
openPopup: OpenPopupEvent
|
||||
|
@ -42,7 +39,6 @@ export type IframeEventMap = {
|
|||
hideLayer: LayerEvent
|
||||
setProperty: SetPropertyEvent
|
||||
getDataLayer: undefined
|
||||
getTag: undefined
|
||||
//tilsetEvent: TilesetEvent
|
||||
}
|
||||
export interface IframeEvent<T extends keyof IframeEventMap> {
|
||||
|
@ -63,7 +59,6 @@ export interface IframeResponseEventMap {
|
|||
hasPlayerMoved: HasPlayerMovedEvent
|
||||
dataLayer: DataLayerEvent
|
||||
menuItemClicked: MenuItemClickedEvent
|
||||
tagList: TagEvent
|
||||
}
|
||||
export interface IframeResponseEvent<T extends keyof IframeResponseEventMap> {
|
||||
type: T;
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
import * as tg from "generic-type-guard";
|
||||
|
||||
export const isTagEvent =
|
||||
new tg.IsInterface().withProperties({
|
||||
list: tg.isArray(tg.isString),
|
||||
}).get();
|
||||
/**
|
||||
* A message sent from the iFrame to the game to show/hide a layer.
|
||||
*/
|
||||
export type TagEvent = tg.GuardedType<typeof isTagEvent>;
|
|
@ -1,15 +0,0 @@
|
|||
import * as tg from "generic-type-guard";
|
||||
|
||||
export const isTilesetEvent =
|
||||
new tg.IsInterface().withProperties({
|
||||
name : tg.isString,
|
||||
imgUrl : tg.isString,
|
||||
tilewidth : tg.isNumber,
|
||||
tileheight : tg.isNumber,
|
||||
margin : tg.isNumber,
|
||||
spacing : tg.isNumber,
|
||||
}).get();
|
||||
/**
|
||||
* A message sent from the iFrame to the game to show/hide a layer.
|
||||
*/
|
||||
export type TilesetEvent = tg.GuardedType<typeof isTilesetEvent>;
|
Loading…
Add table
Add a link
Reference in a new issue