vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | -- Sudoku by Fricks |
2 | -- Start : 28.04.06 |
||
3 | -- Update : 20.05.06 |
||
4 | SUDOKUPUZZLE_VERSION = "Version 1.0 by Fricks"; |
||
5 | |||
6 | -- Variablen |
||
7 | |||
8 | Sudoku_Config={}; |
||
9 | Sudoku_Config[1]={}; -- GTable |
||
10 | Sudoku_Config[2]={}; -- GTableR |
||
11 | Sudoku_Config[3]={}; -- GTableL |
||
12 | Sudoku_Config[4]={}; -- GTableC |
||
13 | Sudoku_Config[5]=3; -- Level |
||
14 | Sudoku_Config[6]=0; -- ListID |
||
15 | Sudoku_Config[7]=0; -- Zahlen count |
||
16 | Sudoku_Config[8]=0; -- Hilfe count |
||
17 | Sudoku_Config[9]={1}; -- GTableH |
||
18 | |||
19 | -- ButtonID > Gitter Koordinaten |
||
20 | local Sudoku_GTableID = { |
||
21 | [11] = { x = 1, y = 1}, |
||
22 | [12] = { x = 2, y = 1}, |
||
23 | [13] = { x = 3, y = 1}, |
||
24 | [14] = { x = 4, y = 1}, |
||
25 | [15] = { x = 5, y = 1}, |
||
26 | [16] = { x = 6, y = 1}, |
||
27 | [17] = { x = 7, y = 1}, |
||
28 | [18] = { x = 8, y = 1}, |
||
29 | [19] = { x = 9, y = 1}, |
||
30 | [21] = { x = 1, y = 2}, |
||
31 | [22] = { x = 2, y = 2}, |
||
32 | [23] = { x = 3, y = 2}, |
||
33 | [24] = { x = 4, y = 2}, |
||
34 | [25] = { x = 5, y = 2}, |
||
35 | [26] = { x = 6, y = 2}, |
||
36 | [27] = { x = 7, y = 2}, |
||
37 | [28] = { x = 8, y = 2}, |
||
38 | [29] = { x = 9, y = 2}, |
||
39 | [31] = { x = 1, y = 3}, |
||
40 | [32] = { x = 2, y = 3}, |
||
41 | [33] = { x = 3, y = 3}, |
||
42 | [34] = { x = 4, y = 3}, |
||
43 | [35] = { x = 5, y = 3}, |
||
44 | [36] = { x = 6, y = 3}, |
||
45 | [37] = { x = 7, y = 3}, |
||
46 | [38] = { x = 8, y = 3}, |
||
47 | [39] = { x = 9, y = 3}, |
||
48 | [41] = { x = 1, y = 4}, |
||
49 | [42] = { x = 2, y = 4}, |
||
50 | [43] = { x = 3, y = 4}, |
||
51 | [44] = { x = 4, y = 4}, |
||
52 | [45] = { x = 5, y = 4}, |
||
53 | [46] = { x = 6, y = 4}, |
||
54 | [47] = { x = 7, y = 4}, |
||
55 | [48] = { x = 8, y = 4}, |
||
56 | [49] = { x = 9, y = 4}, |
||
57 | [51] = { x = 1, y = 5}, |
||
58 | [52] = { x = 2, y = 5}, |
||
59 | [53] = { x = 3, y = 5}, |
||
60 | [54] = { x = 4, y = 5}, |
||
61 | [55] = { x = 5, y = 5}, |
||
62 | [56] = { x = 6, y = 5}, |
||
63 | [57] = { x = 7, y = 5}, |
||
64 | [58] = { x = 8, y = 5}, |
||
65 | [59] = { x = 9, y = 5}, |
||
66 | [61] = { x = 1, y = 6}, |
||
67 | [62] = { x = 2, y = 6}, |
||
68 | [63] = { x = 3, y = 6}, |
||
69 | [64] = { x = 4, y = 6}, |
||
70 | [65] = { x = 5, y = 6}, |
||
71 | [66] = { x = 6, y = 6}, |
||
72 | [67] = { x = 7, y = 6}, |
||
73 | [68] = { x = 8, y = 6}, |
||
74 | [69] = { x = 9, y = 6}, |
||
75 | [71] = { x = 1, y = 7}, |
||
76 | [72] = { x = 2, y = 7}, |
||
77 | [73] = { x = 3, y = 7}, |
||
78 | [74] = { x = 4, y = 7}, |
||
79 | [75] = { x = 5, y = 7}, |
||
80 | [76] = { x = 6, y = 7}, |
||
81 | [77] = { x = 7, y = 7}, |
||
82 | [78] = { x = 8, y = 7}, |
||
83 | [79] = { x = 9, y = 7}, |
||
84 | [81] = { x = 1, y = 8}, |
||
85 | [82] = { x = 2, y = 8}, |
||
86 | [83] = { x = 3, y = 8}, |
||
87 | [84] = { x = 4, y = 8}, |
||
88 | [85] = { x = 5, y = 8}, |
||
89 | [86] = { x = 6, y = 8}, |
||
90 | [87] = { x = 7, y = 8}, |
||
91 | [88] = { x = 8, y = 8}, |
||
92 | [89] = { x = 9, y = 8}, |
||
93 | [91] = { x = 1, y = 9}, |
||
94 | [92] = { x = 2, y = 9}, |
||
95 | [93] = { x = 3, y = 9}, |
||
96 | [94] = { x = 4, y = 9}, |
||
97 | [95] = { x = 5, y = 9}, |
||
98 | [96] = { x = 6, y = 9}, |
||
99 | [97] = { x = 7, y = 9}, |
||
100 | [98] = { x = 8, y = 9}, |
||
101 | [99] = { x = 9, y = 9}, |
||
102 | }; |
||
103 | |||
104 | -- Aktuelle Zahlenanordnung |
||
105 | local Sudoku_GTable = { |
||
106 | [1] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
107 | [2] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
108 | [3] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
109 | [4] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
110 | [5] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
111 | [6] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
112 | [7] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
113 | [8] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
114 | [9] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
115 | }; |
||
116 | |||
117 | -- Zahlenanordnung zu Beginn |
||
118 | local Sudoku_GTableR = { |
||
119 | [1] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
120 | [2] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
121 | [3] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
122 | [4] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
123 | [5] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
124 | [6] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
125 | [7] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
126 | [8] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
127 | [9] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
128 | }; |
||
129 | |||
130 | -- Zahlenanordnung Lösung |
||
131 | local Sudoku_GTableL = { |
||
132 | [1] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
133 | [2] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
134 | [3] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
135 | [4] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
136 | [5] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
137 | [6] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
138 | [7] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
139 | [8] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
140 | [9] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
141 | }; |
||
142 | |||
143 | -- Ziffern die mit Hilfe gesetzt wurden |
||
144 | local Sudoku_GTableH = { |
||
145 | [1] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
146 | [2] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
147 | [3] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
148 | [4] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
149 | [5] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
150 | [6] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
151 | [7] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
152 | [8] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
153 | [9] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
154 | }; |
||
155 | |||
156 | -- Hintergrundfarbe bestimmen |
||
157 | local Sudoku_GTableC = { |
||
158 | [1] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
159 | [2] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
160 | [3] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
161 | [4] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
162 | [5] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
163 | [6] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
164 | [7] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
165 | [8] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
166 | [9] = { [1] = 0, [2] = 0, [3] = 0, [4] = 0, [5] = 0, [6] = 0, [7] = 0, [8] = 0, [9] = 0 }, |
||
167 | }; |
||
168 | |||
169 | -- Farben von Text und Hintergrund, Rahmen |
||
170 | local Sudoku_Color = { |
||
171 | ["blau"] = { ["r"] = 0, ["g"] = 0, ["b"] = 0.6 }, |
||
172 | ["gruen"] = { ["r"] = 0, ["g"] = 0.6, ["b"] = 0 }, |
||
173 | ["rot"] = { ["r"] = 0.6, ["g"] = 0, ["b"] = 0 }, |
||
174 | ["schwarz"] = { ["r"] = 0.3, ["g"] = 0.3, ["b"] = 0.3 }, |
||
175 | ["textweiss"] = { ["r"] = 1, ["g"] = 1, ["b"] = 1 }, |
||
176 | ["textgelb"] = { ["r"] = 1, ["g"] = 1, ["b"] = 0 }, |
||
177 | ["textlila"] = { ["r"] = 1, ["g"] = 0, ["b"] = 1 }, |
||
178 | ["textgruen"] = { ["r"] = 0, ["g"] = 1, ["b"] = 0 }, |
||
179 | }; |
||
180 | |||
181 | local auswahl=0; -- Auswahl der Zahl 1-9, 0 , ? |
||
182 | local level=3; -- Level : 3=Leicht, 2=Mittel, 1=Schwer |
||
183 | local level2=3; |
||
184 | local listid=0; |
||
185 | local listid1=0; |
||
186 | local listid2=0; |
||
187 | local listid3=0; |
||
188 | local zahlencount=0; |
||
189 | local hilfecount=0; |
||
190 | local sudoplay=0; -- 0 = nicht anklickbar, 1 = anklickbar |
||
191 | |||
192 | -- Functions |
||
193 | |||
194 | function Sudoku_OnLoad() |
||
195 | this:RegisterEvent("VARIABLES_LOADED"); |
||
196 | tinsert(UISpecialFrames, "Sudoku_MainFrame"); |
||
197 | UIPanelWindows["Sudoku_MainFrame"] = nil; |
||
198 | Sudoku_MainFrame:RegisterForDrag("LeftButton"); |
||
199 | |||
200 | SLASH_SUDOKU_FRAME1 = SUDOKU_FRAME_SLASH; |
||
201 | SlashCmdList["SUDOKU_FRAME"] = function(msg) |
||
202 | Sudoku_SlashCommand(msg); |
||
203 | end |
||
204 | |||
205 | if( DEFAULT_CHAT_FRAME ) then |
||
206 | DEFAULT_CHAT_FRAME:AddMessage(SUDOKU_ONLOAD_MESSAGE, 1, 1, 0); |
||
207 | end |
||
208 | |||
209 | Sudoku_ViewGameButton:Disable(); |
||
210 | |||
211 | Sudoku_Auswahl1Text:SetText("1"); |
||
212 | Sudoku_Auswahl2Text:SetText("2"); |
||
213 | Sudoku_Auswahl3Text:SetText("3"); |
||
214 | Sudoku_Auswahl4Text:SetText("4"); |
||
215 | Sudoku_Auswahl5Text:SetText("5"); |
||
216 | Sudoku_Auswahl6Text:SetText("6"); |
||
217 | Sudoku_Auswahl7Text:SetText("7"); |
||
218 | Sudoku_Auswahl8Text:SetText("8"); |
||
219 | Sudoku_Auswahl9Text:SetText("9"); |
||
220 | Sudoku_Auswahl10Text:SetText(""); |
||
221 | Sudoku_Auswahl11Text:SetText("?"); |
||
222 | |||
223 | Sudoku_LevelAuswahl3Text:SetText(SUDOKU_LEVEL_EASY); |
||
224 | Sudoku_LevelAuswahl2Text:SetText(SUDOKU_LEVEL_MEDIUM); |
||
225 | Sudoku_LevelAuswahl1Text:SetText(SUDOKU_LEVEL_HARD); |
||
226 | |||
227 | Sudoku_LevelAuswahl_OnClick("LeftButton",3); |
||
228 | |||
229 | Sudoku_Count1Text:SetText("ID #0"); |
||
230 | Sudoku_Count2Text:SetText(SUDOKU_EMPTYCELLS..zahlencount); |
||
231 | Sudoku_Count3Text:SetText("? : 0"); |
||
232 | |||
233 | --Sudoku_MainFrameVersionText:SetTextColor(0.7,0,0,1); |
||
234 | |||
235 | end |
||
236 | |||
237 | function Sudoku_OnEvent() |
||
238 | if (event == "VARIABLES_LOADED") then |
||
239 | Sudoku_Load(); |
||
240 | end |
||
241 | end |
||
242 | |||
243 | function Sudoku_Load() |
||
244 | if (getn(Sudoku_Config[1])>0) then |
||
245 | Sudoku_GTable=Sudoku_Config[1]; |
||
246 | Sudoku_GTableR=Sudoku_Config[2]; |
||
247 | Sudoku_GTableL=Sudoku_Config[3]; |
||
248 | Sudoku_GTableC=Sudoku_Config[4]; |
||
249 | level=Sudoku_Config[5]; |
||
250 | listid=Sudoku_Config[6]; |
||
251 | hilfecount=Sudoku_Config[8]; |
||
252 | |||
253 | if (getn(Sudoku_Config[9])>1) then |
||
254 | Sudoku_GTableH=Sudoku_Config[9]; |
||
255 | end |
||
256 | |||
257 | if (level==1) then |
||
258 | listid1=listid; |
||
259 | elseif (level==2) then |
||
260 | listid2=listid; |
||
261 | elseif (level==3) then |
||
262 | listid3=listid; |
||
263 | end |
||
264 | |||
265 | Sudoku_Count1Text:SetText("ID #"..listid); |
||
266 | Sudoku_Count3Text:SetText("? : "..hilfecount); |
||
267 | Sudoku_LevelAuswahl_OnClick("LeftButton",level); |
||
268 | Sudoku_ViewGameButton:Enable(); |
||
269 | sudoplay=1; |
||
270 | end |
||
271 | Sudoku_ErstelleGitter(); |
||
272 | Sudoku_GitterFarbe(); |
||
273 | end |
||
274 | |||
275 | function Sudoku_SlashCommand(msg) |
||
276 | Sudoku_Toggle(); |
||
277 | end |
||
278 | |||
279 | function Sudoku_Toggle() |
||
280 | if(Sudoku_MainFrame:IsVisible()) then |
||
281 | HideUIPanel(Sudoku_MainFrame); |
||
282 | else |
||
283 | ShowUIPanel(Sudoku_MainFrame); |
||
284 | end |
||
285 | end |
||
286 | |||
287 | function Sudoku_Gitter_OnClick(button,gitterid) |
||
288 | if (sudoplay==1) then |
||
289 | local gx=Sudoku_GTableID[gitterid]["x"]; |
||
290 | local gy=Sudoku_GTableID[gitterid]["y"]; |
||
291 | if ((button == "LeftButton" or button == "RightButton") and Sudoku_GTableR[gy][gx]==0) then |
||
292 | local GitterText = getglobal("Sudoku_Gitter"..gitterid.."Text"); |
||
293 | if (auswahl>0 and auswahl<10 and Sudoku_GTable[gy][gx]~=auswahl and Sudoku_GTableH[gy][gx]==0) then |
||
294 | Sudoku_GTable[gy][gx]=auswahl; |
||
295 | GitterText:SetText(auswahl); |
||
296 | elseif (auswahl==10 and Sudoku_GTableH[gy][gx]==0) then |
||
297 | Sudoku_GTable[gy][gx]=0; |
||
298 | GitterText:SetText(""); |
||
299 | elseif (auswahl==11 and Sudoku_GTableH[gy][gx]==0) then |
||
300 | Sudoku_GTableH[gy][gx]=1; |
||
301 | Sudoku_GTable[gy][gx]=Sudoku_GTableL[gy][gx]; |
||
302 | GitterText:SetText(Sudoku_GTableL[gy][gx]); |
||
303 | GitterText:SetTextColor(Sudoku_Color["textgruen"]["r"],Sudoku_Color["textgruen"]["g"],Sudoku_Color["textgruen"]["b"]); |
||
304 | Sudoku_Config[9]=Sudoku_GTableH; |
||
305 | hilfecount=Sudoku_GetHelp(); |
||
306 | Sudoku_Count3Text:SetText("? : "..hilfecount); |
||
307 | end |
||
308 | |||
309 | zahlencount=Sudoku_GetEmpty(); |
||
310 | Sudoku_Count2Text:SetText(SUDOKU_EMPTYCELLS..zahlencount); |
||
311 | |||
312 | Sudoku_Config[1]=Sudoku_GTable; |
||
313 | Sudoku_Check(); |
||
314 | Sudoku_Config[4]=Sudoku_GTableC; |
||
315 | |||
316 | Sudoku_Config[7]=zahlencount; |
||
317 | Sudoku_Config[8]=hilfecount; |
||
318 | |||
319 | Sudoku_CheckSuccess(); |
||
320 | |||
321 | end |
||
322 | end |
||
323 | end |
||
324 | |||
325 | function Sudoku_Auswahl_OnClick(button,auswahlid) |
||
326 | if( (button == "LeftButton" or button == "RightButton") and sudoplay==1) then |
||
327 | auswahl=auswahlid; |
||
328 | local i=0; |
||
329 | for i=1,11 do |
||
330 | local Gitter = getglobal("Sudoku_Auswahl"..i.."Texture"); |
||
331 | local Gitter2 = getglobal("Sudoku_Auswahl"..i.."Texture2"); |
||
332 | if (i==auswahlid) then |
||
333 | Gitter:Hide(); |
||
334 | Gitter2:Show(); |
||
335 | else |
||
336 | Gitter2:Hide(); |
||
337 | Gitter:Show(); |
||
338 | end |
||
339 | end |
||
340 | end |
||
341 | end |
||
342 | |||
343 | function Sudoku_LevelAuswahl_OnClick(button,levelid) |
||
344 | if( button == "LeftButton" or button == "RightButton" ) then |
||
345 | level2=levelid; |
||
346 | local i=0; |
||
347 | for i=1,3 do |
||
348 | local Gitter = getglobal("Sudoku_LevelAuswahl"..i.."Texture"); |
||
349 | local Gitter2 = getglobal("Sudoku_LevelAuswahl"..i.."Texture2"); |
||
350 | if (i==levelid) then |
||
351 | Gitter:Hide(); |
||
352 | Gitter2:Show(); |
||
353 | else |
||
354 | Gitter2:Hide(); |
||
355 | Gitter:Show(); |
||
356 | end |
||
357 | end |
||
358 | if (level2==1) then |
||
359 | Sudoku_Count1Text:SetText("ID #"..listid1); |
||
360 | elseif (level2==2) then |
||
361 | Sudoku_Count1Text:SetText("ID #"..listid2); |
||
362 | elseif (level2==3) then |
||
363 | Sudoku_Count1Text:SetText("ID #"..listid3); |
||
364 | end |
||
365 | end |
||
366 | end |
||
367 | |||
368 | function Sudoku_LevelID_OnClick(button) |
||
369 | if( button == "LeftButton") then |
||
370 | if (level2==1) then |
||
371 | listid1=math.random(getn(Sudoku_List1A)); |
||
372 | listid=listid1; |
||
373 | elseif (level2==2) then |
||
374 | listid2=math.random(getn(Sudoku_List2A)); |
||
375 | listid=listid2; |
||
376 | elseif (level2==3) then |
||
377 | listid3=math.random(getn(Sudoku_List3A)); |
||
378 | listid=listid3; |
||
379 | end |
||
380 | Sudoku_Count1Text:SetText("ID #"..listid); |
||
381 | end |
||
382 | if( button == "RightButton") then |
||
383 | Sudoku_Count1:Hide(); |
||
384 | Sudoku_EditID:SetText(""); |
||
385 | Sudoku_EditID:Show(); |
||
386 | end |
||
387 | end |
||
388 | |||
389 | function Sudoku_EditListID(lista) |
||
390 | if (lista>"") then |
||
391 | local list=tonumber(lista); |
||
392 | if (level2==1) then |
||
393 | if (list>getn(Sudoku_List1A)) then |
||
394 | list=getn(Sudoku_List1A); |
||
395 | elseif (list<1) then |
||
396 | list=1; |
||
397 | end |
||
398 | listid1=list; |
||
399 | elseif (level2==2) then |
||
400 | if (list>getn(Sudoku_List2A)) then |
||
401 | list=getn(Sudoku_List2A); |
||
402 | elseif (list<1) then |
||
403 | list=1; |
||
404 | end |
||
405 | listid2=list; |
||
406 | elseif (level2==3) then |
||
407 | if (list>getn(Sudoku_List3A)) then |
||
408 | list=getn(Sudoku_List3A); |
||
409 | elseif (list<1) then |
||
410 | list=1; |
||
411 | end |
||
412 | listid3=list; |
||
413 | end |
||
414 | listid=list; |
||
415 | Sudoku_Count1Text:SetText("ID #"..listid); |
||
416 | end |
||
417 | end |
||
418 | |||
419 | function Sudoku_GetEmpty() |
||
420 | local x=0; |
||
421 | local y=0; |
||
422 | local empty=0; |
||
423 | for y=1,9 do |
||
424 | for x=1,9 do |
||
425 | if (Sudoku_GTable[y][x]==0) then |
||
426 | empty=empty+1; |
||
427 | end |
||
428 | end |
||
429 | end |
||
430 | return empty; |
||
431 | end |
||
432 | |||
433 | function Sudoku_GetHelp() |
||
434 | local x=0; |
||
435 | local y=0; |
||
436 | local ret=0; |
||
437 | for y=1,9 do |
||
438 | for x=1,9 do |
||
439 | if (Sudoku_GTableH[y][x]==1) then |
||
440 | ret=ret+1; |
||
441 | end |
||
442 | end |
||
443 | end |
||
444 | return ret; |
||
445 | end |
||
446 | |||
447 | function Sudoku_CheckSuccess() |
||
448 | |||
449 | local x=0; |
||
450 | local y=0; |
||
451 | local success=0; |
||
452 | for y=1,9 do |
||
453 | for x=1,9 do |
||
454 | if (Sudoku_GTable[y][x]~=Sudoku_GTableL[y][x]) then |
||
455 | success=1; |
||
456 | end |
||
457 | end |
||
458 | end |
||
459 | if (success==0) then |
||
460 | sudoplay=1; |
||
461 | Sudoku_Auswahl_OnClick("LeftButton",0); |
||
462 | Sudoku_ViewGameButton:Disable(); |
||
463 | sudoplay=0; |
||
464 | |||
465 | Sudoku_Config[1]={}; |
||
466 | Sudoku_Config[2]={}; |
||
467 | Sudoku_Config[3]={}; |
||
468 | Sudoku_Config[4]={}; |
||
469 | Sudoku_Config[9]={}; |
||
470 | |||
471 | Sudoku_SuccessFarbe(); |
||
472 | end |
||
473 | |||
474 | end |
||
475 | |||
476 | function Sudoku_NewGame() |
||
477 | |||
478 | local x=1; |
||
479 | local y=1; |
||
480 | local sR=""; |
||
481 | local sL=""; |
||
482 | local c=0; |
||
483 | local r=0; |
||
484 | local puzzleL=""; |
||
485 | local puzzleR=""; |
||
486 | |||
487 | level=level2; |
||
488 | Sudoku_Config[5]=level; |
||
489 | |||
490 | if (level==1) then |
||
491 | if( listid1 == 0) then |
||
492 | Sudoku_LevelID_OnClick("LeftButton") |
||
493 | end |
||
494 | puzzleL=Sudoku_List1A[listid1]; |
||
495 | puzzleR=Sudoku_List1B[listid1]; |
||
496 | Sudoku_Config[6]=listid1; |
||
497 | elseif (level==2) then |
||
498 | if( listid2 == 0) then |
||
499 | Sudoku_LevelID_OnClick("LeftButton") |
||
500 | end |
||
501 | puzzleL=Sudoku_List2A[listid2]; |
||
502 | puzzleR=Sudoku_List2B[listid2]; |
||
503 | Sudoku_Config[6]=listid2; |
||
504 | elseif (level==3) then |
||
505 | if( listid3 == 0) then |
||
506 | Sudoku_LevelID_OnClick("LeftButton") |
||
507 | end |
||
508 | puzzleL=Sudoku_List3A[listid3]; |
||
509 | puzzleR=Sudoku_List3B[listid3]; |
||
510 | Sudoku_Config[6]=listid3; |
||
511 | end |
||
512 | |||
513 | for y = 1, 9 do |
||
514 | for x = 1, 9 do |
||
515 | c=c+1; |
||
516 | sL=strsub(puzzleL,c,c); |
||
517 | sR=strsub(puzzleR,c,c); |
||
518 | Sudoku_GTableL[y][x] = tonumber(sL); |
||
519 | Sudoku_GTableC[y][x] = 0; |
||
520 | Sudoku_GTableH[y][x] = 0; |
||
521 | if (sR==".") then |
||
522 | Sudoku_GTable[y][x] = 0; |
||
523 | Sudoku_GTableR[y][x] = 0; |
||
524 | else |
||
525 | Sudoku_GTable[y][x] = tonumber(sR); |
||
526 | Sudoku_GTableR[y][x] = tonumber(sR); |
||
527 | end |
||
528 | end |
||
529 | end |
||
530 | |||
531 | Sudoku_Config[1]=Sudoku_GTable; |
||
532 | Sudoku_Config[2]=Sudoku_GTableR; |
||
533 | Sudoku_Config[3]=Sudoku_GTableL; |
||
534 | Sudoku_Config[4]=Sudoku_GTableC; |
||
535 | Sudoku_Config[9]=Sudoku_GTableH; |
||
536 | |||
537 | hilfecount=0; |
||
538 | Sudoku_Config[8]=hilfecount; |
||
539 | Sudoku_Count3Text:SetText("? : "..hilfecount); |
||
540 | |||
541 | Sudoku_ErstelleGitter(); |
||
542 | Sudoku_GitterFarbe(); |
||
543 | |||
544 | sudoplay=1; |
||
545 | Sudoku_Auswahl_OnClick("LeftButton",0); |
||
546 | Sudoku_ViewGameButton:Enable(); |
||
547 | end |
||
548 | |||
549 | function Sudoku_ErstelleGitter() |
||
550 | zahlencount=0; |
||
551 | for y = 1, 9 do |
||
552 | for x = 1, 9 do |
||
553 | local GitterText = getglobal("Sudoku_Gitter"..y..x.."Text"); |
||
554 | if (Sudoku_GTableR[y][x]==0 and Sudoku_GTableH[y][x]==0) then |
||
555 | GitterText:SetTextColor(Sudoku_Color["textweiss"]["r"],Sudoku_Color["textweiss"]["g"],Sudoku_Color["textweiss"]["b"]); |
||
556 | elseif (Sudoku_GTableR[y][x]==0 and Sudoku_GTableH[y][x]==1) then |
||
557 | GitterText:SetTextColor(Sudoku_Color["textgruen"]["r"],Sudoku_Color["textgruen"]["g"],Sudoku_Color["textgruen"]["b"]); |
||
558 | else |
||
559 | GitterText:SetTextColor(Sudoku_Color["textgelb"]["r"],Sudoku_Color["textgelb"]["g"],Sudoku_Color["textgelb"]["b"]); |
||
560 | end |
||
561 | if (Sudoku_GTable[y][x]==0) then |
||
562 | GitterText:SetText(""); |
||
563 | zahlencount=zahlencount+1; |
||
564 | else |
||
565 | GitterText:SetText(Sudoku_GTable[y][x]); |
||
566 | end |
||
567 | end |
||
568 | end |
||
569 | Sudoku_Config[7]=zahlencount; |
||
570 | Sudoku_Count2Text:SetText(SUDOKU_EMPTYCELLS..zahlencount); |
||
571 | end |
||
572 | |||
573 | function Sudoku_SuccessFarbe() |
||
574 | for y = 1, 9 do |
||
575 | for x = 1, 9 do |
||
576 | local GitterText = getglobal("Sudoku_Gitter"..y..x.."Text"); |
||
577 | GitterText:SetTextColor(Sudoku_Color["textgelb"]["r"],Sudoku_Color["textgelb"]["g"],Sudoku_Color["textgelb"]["b"]); |
||
578 | end |
||
579 | end |
||
580 | end |
||
581 | |||
582 | function Sudoku_Check() |
||
583 | local x=1; |
||
584 | local y=1; |
||
585 | for y=1,9 do |
||
586 | for x=1,9 do |
||
587 | Sudoku_GTableC[y][x]=0; |
||
588 | end |
||
589 | end |
||
590 | for y=1,9 do |
||
591 | for x=1,9 do |
||
592 | Sudoku_CheckZahl(x,y) |
||
593 | end |
||
594 | end |
||
595 | Sudoku_GitterFarbe(); |
||
596 | end |
||
597 | |||
598 | function Sudoku_CheckZahl(x1,y1) |
||
599 | |||
600 | local x=1; |
||
601 | local y=1; |
||
602 | local z=Sudoku_GTable[y1][x1]; |
||
603 | |||
604 | for x = 1,9 do |
||
605 | if (Sudoku_GTable[y1][x]==z and z>0 and x~=x1) then |
||
606 | Sudoku_GTableC[y1][x]=1; |
||
607 | Sudoku_GTableC[y1][x1]=1; |
||
608 | end |
||
609 | end |
||
610 | for y = 1,9 do |
||
611 | if (Sudoku_GTable[y][x1]==z and z>0 and y~=y1) then |
||
612 | Sudoku_GTableC[y][x1]=1; |
||
613 | Sudoku_GTableC[y1][x1]=1; |
||
614 | end |
||
615 | end |
||
616 | |||
617 | if ((x1==1 or x1==2 or x1==3) and (y1==1 or y1==2 or y1==3)) then |
||
618 | for x = 1,3 do |
||
619 | for y=1,3 do |
||
620 | if (Sudoku_GTable[y][x]==z and z>0 and x~=x1 and y~=y1) then |
||
621 | Sudoku_GTableC[y][x]=1; |
||
622 | Sudoku_GTableC[y1][x1]=1; |
||
623 | end |
||
624 | end |
||
625 | end |
||
626 | elseif ((x1==4 or x1==5 or x1==6) and (y1==1 or y1==2 or y1==3)) then |
||
627 | for x = 4,6 do |
||
628 | for y=1,3 do |
||
629 | if (Sudoku_GTable[y][x]==z and z>0 and x~=x1 and y~=y1) then |
||
630 | Sudoku_GTableC[y][x]=1; |
||
631 | Sudoku_GTableC[y1][x1]=1; |
||
632 | end |
||
633 | end |
||
634 | end |
||
635 | elseif ((x1==7 or x1==8 or x1==9) and (y1==1 or y1==2 or y1==3)) then |
||
636 | for x = 7,9 do |
||
637 | for y=1,3 do |
||
638 | if (Sudoku_GTable[y][x]==z and z>0 and x~=x1 and y~=y1) then |
||
639 | Sudoku_GTableC[y][x]=1; |
||
640 | Sudoku_GTableC[y1][x1]=1; |
||
641 | end |
||
642 | end |
||
643 | end |
||
644 | elseif ((x1==1 or x1==2 or x1==3) and (y1==4 or y1==5 or y1==6)) then |
||
645 | for x = 1,3 do |
||
646 | for y=4,6 do |
||
647 | if (Sudoku_GTable[y][x]==z and z>0 and x~=x1 and y~=y1) then |
||
648 | Sudoku_GTableC[y][x]=1; |
||
649 | Sudoku_GTableC[y1][x1]=1; |
||
650 | end |
||
651 | end |
||
652 | end |
||
653 | elseif ((x1==4 or x1==5 or x1==6) and (y1==4 or y1==5 or y1==6)) then |
||
654 | for x = 4,6 do |
||
655 | for y=4,6 do |
||
656 | if (Sudoku_GTable[y][x]==z and z>0 and x~=x1 and y~=y1) then |
||
657 | Sudoku_GTableC[y][x]=1; |
||
658 | Sudoku_GTableC[y1][x1]=1; |
||
659 | end |
||
660 | end |
||
661 | end |
||
662 | elseif ((x1==7 or x1==8 or x1==9) and (y1==4 or y1==5 or y1==6)) then |
||
663 | for x = 7,9 do |
||
664 | for y=4,6 do |
||
665 | if (Sudoku_GTable[y][x]==z and z>0 and x~=x1 and y~=y1) then |
||
666 | Sudoku_GTableC[y][x]=1; |
||
667 | Sudoku_GTableC[y1][x1]=1; |
||
668 | end |
||
669 | end |
||
670 | end |
||
671 | elseif ((x1==1 or x1==2 or x1==3) and (y1==7 or y1==8 or y1==9)) then |
||
672 | for x = 1,3 do |
||
673 | for y=7,9 do |
||
674 | if (Sudoku_GTable[y][x]==z and z>0 and x~=x1 and y~=y1) then |
||
675 | Sudoku_GTableC[y][x]=1; |
||
676 | Sudoku_GTableC[y1][x1]=1; |
||
677 | end |
||
678 | end |
||
679 | end |
||
680 | elseif ((x1==4 or x1==5 or x1==6) and (y1==7 or y1==8 or y1==9)) then |
||
681 | for x = 4,6 do |
||
682 | for y=7,9 do |
||
683 | if (Sudoku_GTable[y][x]==z and z>0 and x~=x1 and y~=y1) then |
||
684 | Sudoku_GTableC[y][x]=1; |
||
685 | Sudoku_GTableC[y1][x1]=1; |
||
686 | end |
||
687 | end |
||
688 | end |
||
689 | elseif ((x1==7 or x1==8 or x1==9) and (y1==7 or y1==8 or y1==9)) then |
||
690 | for x = 7,9 do |
||
691 | for y=7,9 do |
||
692 | if (Sudoku_GTable[y][x]==z and z>0 and x~=x1 and y~=y1) then |
||
693 | Sudoku_GTableC[y][x]=1; |
||
694 | Sudoku_GTableC[y1][x1]=1; |
||
695 | end |
||
696 | end |
||
697 | end |
||
698 | end |
||
699 | end |
||
700 | |||
701 | function Sudoku_GitterFarbe() |
||
702 | local x=1; |
||
703 | local y=1; |
||
704 | for y=1,9 do |
||
705 | for x=1,9 do |
||
706 | local Gitter = getglobal("Sudoku_Gitter"..y..x.."Texture"); |
||
707 | local Gitter2 = getglobal("Sudoku_Gitter"..y..x.."Texture2"); |
||
708 | if (Sudoku_GTableC[y][x]==1) then |
||
709 | Gitter:Hide(); |
||
710 | Gitter2:Show(); |
||
711 | else |
||
712 | Gitter2:Hide(); |
||
713 | Gitter:Show(); |
||
714 | end |
||
715 | --DEFAULT_CHAT_FRAME:AddMessage(Gitter:GetTexture(), 1, 1, 0); |
||
716 | end |
||
717 | end |
||
718 | end |
||
719 | |||
720 | function Sudoku_ZeigeLoesung() |
||
721 | local x=1; |
||
722 | local y=1; |
||
723 | for y = 1, 9 do |
||
724 | for x = 1, 9 do |
||
725 | local Gitter = getglobal("Sudoku_Gitter"..y..x.."Text"); |
||
726 | local GitterT1 = getglobal("Sudoku_Gitter"..y..x.."Texture"); |
||
727 | local GitterT2 = getglobal("Sudoku_Gitter"..y..x.."Texture2"); |
||
728 | Gitter:SetTextColor(Sudoku_Color["textgelb"]["r"],Sudoku_Color["textgelb"]["g"],Sudoku_Color["textgelb"]["b"]); |
||
729 | Gitter:SetText(Sudoku_GTableL[y][x]); |
||
730 | GitterT2:Hide(); |
||
731 | GitterT1:Show(); |
||
732 | end |
||
733 | end |
||
734 | |||
735 | sudoplay=1; |
||
736 | Sudoku_Auswahl_OnClick("LeftButton",0); |
||
737 | Sudoku_ViewGameButton:Disable(); |
||
738 | sudoplay=0; |
||
739 | |||
740 | zahlencount=0; |
||
741 | Sudoku_Count2Text:SetText(SUDOKU_EMPTYCELLS..zahlencount); |
||
742 | Sudoku_Config[7]=zahlencount; |
||
743 | hilfecount=0; |
||
744 | Sudoku_Config[8]=hilfecount; |
||
745 | Sudoku_Count3Text:SetText("? : "..hilfecount); |
||
746 | |||
747 | Sudoku_Config[1]={}; |
||
748 | Sudoku_Config[2]={}; |
||
749 | Sudoku_Config[3]={}; |
||
750 | Sudoku_Config[4]={}; |
||
751 | Sudoku_Config[9]={}; |
||
752 | end |