vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 function Tetris_Load ()
2 --allgemeine variablen
3 if (not Tetris) then
4 Tetris={ };
5 Tetris["game"]= { };
6 Tetris["game"]["feld"]= { };
7 Tetris["game"]["s_temp"]= { };
8 Tetris["game"]["s_temp"]["temp"]= { };
9 Tetris["game"]["s_NS_temp"]= { };
10 Tetris["highscore"]= { };
11 Tetris["options"]= { };
12 Tetris["options"]["stones"]= { };
13 --spiel typ
14 Tetris["game"]["gametyp"]="ms-dos";
15 --x spalten
16 Tetris["game"]["x"]=10;
17 --y zeilen
18 Tetris["game"]["y"]=20;
19 --x NS spalten
20 Tetris["game"]["NS_x"]=4;
21 --y NS zeilen
22 Tetris["game"]["NS_y"]=3;
23 --nummer des nächsten bausteins
24 Tetris["game"]["s_next"]=0;
25 --nummer des aktuellen bausteins
26 Tetris["game"]["s"]=0;
27 --anz_steine des aktuellen bausteins
28 Tetris["game"]["s_anz_s"]=0;
29 --anz_lagen aktuellen bausteins
30 Tetris["game"]["s_anz_l"]=0;
31 --aktuelle lage des bausteins
32 Tetris["game"]["s_lage"]=0;
33 --x pos des hauptbausteins
34 Tetris["game"]["s_pos_x"]=0;
35 --y pos des hauptbausteins
36 Tetris["game"]["s_pos_y"]=0;
37 --timer
38 Tetris["game"]["timer"] = 0.5;
39 --läuft der timer?
40 Tetris["game"]["timer_go"] = 0;
41 --scores
42 Tetris["game"]["score"] = {};
43 Tetris["game"]["score"]["points"]=0;
44 Tetris["game"]["score"]["lvl"]=0;
45 Tetris["game"]["score"]["linie"]=0;
46 --GF_Gamewindow-------------------
47 --button höhe des gamewindow button
48 Tetris["options"]["b_hohe"]=20;
49 --button breite des gamewindow button
50 Tetris["options"]["b_breite"]=20;
51 --x randabstand des gamewindow
52 Tetris["options"]["r_abstand_x"]=15;
53 --y randabstand des gamewindow
54 Tetris["options"]["r_abstand_y"]=15;
55 --x offset des gamewindow
56 Tetris["options"]["r_a-faktor_x"]=180;
57 --y offset des gamewindow
58 Tetris["options"]["r_a-faktor_y"]=25;
59 ----------------------------------
60 ----GF_NS_Window------------------
61 --button höhe des gamewindow button
62 Tetris["options"]["b_NS_hohe"]=20;
63 --button breite des gamewindow button
64 Tetris["options"]["b_NS_breite"]=20;
65 --x randabstand des gamewindow
66 Tetris["options"]["r_NS_abstand_x"]=15;
67 --y randabstand des gamewindow
68 Tetris["options"]["r_NS_abstand_y"]=15;
69 --x offset des NS window
70 Tetris["options"]["r_a_NS-faktor_x"]=0;
71 --y offset des NS window
72 Tetris["options"]["r_a_NS-faktor_y"]=18;
73 -----------------------------------
74 --highscore
75 Tetris["highscore"]["ms_dos"]= 0;
76 --max. verschiedene steine
77 Tetris["options"]["max_s"]=7;
78 --texturenset (ordnername)
79 Tetris["options"]["texturenset"]="color";
80 --version dieses scriptes
81 Tetris["version"]= 0.1;
82 -- im spiel?
83 Tetris["ingame"]=0;
84 Tetris["debug"]= 0;
85 end
86  
87 --update
88 if (Tetris["version"]==0.1) then
89 Tetris["version"]=0.5;
90 --anz x
91 Tetris["options"]["breite"]=10;
92 --anz y
93 Tetris["options"]["hohe"]=20;
94 --random lines
95 Tetris["options"]["r_lines"]=1;
96 Tetris["options"]["r_lines_activ"]=1;
97 --stonelist
98 --max. verschiedene steine
99 Tetris["options"]["max_s"]=46;
100 Tetris["options"]["stones"] = { };
101 --table füllen
102 for num = 1, Tetris["options"]["max_s"] do
103 table.insert(Tetris["options"]["stones"],1)
104 end
105 Tetris["ingame"]=0;
106 Tetris["game"]["gametyp"]=1;
107 Tetris["options"]["gametyp"]=1;
108 Tetris["options"]["SOF_s_show"]=1;
109 end
110 if (Tetris["version"]==0.5) then
111 Tetris["version"]=0.6;
112 --texturenset (ordnername)
113 Tetris["options"]["texturenset"]=1;
114 end
115 if (Tetris["version"]==0.6) then
116 Tetris["version"]=0.7;
117 --max. verschiedene steine
118 Tetris["options"]["max_s"]=57;
119 Tetris["options"]["stones"] = { };
120 --table füllen
121 for num = 1, Tetris["options"]["max_s"] do
122 table.insert(Tetris["options"]["stones"],1)
123 end
124 end
125 if (Tetris["version"]==0.7) then
126 Tetris["version"]=0.8;
127 --max. verschiedene steine
128 Tetris["options"]["max_s"]=60;
129 Tetris["options"]["stones"] = { };
130 --table füllen
131 for num = 1, Tetris["options"]["max_s"] do
132 table.insert(Tetris["options"]["stones"],1)
133 end
134 --neue gametyps
135 Tetris["highscore"]["gameboy"]= 0;
136 Tetris["highscore"]["retris"]= 0;
137 --button grösse
138 Tetris["options"]["b_hohe"] = 15;
139 Tetris["options"]["b_breite"] = 15;
140 --checkbox gost
141 Tetris["options"]["gost"]=1;
142 end
143 if (Tetris["version"]==0.8) then
144 Tetris["version"]=0.9;
145 --checkbox musik
146 Tetris["options"]["musik"]=1;
147 --checkbox sound
148 Tetris["options"]["sound"]=1;
149 --musik track
150 Tetris["options"]["musik-track"]=1;
151 end
152 if (Tetris["version"]==0.9) then
153 Tetris["version"]=1.1;
154 end
155 if (Tetris["version"]==1.1) then
156 Tetris["version"]=1.2;
157 --checkbox mous
158 Tetris["options"]["mous"]=1;
159 --neue gametyps
160 Tetris["highscore"]["highest_hopes"]= 0;
161 end
162 --slash command
163 SLASH_Tetris1 = "/tetris";
164 SlashCmdList["Tetris"] = function(msg)
165 Tetris_SlashCommand(msg);
166 end
167 Tetris_sprachesetzen();
168 end
169  
170 function Tetris_SlashCommand(msg)
171 Tetris_MF_Toggle();
172 end
173  
174 function Tetris_stone_move (r)
175 --r = move-richtung
176 -- u = drehen
177 -- d = runter (instant)
178 -- dd= runter (einen schritt)
179 -- l = links
180 -- r = rechts
181 -- oder = timer wenn zeit down
182 --variablen holen und setzen
183 local anz_l = Tetris["game"]["s_anz_l"];
184 local s_l = Tetris["game"]["s_lage"];
185 local pos_x = Tetris["game"]["s_pos_x"];
186 local pos_y = Tetris["game"]["s_pos_y"];
187 --backup der nötigen variablen erstellen
188 local b_s_l = Tetris["game"]["s_lage"];
189 local b_pos_x = Tetris["game"]["s_pos_x"];
190 local b_pos_y = Tetris["game"]["s_pos_y"];
191  
192 if (Tetris["ingame"]==0) then
193 return;
194 end
195  
196 --stein drehen
197 if (r == "u") then
198 if not (anz_l == 1) then
199 s_l = s_l + 1;
200 if (s_l > anz_l) then
201 s_l = 1;
202 end
203 end
204 end
205 --stein nach links
206 if (r == "l") then
207 pos_x = pos_x-1;
208 end
209 --stein nach rechts
210 if (r == "r") then
211 pos_x = pos_x+1;
212 end
213 --stein nach unten
214 if (r == "d") or (r == "timer") or (r == "dd") then
215 pos_y = pos_y-1;
216 end
217 --änderungen speichern
218 Tetris["game"]["s_lage"] = s_l
219 Tetris["game"]["s_pos_x"] = pos_x;
220 Tetris["game"]["s_pos_y"] = pos_y;
221 --neue position der steine berechnen
222 Tetris_falling_stone_coming_soon ();
223 --test laufen lassen und reagieren
224 if (Tetris_stone_outside_test()==true) then
225 if (r == "d") or (r =="timer") or (r == "dd") then
226 --stein kann nicht weiter
227 --wenn scroll down wie timer handeln
228 if (r == "dd") then
229 r = "timer"
230 end
231 Tetris_stone_is_down (r);
232  
233 else
234 --gemachte änderungen rückgängig machen
235 Tetris["game"]["s_lage"]=b_s_l;
236 Tetris["game"]["s_pos_x"]=b_pos_x;
237 Tetris["game"]["s_pos_y"]=b_pos_y;
238 end
239 --test war false --> stein bewegen
240 else
241 if ((r ~= "d") and (r ~= "timer") and (r ~= "dd")) then
242 Tetris_gost_stone ();
243 end
244 --aktuell angezeigter stein löschen
245 Tetris_GF_gamewindow_falling_stone_Hide ();
246 --neue position der steine speichern
247 Tetris_falling_stone ();
248 --neue position des bausteins anzeigen
249 Tetris_GF_gamewindow_falling_stone_Show ();
250 --timer starten, wenn nötig
251 if (r == "timer") then
252 Tetris_timer_go ();
253 end
254 --für instant drop nochmal durchrechnen
255 if (r == "d") then
256 Tetris_stone_move ("d");
257 end
258 --sound
259 if ((r ~= "d") and (r ~= "timer") and (r ~= "dd")) then
260 Tetris_play_sound (r);
261 end
262 end
263 end
264  
265 --fallender baustein ist unten angekommen
266 function Tetris_stone_is_down (r)
267 --r = wie ist der stein nach unten gekommen?
268 -- d = instant drop
269 -- timer = normaler fall durch timer
270 local gametyp = Tetris["game"]["gametyp"];
271 local custom = Tetris["game"]["gametypc"];
272 if (custom == 1) then
273 Tetris_stone_is_down_custom (r);
274 else
275 if (gametyp == 1) then
276 Tetris_stone_is_down_ms_dos (r);
277 end
278 if (gametyp == 2) then
279 Tetris_stone_is_down_gameboy (r);
280 end
281 if (gametyp == 3) then
282 Tetris_stone_is_down_retris (r);
283 end
284 if (gametyp == 4) then
285 Tetris_stone_is_down_highest_hopes (r);
286 end
287 end
288 end
289  
290  
291 function Tetris_new_stone ()
292 --stein generieren anzeigen
293 Tetris_release_stone ();
294 Tetris_falling_stone_coming_soon ();
295 Tetris_falling_stone ();
296 Tetris_GF_gamewindow_falling_stone_Show ();
297 --GF_NS Frame
298 Tetris_falling_stone_coming_soon_NS ();
299 Tetris_GF_NS_Clear ();
300 Tetris_GF_NS_Show ();
301 --Score Updaten
302 Tetris_GF_Text_Score_Update ();
303 --game over?
304 if (Tetris_stone_outside_test()==true) then
305 Tetris_gameover ();
306 else
307 Tetris_timer_go ();
308 end
309 --chache für gost-stone löschen
310 Tetris["game"]["s_gost"]["temp"] = { };
311 if (Tetris["debug"]==1) then
312 DEFAULT_CHAT_FRAME:AddMessage("Delet saved Gost (NewStone)");
313 end
314 Tetris_gost_stone ();
315 --wenn maussteuerung aktiv, stein gleich zur maus verschieben
316 if (Tetris["options"]["mous"] == 1) and (Tetris["game"]["mous"] ~= nil) then
317 Tetris_mous_OnPieceEnter (1)
318 end
319 end
320  
321 function Tetris_timer_go ()
322 --Chronos.unscheduleByName (Tetris_stone_timer);
323 --timer dem lvl entsprechend holen
324 local timer = Tetris["game"]["timer"];
325 Timex:AddNamedSchedule("Tetris_stone_timer", timer, nil, 1, Tetris_timer_end)
326 end
327  
328 function Tetris_timer_toggle ()
329 --timer abgeschaltet dann anschalten
330 if (Timex:NamedScheduleCheck("Tetris_stone_timer") == nil) then
331 Tetris["game"]["timer_go"] = 1;
332 Tetris_timer_go ();
333 else
334 --timer läuft dann stoppen
335 Timex:DeleteNamedSchedule("Tetris_stone_timer");
336 Tetris["game"]["timer_go"] = 0;
337 end
338 --anzeige updaten
339 Tetris_GF_timer_Update ();
340 end
341  
342 function Tetris_timer_end ()
343 --stein nach unten bewegen
344 Tetris_stone_move ("timer");
345 end
346  
347 function Tetris_gf_buttonclick (b)
348 --b = button der gedrückt wurde
349 local gametyp = Tetris["game"]["gametyp"];
350 local custom = Tetris["game"]["gametypc"];
351 if (b == "newgame") then
352 if (custom == 1) then
353 Tetris_newgame_custom ();
354 else
355 if (gametyp == 1) then
356 Tetris_newgame_ms_dos ();
357 end
358 if (gametyp == 2) then
359 Tetris_newgame_gameboy ();
360 end
361 if (gametyp == 3) then
362 Tetris_newgame_retris ();
363 end
364 if (gametyp == 4) then
365 Tetris_newgame_highest_hopes ();
366 end
367 end
368 end
369 if (b == "pause") then
370 Tetris_timer_toggle ();
371 end
372 if (b == "close") then
373 if ( Tetris["game"]["timer_go"] == 1) then
374 Tetris_timer_toggle ();
375 end
376 Tetris_GF_Toggle();
377 Tetris_MF_Toggle();
378 end
379 end
380  
381 function Tetris_gameover ()
382 local gametyp = Tetris["game"]["gametyp"];
383 local custom = Tetris["game"]["gametypc"];
384 --sound
385 Tetris_play_sound ("go");
386 if (custom == 1) then
387 Tetris_gameover_custom ();
388 else
389 if (gametyp == 1) then
390 Tetris_gameover_ms_dos ();
391 end
392 if (gametyp == 2) then
393 Tetris_gameover_gameboy ();
394 end
395 if (gametyp == 3) then
396 Tetris_gameover_retris ();
397 end
398 if (gametyp == 4) then
399 Tetris_gameover_highest_hopes ();
400 end
401 end
402 end
403  
404 function Tetris_gameresume ()
405 local gametyp = Tetris["game"]["gametyp"];
406 if (gametyp == 1) then
407 Tetris_gameresume_ms_dos ();
408 end
409 if (gametyp == 2) then
410 Tetris_gameresume_gameboy ();
411 end
412 if (gametyp == 3) then
413 Tetris_gameresume_retris ();
414 end
415 if (gametyp == 4) then
416 Tetris_gameresume_highest_hopes ();
417 end
418 end
419  
420 function Tetris_gametyp_list_create()
421 Tetris_gametyp_list = {
422 Tetris_UBE_gt_ms_dos,
423 Tetris_UBE_gt_gameboy,
424 Tetris_UBE_gt_retris,
425 Tetris_UBE_gt_highest_hopes,
426 };
427 end
428  
429 function Tetris_textur_list_create()
430 Tetris_textur_list = {
431 Tetris_UBE_tex_color,
432 Tetris_UBE_tex_bw,
433 Tetris_UBE_tex_wow,
434 };
435 end
436  
437 function Tetris_musik_list_create()
438 Tetris_musik_list = {
439 Tetris_UBE_musik_random,
440 Tetris_UBE_musik_a,
441 Tetris_UBE_musik_b,
442 Tetris_UBE_musik_c,
443 Tetris_UBE_musik_musik,
444 Tetris_UBE_musik_remix,
445 };
446 end
447  
448 function Tetris_GF_Titeltext_Update ()
449 --variablen holen und setzen
450 local UBE_tetris = Tetris_UBE_GF_Titeltext;
451 local UBE_msdos = Tetris_UBE_gt_ms_dos;
452 local UBE_gameboy = Tetris_UBE_gt_gameboy;
453 local UBE_retris = Tetris_UBE_gt_retris;
454 local UBE_custom = Tetris_UBE_gt_custom;
455 local UBE_highest_hopes = Tetris_UBE_gt_highest_hopes;
456 local gametyp = Tetris["game"]["gametyp"];
457 local custom = Tetris["game"]["gametypc"];
458 if (custom == 1) then
459 Tetris_GF_Titeltext:SetText(UBE_tetris.." "..UBE_custom);
460 else
461 if (gametyp == 1) then
462 Tetris_GF_Titeltext:SetText(UBE_tetris.." "..UBE_msdos);
463 end
464 if (gametyp == 2) then
465 Tetris_GF_Titeltext:SetText(UBE_tetris.." "..UBE_gameboy);
466 end
467 if (gametyp == 3) then
468 Tetris_GF_Titeltext:SetText(UBE_tetris.." "..UBE_retris);
469 end
470 if (gametyp == 4) then
471 Tetris_GF_Titeltext:SetText(UBE_tetris.." "..UBE_highest_hopes);
472 end
473 end
474 end
475  
476 function Tetris_GF_highscore_Show ()
477 --variablen holen und setzen
478 local UBE_hs = Tetris_UBE_GF_Text_Highscore;
479 local gametyp = Tetris["game"]["gametyp"];
480 local UBE_msdos = Tetris_UBE_gt_ms_dos;
481 local UBE_gameboy = Tetris_UBE_gt_gameboy;
482 local UBE_retris = Tetris_UBE_gt_retris;
483 local UBE_highest_hopes = Tetris_UBE_gt_highest_hopes;
484 local custom = Tetris["game"]["gametypc"];
485 local UBE_gametyp = Tetris_UBE_GF_Text_Gametyp
486 if (custom == 1) then
487 if (gametyp == 1) then
488 Tetris_GF_Text_Highscore:SetText(UBE_gametyp.." "..UBE_msdos);
489 end
490 if (gametyp == 2) then
491 Tetris_GF_Text_Highscore:SetText(UBE_gametyp.." "..UBE_gameboy);
492 end
493 if (gametyp == 3) then
494 Tetris_GF_Text_Highscore:SetText(UBE_gametyp.." "..UBE_retris);
495 end
496 if (gametyp == 4) then
497 Tetris_GF_Text_Highscore:SetText(UBE_gametyp.." "..UBE_highest_hopes);
498 end
499 else
500 if (gametyp == 1) then
501 local highscore = Tetris["highscore"]["ms_dos"]
502 Tetris_GF_Text_Highscore:SetText(UBE_hs.." "..highscore);
503 end
504 if (gametyp == 2) then
505 local highscore = Tetris["highscore"]["gameboy"]
506 Tetris_GF_Text_Highscore:SetText(UBE_hs.." "..highscore);
507 end
508 if (gametyp == 3) then
509 local highscore = Tetris["highscore"]["retris"]
510 Tetris_GF_Text_Highscore:SetText(UBE_hs.." "..highscore);
511 end
512 if (gametyp == 4) then
513 local highscore = Tetris["highscore"]["highest_hopes"]
514 Tetris_GF_Text_Highscore:SetText(UBE_hs.." "..highscore);
515 end
516 end
517 end
518  
519 function Tetris_newgame ()
520 local game = Tetris["game"]["next_game"];
521 if (game == "ms_dos") then
522 Tetris_newgame_ms_dos ();
523 Tetris_GF_Toggle();
524 end
525 if (game == "retris") then
526 Tetris_newgame_retris ();
527 Tetris_GF_Toggle();
528 end
529 if (game == "gameboy") then
530 Tetris_newgame_gameboy ();
531 Tetris_GF_Toggle();
532 end
533 if (game == "highest_hopes") then
534 Tetris_newgame_highest_hopes ();
535 Tetris_GF_Toggle();
536 end
537 if (game == "custom") then
538 Tetris_CF_Toggle();
539 end
540 end