Main.java (27180B)
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 Frame frame; 33 public static String version = "0.1.1"; 34 public static String stringaBottonePrendi = "Prendi/Lascia carte"; 35 public static String stringaPrimaGioca = "Prima Gioca!"; 36 public static String stringaUltime4 = "Ultima carta - Occhio alla briscola!"; 37 public static String stringaVinto = "Hai Vinto!"; 38 public static String stringaPerso = "Hai Perso"; 39 public static String stringaPareggio = "Pareggio"; 40 public static String stringaGiocatore = "Giocatore: "; 41 public static String stringaComputer = "\nComputer: "; 42 public static String stringaNuovaPartita = "Nuova Partita"; 43 public static String stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; 44 public static String stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; 45 public static String stringaSi = "Si"; 46 public static String stringaNo = "No"; 47 public static String stringaOpzioni = "Opzioni..."; 48 public static String stringaEsci = "Esci"; 49 public static String stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; 50 public static String stringaLingua = "Lingua"; 51 public static String stringaAnnulla = "Annulla"; 52 public static String stringaIt = "Italiano"; 53 public static String stringaLa = "Latino"; 54 public static String stringaBL = "Dialetto Bellunese"; 55 public static String stringaBV = "Dialetto Basso Veneto"; 56 public static String stringaNecessarioRiavviare = "E' necessario riavviare JBriscola se sono state\nmodificate impostazioni riguardanti la lingua.\nAlcune parti saranno comunque tradotte prima."; 57 public static String stringaModificaOpzioni = "Modifica Opzioni"; 58 public static String stringaInformazioni = "Informazioni"; 59 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"; 60 public static void main( String args[] ) { 61 settaOpzioni(); 62 frame = new Frame(); 63 frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); 64 frame.setResizable( false ); 65 frame.setSize( 600, 600 ); 66 frame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 600) / 2, 67 (Toolkit.getDefaultToolkit().getScreenSize().height - 600) / 2); 68 69 frame.setVisible( true ); 70 } 71 public void mischia() { 72 mano = 0; 73 punteggio = 0; 74 punteggioCPU = 0; 75 cartaDaPescare = 6; 76 ImageIcon aux; 77 frame.mazzo = true; 78 toccaAllaCPU = false; 79 CPUHaGiocato = false; 80 haGiocatoPrima = true; 81 for ( int i = 0, k = 0; i < 10; i++ ) 82 for ( int j = 0; j < 4; j++, k++ ) 83 frame.arrayCarteMescolate[k] = frame.arrayCarte[i][j]; 84 for ( int i = 0; i < 391; i++ ) { 85 double a = Math.random() * 40; 86 int x = (int) a; 87 double b = Math.random() * 40; 88 int y = (int) b; 89 aux = frame.arrayCarteMescolate[x]; 90 frame.arrayCarteMescolate[x] = frame.arrayCarteMescolate[y]; 91 frame.arrayCarteMescolate[y] = aux; 92 } 93 char auxChar[] = frame.arrayCarteMescolate[39].toString().toCharArray(); 94 semeBriscola = auxChar[auxChar.length-5] - 49; 95 frame.carteInMano[0] = frame.arrayCarteMescolate[0]; 96 frame.carteInMano[1] = frame.arrayCarteMescolate[1]; 97 frame.carteInMano[2] = frame.arrayCarteMescolate[2]; 98 frame.carteCPU[0] = frame.arrayCarteMescolate[3]; 99 frame.carteCPU[1] = frame.arrayCarteMescolate[4]; 100 frame.carteCPU[2] = frame.arrayCarteMescolate[5]; 101 frame.ultimaCarta = frame.arrayCarteMescolate[39]; 102 frame.giocata[0] = null; 103 frame.giocata[1] = null; 104 } 105 public void giocaCPU() { 106 if ( frame.giocata[0] == null ) { 107 if ( vaiLiscio() ); 108 else if ( vaiPunti() ); 109 else if ( vaiTaglio() ); 110 else if ( vaiBriscolaAlta() ); 111 else if ( vaiCarico() ); 112 else if ( vaiTre() ); 113 else if ( vaiAsso() ); 114 else; 115 } 116 else { 117 if ( haLisciato() ) { 118 if ( vaiSopra() ); 119 else if ( vaiLiscio() ); 120 else if ( vaiPunti() ); 121 else if ( vaiTaglio() ); 122 else if ( vaiTre() ); 123 else if ( vaiBriscolaAlta() ); 124 else if ( vaiCarico() ); 125 else if ( vaiAsso() ); 126 } else if ( haMessoPunti() ) { 127 if ( vaiSopra() ); 128 else if ( vaiLiscio() ); 129 else if ( vaiTaglio() ); 130 else if ( vaiPunti() ); 131 else if ( vaiTre() ); 132 else if ( vaiBriscolaAlta() ); 133 else if ( vaiCarico() ); 134 else if ( vaiAsso() ); 135 } else if ( haTagliato() ) { 136 if ( vaiLiscio() ); 137 else if ( vaiPunti() ); 138 else if ( vaiTaglio() ); 139 else if ( vaiTre() ); 140 else if ( vaiBriscolaAlta() ); 141 else if ( vaiCarico() ); 142 else if ( vaiAsso() ); 143 } else if ( haMessoBriscolaAlta() ) { 144 if ( vaiLiscio() ); 145 else if ( vaiPunti() ); 146 else if ( vaiTre() ); 147 else if ( vaiTaglio() ); 148 else if ( vaiBriscolaAlta() ); 149 else if ( vaiCarico() ); 150 else if ( vaiAsso() ); 151 } else if ( haMessoTre() ) { 152 if ( vaiAsso() ); 153 else if ( vaiLiscio() ); 154 else if ( vaiPunti() ); 155 else if ( vaiTaglio() ); 156 else if ( vaiBriscolaAlta() ); 157 else if ( vaiCarico() ); 158 } else if ( haMessoAsso() ) { 159 if ( vaiLiscio() ); 160 else if ( vaiPunti() ); 161 else if ( vaiTaglio() ); 162 else if ( vaiBriscolaAlta() ); 163 else if ( vaiCarico() ); 164 else if ( vaiTre() ); 165 } else if ( haCaricato() ) { 166 if ( vaiSopra() ); 167 else if ( vaiTre() ); 168 else if ( vaiBriscolaAlta() ); 169 else if ( vaiAsso() ); 170 else if ( vaiTaglio() ); 171 else if ( vaiLiscio() ); 172 else if ( vaiPunti() ); 173 else if ( vaiCarico() ); 174 } 175 } 176 frame.giocata[1] = frame.carteCPU[cartaDaGiocare]; 177 frame.carteCPU[cartaDaGiocare] = null; 178 frame.pannello.repaint(); 179 CPUHaGiocato = true; 180 if ( frame.giocata[0] == null ) 181 toccaAllaCPU = false; 182 } 183 public void chiPrende() { 184 char aux[], auxCPU[]; 185 aux = frame.giocata[0].toString().toCharArray(); 186 auxCPU = frame.giocata[1].toString().toCharArray(); 187 giocatorePrende( ( (aux[aux.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) ) 188 || ( (aux[aux.length-5] == auxCPU[auxCPU.length-5]) && laPrimaEPiuAlta( aux[aux.length-7] - 48, auxCPU[auxCPU.length-7] - 48 ) ) 189 || ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (aux[aux.length-5] != auxCPU[auxCPU.length-5]) && haGiocatoPrima ) ); 190 } 191 public boolean laPrimaEPiuAlta( int prima, int seconda ) { 192 int a, b; 193 switch ( prima ) { 194 case 0: 195 a = 10; 196 break; 197 case 1: 198 a = 12; 199 break; 200 case 3: 201 a = 11; 202 break; 203 default: 204 a = prima; 205 break; 206 } 207 switch ( seconda ) { 208 case 0: 209 b = 10; 210 break; 211 case 1: 212 b = 12; 213 break; 214 case 3: 215 b = 11; 216 break; 217 default: 218 b = seconda; 219 break; 220 } 221 return a > b; 222 } 223 public void giocatorePrende( boolean giocatore ) { 224 if ( giocatore ) { 225 toccaAllaCPU = CPUHaGiocato = false; 226 haGiocatoPrima = true; 227 } 228 else { 229 toccaAllaCPU = true; 230 CPUHaGiocato = haGiocatoPrima = false; 231 } 232 daiPunti( giocatore ); 233 if ( toccaAllaCPU ) 234 giocaCPU(); 235 } 236 public void daiPunti( boolean giocatore ) { 237 char aux[], auxCPU[]; 238 aux = frame.giocata[0].toString().toCharArray(); 239 auxCPU = frame.giocata[1].toString().toCharArray(); 240 int punti = 0; 241 switch( aux[aux.length-7] - 48 ) { 242 case 0: 243 punti += 4; 244 break; 245 case 1: 246 punti += 11; 247 break; 248 case 3: 249 punti += 10; 250 break; 251 case 8: 252 punti += 2; 253 break; 254 case 9: 255 punti += 3; 256 break; 257 default: 258 break; 259 } 260 switch( auxCPU[auxCPU.length-7] - 48 ) { 261 case 0: 262 punti += 4; 263 break; 264 case 1: 265 punti += 11; 266 break; 267 case 3: 268 punti += 10; 269 break; 270 case 8: 271 punti += 2; 272 break; 273 case 9: 274 punti += 3; 275 break; 276 default: 277 break; 278 } 279 frame.giocata[0] = frame.giocata[1] = null; 280 if ( giocatore ) { 281 punteggio += punti; 282 if ( mano < 18 ) { 283 if ( frame.carteInMano[0] == null ) 284 frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; 285 if ( frame.carteInMano[1] == null ) 286 frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; 287 if ( frame.carteInMano[2] == null ) 288 frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; 289 cartaDaPescare++; 290 if ( frame.carteCPU[0] == null ) 291 frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; 292 if ( frame.carteCPU[1] == null ) 293 frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; 294 if ( frame.carteCPU[2] == null ) 295 frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; 296 cartaDaPescare++; 297 } 298 } 299 else { 300 punteggioCPU += punti; 301 if ( mano < 18 ) { 302 if ( frame.carteCPU[0] == null ) 303 frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; 304 if ( frame.carteCPU[1] == null ) 305 frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; 306 if ( frame.carteCPU[2] == null ) 307 frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; 308 cartaDaPescare++; 309 if ( frame.carteInMano[0] == null ) 310 frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; 311 if ( frame.carteInMano[1] == null ) 312 frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; 313 if ( frame.carteInMano[2] == null ) 314 frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; 315 cartaDaPescare++; 316 } 317 } 318 frame.pannello.repaint(); 319 frame.repaint(); 320 } 321 public boolean haLisciato() { 322 char auxCPU[]; 323 auxCPU = frame.giocata[0].toString().toCharArray(); 324 return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && 325 (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && 326 (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ); 327 } 328 public boolean haMessoPunti() { 329 char auxCPU[]; 330 auxCPU = frame.giocata[0].toString().toCharArray(); 331 return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && 332 ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || 333 (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ); 334 } 335 public boolean haTagliato() { 336 char auxCPU[]; 337 auxCPU = frame.giocata[0].toString().toCharArray(); 338 return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && 339 (auxCPU[auxCPU.length-7] - 48 != 0) && (auxCPU[auxCPU.length-7] - 48 != 1) && 340 (auxCPU[auxCPU.length-7] - 48 != 3) && (auxCPU[auxCPU.length-7] - 48 <= 7) ); 341 } 342 public boolean haMessoBriscolaAlta() { 343 char auxCPU[]; 344 auxCPU = frame.giocata[0].toString().toCharArray(); 345 return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && 346 ( (auxCPU[auxCPU.length-7] - 48 == 0) || (auxCPU[auxCPU.length-7] - 48 == 8) || 347 (auxCPU[auxCPU.length-7] - 48 == 9) ) ); 348 } 349 public boolean haMessoTre() { 350 char auxCPU[]; 351 auxCPU = frame.giocata[0].toString().toCharArray(); 352 return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && 353 (auxCPU[auxCPU.length-7] - 48 == 3) ); 354 } 355 public boolean haMessoAsso() { 356 char auxCPU[]; 357 auxCPU = frame.giocata[0].toString().toCharArray(); 358 return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && 359 (auxCPU[auxCPU.length-7] - 48 == 1) ); 360 } 361 public boolean haCaricato() { 362 char auxCPU[]; 363 auxCPU = frame.giocata[0].toString().toCharArray(); 364 return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && 365 ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ); 366 } 367 public boolean vaiLiscio() { 368 char auxCPU[]; 369 for ( int i = 0; i < 3; i++ ) { 370 if ( frame.carteCPU[i] != null ) { 371 auxCPU = frame.carteCPU[i].toString().toCharArray(); 372 if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && 373 (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && 374 (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ) { 375 cartaDaGiocare = i; 376 return true; 377 } 378 } 379 } 380 return false; 381 } 382 public boolean vaiPunti() { 383 char[] auxCPU; 384 for ( int i = 0; i < 3; i++ ) { 385 if ( frame.carteCPU[i] != null ) { 386 auxCPU = frame.carteCPU[i].toString().toCharArray(); 387 if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 8 ) ) { 388 cartaDaGiocare = i; 389 return true; 390 } 391 } 392 } 393 for ( int i = 0; i < 3; i++ ) { 394 if ( frame.carteCPU[i] != null ) { 395 auxCPU = frame.carteCPU[i].toString().toCharArray(); 396 if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 9 ) ) { 397 cartaDaGiocare = i; 398 return true; 399 } 400 } 401 } 402 for ( int i = 0; i < 3; i++ ) { 403 if ( frame.carteCPU[i] != null ) { 404 auxCPU = frame.carteCPU[i].toString().toCharArray(); 405 if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 0 ) ) { 406 cartaDaGiocare = i; 407 return true; 408 } 409 } 410 } 411 return false; 412 } 413 public boolean vaiTaglio() { 414 char auxCPU[]; 415 for ( int i = 0; i < 3; i++ ) { 416 if ( frame.carteCPU[i] != null ) { 417 auxCPU = frame.carteCPU[i].toString().toCharArray(); 418 if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && 419 (auxCPU[auxCPU.length-7] - 48 != 0) && (auxCPU[auxCPU.length-7] - 48 != 1) && 420 (auxCPU[auxCPU.length-7] - 48 != 3) && (auxCPU[auxCPU.length-7] - 48 <= 7) ) { 421 cartaDaGiocare = i; 422 return true; 423 } 424 } 425 } 426 return false; 427 } 428 public boolean vaiBriscolaAlta() { 429 char[] auxCPU; 430 for ( int i = 0; i < 3; i++ ) { 431 if ( frame.carteCPU[i] != null ) { 432 auxCPU = frame.carteCPU[i].toString().toCharArray(); 433 if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 8 ) ) { 434 cartaDaGiocare = i; 435 return true; 436 } 437 } 438 } 439 for ( int i = 0; i < 3; i++ ) { 440 if ( frame.carteCPU[i] != null ) { 441 auxCPU = frame.carteCPU[i].toString().toCharArray(); 442 if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 9 ) ) { 443 cartaDaGiocare = i; 444 return true; 445 } 446 } 447 } 448 for ( int i = 0; i < 3; i++ ) { 449 if ( frame.carteCPU[i] != null ) { 450 auxCPU = frame.carteCPU[i].toString().toCharArray(); 451 if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 0 ) ) { 452 cartaDaGiocare = i; 453 return true; 454 } 455 } 456 } 457 return false; 458 } 459 public boolean vaiTre() { 460 char auxCPU[]; 461 for ( int i = 0; i < 3; i++ ) { 462 if ( frame.carteCPU[i] != null ) { 463 auxCPU = frame.carteCPU[i].toString().toCharArray(); 464 if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && (auxCPU[auxCPU.length-7] - 48 == 3) ) { 465 cartaDaGiocare = i; 466 return true; 467 } 468 } 469 } 470 return false; 471 } 472 public boolean vaiAsso() { 473 char auxCPU[]; 474 for ( int i = 0; i < 3; i++ ) { 475 if ( frame.carteCPU[i] != null ) { 476 auxCPU = frame.carteCPU[i].toString().toCharArray(); 477 if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && (auxCPU[auxCPU.length-7] - 48 == 1) ) { 478 cartaDaGiocare = i; 479 return true; 480 } 481 } 482 } 483 return false; 484 } 485 public boolean vaiCarico() { 486 char[] auxCPU; 487 for ( int i = 0; i < 3; i++ ) { 488 if ( frame.carteCPU[i] != null ) { 489 auxCPU = frame.carteCPU[i].toString().toCharArray(); 490 if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 3 ) ) { 491 cartaDaGiocare = i; 492 return true; 493 } 494 } 495 } 496 for ( int i = 0; i < 3; i++ ) { 497 if ( frame.carteCPU[i] != null ) { 498 auxCPU = frame.carteCPU[i].toString().toCharArray(); 499 if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 1 ) ) { 500 cartaDaGiocare = i; 501 return true; 502 } 503 } 504 } 505 return false; 506 } 507 public boolean vaiSopra() { 508 if ( frame.giocata[0] == null ) 509 return false; 510 int a = -1; 511 int b = -1; 512 int c = -1; 513 boolean laPrimaPuoAndareSopra = false; 514 boolean laSecondaPuoAndareSopra = false; 515 boolean laTerzaPuoAndareSopra = false; 516 char[] auxCPU1 = new char[1024]; 517 char[] auxCPU2 = new char[1024]; 518 char[] auxCPU3 = new char[1024]; 519 char[] aux = frame.giocata[0].toString().toCharArray(); 520 if ( aux[aux.length-7] - 48 == 1 ) 521 return false; 522 if ( frame.carteCPU[0] != null ) { 523 auxCPU1 = frame.carteCPU[0].toString().toCharArray(); 524 a = auxCPU1[auxCPU1.length-7] - 48; 525 if ( (auxCPU1[auxCPU1.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( a, aux[aux.length-7] - 48 ) ) 526 laPrimaPuoAndareSopra = true; 527 } 528 if ( frame.carteCPU[1] != null ) { 529 auxCPU2 = frame.carteCPU[1].toString().toCharArray(); 530 b = auxCPU2[auxCPU2.length-7] - 48; 531 if ( (auxCPU2[auxCPU2.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( b, aux[aux.length-7] - 48 ) ) 532 laSecondaPuoAndareSopra = true; 533 } 534 if ( frame.carteCPU[2] != null ) { 535 auxCPU3 = frame.carteCPU[2].toString().toCharArray(); 536 c = auxCPU3[auxCPU3.length-7] - 48; 537 if ( (auxCPU3[auxCPU3.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( c, aux[aux.length-7] - 48 ) ) 538 laTerzaPuoAndareSopra = true; 539 } 540 if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) 541 return false; 542 else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) 543 cartaDaGiocare = 0; 544 else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) 545 cartaDaGiocare = 1; 546 else if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) 547 cartaDaGiocare = 2; 548 else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) 549 if ( laPrimaEPiuAlta( a, b ) ) 550 cartaDaGiocare = 0; 551 else 552 cartaDaGiocare = 1; 553 else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) 554 if ( laPrimaEPiuAlta( b, c ) ) 555 cartaDaGiocare = 1; 556 else 557 cartaDaGiocare = 2; 558 else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) 559 if ( laPrimaEPiuAlta( a, c ) ) 560 cartaDaGiocare = 0; 561 else 562 cartaDaGiocare = 2; 563 else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) 564 if ( laPrimaEPiuAlta( a, b ) ) 565 if ( laPrimaEPiuAlta( a, c ) ) 566 cartaDaGiocare = 0; 567 else 568 cartaDaGiocare = 2; 569 else 570 if ( laPrimaEPiuAlta( b, c ) ) 571 cartaDaGiocare = 1; 572 else 573 cartaDaGiocare = 2; 574 aux = frame.carteCPU[cartaDaGiocare].toString().toCharArray(); 575 if ( (aux[aux.length-7] - 48 != 0) && (aux[aux.length-7] - 48 != 1) && 576 (aux[aux.length-7] - 48 != 3) && (aux[aux.length-7] - 48 <= 7) ) 577 return false; 578 return true; 579 } 580 public static void settaOpzioni() { 581 String lang; 582 Scanner scanner = null; 583 File file = new File( "JBriscolaConfig.txt" ); 584 if ( file.exists() ) { 585 try { 586 scanner = new Scanner( file ); 587 } catch ( FileNotFoundException e ) { 588 lang = "it"; 589 } 590 lang = scanner.next(); 591 } 592 else { 593 lang = "it"; 594 } 595 if ( lang.equals( "it" ) ) { 596 stringaBottonePrendi = "Prendi/Lascia carte"; 597 stringaPrimaGioca = "Prima Gioca!"; 598 stringaUltime4 = "Ultima carta - Occhio alla briscola!"; 599 stringaVinto = "Hai Vinto!"; 600 stringaPerso = "Hai Perso"; 601 stringaPareggio = "Pareggio"; 602 stringaGiocatore = "Giocatore: "; 603 stringaComputer = "\nComputer: "; 604 stringaNuovaPartita = "Nuova Partita"; 605 stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; 606 stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; 607 stringaSi = "Si"; 608 stringaNo = "No"; 609 stringaOpzioni = "Opzioni..."; 610 stringaEsci = "Esci"; 611 stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; 612 stringaLingua = "Lingua"; 613 stringaAnnulla = "Annulla"; 614 stringaIt = "Italiano"; 615 stringaLa = "Latino"; 616 stringaBL = "Dialetto Bellunese"; 617 stringaBV = "Dialetto Basso Veneto"; 618 stringaNecessarioRiavviare = "E' necessario riavviare JBriscola se sono state\nmodificate impostazioni riguardanti la lingua\nAlcune parti saranno comunque tradotte prima."; 619 stringaModificaOpzioni = "Modifica Opzioni"; 620 stringaInformazioni = "Informazioni"; 621 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"; 622 } 623 else if ( lang.equals( "la" ) ) { 624 stringaBottonePrendi = "CAPIS/RELINQVIS CHARTAS"; 625 stringaPrimaGioca = "ANTE CHARTAM PONE!"; 626 stringaUltime4 = "CHARTA POSTREMA - INTVERE BRISCOLAM!"; 627 stringaVinto = "VICISTI!"; 628 stringaPerso = "PERDIDISTI"; 629 stringaPareggio = "AEQVATIO!"; 630 stringaGiocatore = "LVSOR: "; 631 stringaComputer = "\nCOMPVTER: "; 632 stringaNuovaPartita = "NOVA LVSO"; 633 stringaVuoiDavveroIniziare = "NOVAM LVSIONEM INCIPERE?"; 634 stringaVuoiDavveroUscire = "EXIRE?"; 635 stringaSi = "ID VOLO"; 636 stringaNo = "NOLO"; 637 stringaOpzioni = "OPTIONES..."; 638 stringaEsci = "EXIRE"; 639 stringaImpossibileConfigurare = "CONFIGVRATIONIS FILE SCRIBERE NON POTVI.\nERROREM ME CERTIOREM FACITE: sebastiano@luganega.org\n\nEXCEPTIO:\n"; 640 stringaLingua = "LINGVA"; 641 stringaAnnulla = "ABROGA"; 642 stringaIt = "ITALICA"; 643 stringaLa = "LATINA"; 644 stringaBL = "BELLUNI"; 645 stringaBV = "VENETIAE"; 646 stringaNecessarioRiavviare = "JBRISCOLAM RVRSVS INCIPERE NECESSE EST\nSI LINGVA PRAELATIONES NOVATAE SVNT.\nALIQVAE ANTE ID VERSA ERVNT"; 647 stringaModificaOpzioni = "OPTIONES NOVARE"; 648 stringaInformazioni = "INFORMATIONES"; 649 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"; 650 } 651 if ( lang.equals( "bl" ) ) { 652 stringaBottonePrendi = "Cio' su/lasa le carte"; 653 stringaPrimaGioca = "Prima Duga!"; 654 stringaUltime4 = "Ultima carta - Ocio a la briscola!"; 655 stringaVinto = "Te ha vint!"; 656 stringaPerso = "Te ha pers"; 657 stringaPareggio = "Pari"; 658 stringaGiocatore = "Dugador: "; 659 stringaComputer = "\nComputer: "; 660 stringaNuovaPartita = "Taca n'altra partida"; 661 stringaVuoiDavveroIniziare = "Utu sul serio scuminziar n'altra partida?"; 662 stringaVuoiDavveroUscire = "Utu sul serio stusar su?"; 663 stringaSi = "Si"; 664 stringaNo = "No"; 665 stringaOpzioni = "Opzioni..."; 666 stringaEsci = "Stusa su"; 667 stringaImpossibileConfigurare = "No ghe ho riva' a scrivere al file de configurazion.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; 668 stringaLingua = "Lengua"; 669 stringaAnnulla = "Annulla"; 670 stringaIt = "Italian"; 671 stringaLa = "Latin"; 672 stringaBL = "Dialeto de Belun"; 673 stringaBV = "Dialeto de la basa"; 674 stringaNecessarioRiavviare = "Se te ha cambia' la lengua te toca\nstusar su e impizar de novo al dugo\nPero' zerte robe le e' belche tradote."; 675 stringaModificaOpzioni = "Modifica Opzioni"; 676 stringaInformazioni = "Informazioni"; 677 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"; 678 } 679 if ( lang.equals( "bv" ) ) { 680 stringaBottonePrendi = "Ciapa su/lasa e carte"; 681 stringaPrimaGioca = "Prima Zuga!"; 682 stringaUltime4 = "Ultima carta - Ocio a la briscola!"; 683 stringaVinto = "Ti ga vinto!"; 684 stringaPerso = "Ti ga perso"; 685 stringaPareggio = "Pari"; 686 stringaGiocatore = "Zugador: "; 687 stringaComputer = "\nComputer: "; 688 stringaNuovaPartita = "N'altra Partida"; 689 stringaVuoiDavveroIniziare = "Ti vol sul serio scuminziar n'altra partida?"; 690 stringaVuoiDavveroUscire = "Ti vol sul serio stusar su?"; 691 stringaSi = "Si"; 692 stringaNo = "No"; 693 stringaOpzioni = "Opzioni..."; 694 stringaEsci = "Stusa su"; 695 stringaImpossibileConfigurare = "No ghe son riusito a scrivere al file de configurazione.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; 696 stringaLingua = "Lengua"; 697 stringaAnnulla = "Annulla"; 698 stringaIt = "Italian"; 699 stringaLa = "Latin"; 700 stringaBL = "Dialeto Belumat"; 701 stringaBV = "Dialeto Veneto"; 702 stringaNecessarioRiavviare = "Se ti ga cambia' la lengua te toca\nstusar su e impizar de novo al zugo\nPero' zerte robe le e' belche tradote."; 703 stringaModificaOpzioni = "Modifica Opzioni"; 704 stringaInformazioni = "Informasioni"; 705 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"; 706 } 707 } 708 }