forked from VincentSmit/cappening
-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.client.coffee
180 lines (179 loc) · 6.44 KB
/
events.client.coffee
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
Shared = require 'shared'
Config = Shared.config()
tr = I18n.tr
# Eventlog page
exports.render = !->
Page.setTitle !->
Dom.text 'Conquest game events'
Event.showStar tr('Game events')
Dom.div !->
Dom.style MarginPolicy: 'adopt'
Db.shared.iterate 'game', 'eventlist', (capture) !->
if capture.key() != "maxId"
Ui.item !->
if capture.peek('type') is "capture"
beaconId = capture.peek('beacon')
teamId = capture.peek('conqueror')
teamColor = Config.teams[teamId].hex
teamName = Config.teams[teamId].name
Dom.onTap !->
Toast.show !->
Dom.text 'Captured '
Time.deltaText(capture.peek('timestamp'))
if capture.peek('members')?
Dom.text " by " + Shared.userStringToFriendly(capture.peek('members')) + ' of team ' + teamName
else
Dom.text ' by team '+teamName
Db.local.set 'switchToMapLocation', Db.shared.peek('game', 'beacons', beaconId, 'location')
Db.local.set 'switchToMapZoom', 16
Db.local.set 'switchToPopup', beaconId
Page.nav()
Dom.div !->
Dom.style
width: '70px'
height: '70px'
marginRight: '10px'
background: teamColor+" url(#{App.resourceUri('marker-plain.png')}) no-repeat 10px 10px"
backgroundSize: '50px 50px'
Dom.div !->
Dom.style Flex: 1, fontSize: '100%'
if Event.isNew(capture.peek('timestamp'))
Dom.style color: '#5b0'
if capture.peek('members')?
Dom.text Shared.userStringToFriendly(capture.peek('members')) + ' of team ' + teamName + ' captured a beacon'
else
Dom.text "Team " + teamName + " captured a beacon"
Dom.div !->
Dom.style fontSize: '75%', marginTop: '6px'
Dom.text "Captured "
Time.deltaText capture.peek('timestamp')
else if capture.peek('type') is "captureAll"
beaconId = capture.peek('beacon')
teamId = capture.peek('conqueror')
teamColor = Config.teams[teamId].hex
teamName = Config.teams[teamId].name
log "print capture: teamId; " + teamId
Dom.onTap !->
Toast.show !->
Dom.text 'Captured '
Time.deltaText(capture.peek('timestamp'))
if capture.peek('members')?
Dom.text " by " + Shared.userStringToFriendly(capture.peek('members')) + ' of team ' + teamName
else
Dom.text ' by team '+teamName
Db.local.set 'switchToMapLocation', Db.shared.peek('game', 'beacons', beaconId, 'location')
Db.local.set 'switchToMapZoom', 16
Db.local.set 'switchToPopup', beaconId
Page.nav()
Dom.div !->
Dom.style
width: '70px'
height: '70px'
marginRight: '10px'
background: teamColor+" url(#{App.resourceUri('markers-plain.png')}) no-repeat 10px 10px"
backgroundSize: '50px 50px'
Dom.div !->
Dom.style Flex: 1, fontSize: '100%'
if Event.isNew(capture.peek('timestamp'))
Dom.style color: '#5b0'
Dom.text "Team " + teamName + " team captured all beacons"
if capture.peek('members')?
Dom.text " thanks to " + Shared.userStringToFriendly(capture.peek('members'))
Dom.div !->
Dom.style fontSize: '75%', marginTop: '6px'
Dom.text "Captured "
Time.deltaText capture.peek('timestamp')
else if capture.peek('type') is "score"
teamId = capture.peek('leading')
teamColor = Config.teams[teamId].hex
teamName = Config.teams[teamId].name
Dom.onTap !->
Page.nav 'scores'
Dom.div !->
Dom.style
width: '70px'
height: '70px'
marginRight: '10px'
background: teamColor+" url(#{App.resourceUri('rank-switch.png')}) no-repeat 10px 10px"
backgroundSize: '50px 50px'
Dom.div !->
Dom.style Flex: 1, fontSize: '100%'
if Event.isNew(capture.peek('timestamp'))
Dom.style color: '#5b0'
Dom.text "Team " + teamName + " took the lead"
Dom.div !->
Dom.style fontSize: '75%', marginTop: '6px'
Dom.text "Captured "
Time.deltaText capture.peek('timestamp')
else if capture.peek('type') is "cancel"
Dom.div !->
Dom.style
width: '70px'
height: '70px'
marginRight: '10px'
background: "#DDDDDD url(#{App.resourceUri('markers-cancel-plain.png')}) no-repeat 10px 10px"
backgroundSize: '50px 50px'
Dom.div !->
Dom.style Flex: 1, fontSize: '16px'
if Event.isNew(capture.peek('timestamp'))
Dom.style color: '#5b0'
Dom.text "No longer are all beacons owned by one team"
started = Db.shared.peek 'game', 'startTime'
if started?
Dom.div !->
Dom.style fontSize: '75%', marginTop: '6px'
Dom.text 'Happened '
Time.deltaText started
else if capture.peek('type') is "start"
Dom.style
padding: '14px'
Dom.div !->
Dom.style
width: '70px'
height: '55px'
marginRight: '10px'
background: '#DDDDDD'
backgroundSize: 'cover'
paddingTop: '15px'
Dom.div !->
Dom.style
margin: '0 0 0 20px'
borderLeft: '34px solid #FFFFFF'
borderTop: '20px solid transparent'
borderBottom: '20px solid transparent'
Dom.div !->
Dom.style Flex: 1, fontSize: '16px'
if Event.isNew(capture.peek('timestamp'))
Dom.style color: '#5b0'
Dom.text "Start of the game!"
started = Db.shared.peek 'game', 'startTime'
if started?
Dom.div !->
Dom.style fontSize: '75%', marginTop: '6px'
Dom.text 'Started '
Time.deltaText started
else if capture.peek('type') is "end"
teamId = Db.shared.peek('game', 'firstTeam')
teamColor = Config.teams[teamId].hex
teamName = Config.teams[teamId].name
Dom.style
padding: '14px'
Dom.div !->
Dom.style
width: '70px'
height: '70px'
marginRight: '10px'
background: teamColor + " url(#{App.resourceUri('ranking-plain.png')}) no-repeat 10px 10px"
backgroundSize: '50px 50px'
Dom.div !->
Dom.style Flex: 1, fontSize: '16px'
if Event.isNew(capture.peek('timestamp'))
Dom.style color: '#5b0'
Dom.text "Team " + teamName + " won the game"
started = Db.shared.peek 'game', 'startTime'
if started?
Dom.div !->
Dom.style fontSize: '75%', marginTop: '6px'
Dom.text 'Started '
Time.deltaText started
, (capture) -> (-capture.key())