forked from holochain/minersweeper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
minersweeper.ts
52 lines (38 loc) · 1.06 KB
/
minersweeper.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import { Hash } from "./holochain"
export type XY = {x: number, y: number}
export type Size = XY
export type Pos = XY
export type BoardActionType
= "reveal"
| "flag"
export type ChatActionType
= "chat"
export type ActionType
= BoardActionType
| ChatActionType
export type BoardActionDefinition
= {actionType: BoardActionType, position: Pos}
export type ChatActionDefinition
= {actionType: ChatActionType, text: string}
export type ActionDefinition
= BoardActionDefinition
| ChatActionDefinition
export type BoardAction = BoardActionDefinition & { agentHash: Hash, timestamp: number }
export type ChatAction = ChatActionDefinition & { agentHash: Hash, timestamp: number }
export type Action = BoardAction | ChatAction
export interface MoveDefinition {
gameHash: Hash;
action: ActionDefinition;
}
export type GameState = GameBoard & {actions: Action[]}
export interface GameParams {
description: string;
nMines: number;
size: Size;
}
export interface GameBoard {
description: string;
mines: Pos[];
size: Size;
creatorHash: Hash;
}