4 * Copyright (C) 2006-2008 Matteo Nastasi
5 * mailto: nastasi@alternativeoutput.it
6 * matteo.nastasi@milug.org
7 * web: http://www.alternativeoutput.it
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details. You should have received a
18 * copy of the GNU General Public License along with this program; if
19 * not, write to the Free Software Foundation, Inc, 59 Temple Place -
20 * Suite 330, Boston, MA 02111-1307, USA.
26 function background_set()
28 $("bg").style.backgroundImage = 'url("img/brisk_table_sand'+table_pos+'.jpg")';
31 /* Stat: TABLE Subst: ASTA */
32 function act_asta(card,pnt)
34 send_mesg("asta|"+card+"|"+pnt);
37 var asta_xarr = new Array(0,66,132);
39 /* TODO: impostare gli onclick */
40 function dispose_asta(idx, pnt, nopoint)
44 var lng = langtolng(g_lang);
46 for (i = 0 ; i < 10 ; i++) {
49 btn.src = "img/astapasso"+(pnt >= 0 ? "" : "_ro")+lng+".png";
50 btn.style.cursor = (pnt >= 0 ? "pointer" : "default");
54 btn.src = "img/asta"+i+(pnt >= 0 ? "" : "_ro")+lng+".png";
55 btn.style.cursor = (pnt >= 0 ? "pointer" : "default");
59 btn.style.left = asta_xarr[i % 3];
61 btn.style.left = asta_xarr[(i+1) % 3];
63 btn.style.top = parseInt(i / 3) * 50 + (i == 9 ? 0 : 1);
66 eval("btn.onclick = function () { act_asta("+pass+",61); }");
67 btn.style.cursor = "pointer";
71 btn.style.cursor = "default";
77 btn.style.left = asta_xarr[i % 3];
78 btn.style.top = parseInt(i / 3) * 50 - 2;
79 // btn.style.visibility = "visible";
82 var rpnt = (pnt < 0 ? -pnt : pnt);
83 btn.value = (rpnt < 61 ? 61 : (rpnt > 120 ? 120 : rpnt));
86 btn.style.left = asta_xarr[i % 3];
87 btn.style.top = 25 + parseInt(i / 3) * 50 - 1;
88 btn.src = "img/astaptsub"+(pnt >= 0 ? "" : "_ro")+lng+".png";
89 btn.style.cursor = (pnt >= 0 ? "pointer" : "default");
91 btn.onclick = function () { act_asta(9,$("astapt").value); };
92 btn.style.cursor = "pointer";
96 btn.style.cursor = "default";
101 btn = $("astapasso");
102 btn.style.left = asta_xarr[i % 3];
103 btn.style.top = parseInt(i / 3) * 50;
104 btn.src = "img/astapashalf"+(pnt >= 0 ? "" : "_ro")+lng+".png";
105 btn.style.cursor = (pnt >= 0 ? "pointer" : "default");
107 btn.onclick = function () { act_asta(-1,0); };
113 btn = $("astalascio");
114 btn.style.left = asta_xarr[i % 3];
115 btn.style.top = parseInt(i / 3) * 50 + 24;
116 btn.src = "img/astalascio"+lng+".png";
117 btn.style.visibility = "visible";
118 btn.onclick = function () { safelascio(); };
121 btn = $("astapasso");
122 btn.style.left = asta_xarr[i % 3];
123 btn.style.top = parseInt(i / 3) * 50;;
124 btn.src = "img/astapasso"+(pnt >= 0 ? "" : "_ro")+lng+".png";
125 btn.style.cursor = (pnt >= 0 ? "pointer" : "default");
127 btn.onclick = function () { act_asta(-1,0); };
133 btn = $("astalascio");
134 btn.style.visibility = "hidden";
137 // btn.style.visibility = "visible";
138 $("asta").style.visibility = "visible";
141 function asta_pnt_set(pnt)
144 var rpnt = (pnt < 0 ? -pnt : pnt);
145 btn.value = (rpnt < 61 ? 61 : (rpnt > 120 ? 120 : rpnt));
150 $("asta").style.visibility = "hidden";
153 function choose_seed(card)
157 $("asta").style.visibility = "hidden";
158 $("astalascio").style.visibility = "hidden";
159 $("chooseed").style.visibility = "visible";
160 for (i = 0 ; i < 4 ; i++) {
161 $("seed"+i).src = "img/"+i+""+card+".png";
163 eval("seed.onclick = function () { act_choose("+i+""+card+"); };");
167 var astat_suffix = new Array("","_ea","_ne","_nw","_we");
169 function show_astat(zer,uno,due,tre,qua)
171 var astat = new Array(zer,uno,due,tre,qua);
172 var lng = langtolng(g_lang);
174 for (i = 0 ; i < PLAYERS_N ; i++) {
175 idx = (PLAYERS_N + i - table_pos) % PLAYERS_N;
177 if (astat[i] == -2) {
178 $("public"+astat_suffix[idx]).style.visibility = "hidden";
180 else if (astat[i] == -1) {
181 $("public"+astat_suffix[idx]).style.visibility = "visible";
182 $("pubacard"+astat_suffix[idx]).src = "img/astapasso"+lng+".png";
183 $("pubapnt"+astat_suffix[idx]).innerHTML = "";
184 $("pubapnt"+astat_suffix[idx]).style.visibility = "hidden";
186 else if (astat[i] <= 10) {
187 $("public"+astat_suffix[idx]).style.visibility = "visible";
188 $("pubacard"+astat_suffix[idx]).src = "img/asta"+astat[i]+lng+".png";
189 $("pubapnt"+astat_suffix[idx]).style.visibility = "hidden";
191 else if (astat[i] <= 120) {
192 $("public"+astat_suffix[idx]).style.visibility = "visible";
193 $("pubacard"+astat_suffix[idx]).src = "img/asta9"+lng+".png";
194 $("pubapnt"+astat_suffix[idx]).style.visibility = "inherit"; // XXX VISIBLE
195 $("pubapnt"+astat_suffix[idx]).innerHTML = astat[i];
201 function table_init() {
202 var sux = new Array("", "_ea", "_ne", "_nw", "_we");
204 // console.log("table_init");
207 $("asta").style.visibility = "hidden";
208 $("caller").style.visibility = "hidden";
209 show_astat(-2,-2,-2,-2,-2);
210 for (i=0 ; i < 8 ; i++) {
211 Drag.init($("card" + i), card_mouseup_cb);
212 for (e = 0 ; e < PLAYERS_N ; e++)
213 $("card"+sux[e]+i).style.visibility = "hidden";
215 for (i=0 ; i < PLAYERS_N ; i++) {
216 // console.log("shut: "+"takes"+sux[i]);
217 $("takes"+sux[i]).style.visibility = "hidden";
220 for (i = 0 ; i < 8 ; i++) {
230 function act_choose(card)
232 send_mesg("choose|"+card);
235 function act_play(card,x,y)
237 send_mesg("play|"+card+"|"+x+"|"+y);
240 function act_tableinfo()
242 send_mesg("tableinfo");
245 function act_exitlock()
247 send_mesg("exitlock");
250 function safelogout()
255 res = window.confirm("Sei sicuro di volere abbandonare la partita?\nATTENZIONE: se esci adesso senza il consenso degli altri giocatori non potrai sederti ai tavoli per "+(Math.floor(EXIT_BAN_TIME/60))+" minuti.");
257 res = window.confirm("Sei sicuro di volere abbandonare la partita?");
259 act_logout(g_exitlock);
262 function act_reload()
264 window.onunload = null;
265 window.onbeforeunload = null;
266 document.location.reload();
269 function set_names(so,ea,ne,nw,we)
272 $("name").innerHTML = italizer(so);
273 $("name").title = unescapeHTML(so[1]);
274 $("name_ea").innerHTML = italizer(ea);
275 $("name_ea").title = unescapeHTML(ea[1]);
276 $("name_ne").innerHTML = italizer(ne);
277 $("name_ne").title = unescapeHTML(ne[1]);
278 $("name_nw").innerHTML = italizer(nw);
279 $("name_nw").title = unescapeHTML(nw[1]);
280 $("name_we").innerHTML = italizer(we);
281 $("name_we").title = unescapeHTML(we[1]);