You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1007 B
TypeScript
48 lines
1007 B
TypeScript
type GameState = {
|
|
readonly directions: Map<ObjectID, Direction>,
|
|
readonly rooms: Map<ObjectID, Room>,
|
|
readonly doors: Map<ObjectID, Door>,
|
|
readonly items: Map<ObjectID, Item>,
|
|
readonly player: {
|
|
readonly location: ObjectID
|
|
}
|
|
}
|
|
|
|
export default GameState
|
|
|
|
export enum ObjectType {
|
|
Item = 'item',
|
|
Room = 'room',
|
|
Door = 'door',
|
|
Direction = 'direction'
|
|
}
|
|
|
|
type ObjectID = string
|
|
|
|
export type GameObject = {
|
|
readonly type : ObjectType,
|
|
readonly name : ObjectID,
|
|
readonly aliases : string[]
|
|
}
|
|
|
|
export type Direction = GameObject & {
|
|
readonly type : ObjectType.Direction
|
|
}
|
|
|
|
export type Room = GameObject & {
|
|
readonly type : ObjectType.Room,
|
|
readonly neighbors : Map<ObjectID, ObjectID>
|
|
}
|
|
|
|
export type Door = GameObject & {
|
|
readonly type : ObjectType.Door,
|
|
readonly neighbors : Map<ObjectID, ObjectID>
|
|
readonly locked : boolean,
|
|
readonly key : ObjectID
|
|
}
|
|
|
|
export type Item = GameObject & {
|
|
readonly type : ObjectType.Item,
|
|
readonly location: ObjectID | 'inventory'
|
|
}
|