GameState is now save in cache
HasPlayerMoved is send when the player is actually moving on the map every 200ms.
This commit is contained in:
parent
8cef4f6e90
commit
3edfd5b285
13 changed files with 404 additions and 100 deletions
|
@ -1,6 +1,6 @@
|
|||
import * as tg from "generic-type-guard";
|
||||
|
||||
export const isPositionState = new tg.IsInterface().withProperties({
|
||||
/*export const isPositionState = new tg.IsInterface().withProperties({
|
||||
x: tg.isNumber,
|
||||
y: tg.isNumber
|
||||
}).get()
|
||||
|
@ -12,19 +12,16 @@ export const isPlayerState = new tg.IsInterface()
|
|||
}).get()
|
||||
).get()
|
||||
|
||||
export type PlayerStateObject = tg.GuardedType<typeof isPlayerState>;
|
||||
export type PlayerStateObject = tg.GuardedType<typeof isPlayerState>;*/
|
||||
|
||||
export const isGameStateEvent =
|
||||
new tg.IsInterface().withProperties({
|
||||
roomId: tg.isString,
|
||||
data: tg.isObject,
|
||||
mapUrl: tg.isString,
|
||||
nickName: tg.isString,
|
||||
uuid: tg.isUnion(tg.isString, tg.isUndefined),
|
||||
players: isPlayerState,
|
||||
startLayerName: tg.isUnion(tg.isString, tg.isNull)
|
||||
}).get();
|
||||
/**
|
||||
* A message sent from the game to the iFrame when a user enters or leaves a zone marked with the "zone" property.
|
||||
* A message sent from the game to the iFrame when the gameState is got by the script
|
||||
*/
|
||||
export type GameStateEvent = tg.GuardedType<typeof isGameStateEvent>;
|
16
front/src/Api/Events/HasDataLayerChangedEvent.ts
Normal file
16
front/src/Api/Events/HasDataLayerChangedEvent.ts
Normal file
|
@ -0,0 +1,16 @@
|
|||
import * as tg from "generic-type-guard";
|
||||
|
||||
|
||||
|
||||
export const isHasDataLayerChangedEvent =
|
||||
new tg.IsInterface().withProperties({
|
||||
data: tg.isObject
|
||||
}).get();
|
||||
|
||||
/**
|
||||
* A message sent from the game to the iFrame when the data of the layers change after the iFrame send a message to the game that it want to listen to the data of the layers
|
||||
*/
|
||||
export type HasDataLayerChangedEvent = tg.GuardedType<typeof isHasDataLayerChangedEvent>;
|
||||
|
||||
|
||||
export type HasDataLayerChangedEventCallback = (event: HasDataLayerChangedEvent) => void
|
|
@ -1,19 +0,0 @@
|
|||
import * as tg from "generic-type-guard";
|
||||
|
||||
|
||||
|
||||
export const isHasMovedEvent =
|
||||
new tg.IsInterface().withProperties({
|
||||
direction: tg.isString,
|
||||
moving: tg.isBoolean,
|
||||
x: tg.isNumber,
|
||||
y: tg.isNumber
|
||||
}).get();
|
||||
|
||||
/**
|
||||
* A message sent from the iFrame to the game to add a message in the chat.
|
||||
*/
|
||||
export type HasMovedEvent = tg.GuardedType<typeof isHasMovedEvent>;
|
||||
|
||||
|
||||
export type HasMovedEventCallback = (event: HasMovedEvent) => void
|
19
front/src/Api/Events/HasPlayerMovedEvent.ts
Normal file
19
front/src/Api/Events/HasPlayerMovedEvent.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import * as tg from "generic-type-guard";
|
||||
|
||||
|
||||
|
||||
export const isHasPlayerMovedEvent =
|
||||
new tg.IsInterface().withProperties({
|
||||
direction: tg.isString,
|
||||
moving: tg.isBoolean,
|
||||
x: tg.isNumber,
|
||||
y: tg.isNumber
|
||||
}).get();
|
||||
|
||||
/**
|
||||
* A message sent from the game to the iFrame when the player move after the iFrame send a message to the game that it want to listen to the position of the player
|
||||
*/
|
||||
export type HasPlayerMovedEvent = tg.GuardedType<typeof isHasPlayerMovedEvent>;
|
||||
|
||||
|
||||
export type HasPlayerMovedEventCallback = (event: HasPlayerMovedEvent) => void
|
|
@ -1,15 +1,16 @@
|
|||
|
||||
import { GameStateEvent } from './ApiGameStateEvent';
|
||||
import { GameStateEvent } from './GameStateEvent';
|
||||
import { ButtonClickedEvent } from './ButtonClickedEvent';
|
||||
import { ChatEvent } from './ChatEvent';
|
||||
import { ClosePopupEvent } from './ClosePopupEvent';
|
||||
import { EnterLeaveEvent } from './EnterLeaveEvent';
|
||||
import { GoToPageEvent } from './GoToPageEvent';
|
||||
import { HasMovedEvent } from './HasMovedEvent';
|
||||
import { HasPlayerMovedEvent } from './HasPlayerMovedEvent';
|
||||
import { OpenCoWebSiteEvent } from './OpenCoWebSiteEvent';
|
||||
import { OpenPopupEvent } from './OpenPopupEvent';
|
||||
import { OpenTabEvent } from './OpenTabEvent';
|
||||
import { UserInputChatEvent } from './UserInputChatEvent';
|
||||
import { HasDataLayerChangedEvent } from "./HasDataLayerChangedEvent";
|
||||
|
||||
|
||||
export interface TypedMessageEvent<T> extends MessageEvent {
|
||||
|
@ -30,7 +31,8 @@ export type IframeEventMap = {
|
|||
restorePlayerControls: null
|
||||
displayBubble: null
|
||||
removeBubble: null
|
||||
enableMoveEvents: undefined
|
||||
onPlayerMove: undefined
|
||||
onDataLayerChange: undefined
|
||||
}
|
||||
export interface IframeEvent<T extends keyof IframeEventMap> {
|
||||
type: T;
|
||||
|
@ -47,7 +49,8 @@ export interface IframeResponseEventMap {
|
|||
leaveEvent: EnterLeaveEvent
|
||||
buttonClickedEvent: ButtonClickedEvent
|
||||
gameState: GameStateEvent
|
||||
hasMovedEvent: HasMovedEvent
|
||||
hasPlayerMoved: HasPlayerMovedEvent
|
||||
hasDataLayerChanged: HasDataLayerChangedEvent
|
||||
}
|
||||
export interface IframeResponseEvent<T extends keyof IframeResponseEventMap> {
|
||||
type: T;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue