-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirebase-rules.json
58 lines (58 loc) · 1.55 KB
/
firebase-rules.json
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
53
54
55
56
57
58
{
"rules": {
".read": "auth !== null",
"playersOnline": {
"$user_id": {
".write": "auth.uid === $user_id"
}
},
"games": {
"$game_id": {
// create Games
".write": "!data.exists()",
// reveal a card
"turn": {
".write": "data.parent().child('currentPlayer').val() === auth.uid"
},
// end your turn
"currentPlayer": {
".write": "data.val() === auth.uid"
},
// update the board
"board": {
".write": "data.parent().child('currentPlayer').val() === auth.uid"
},
"scores": {
// initialize scores
".write": "!data.exists()",
// update your score
"$user_id": {
".write": "auth.uid === $user_id"
}
},
// join / leave games
"players": {
"$user_id": {
".write": "auth.uid === $user_id"
}
},
// set your ready state
"playersReady": {
"$user_id": {
".write": "auth.uid === $user_id"
}
},
// set your rematch state
"rematch": {
"$user_id": {
".write": "auth.uid === $user_id"
}
},
// start the game if you are the creator the game hasn't started or ended yet || TODO: end the game
"state": {
".write": "(data.parent().child('creator').val() === auth.uid && data.val() === 'waiting' && newData.val() === 'started') || newData.val() === 'done'"
}
}
}
}
}