diff options
Diffstat (limited to 'JBriscola/all_versions/0.2/0.2.1/src/Main.java')
| -rwxr-xr-x | JBriscola/all_versions/0.2/0.2.1/src/Main.java | 1101 |
1 files changed, 1101 insertions, 0 deletions
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/Main.java b/JBriscola/all_versions/0.2/0.2.1/src/Main.java new file mode 100755 index 0000000..9c0cacf --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/Main.java | |||
| @@ -0,0 +1,1101 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2009 Sebastiano Tronto <sebastiano@luganega.org> | ||
| 3 | |||
| 4 | This file is part of JBriscola. | ||
| 5 | |||
| 6 | JBriscola is free software; you can redistribute it and/or modify | ||
| 7 | it under the terms of the GNU General Public License as published by | ||
| 8 | the Free Software Foundation; either version 2 of the License, or | ||
| 9 | (at your option) any later version. | ||
| 10 | |||
| 11 | JBriscola is distributed in the hope that it will be useful, | ||
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | GNU General Public License for more details. | ||
| 15 | |||
| 16 | You should have received a copy of the GNU General Public License | ||
| 17 | along with JBriscola; if not, write to the Free Software | ||
| 18 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 19 | |||
| 20 | */ | ||
| 21 | |||
| 22 | import java.io.*; | ||
| 23 | import java.util.*; | ||
| 24 | import javax.swing.*; | ||
| 25 | import java.awt.*; | ||
| 26 | |||
| 27 | public class Main { | ||
| 28 | public static int semeBriscola, punteggio, punteggioCPU, mano, cartaDaPescare, cartaDaGiocare; | ||
| 29 | public static boolean toccaAllaCPU = false; | ||
| 30 | public static boolean CPUHaGiocato = false; | ||
| 31 | public static boolean haGiocatoPrima = true; | ||
| 32 | public static boolean sound = true; | ||
| 33 | public static boolean keys = true; | ||
| 34 | public static Frame frame; | ||
| 35 | public static Color color = new Color( 0, 150, 0 ); | ||
| 36 | public static String version = "0.2.1"; | ||
| 37 | public static String stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 38 | public static String stringaPrimaGioca = "Prima Gioca!"; | ||
| 39 | public static String stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 40 | public static String stringaVinto = "Hai Vinto!"; | ||
| 41 | public static String stringaPerso = "Hai Perso"; | ||
| 42 | public static String stringaPareggio = "Pareggio"; | ||
| 43 | public static String stringaGiocatore = "Giocatore: "; | ||
| 44 | public static String stringaComputer = "\nComputer: "; | ||
| 45 | public static String stringaNuovaPartita = "Nuova Partita"; | ||
| 46 | public static String stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 47 | public static String stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 48 | public static String stringaSi = "Si"; | ||
| 49 | public static String stringaNo = "No"; | ||
| 50 | public static String stringaOpzioni = "Opzioni..."; | ||
| 51 | public static String stringaEsci = "Esci"; | ||
| 52 | public static String stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 53 | public static String stringaLingua = "Lingua"; | ||
| 54 | public static String stringaAnnulla = "Annulla"; | ||
| 55 | public static String stringaIt = "Italiano"; | ||
| 56 | public static String stringaLa = "Latino"; | ||
| 57 | public static String stringaBL = "Dialetto Bellunese"; | ||
| 58 | public static String stringaBV = "Dialetto Basso Veneto"; | ||
| 59 | public static String stringaNecessarioRiavviare = "E' necessario riavviare JBriscola se sono state\nmodificate impostazioni riguardanti la lingua.\nAlcune parti saranno comunque tradotte prima."; | ||
| 60 | public static String stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 61 | public static String stringaInformazioni = "Informazioni"; | ||
| 62 | public static String stringaInformazioni2 = "JBriscola e' un gioco di briscola per pc scritto in java ideato\ne realizzato da Sebastiano Tronto. Il gioco viene rilasciato sotto licenza GNU/Gpl versione 2 o successive; questo permette\npotenzialmente a chiunque di modificare il gioco partendo dal codice sorgente del programma. Se non avete ricevuto i sorgenti\nassieme al gioco, potete richiedermeli con un'e-mail a sebastiano@luganega.org.\n\nJBriscola version " + version + "\nCopyright 2009 Sebastiano Tronto, license GNU/Gpl 2.0 or later\nE-mail: sebastiano@luganega.org"; | ||
| 63 | public static String stringaSuono = "Effetti Sonori"; | ||
| 64 | public static String stringaPunteggio = "Punteggio"; | ||
| 65 | public static String stringaSfondo = "Sfondo"; | ||
| 66 | public static String stringaTasti = "Tasti rapidi"; | ||
| 67 | public static String stringaAggiornamenti = "Cerca aggiornamenti"; | ||
| 68 | public static String stringaAggiornamentiSi = "Aggiornamento disponibile: "; | ||
| 69 | public static String stringaAggiornamentiNo = "Nessun aggiornamento disponibile"; | ||
| 70 | public static String stringaScarica = "E' possibile scaricare la versione più recente\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 71 | public static String stringaNoInternet = "Errore: nessuna connessione internet"; | ||
| 72 | public static String stringaTasti2 = "1 Gioca la prima carta\n2 Gioca la seconda carta\n3 Gioca la terza carta\nF1 Visualizza questo messaggio\nF2 " + stringaNuovaPartita + "\nF3 " + stringaOpzioni + "\nF4 " + stringaPunteggio + "\nF5 " + stringaInformazioni + "\nF6 " + stringaAggiornamenti + "\nq " + stringaEsci; | ||
| 73 | public static String lang, soundString, keysString; | ||
| 74 | public static File[] suoni = new File[6]; | ||
| 75 | public static File suonoVinto, suonoPerso, suonoPareggio; | ||
| 76 | public static void main( String args[] ) { | ||
| 77 | settaOpzioni(); | ||
| 78 | frame = new Frame(); | ||
| 79 | frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); | ||
| 80 | frame.setResizable( false ); | ||
| 81 | frame.setSize( 600, 600 ); | ||
| 82 | frame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 600) / 2, | ||
| 83 | (Toolkit.getDefaultToolkit().getScreenSize().height - 600) / 2); | ||
| 84 | frame.setVisible( true ); | ||
| 85 | } | ||
| 86 | public void mischia() { | ||
| 87 | mano = 0; | ||
| 88 | punteggio = 0; | ||
| 89 | punteggioCPU = 0; | ||
| 90 | cartaDaPescare = 6; | ||
| 91 | ImageIcon aux; | ||
| 92 | frame.mazzo = true; | ||
| 93 | toccaAllaCPU = false; | ||
| 94 | CPUHaGiocato = false; | ||
| 95 | haGiocatoPrima = true; | ||
| 96 | for ( int i = 0, k = 0; i < 10; i++ ) | ||
| 97 | for ( int j = 0; j < 4; j++, k++ ) | ||
| 98 | frame.arrayCarteMescolate[k] = frame.arrayCarte[i][j]; | ||
| 99 | for ( int i = 0; i < 391; i++ ) { | ||
| 100 | double a = Math.random() * 40; | ||
| 101 | int x = (int) a; | ||
| 102 | double b = Math.random() * 40; | ||
| 103 | int y = (int) b; | ||
| 104 | aux = frame.arrayCarteMescolate[x]; | ||
| 105 | frame.arrayCarteMescolate[x] = frame.arrayCarteMescolate[y]; | ||
| 106 | frame.arrayCarteMescolate[y] = aux; | ||
| 107 | } | ||
| 108 | char auxChar[] = frame.arrayCarteMescolate[39].toString().toCharArray(); | ||
| 109 | semeBriscola = auxChar[auxChar.length-5] - 49; | ||
| 110 | frame.carteInMano[0] = frame.arrayCarteMescolate[0]; | ||
| 111 | frame.carteInMano[1] = frame.arrayCarteMescolate[1]; | ||
| 112 | frame.carteInMano[2] = frame.arrayCarteMescolate[2]; | ||
| 113 | frame.carteCPU[0] = frame.arrayCarteMescolate[3]; | ||
| 114 | frame.carteCPU[1] = frame.arrayCarteMescolate[4]; | ||
| 115 | frame.carteCPU[2] = frame.arrayCarteMescolate[5]; | ||
| 116 | frame.ultimaCarta = frame.arrayCarteMescolate[39]; | ||
| 117 | frame.giocata[0] = null; | ||
| 118 | frame.giocata[1] = null; | ||
| 119 | } | ||
| 120 | public void giocaCPU() { | ||
| 121 | if ( mano < 16 ) { | ||
| 122 | if ( frame.giocata[0] == null ) { | ||
| 123 | if ( vaiPunti() ); | ||
| 124 | else if ( vaiLiscio() ); | ||
| 125 | else if ( vaiTaglio() ); | ||
| 126 | else if ( vaiBriscolaAlta() ); | ||
| 127 | else if ( vaiCarico() ); | ||
| 128 | else if ( vaiTre() ); | ||
| 129 | else if ( vaiAsso() ); | ||
| 130 | else; | ||
| 131 | } | ||
| 132 | else { | ||
| 133 | if ( haLisciato() ) { | ||
| 134 | if ( vaiSopra() ); | ||
| 135 | else if ( vaiLiscio() ); | ||
| 136 | else if ( vaiPunti() ); | ||
| 137 | else if ( vaiTaglio() ); | ||
| 138 | else if ( vaiTre() ); | ||
| 139 | else if ( vaiBriscolaAlta() ); | ||
| 140 | else if ( vaiCarico() ); | ||
| 141 | else if ( vaiAsso() ); | ||
| 142 | } else if ( haMessoPunti() ) { | ||
| 143 | if ( vaiSopra() ); | ||
| 144 | else if ( vaiLiscio() ); | ||
| 145 | else if ( vaiTaglio() ); | ||
| 146 | else if ( vaiPunti() ); | ||
| 147 | else if ( vaiTre() ); | ||
| 148 | else if ( vaiBriscolaAlta() ); | ||
| 149 | else if ( vaiCarico() ); | ||
| 150 | else if ( vaiAsso() ); | ||
| 151 | } else if ( haTagliato() ) { | ||
| 152 | if ( vaiLiscio() ); | ||
| 153 | else if ( vaiPunti() ); | ||
| 154 | else if ( vaiTaglio() ); | ||
| 155 | else if ( vaiTre() ); | ||
| 156 | else if ( vaiBriscolaAlta() ); | ||
| 157 | else if ( vaiCarico() ); | ||
| 158 | else if ( vaiAsso() ); | ||
| 159 | } else if ( haMessoBriscolaAlta() ) { | ||
| 160 | if ( vaiLiscio() ); | ||
| 161 | else if ( vaiPunti() ); | ||
| 162 | else if ( vaiTre() ); | ||
| 163 | else if ( vaiTaglio() ); | ||
| 164 | else if ( vaiBriscolaAlta() ); | ||
| 165 | else if ( vaiCarico() ); | ||
| 166 | else if ( vaiAsso() ); | ||
| 167 | } else if ( haMessoTre() ) { | ||
| 168 | if ( vaiAsso() ); | ||
| 169 | else if ( vaiLiscio() ); | ||
| 170 | else if ( vaiPunti() ); | ||
| 171 | else if ( vaiTaglio() ); | ||
| 172 | else if ( vaiBriscolaAlta() ); | ||
| 173 | else if ( vaiCarico() ); | ||
| 174 | } else if ( haMessoAsso() ) { | ||
| 175 | if ( vaiLiscio() ); | ||
| 176 | else if ( vaiPunti() ); | ||
| 177 | else if ( vaiTaglio() ); | ||
| 178 | else if ( vaiBriscolaAlta() ); | ||
| 179 | else if ( vaiCarico() ); | ||
| 180 | else if ( vaiTre() ); | ||
| 181 | } else if ( haCaricato() ) { | ||
| 182 | if ( vaiSopra() ); | ||
| 183 | else if ( vaiTre() ); | ||
| 184 | else if ( vaiBriscolaAlta() ); | ||
| 185 | else if ( vaiAsso() ); | ||
| 186 | else if ( vaiTaglio() ); | ||
| 187 | else if ( vaiLiscio() ); | ||
| 188 | else if ( vaiPunti() ); | ||
| 189 | else if ( vaiCarico() ); | ||
| 190 | } | ||
| 191 | } | ||
| 192 | } | ||
| 193 | else if ( mano == 16 ) { | ||
| 194 | if ( frame.giocata[0] == null ) { | ||
| 195 | char aux[]; | ||
| 196 | aux = frame.ultimaCarta.toString().toCharArray(); | ||
| 197 | if ( aux[aux.length-7] - 48 == 3 || aux[aux.length-7] - 48 == 1 ) { | ||
| 198 | if ( vaiCarico() ); | ||
| 199 | else if ( vaiPunti() ); | ||
| 200 | else if ( vaiLiscio() ); | ||
| 201 | else if ( vaiTaglio() ); | ||
| 202 | else if ( vaiBriscolaAlta() ); | ||
| 203 | else if ( vaiTre() ); | ||
| 204 | else if ( vaiAsso() ); | ||
| 205 | else; | ||
| 206 | } else { | ||
| 207 | if ( vaiPunti() ); | ||
| 208 | else if ( vaiLiscio() ); | ||
| 209 | else if ( vaiTaglio() ); | ||
| 210 | else if ( vaiBriscolaAlta() ); | ||
| 211 | else if ( vaiCarico() ); | ||
| 212 | else if ( vaiTre() ); | ||
| 213 | else if ( vaiAsso() ); | ||
| 214 | else; | ||
| 215 | } | ||
| 216 | } | ||
| 217 | else { | ||
| 218 | char aux[]; | ||
| 219 | aux = frame.ultimaCarta.toString().toCharArray(); | ||
| 220 | if ( aux[aux.length-7] - 48 == 3 || aux[aux.length-7] - 48 == 1 ) { | ||
| 221 | if ( haCaricato() ) { | ||
| 222 | if ( vaiSopra() ); | ||
| 223 | else if ( vaiLiscio() ); | ||
| 224 | else if ( vaiPunti() ); | ||
| 225 | else if ( vaiTre() ); | ||
| 226 | else if ( vaiTaglio() ); | ||
| 227 | else if ( vaiBriscolaAlta() ); | ||
| 228 | else if ( vaiAsso() ); | ||
| 229 | else if ( vaiCarico() ); | ||
| 230 | } | ||
| 231 | } else { | ||
| 232 | if ( haLisciato() ) { | ||
| 233 | if ( vaiSopra() ); | ||
| 234 | else if ( vaiLiscio() ); | ||
| 235 | else if ( vaiPunti() ); | ||
| 236 | else if ( vaiTaglio() ); | ||
| 237 | else if ( vaiTre() ); | ||
| 238 | else if ( vaiBriscolaAlta() ); | ||
| 239 | else if ( vaiCarico() ); | ||
| 240 | else if ( vaiAsso() ); | ||
| 241 | } else if ( haMessoPunti() ) { | ||
| 242 | if ( vaiSopra() ); | ||
| 243 | else if ( vaiLiscio() ); | ||
| 244 | else if ( vaiTaglio() ); | ||
| 245 | else if ( vaiPunti() ); | ||
| 246 | else if ( vaiTre() ); | ||
| 247 | else if ( vaiBriscolaAlta() ); | ||
| 248 | else if ( vaiCarico() ); | ||
| 249 | else if ( vaiAsso() ); | ||
| 250 | } else if ( haTagliato() ) { | ||
| 251 | if ( vaiLiscio() ); | ||
| 252 | else if ( vaiPunti() ); | ||
| 253 | else if ( vaiTaglio() ); | ||
| 254 | else if ( vaiTre() ); | ||
| 255 | else if ( vaiBriscolaAlta() ); | ||
| 256 | else if ( vaiCarico() ); | ||
| 257 | else if ( vaiAsso() ); | ||
| 258 | } else if ( haMessoBriscolaAlta() ) { | ||
| 259 | if ( vaiLiscio() ); | ||
| 260 | else if ( vaiPunti() ); | ||
| 261 | else if ( vaiTre() ); | ||
| 262 | else if ( vaiTaglio() ); | ||
| 263 | else if ( vaiBriscolaAlta() ); | ||
| 264 | else if ( vaiCarico() ); | ||
| 265 | else if ( vaiAsso() ); | ||
| 266 | } else if ( haMessoTre() ) { | ||
| 267 | if ( vaiAsso() ); | ||
| 268 | else if ( vaiLiscio() ); | ||
| 269 | else if ( vaiPunti() ); | ||
| 270 | else if ( vaiTaglio() ); | ||
| 271 | else if ( vaiBriscolaAlta() ); | ||
| 272 | else if ( vaiCarico() ); | ||
| 273 | } else if ( haMessoAsso() ) { | ||
| 274 | if ( vaiLiscio() ); | ||
| 275 | else if ( vaiPunti() ); | ||
| 276 | else if ( vaiTaglio() ); | ||
| 277 | else if ( vaiBriscolaAlta() ); | ||
| 278 | else if ( vaiCarico() ); | ||
| 279 | else if ( vaiTre() ); | ||
| 280 | } else if ( haCaricato() ) { | ||
| 281 | if ( vaiSopra() ); | ||
| 282 | else if ( vaiTre() ); | ||
| 283 | else if ( vaiBriscolaAlta() ); | ||
| 284 | else if ( vaiAsso() ); | ||
| 285 | else if ( vaiTaglio() ); | ||
| 286 | else if ( vaiLiscio() ); | ||
| 287 | else if ( vaiPunti() ); | ||
| 288 | else if ( vaiCarico() ); | ||
| 289 | } | ||
| 290 | } | ||
| 291 | } | ||
| 292 | } else if ( mano == 17 ) { | ||
| 293 | if ( frame.giocata[0] == null ) { | ||
| 294 | if ( hoAsso() ) { | ||
| 295 | if ( vaiTre() ); | ||
| 296 | else if ( vaiBriscolaAlta() ); | ||
| 297 | else if ( vaiTaglio() ); | ||
| 298 | else if ( vaiLiscio() ); | ||
| 299 | else if ( vaiPunti() ); | ||
| 300 | else if ( vaiAsso() ); | ||
| 301 | else if ( vaiCarico() ); | ||
| 302 | } else { | ||
| 303 | if ( vaiLiscio() ); | ||
| 304 | else if ( vaiPunti() ); | ||
| 305 | else if ( vaiTaglio() ); | ||
| 306 | else if ( vaiBriscolaAlta() ); | ||
| 307 | else if ( vaiCarico() ); | ||
| 308 | else if ( vaiTre() ); | ||
| 309 | } | ||
| 310 | } | ||
| 311 | else { | ||
| 312 | if ( haLisciato() ) { | ||
| 313 | if ( vaiSopra() ); | ||
| 314 | else if ( vaiLiscio() ); | ||
| 315 | else if ( vaiPunti() ); | ||
| 316 | else if ( vaiTaglio() ); | ||
| 317 | else if ( vaiTre() ); | ||
| 318 | else if ( vaiBriscolaAlta() ); | ||
| 319 | else if ( vaiCarico() ); | ||
| 320 | else if ( vaiAsso() ); | ||
| 321 | } else if ( haMessoPunti() ) { | ||
| 322 | if ( vaiSopra() ); | ||
| 323 | else if ( vaiLiscio() ); | ||
| 324 | else if ( vaiTaglio() ); | ||
| 325 | else if ( vaiPunti() ); | ||
| 326 | else if ( vaiTre() ); | ||
| 327 | else if ( vaiBriscolaAlta() ); | ||
| 328 | else if ( vaiCarico() ); | ||
| 329 | else if ( vaiAsso() ); | ||
| 330 | } else if ( haTagliato() ) { | ||
| 331 | if ( vaiLiscio() ); | ||
| 332 | else if ( vaiPunti() ); | ||
| 333 | else if ( vaiTaglio() ); | ||
| 334 | else if ( vaiTre() ); | ||
| 335 | else if ( vaiBriscolaAlta() ); | ||
| 336 | else if ( vaiCarico() ); | ||
| 337 | else if ( vaiAsso() ); | ||
| 338 | } else if ( haMessoBriscolaAlta() ) { | ||
| 339 | if ( vaiLiscio() ); | ||
| 340 | else if ( vaiPunti() ); | ||
| 341 | else if ( vaiTre() ); | ||
| 342 | else if ( vaiTaglio() ); | ||
| 343 | else if ( vaiBriscolaAlta() ); | ||
| 344 | else if ( vaiCarico() ); | ||
| 345 | else if ( vaiAsso() ); | ||
| 346 | } else if ( haMessoTre() ) { | ||
| 347 | if ( vaiAsso() ); | ||
| 348 | else if ( vaiLiscio() ); | ||
| 349 | else if ( vaiPunti() ); | ||
| 350 | else if ( vaiTaglio() ); | ||
| 351 | else if ( vaiBriscolaAlta() ); | ||
| 352 | else if ( vaiCarico() ); | ||
| 353 | } else if ( haMessoAsso() ) { | ||
| 354 | if ( vaiLiscio() ); | ||
| 355 | else if ( vaiPunti() ); | ||
| 356 | else if ( vaiTaglio() ); | ||
| 357 | else if ( vaiBriscolaAlta() ); | ||
| 358 | else if ( vaiCarico() ); | ||
| 359 | else if ( vaiTre() ); | ||
| 360 | } else if ( haCaricato() ) { | ||
| 361 | if ( vaiSopra() ); | ||
| 362 | else if ( vaiTre() ); | ||
| 363 | else if ( vaiBriscolaAlta() ); | ||
| 364 | else if ( vaiAsso() ); | ||
| 365 | else if ( vaiTaglio() ); | ||
| 366 | else if ( vaiLiscio() ); | ||
| 367 | else if ( vaiPunti() ); | ||
| 368 | else if ( vaiCarico() ); | ||
| 369 | } | ||
| 370 | } | ||
| 371 | } else if ( mano == 18 ) { | ||
| 372 | if ( frame.giocata[0] == null ) { | ||
| 373 | if ( vaiAsso() ); | ||
| 374 | else if ( vaiCarico() ); | ||
| 375 | else if ( vaiBriscolaAlta() ); | ||
| 376 | else if ( vaiTaglio() ); | ||
| 377 | else if ( vaiPunti() ); | ||
| 378 | else if ( vaiLiscio() ); | ||
| 379 | else if ( vaiTre() ); | ||
| 380 | } | ||
| 381 | else { | ||
| 382 | if ( haLisciato() ) { | ||
| 383 | if ( vaiSopra() ); | ||
| 384 | else if ( vaiLiscio() ); | ||
| 385 | else if ( vaiPunti() ); | ||
| 386 | else if ( vaiTaglio() ); | ||
| 387 | else if ( vaiTre() ); | ||
| 388 | else if ( vaiBriscolaAlta() ); | ||
| 389 | else if ( vaiCarico() ); | ||
| 390 | else if ( vaiAsso() ); | ||
| 391 | } else if ( haMessoPunti() ) { | ||
| 392 | if ( vaiSopra() ); | ||
| 393 | else if ( vaiLiscio() ); | ||
| 394 | else if ( vaiTaglio() ); | ||
| 395 | else if ( vaiPunti() ); | ||
| 396 | else if ( vaiTre() ); | ||
| 397 | else if ( vaiBriscolaAlta() ); | ||
| 398 | else if ( vaiCarico() ); | ||
| 399 | else if ( vaiAsso() ); | ||
| 400 | } else if ( haTagliato() ) { | ||
| 401 | if ( vaiLiscio() ); | ||
| 402 | else if ( vaiPunti() ); | ||
| 403 | else if ( vaiTaglio() ); | ||
| 404 | else if ( vaiTre() ); | ||
| 405 | else if ( vaiBriscolaAlta() ); | ||
| 406 | else if ( vaiCarico() ); | ||
| 407 | else if ( vaiAsso() ); | ||
| 408 | } else if ( haMessoBriscolaAlta() ) { | ||
| 409 | if ( vaiLiscio() ); | ||
| 410 | else if ( vaiPunti() ); | ||
| 411 | else if ( vaiTre() ); | ||
| 412 | else if ( vaiTaglio() ); | ||
| 413 | else if ( vaiBriscolaAlta() ); | ||
| 414 | else if ( vaiCarico() ); | ||
| 415 | else if ( vaiAsso() ); | ||
| 416 | } else if ( haMessoTre() ) { | ||
| 417 | if ( vaiAsso() ); | ||
| 418 | else if ( vaiLiscio() ); | ||
| 419 | else if ( vaiPunti() ); | ||
| 420 | else if ( vaiTaglio() ); | ||
| 421 | else if ( vaiBriscolaAlta() ); | ||
| 422 | else if ( vaiCarico() ); | ||
| 423 | } else if ( haMessoAsso() ) { | ||
| 424 | if ( vaiLiscio() ); | ||
| 425 | else if ( vaiPunti() ); | ||
| 426 | else if ( vaiTaglio() ); | ||
| 427 | else if ( vaiBriscolaAlta() ); | ||
| 428 | else if ( vaiCarico() ); | ||
| 429 | else if ( vaiTre() ); | ||
| 430 | } else if ( haCaricato() ) { | ||
| 431 | if ( vaiSopra() ); | ||
| 432 | else if ( vaiTre() ); | ||
| 433 | else if ( vaiBriscolaAlta() ); | ||
| 434 | else if ( vaiAsso() ); | ||
| 435 | else if ( vaiTaglio() ); | ||
| 436 | else if ( vaiLiscio() ); | ||
| 437 | else if ( vaiPunti() ); | ||
| 438 | else if ( vaiCarico() ); | ||
| 439 | } | ||
| 440 | } | ||
| 441 | } else { | ||
| 442 | if ( vaiTre() ); | ||
| 443 | else if ( vaiBriscolaAlta() ); | ||
| 444 | else if ( vaiAsso() ); | ||
| 445 | else if ( vaiTaglio() ); | ||
| 446 | else if ( vaiLiscio() ); | ||
| 447 | else if ( vaiPunti() ); | ||
| 448 | else if ( vaiCarico() ); | ||
| 449 | } | ||
| 450 | frame.giocata[1] = frame.carteCPU[cartaDaGiocare]; | ||
| 451 | frame.carteCPU[cartaDaGiocare] = null; | ||
| 452 | frame.pannello.repaint(); | ||
| 453 | CPUHaGiocato = true; | ||
| 454 | if ( frame.giocata[0] == null ) | ||
| 455 | toccaAllaCPU = false; | ||
| 456 | } | ||
| 457 | public void chiPrende() { | ||
| 458 | char aux[], auxCPU[]; | ||
| 459 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 460 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 461 | giocatorePrende( ( (aux[aux.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) ) | ||
| 462 | || ( (aux[aux.length-5] == auxCPU[auxCPU.length-5]) && laPrimaEPiuAlta( aux[aux.length-7] - 48, auxCPU[auxCPU.length-7] - 48 ) ) | ||
| 463 | || ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (aux[aux.length-5] != auxCPU[auxCPU.length-5]) && haGiocatoPrima ) ); | ||
| 464 | } | ||
| 465 | public boolean laPrimaEPiuAlta( int prima, int seconda ) { | ||
| 466 | int a, b; | ||
| 467 | switch ( prima ) { | ||
| 468 | case 0: | ||
| 469 | a = 10; | ||
| 470 | break; | ||
| 471 | case 1: | ||
| 472 | a = 12; | ||
| 473 | break; | ||
| 474 | case 3: | ||
| 475 | a = 11; | ||
| 476 | break; | ||
| 477 | default: | ||
| 478 | a = prima; | ||
| 479 | break; | ||
| 480 | } | ||
| 481 | switch ( seconda ) { | ||
| 482 | case 0: | ||
| 483 | b = 10; | ||
| 484 | break; | ||
| 485 | case 1: | ||
| 486 | b = 12; | ||
| 487 | break; | ||
| 488 | case 3: | ||
| 489 | b = 11; | ||
| 490 | break; | ||
| 491 | default: | ||
| 492 | b = seconda; | ||
| 493 | break; | ||
| 494 | } | ||
| 495 | return a > b; | ||
| 496 | } | ||
| 497 | public void giocatorePrende( boolean giocatore ) { | ||
| 498 | if ( giocatore ) { | ||
| 499 | toccaAllaCPU = CPUHaGiocato = false; | ||
| 500 | haGiocatoPrima = true; | ||
| 501 | } | ||
| 502 | else { | ||
| 503 | toccaAllaCPU = true; | ||
| 504 | CPUHaGiocato = haGiocatoPrima = false; | ||
| 505 | } | ||
| 506 | daiPunti( giocatore ); | ||
| 507 | if ( toccaAllaCPU ) | ||
| 508 | giocaCPU(); | ||
| 509 | } | ||
| 510 | public void daiPunti( boolean giocatore ) { | ||
| 511 | char aux[], auxCPU[]; | ||
| 512 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 513 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 514 | int punti = 0; | ||
| 515 | switch( aux[aux.length-7] - 48 ) { | ||
| 516 | case 0: | ||
| 517 | punti += 4; | ||
| 518 | break; | ||
| 519 | case 1: | ||
| 520 | punti += 11; | ||
| 521 | break; | ||
| 522 | case 3: | ||
| 523 | punti += 10; | ||
| 524 | break; | ||
| 525 | case 8: | ||
| 526 | punti += 2; | ||
| 527 | break; | ||
| 528 | case 9: | ||
| 529 | punti += 3; | ||
| 530 | break; | ||
| 531 | default: | ||
| 532 | break; | ||
| 533 | } | ||
| 534 | switch( auxCPU[auxCPU.length-7] - 48 ) { | ||
| 535 | case 0: | ||
| 536 | punti += 4; | ||
| 537 | break; | ||
| 538 | case 1: | ||
| 539 | punti += 11; | ||
| 540 | break; | ||
| 541 | case 3: | ||
| 542 | punti += 10; | ||
| 543 | break; | ||
| 544 | case 8: | ||
| 545 | punti += 2; | ||
| 546 | break; | ||
| 547 | case 9: | ||
| 548 | punti += 3; | ||
| 549 | break; | ||
| 550 | default: | ||
| 551 | break; | ||
| 552 | } | ||
| 553 | frame.giocata[0] = frame.giocata[1] = null; | ||
| 554 | if ( giocatore ) { | ||
| 555 | punteggio += punti; | ||
| 556 | if ( mano < 18 ) { | ||
| 557 | if ( frame.carteInMano[0] == null ) | ||
| 558 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 559 | if ( frame.carteInMano[1] == null ) | ||
| 560 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 561 | if ( frame.carteInMano[2] == null ) | ||
| 562 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 563 | cartaDaPescare++; | ||
| 564 | if ( frame.carteCPU[0] == null ) | ||
| 565 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 566 | if ( frame.carteCPU[1] == null ) | ||
| 567 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 568 | if ( frame.carteCPU[2] == null ) | ||
| 569 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 570 | cartaDaPescare++; | ||
| 571 | } | ||
| 572 | } | ||
| 573 | else { | ||
| 574 | punteggioCPU += punti; | ||
| 575 | if ( mano < 18 ) { | ||
| 576 | if ( frame.carteCPU[0] == null ) | ||
| 577 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 578 | if ( frame.carteCPU[1] == null ) | ||
| 579 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 580 | if ( frame.carteCPU[2] == null ) | ||
| 581 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 582 | cartaDaPescare++; | ||
| 583 | if ( frame.carteInMano[0] == null ) | ||
| 584 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 585 | if ( frame.carteInMano[1] == null ) | ||
| 586 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 587 | if ( frame.carteInMano[2] == null ) | ||
| 588 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 589 | cartaDaPescare++; | ||
| 590 | } | ||
| 591 | } | ||
| 592 | frame.pannello.repaint(); | ||
| 593 | frame.repaint(); | ||
| 594 | } | ||
| 595 | public boolean haLisciato() { | ||
| 596 | char auxCPU[]; | ||
| 597 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 598 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 599 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 600 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ); | ||
| 601 | } | ||
| 602 | public boolean haMessoPunti() { | ||
| 603 | char auxCPU[]; | ||
| 604 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 605 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 606 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || | ||
| 607 | (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ); | ||
| 608 | } | ||
| 609 | public boolean haTagliato() { | ||
| 610 | char auxCPU[]; | ||
| 611 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 612 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 613 | (auxCPU[auxCPU.length-7] - 48 != 0) && (auxCPU[auxCPU.length-7] - 48 != 1) && | ||
| 614 | (auxCPU[auxCPU.length-7] - 48 != 3) && (auxCPU[auxCPU.length-7] - 48 <= 7) ); | ||
| 615 | } | ||
| 616 | public boolean haMessoBriscolaAlta() { | ||
| 617 | char auxCPU[]; | ||
| 618 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 619 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 620 | ( (auxCPU[auxCPU.length-7] - 48 == 0) || (auxCPU[auxCPU.length-7] - 48 == 8) || | ||
| 621 | (auxCPU[auxCPU.length-7] - 48 == 9) ) ); | ||
| 622 | } | ||
| 623 | public boolean haMessoTre() { | ||
| 624 | char auxCPU[]; | ||
| 625 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 626 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 627 | (auxCPU[auxCPU.length-7] - 48 == 3) ); | ||
| 628 | } | ||
| 629 | public boolean haMessoAsso() { | ||
| 630 | char auxCPU[]; | ||
| 631 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 632 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 633 | (auxCPU[auxCPU.length-7] - 48 == 1) ); | ||
| 634 | } | ||
| 635 | public boolean haCaricato() { | ||
| 636 | char auxCPU[]; | ||
| 637 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 638 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 639 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ); | ||
| 640 | } | ||
| 641 | public boolean vaiLiscio() { | ||
| 642 | char auxCPU[]; | ||
| 643 | for ( int i = 0; i < 3; i++ ) { | ||
| 644 | if ( frame.carteCPU[i] != null ) { | ||
| 645 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 646 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 647 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 648 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ) { | ||
| 649 | cartaDaGiocare = i; | ||
| 650 | return true; | ||
| 651 | } | ||
| 652 | } | ||
| 653 | } | ||
| 654 | return false; | ||
| 655 | } | ||
| 656 | public boolean vaiPunti() { | ||
| 657 | char[] auxCPU; | ||
| 658 | for ( int i = 0; i < 3; i++ ) { | ||
| 659 | if ( frame.carteCPU[i] != null ) { | ||
| 660 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 661 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 8 ) ) { | ||
| 662 | cartaDaGiocare = i; | ||
| 663 | return true; | ||
| 664 | } | ||
| 665 | } | ||
| 666 | } | ||
| 667 | for ( int i = 0; i < 3; i++ ) { | ||
| 668 | if ( frame.carteCPU[i] != null ) { | ||
| 669 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 670 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 9 ) ) { | ||
| 671 | cartaDaGiocare = i; | ||
| 672 | return true; | ||
| 673 | } | ||
| 674 | } | ||
| 675 | } | ||
| 676 | for ( int i = 0; i < 3; i++ ) { | ||
| 677 | if ( frame.carteCPU[i] != null ) { | ||
| 678 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 679 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 0 ) ) { | ||
| 680 | cartaDaGiocare = i; | ||
| 681 | return true; | ||
| 682 | } | ||
| 683 | } | ||
| 684 | } | ||
| 685 | return false; | ||
| 686 | } | ||
| 687 | public boolean vaiTaglio() { | ||
| 688 | char auxCPU[]; | ||
| 689 | for ( int i = 0; i < 3; i++ ) { | ||
| 690 | if ( frame.carteCPU[i] != null ) { | ||
| 691 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 692 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && | ||
| 693 | (auxCPU[auxCPU.length-7] - 48 != 0) && (auxCPU[auxCPU.length-7] - 48 != 1) && | ||
| 694 | (auxCPU[auxCPU.length-7] - 48 != 3) && (auxCPU[auxCPU.length-7] - 48 <= 7) ) { | ||
| 695 | cartaDaGiocare = i; | ||
| 696 | return true; | ||
| 697 | } | ||
| 698 | } | ||
| 699 | } | ||
| 700 | return false; | ||
| 701 | } | ||
| 702 | public boolean vaiBriscolaAlta() { | ||
| 703 | char[] auxCPU; | ||
| 704 | for ( int i = 0; i < 3; i++ ) { | ||
| 705 | if ( frame.carteCPU[i] != null ) { | ||
| 706 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 707 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 8 ) ) { | ||
| 708 | cartaDaGiocare = i; | ||
| 709 | return true; | ||
| 710 | } | ||
| 711 | } | ||
| 712 | } | ||
| 713 | for ( int i = 0; i < 3; i++ ) { | ||
| 714 | if ( frame.carteCPU[i] != null ) { | ||
| 715 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 716 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 9 ) ) { | ||
| 717 | cartaDaGiocare = i; | ||
| 718 | return true; | ||
| 719 | } | ||
| 720 | } | ||
| 721 | } | ||
| 722 | for ( int i = 0; i < 3; i++ ) { | ||
| 723 | if ( frame.carteCPU[i] != null ) { | ||
| 724 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 725 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 0 ) ) { | ||
| 726 | cartaDaGiocare = i; | ||
| 727 | return true; | ||
| 728 | } | ||
| 729 | } | ||
| 730 | } | ||
| 731 | return false; | ||
| 732 | } | ||
| 733 | public boolean vaiTre() { | ||
| 734 | char auxCPU[]; | ||
| 735 | for ( int i = 0; i < 3; i++ ) { | ||
| 736 | if ( frame.carteCPU[i] != null ) { | ||
| 737 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 738 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && (auxCPU[auxCPU.length-7] - 48 == 3) ) { | ||
| 739 | cartaDaGiocare = i; | ||
| 740 | return true; | ||
| 741 | } | ||
| 742 | } | ||
| 743 | } | ||
| 744 | return false; | ||
| 745 | } | ||
| 746 | public boolean vaiAsso() { | ||
| 747 | char auxCPU[]; | ||
| 748 | for ( int i = 0; i < 3; i++ ) { | ||
| 749 | if ( frame.carteCPU[i] != null ) { | ||
| 750 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 751 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && (auxCPU[auxCPU.length-7] - 48 == 1) ) { | ||
| 752 | cartaDaGiocare = i; | ||
| 753 | return true; | ||
| 754 | } | ||
| 755 | } | ||
| 756 | } | ||
| 757 | return false; | ||
| 758 | } | ||
| 759 | public boolean vaiCarico() { | ||
| 760 | char[] auxCPU; | ||
| 761 | for ( int i = 0; i < 3; i++ ) { | ||
| 762 | if ( frame.carteCPU[i] != null ) { | ||
| 763 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 764 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 3 ) ) { | ||
| 765 | cartaDaGiocare = i; | ||
| 766 | return true; | ||
| 767 | } | ||
| 768 | } | ||
| 769 | } | ||
| 770 | for ( int i = 0; i < 3; i++ ) { | ||
| 771 | if ( frame.carteCPU[i] != null ) { | ||
| 772 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 773 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 1 ) ) { | ||
| 774 | cartaDaGiocare = i; | ||
| 775 | return true; | ||
| 776 | } | ||
| 777 | } | ||
| 778 | } | ||
| 779 | return false; | ||
| 780 | } | ||
| 781 | public boolean vaiSopra() { | ||
| 782 | if ( frame.giocata[0] == null ) | ||
| 783 | return false; | ||
| 784 | int a = -1; | ||
| 785 | int b = -1; | ||
| 786 | int c = -1; | ||
| 787 | boolean laPrimaPuoAndareSopra = false; | ||
| 788 | boolean laSecondaPuoAndareSopra = false; | ||
| 789 | boolean laTerzaPuoAndareSopra = false; | ||
| 790 | char[] auxCPU1 = new char[1024]; | ||
| 791 | char[] auxCPU2 = new char[1024]; | ||
| 792 | char[] auxCPU3 = new char[1024]; | ||
| 793 | char[] aux = frame.giocata[0].toString().toCharArray(); | ||
| 794 | if ( aux[aux.length-7] - 48 == 1 ) | ||
| 795 | return false; | ||
| 796 | if ( frame.carteCPU[0] != null ) { | ||
| 797 | auxCPU1 = frame.carteCPU[0].toString().toCharArray(); | ||
| 798 | a = auxCPU1[auxCPU1.length-7] - 48; | ||
| 799 | if ( (auxCPU1[auxCPU1.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( a, aux[aux.length-7] - 48 ) ) | ||
| 800 | laPrimaPuoAndareSopra = true; | ||
| 801 | } | ||
| 802 | if ( frame.carteCPU[1] != null ) { | ||
| 803 | auxCPU2 = frame.carteCPU[1].toString().toCharArray(); | ||
| 804 | b = auxCPU2[auxCPU2.length-7] - 48; | ||
| 805 | if ( (auxCPU2[auxCPU2.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( b, aux[aux.length-7] - 48 ) ) | ||
| 806 | laSecondaPuoAndareSopra = true; | ||
| 807 | } | ||
| 808 | if ( frame.carteCPU[2] != null ) { | ||
| 809 | auxCPU3 = frame.carteCPU[2].toString().toCharArray(); | ||
| 810 | c = auxCPU3[auxCPU3.length-7] - 48; | ||
| 811 | if ( (auxCPU3[auxCPU3.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( c, aux[aux.length-7] - 48 ) ) | ||
| 812 | laTerzaPuoAndareSopra = true; | ||
| 813 | } | ||
| 814 | if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 815 | return false; | ||
| 816 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 817 | cartaDaGiocare = 0; | ||
| 818 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 819 | cartaDaGiocare = 1; | ||
| 820 | else if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 821 | cartaDaGiocare = 2; | ||
| 822 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 823 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 824 | cartaDaGiocare = 0; | ||
| 825 | else | ||
| 826 | cartaDaGiocare = 1; | ||
| 827 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 828 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 829 | cartaDaGiocare = 1; | ||
| 830 | else | ||
| 831 | cartaDaGiocare = 2; | ||
| 832 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 833 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 834 | cartaDaGiocare = 0; | ||
| 835 | else | ||
| 836 | cartaDaGiocare = 2; | ||
| 837 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 838 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 839 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 840 | cartaDaGiocare = 0; | ||
| 841 | else | ||
| 842 | cartaDaGiocare = 2; | ||
| 843 | else | ||
| 844 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 845 | cartaDaGiocare = 1; | ||
| 846 | else | ||
| 847 | cartaDaGiocare = 2; | ||
| 848 | aux = frame.carteCPU[cartaDaGiocare].toString().toCharArray(); | ||
| 849 | if ( (aux[aux.length-7] - 48 != 0) && (aux[aux.length-7] - 48 != 1) && | ||
| 850 | (aux[aux.length-7] - 48 != 3) && (aux[aux.length-7] - 48 <= 7) ) | ||
| 851 | return false; | ||
| 852 | return true; | ||
| 853 | } | ||
| 854 | public boolean hoCarico() { | ||
| 855 | char auxCPU[]; | ||
| 856 | for ( int i = 0; i < 3; i++ ) { | ||
| 857 | if ( frame.carteCPU[i] != null ) { | ||
| 858 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 859 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 860 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ) { | ||
| 861 | return true; | ||
| 862 | } | ||
| 863 | } | ||
| 864 | } | ||
| 865 | return false; | ||
| 866 | } | ||
| 867 | public boolean hoAsso() { | ||
| 868 | char auxCPU[]; | ||
| 869 | for ( int i = 0; i < 3; i++ ) { | ||
| 870 | if ( frame.carteCPU[i] != null ) { | ||
| 871 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 872 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 1 ) ) { | ||
| 873 | return true; | ||
| 874 | } | ||
| 875 | } | ||
| 876 | } | ||
| 877 | return false; | ||
| 878 | } | ||
| 879 | public boolean hoTre() { | ||
| 880 | char auxCPU[]; | ||
| 881 | for ( int i = 0; i < 3; i++ ) { | ||
| 882 | if ( frame.carteCPU[i] != null ) { | ||
| 883 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 884 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 3 ) ) { | ||
| 885 | return true; | ||
| 886 | } | ||
| 887 | } | ||
| 888 | } | ||
| 889 | return false; | ||
| 890 | } | ||
| 891 | public boolean hoBriscolaAlta() { | ||
| 892 | char auxCPU[]; | ||
| 893 | for ( int i = 0; i < 3; i++ ) { | ||
| 894 | if ( frame.carteCPU[i] != null ) { | ||
| 895 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 896 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 897 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ) { | ||
| 898 | return true; | ||
| 899 | } | ||
| 900 | } | ||
| 901 | } | ||
| 902 | return false; | ||
| 903 | } | ||
| 904 | public boolean hoTaglio() { | ||
| 905 | char auxCPU[]; | ||
| 906 | for ( int i = 0; i < 3; i++ ) { | ||
| 907 | if ( frame.carteCPU[i] != null ) { | ||
| 908 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 909 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 910 | (auxCPU[auxCPU.length-7] - 48 < 8 ) && (auxCPU[auxCPU.length-7] - 48 != 3 ) | ||
| 911 | && (auxCPU[auxCPU.length-7] - 48 != 1 ) && (auxCPU[auxCPU.length-7] - 48 != 0 ) ) { | ||
| 912 | return true; | ||
| 913 | } | ||
| 914 | } | ||
| 915 | } | ||
| 916 | return false; | ||
| 917 | } | ||
| 918 | public static void settaOpzioni() { | ||
| 919 | lang = "it"; | ||
| 920 | soundString = "suono=si"; | ||
| 921 | keysString = "tasti=si"; | ||
| 922 | int r = 0; | ||
| 923 | int g = 150; | ||
| 924 | int b = 0; | ||
| 925 | Scanner scanner = null; | ||
| 926 | File file = new File( "JBriscolaConfig.txt" ); | ||
| 927 | if ( file.exists() ) { | ||
| 928 | try { | ||
| 929 | scanner = new Scanner( file ); | ||
| 930 | } catch ( FileNotFoundException e ) { } | ||
| 931 | try { | ||
| 932 | lang = scanner.next(); | ||
| 933 | soundString = scanner.next(); | ||
| 934 | keysString = scanner.next(); | ||
| 935 | r = scanner.nextInt(); | ||
| 936 | g = scanner.nextInt(); | ||
| 937 | b = scanner.nextInt(); | ||
| 938 | } catch ( NoSuchElementException e ) { } | ||
| 939 | } | ||
| 940 | if ( lang.equals( "it" ) ) { | ||
| 941 | stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 942 | stringaPrimaGioca = "Prima Gioca!"; | ||
| 943 | stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 944 | stringaVinto = "Hai Vinto!"; | ||
| 945 | stringaPerso = "Hai Perso"; | ||
| 946 | stringaPareggio = "Pareggio"; | ||
| 947 | stringaGiocatore = "Giocatore: "; | ||
| 948 | stringaComputer = "\nComputer: "; | ||
| 949 | stringaNuovaPartita = "Nuova Partita"; | ||
| 950 | stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 951 | stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 952 | stringaSi = "Si"; | ||
| 953 | stringaNo = "No"; | ||
| 954 | stringaOpzioni = "Opzioni..."; | ||
| 955 | stringaEsci = "Esci"; | ||
| 956 | stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 957 | stringaLingua = "Lingua"; | ||
| 958 | stringaAnnulla = "Annulla"; | ||
| 959 | stringaIt = "Italiano"; | ||
| 960 | stringaLa = "Latino"; | ||
| 961 | stringaBL = "Dialetto Bellunese"; | ||
| 962 | stringaBV = "Dialetto Basso Veneto"; | ||
| 963 | stringaNecessarioRiavviare = "E' necessario riavviare JBriscola se sono state\nmodificate impostazioni riguardanti la lingua\nAlcune parti saranno comunque tradotte prima."; | ||
| 964 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 965 | stringaInformazioni = "Informazioni"; | ||
| 966 | stringaInformazioni2 = "JBriscola e' un gioco di briscola per pc scritto in java ideato\ne realizzato da Sebastiano Tronto. Il gioco viene rilasciato sotto licenza GNU/Gpl versione 2 o successive; questo permette\npotenzialmente a chiunque di modificare il gioco partendo dal codice sorgente del programma. Se non avete ricevuto i sorgenti\nassieme al gioco, potete richiedermeli con un'e-mail a sebastiano@luganega.org.\n\nJBriscola version" + version + "\nCopyright 2009 Sebastiano Tronto, license GNU/Gpl 2.0 or later\nE-mail: sebastiano@luganega.org"; | ||
| 967 | stringaSuono = "Effetti sonori"; | ||
| 968 | stringaPunteggio = "Punteggio"; | ||
| 969 | stringaSfondo = "Sfondo"; | ||
| 970 | stringaTasti = "Tasti rapidi"; | ||
| 971 | stringaAggiornamenti = "Cerca aggiornamenti"; | ||
| 972 | stringaAggiornamentiSi = "Aggiornamento disponibile: "; | ||
| 973 | stringaAggiornamentiNo = "Nessun aggiornamento disponibile"; | ||
| 974 | stringaScarica = "E' possibile scaricare la versione più recente\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 975 | stringaNoInternet = "Errore: nessuna connessione internet"; | ||
| 976 | stringaTasti2 = "1 Gioca la prima carta\n2 Gioca la seconda carta\n3 Gioca la terza carta\nF1 Visualizza questo messaggio\nF2 " + stringaNuovaPartita + "\nF3 " + stringaOpzioni + "\nF4 " + stringaPunteggio + "\nF5 " + stringaInformazioni + "\nF6 " + stringaAggiornamenti + "\nq " + stringaEsci; | ||
| 977 | } | ||
| 978 | else if ( lang.equals( "la" ) ) { | ||
| 979 | stringaBottonePrendi = "CAPIS/RELINQVIS CHARTAS"; | ||
| 980 | stringaPrimaGioca = "ANTE CHARTAM PONE!"; | ||
| 981 | stringaUltime4 = "CHARTA POSTREMA - INTVERE BRISCOLAM!"; | ||
| 982 | stringaVinto = "VICISTI!"; | ||
| 983 | stringaPerso = "PERDIDISTI"; | ||
| 984 | stringaPareggio = "AEQVATIO!"; | ||
| 985 | stringaGiocatore = "LVSOR: "; | ||
| 986 | stringaComputer = "\nCOMPVTER: "; | ||
| 987 | stringaNuovaPartita = "NOVA LVSO"; | ||
| 988 | stringaVuoiDavveroIniziare = "NOVAM LVSIONEM INCIPERE?"; | ||
| 989 | stringaVuoiDavveroUscire = "EXIRE?"; | ||
| 990 | stringaSi = "ID VOLO"; | ||
| 991 | stringaNo = "NOLO"; | ||
| 992 | stringaOpzioni = "OPTIONES..."; | ||
| 993 | stringaEsci = "EXIRE"; | ||
| 994 | stringaImpossibileConfigurare = "CONFIGVRATIONIS FILE SCRIBERE NON POTVI.\nERROREM ME CERTIOREM FACITE: sebastiano@luganega.org\n\nEXCEPTIO:\n"; | ||
| 995 | stringaLingua = "LINGVA"; | ||
| 996 | stringaAnnulla = "ABROGA"; | ||
| 997 | stringaIt = "ITALICA"; | ||
| 998 | stringaLa = "LATINA"; | ||
| 999 | stringaBL = "BELLUNI"; | ||
| 1000 | stringaBV = "VENETIAE"; | ||
| 1001 | stringaNecessarioRiavviare = "JBRISCOLAM RVRSVS INCIPERE NECESSE EST\nSI LINGVA PRAELATIONES NOVATAE SVNT.\nALIQVAE ANTE ID VERSA ERVNT"; | ||
| 1002 | stringaModificaOpzioni = "OPTIONES NOVARE"; | ||
| 1003 | stringaInformazioni = "INFORMATIONES"; | ||
| 1004 | stringaInformazioni2 = "JBriscola EST LVDVM BRISCOLAE COMPVTERI, JAVA SCRIPTVM, EXCOGITATVM\nFACTVMQUE A SEBASTIANO TRONTO. IPSVM LUDVM REICITUR LICENTIA GNU/Gpl VERSIONE 2 AVT POSTERIORIBUS; ID\nOMNIBVS LVDVM MUTARE CODICE IPSIVS INCIPIENDO LICET. SI CODICES CUM\nLVDO NON PERVENIT, EOS POSCERE POTESTIS E-MAILE sebastiano@luganega.org.\n\nJBriscola version " + version + "\nCopyright 2009 Sebastiano Tronto, license GNU/Gpl 2.0 or later\nE-mail: sebastiano@luganega.org"; | ||
| 1005 | stringaSuono = "SONVS"; | ||
| 1006 | stringaPunteggio = "NVMERI"; | ||
| 1007 | stringaSfondo = "COLOR"; | ||
| 1008 | stringaTasti = "TASTI RAPIDI"; | ||
| 1009 | stringaAggiornamenti = "VERSIONEM RECENTIOREM QVAERERE"; | ||
| 1010 | stringaNoInternet = "ERROR: INTERNETIS CONIVCTIO NON EST"; | ||
| 1011 | stringaAggiornamentiSi = "VERSIO RECENTIOR EST: "; | ||
| 1012 | stringaAggiornamentiNo = "VERSIO RECENTIOR NON EST"; | ||
| 1013 | stringaScarica = "VERSIONEM RECENTIOREM CEPTA ESSE POTEST:\nhttp://porkynator.altervista.org/programmi.html"; | ||
| 1014 | stringaTasti2 = "1 PONE CHARTAM PRIMAM\n2 PONE CHARTAM SECUNDAM\n3 PONE CHARTAM TERTIAM\nF1 HEAC INFORMATIONES\nF2 " + stringaNuovaPartita + "\nF3 " + stringaOpzioni + "\nF4 " + stringaPunteggio + "\nF5 " + stringaInformazioni + "\nF6 " + stringaAggiornamenti + "\nq " + stringaEsci; | ||
| 1015 | } | ||
| 1016 | if ( lang.equals( "bl" ) ) { | ||
| 1017 | stringaBottonePrendi = "Cio' su/lasa le carte"; | ||
| 1018 | stringaPrimaGioca = "Prima Duga!"; | ||
| 1019 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1020 | stringaVinto = "Te ha vint!"; | ||
| 1021 | stringaPerso = "Te ha pers"; | ||
| 1022 | stringaPareggio = "Pari"; | ||
| 1023 | stringaGiocatore = "Dugador: "; | ||
| 1024 | stringaComputer = "\nComputer: "; | ||
| 1025 | stringaNuovaPartita = "Taca n'altra partida"; | ||
| 1026 | stringaVuoiDavveroIniziare = "Utu sul serio scuminziar n'altra partida?"; | ||
| 1027 | stringaVuoiDavveroUscire = "Utu sul serio stusar su?"; | ||
| 1028 | stringaSi = "Si"; | ||
| 1029 | stringaNo = "No"; | ||
| 1030 | stringaOpzioni = "Opzioni..."; | ||
| 1031 | stringaEsci = "Stusa su"; | ||
| 1032 | stringaImpossibileConfigurare = "No ghe ho riva' a scrivere al file de configurazion.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1033 | stringaLingua = "Lengua"; | ||
| 1034 | stringaAnnulla = "Annulla"; | ||
| 1035 | stringaIt = "Italian"; | ||
| 1036 | stringaLa = "Latin"; | ||
| 1037 | stringaBL = "Dialeto de Belun"; | ||
| 1038 | stringaBV = "Dialeto de la basa"; | ||
| 1039 | stringaNecessarioRiavviare = "Se te ha cambia' la lengua te toca\nstusar su e impizar de novo al dugo\nPero' zerte robe le e' belche tradote."; | ||
| 1040 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1041 | stringaInformazioni = "Informazioni"; | ||
| 1042 | stringaInformazioni2 = "JBriscola le' an dugo de briscola par computer scrit in java, pensa' e realiza'\n da Sebastiano Tronto. Al dugo l'e' sotto licenza GNU/Gpl versione 2 o sucesive; questo ol dir che chi che ol\n(se l'e' bon) al pol modificar al dugo coi codici sorgenti del programa. Se no i ve ha dat i sorgenti\nasieme al dugo, pote' domandarmeli co na e-mail a sebastiano@luganega.org.\n\nJBriscola version " + version + "\nCopyright 2009 Sebastiano Tronto, license GNU/Gpl 2.0 or later\nE-mail: sebastiano@luganega.org"; | ||
| 1043 | stringaSuono = "Efeti sonori"; | ||
| 1044 | stringaPunteggio = "Varda i punti"; | ||
| 1045 | stringaSfondo = "Sfondo"; | ||
| 1046 | stringaTasti = "Tasti rapidi"; | ||
| 1047 | stringaAggiornamenti = "Varda se ghe ne' na version pi nova"; | ||
| 1048 | stringaAggiornamentiSi = "Ghe ne' na version pi nova: "; | ||
| 1049 | stringaAggiornamentiNo = "No ghe ne na version pi nova"; | ||
| 1050 | stringaScarica = "Te pol scaricar le version pi nova\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 1051 | stringaNoInternet = "Erore: no te se su internet"; | ||
| 1052 | stringaTasti2 = "1 Duga la prima carta\n2 Duga la seconda carta\n3 Duga la terza carta\nF1 Tasti rapidi\nF2 " + stringaNuovaPartita + "\nF3 " + stringaOpzioni + "\nF4 " + stringaPunteggio + "\nF5 " + stringaInformazioni + "\nF6 " + stringaAggiornamenti + "\nq " + stringaEsci; | ||
| 1053 | } | ||
| 1054 | if ( lang.equals( "bv" ) ) { | ||
| 1055 | stringaBottonePrendi = "Ciapa su/lasa e carte"; | ||
| 1056 | stringaPrimaGioca = "Prima Zuga!"; | ||
| 1057 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1058 | stringaVinto = "Ti ga vinto!"; | ||
| 1059 | stringaPerso = "Ti ga perso"; | ||
| 1060 | stringaPareggio = "Pari"; | ||
| 1061 | stringaGiocatore = "Zugador: "; | ||
| 1062 | stringaComputer = "\nComputer: "; | ||
| 1063 | stringaNuovaPartita = "N'altra Partida"; | ||
| 1064 | stringaVuoiDavveroIniziare = "Ti vol sul serio scuminziar n'altra partida?"; | ||
| 1065 | stringaVuoiDavveroUscire = "Ti vol sul serio stusar su?"; | ||
| 1066 | stringaSi = "Si"; | ||
| 1067 | stringaNo = "No"; | ||
| 1068 | stringaOpzioni = "Opzioni..."; | ||
| 1069 | stringaEsci = "Stusa su"; | ||
| 1070 | stringaImpossibileConfigurare = "No ghe son riusito a scrivere al file de configurazione.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1071 | stringaLingua = "Lengua"; | ||
| 1072 | stringaAnnulla = "Annulla"; | ||
| 1073 | stringaIt = "Italian"; | ||
| 1074 | stringaLa = "Latin"; | ||
| 1075 | stringaBL = "Dialeto Belumat"; | ||
| 1076 | stringaBV = "Dialeto Veneto"; | ||
| 1077 | stringaNecessarioRiavviare = "Se ti ga cambia' la lengua te toca\nstusar su e impizar de novo al zugo\nPero' zerte robe le e' belche tradote."; | ||
| 1078 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1079 | stringaInformazioni = "Informasioni"; | ||
| 1080 | stringaInformazioni2 = "JBriscola xe an zugo de briscola par computer scrito in java, pensato e realisato\n da Sebastiano Tronto. Al zugo xe sotto licenza GNU/Gpl versione 2 o sucesive; questo vol dire che chi che\nvol (se xe bono) al pol modificare al zugo coi codici sorgenti del programa. Se no i ve ha dato i sorgenti\nasieme al zugo, pote' domandarmeli co na e-mail a sebastiano@luganega.org.\n\nJBriscola version " + version + "\nCopyright 2009 Sebastiano Tronto, license GNU/Gpl 2.0 or later\nE-mail: sebastiano@luganega.org"; | ||
| 1081 | stringaSuono = "Efeti sonori"; | ||
| 1082 | stringaPunteggio = "Varda i punti"; | ||
| 1083 | stringaSfondo = "Sfondo"; | ||
| 1084 | stringaTasti = "Tasti rapidi"; | ||
| 1085 | stringaAggiornamenti = "Varda se xe ne' na versione pi nova"; | ||
| 1086 | stringaAggiornamentiSi = "Ghe xe na versione pi nova: "; | ||
| 1087 | stringaAggiornamentiNo = "No ghe xe na versione pi nova"; | ||
| 1088 | stringaScarica = "Te pol scaricar le versione pi nova\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 1089 | stringaNoInternet = "Erore: no ti xe su internet"; | ||
| 1090 | stringaTasti2 = "1 Zuga la prima carta\n2 Zuga la seconda carta\n3 Zuga la terza carta\nF1 Tasti rapidi\nF2 " + stringaNuovaPartita + "\nF3 " + stringaOpzioni + "\nF4 " + stringaPunteggio + "\nF5 " + stringaInformazioni + "\nF6 " + stringaAggiornamenti + "\nq " + stringaEsci; | ||
| 1091 | } | ||
| 1092 | sound = ( soundString.equals( "suono=si" ) ); | ||
| 1093 | keys = ( keysString.equals( "tasti=si" ) ); | ||
| 1094 | color = new Color( r, g, b ); | ||
| 1095 | if ( frame != null ) { | ||
| 1096 | frame.pannello.repaint(); | ||
| 1097 | frame.pannello2.repaint(); | ||
| 1098 | frame.repaint(); | ||
| 1099 | } | ||
| 1100 | } | ||
| 1101 | } | ||
