-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinishGame.lua
More file actions
221 lines (162 loc) · 7.38 KB
/
FinishGame.lua
File metadata and controls
221 lines (162 loc) · 7.38 KB
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
local func = require("functions")
local http = require("httpwork")
local widget = require( "widget" )
local url = require("socket.url")
local socket = require("socket")
local group
local MainGroup
local scView
local CheckResults
local ResultData = {}
local Continue = function(event)
if event.phase == "ended" then
func.LoadScreen("Welcome","crossFade",1000)
end
return true
end
local DisplayResults = function()
scView = widget.newScrollView
{
x = display.contentWidth/2,
y = 1136/2 + 30,
width = 640,
height = 1136 - 240,
bottomPadding = 150,
topPadding = 20,
id = "onBottom",
horizontalScrollDisabled = true,
verticalScrollDisabled = false,
hideBackground = true
}
local v = 30
scView:insert(func.StandardImage("Tile.png",display.contentWidth/2,200,nil,nil,nil,1.5))
if _G.GameStructure[1].GameType == "Cash Game" then
scView:insert(func.StandardImage("Cash.png",display.contentWidth/2,120,nil,nil,nil,1))
scView:insert(func.StandardLabelBold("Cash Prize of: " .. ResultData[1][5] ,display.contentWidth/2,200,45,6/255,4/255,74/255,nil,nil,1))
scView:insert(func.StandardLabelBold("Won by: " .. ResultData[1][4] .. "!" ,display.contentWidth/2,270,45,6/255,4/255,74/255,nil,nil,1))
end
if _G.GameStructure[1].GameType == "Winners Only" then
scView:insert(func.StandardImage("WinnerIcon.png",display.contentWidth/2,120,nil,nil,nil,1))
scView:insert(func.StandardLabelBold("Winner: " .. ResultData[1][4] ,display.contentWidth/2,200,42,6/255,4/255,74/255,nil,nil,1))
scView:insert(func.StandardLabelBold("Prize: " .. _G.GameStructure[1].WinnerGets ,display.contentWidth/2,270,38,6/255,4/255,74/255,nil,nil,1))
end
if _G.GameStructure[1].GameType == "Winners & Losers" then
scView:insert(func.StandardLabelBold("Winner : " .. ResultData[1][4] ,display.contentWidth/2,100,45,6/255,4/255,74/255,nil,nil,1))
scView:insert(func.StandardLabelBold("Prize: " .. _G.GameStructure[1].WinnerGets ,display.contentWidth/2,160,38,6/255,4/255,74/255,nil,nil,1))
scView:insert(func.StandardLabelBold("Loser: " .. ResultData[2][4] ,display.contentWidth/2,220,45,6/255,4/255,74/255,nil,nil,1))
scView:insert(func.StandardLabelBold("Forfiet: " .. _G.GameStructure[1].Forfiet ,display.contentWidth/2,280,38,6/255,4/255,74/255,nil,nil,1))
end
scView:insert(func.DrawLine(40,410,600,410,6,255/255,255/255,0/255))
scView:insert(func.StandardLabelBold("Overall Rankings" ,display.contentWidth/2,450,45,91/255,155/255,213/255,nil,nil,1))
scView:insert(func.StandardLabelBold("Pos.",40,520,38,91/255,155/255,213/255))
scView:insert(func.StandardLabelBold("Player",150,520,38,91/255,155/255,213/255))
scView:insert(func.StandardLabelBold("Score",450,520 ,38,91/255,155/255,213/255))
v = 580
local n = 1
for i = 1, #ResultData do
if ResultData[i][2] == "Section 2" then
scView:insert(func.StandardLabelBold(n .. ".",40,v,38,255/255,255/255,0/255))
scView:insert(func.StandardLabelBold(ResultData[i][3],150,v,38,255/255,255/255,0/255))
scView:insert(func.StandardLabelBold(ResultData[i][4],460,v ,38,255/255,255/255,0/255))
v = v + 70
n = n + 1
end
end
scView:insert(func.DrawLine(40,v,600,v,6,255/255,255/255,0/255))
scView:insert(func.StandardLabelBold("All The Detail!" ,display.contentWidth/2,v + 50,45,91/255,155/255,213/255,nil,nil,1))
local Sect = ""
for i = 1, #ResultData do
if string.find(ResultData[i][2], "Section 3") ~= nil then
if Sect ~= ResultData[i][2] then
Sect = ResultData[i][2]
v = v + 120
scView:insert(func.StandardLabelBoldW("Q " .. ResultData[i][3] .. "?",20,v,550,38,91/255,155/255,213/255))
v = v + 90
scView:insert(func.StandardLabelBold("Correct Answer: ".. ResultData[i][4],20,v,38,255/255,255/255,255/255))
v = v + 90
scView:insert(func.StandardLabelBold("Pos.",30,v,38,91/255,155/255,213/255))
scView:insert(func.StandardLabelBold("Player",110,v,38,91/255,155/255,213/255))
scView:insert(func.StandardLabelBold("Answer",300,v ,38,91/255,155/255,213/255))
scView:insert(func.StandardLabelBold("Time",510,v ,38,91/255,155/255,213/255))
n = 1
end
end
if string.find(ResultData[i][2], "Section 4") ~= nil then
v = v + 60
print(ResultData[i][2])
scView:insert(func.StandardLabelBold(n .. ".",40,v,38,255/255,255/255,0/255))
scView:insert(func.StandardLabelBold(ResultData[i][3],110,v,38,255/255,255/255,0/255))
scView:insert(func.StandardLabelBold(ResultData[i][4],300,v ,38,255/255,255/255,0/255))
scView:insert(func.StandardLabelBold(ResultData[i][5],520,v ,38,255/255,255/255,0/255))
n = n + 1
end
end
-- if ResultData[i][2] == "Section 2" then
-- scView:insert(func.StandardLabelBold(ResultData[i][3],20,v,38,91/255,155/255,213/255))
-- scView:insert(func.StandardLabelBold(ResultData[i][4],400,v,38,255/255,255/255,0/255))
-- end
-- end
MainGroup:insert(scView)
MainGroup:insert( func.StandardImage("ContinueButton.png",display.contentWidth/2,1080,Continue,nil,nil,1))
_G.HaltNav = nil
end
local StartTimer = function()
tmID = timer.performWithDelay( 1000, DisplayTimer, 0 )
end
local CheckonTimer = function()
http.MakeNetworkCall(CheckResults,"GetResults",_G.GameGuid, _G.UserCode )
end
CheckResults = function(HostResponse)
print(HostResponse.response)
_G.NetworkCallOn = false
if (HostResponse.isError) then
func.ShowSimpleAlert("Network Connection Error","There seems to be a problem connecting to Care Control. Please try again.",{"OK"})
else
if string.find(HostResponse.response, "WAITING987654321") ~= nil then
tmID = timer.performWithDelay( 500, CheckonTimer )
else
func.LoadDataSet(HostResponse,ResultData)
DisplayResults()
end
end
end
local LoadPage = function()
local SaveString = ""
for i = 1,#_G.GameStructure[1].Questions do
SaveString = SaveString .. _G.GameStructure[1].Questions[i].UserAnswer .. "~" .. _G.GameStructure[1].Questions[i].AnswerTime .. "~"
end
http.MakeNetworkCall(CheckResults,"SaveGame",_G.GameGuid, _G.UserCode , SaveString)
--http.MakeNetworkCall(CheckResults,"GetResults",'952C77E8F05B453C8985C48BD993ADA0','99670B15CE2347D5B609C4F9723CC2E0')
_G.HaltNav = nil
end
function scene:enterScene(event)
_G.HaltNav = 1
_G.CurrentQuestion = 1
transition.to( MainGroup, { time=700, alpha=1, transition=easing.outQuart,onComplete=LoadPage } )
end
function scene:createScene( event )
group = self.view
local prior_scene = storyboard.getPrevious()
storyboard.removeScenePurgeAll( prior_scene )
MainGroup = display.newGroup()
MainGroup.alpha = 0
MainGroup:insert( func.StandardImage("Results.png",display.contentWidth/2,60,nil,nil,nil,0.7))
group:insert(MainGroup)
end
function scene:destroyScene( event )
func.ClearGroup(scView)
end
-- "createScene" event is dispatched if scene's view does not exist
scene:addEventListener( "createScene", scene )
-- "enterScene" event is dispatched whenever scene transition has finished
scene:addEventListener( "enterScene", scene )
-- "exitScene" event is dispatched before next scene's transition begins
scene:addEventListener( "exitScene", scene )
-- "destroyScene" event is dispatched before view is unloaded, which can be
-- automatically unloaded in low memory situations, or explicitly via a call to
-- storyboard.removeScene() or storyboard.removeScene().
scene:addEventListener( "destroyScene", scene )
---------------------------------------------------------------------------------
return scene