diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2026-03-26 19:27:18 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2026-03-26 19:27:18 +0100 |
| commit | 7167b4341ef290d56fb96e2af10883a4b925d83b (patch) | |
| tree | 1eb1b9e5ab82ddd89540e68d6b22ae69514575c6 /JBriscola | |
| download | ancient-projects-7167b4341ef290d56fb96e2af10883a4b925d83b.tar.gz ancient-projects-7167b4341ef290d56fb96e2af10883a4b925d83b.zip | |
Diffstat (limited to 'JBriscola')
559 files changed, 20482 insertions, 0 deletions
diff --git a/JBriscola/JBriscola.jar b/JBriscola/JBriscola.jar new file mode 100755 index 0000000..9306db5 --- /dev/null +++ b/JBriscola/JBriscola.jar | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1 Alpha 1/src/Frame.java b/JBriscola/all_versions/0.1/0.1 Alpha 1/src/Frame.java new file mode 100755 index 0000000..a372588 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1 Alpha 1/src/Frame.java | |||
| @@ -0,0 +1,118 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | import java.awt.event.*; | ||
| 25 | |||
| 26 | public class Frame extends JFrame { | ||
| 27 | public static boolean mazzo; | ||
| 28 | public static Main main; | ||
| 29 | public static Pannello pannello; | ||
| 30 | public static JButton button; | ||
| 31 | public static ImageIcon retro1, retro2, ultimaCarta; | ||
| 32 | public static ImageIcon[] giocata = new ImageIcon[2]; | ||
| 33 | public static ImageIcon[] carteInMano = new ImageIcon[3]; | ||
| 34 | public static ImageIcon[] carteCPU = new ImageIcon[3]; | ||
| 35 | public static ImageIcon[] arrayCarteMescolate = new ImageIcon[40]; | ||
| 36 | public static ImageIcon[][] arrayCarte = new ImageIcon[10][4]; | ||
| 37 | public Frame() { | ||
| 38 | super( "Tronto's JBriscola 0.1" ); | ||
| 39 | mazzo = true; | ||
| 40 | main = new Main(); | ||
| 41 | pannello = new Pannello(); | ||
| 42 | button = new JButton( "Prendi/Lascia carte" ); | ||
| 43 | button.addActionListener( new ActionListener() { | ||
| 44 | public void actionPerformed( ActionEvent e ) { | ||
| 45 | if ( giocata[0] != null && giocata[1] != null ) | ||
| 46 | main.mano++; | ||
| 47 | else | ||
| 48 | JOptionPane.showMessageDialog( Frame.this, "Prima gioca!" ); | ||
| 49 | try { | ||
| 50 | main.chiPrende(); | ||
| 51 | } catch ( Exception ex ) { | ||
| 52 | JOptionPane.showMessageDialog( Frame.this, "Prima gioca!" ); | ||
| 53 | } | ||
| 54 | if ( main.mano == 16 ) | ||
| 55 | JOptionPane.showMessageDialog( Frame.this, "Ultime 4 mani - occhio alla briscola!" ); | ||
| 56 | if ( main.mano == 17 ) { | ||
| 57 | mazzo = false; | ||
| 58 | ultimaCarta = null; | ||
| 59 | pannello.repaint(); | ||
| 60 | Frame.this.repaint(); | ||
| 61 | } | ||
| 62 | if ( main.mano == 20 ) | ||
| 63 | JOptionPane.showMessageDialog( Frame.this, "Giocatore: " + main.punteggio + "\nComputer: " + main.punteggioCPU + "\n\nMa grazie tante, il computer gioca a caso!\nNon serve che ti gasi tanto." ); | ||
| 64 | } | ||
| 65 | } ); | ||
| 66 | retro1 = new ImageIcon( ClassLoader.getSystemResource( "img/retro1.jpg" ) ); | ||
| 67 | retro2 = new ImageIcon( ClassLoader.getSystemResource( "img/retro2.jpg" ) ); | ||
| 68 | for (int i = 0; i < 10; i++) | ||
| 69 | for (int j = 0; j < 4; j++) | ||
| 70 | arrayCarte[i][j] = new ImageIcon( ClassLoader.getSystemResource( "img/" + (i+1) + "-" + (j+1) + ".jpg" ) ); | ||
| 71 | main.mischia(); | ||
| 72 | carteInMano[0] = arrayCarteMescolate[0]; | ||
| 73 | carteInMano[1] = arrayCarteMescolate[1]; | ||
| 74 | carteInMano[2] = arrayCarteMescolate[2]; | ||
| 75 | carteCPU[0] = arrayCarteMescolate[3]; | ||
| 76 | carteCPU[1] = arrayCarteMescolate[4]; | ||
| 77 | carteCPU[2] = arrayCarteMescolate[5]; | ||
| 78 | ultimaCarta = arrayCarteMescolate[39]; | ||
| 79 | setLayout( new BorderLayout() ); | ||
| 80 | add( pannello, BorderLayout.CENTER ); | ||
| 81 | add( button, BorderLayout.SOUTH ); | ||
| 82 | addMouseListener( | ||
| 83 | new MouseAdapter() { | ||
| 84 | public void mouseClicked ( MouseEvent e ) { | ||
| 85 | if ( mettiCarta( e.getX(), e.getY() ) ) { | ||
| 86 | if ( !main.CPUHaGiocato ) | ||
| 87 | main.giocaCPU(); | ||
| 88 | } | ||
| 89 | } | ||
| 90 | } | ||
| 91 | ); | ||
| 92 | } | ||
| 93 | public boolean mettiCarta( int x, int y ) { | ||
| 94 | if ( !main.toccaAllaCPU && giocata[0] == null ) { | ||
| 95 | if ( x > 230 && x < 290 && y > 340 && y < 566 ) { | ||
| 96 | giocata[0] = carteInMano[0]; | ||
| 97 | carteInMano[0] = null; | ||
| 98 | pannello.repaint(); | ||
| 99 | return true; | ||
| 100 | } | ||
| 101 | if ( x > 300 && x < 360 && y > 340 && y < 566 ) { | ||
| 102 | giocata[0] = carteInMano[1]; | ||
| 103 | carteInMano[1] = null; | ||
| 104 | pannello.repaint(); | ||
| 105 | return true; | ||
| 106 | } | ||
| 107 | if ( x > 370 && x < 430 && y > 340 && y < 566 ) { | ||
| 108 | giocata[0] = carteInMano[2]; | ||
| 109 | carteInMano[2] = null; | ||
| 110 | pannello.repaint(); | ||
| 111 | return true; | ||
| 112 | } | ||
| 113 | } | ||
| 114 | return false; | ||
| 115 | } | ||
| 116 | } | ||
| 117 | |||
| 118 | |||
diff --git a/JBriscola/all_versions/0.1/0.1 Alpha 1/src/Main.java b/JBriscola/all_versions/0.1/0.1 Alpha 1/src/Main.java new file mode 100755 index 0000000..22f6e47 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1 Alpha 1/src/Main.java | |||
| @@ -0,0 +1,211 @@ | |||
| 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 javax.swing.*; | ||
| 23 | |||
| 24 | public class Main { | ||
| 25 | public static int semeBriscola, punteggio, punteggioCPU, mano, cartaDaPescare; | ||
| 26 | public static boolean toccaAllaCPU = false; | ||
| 27 | public static boolean CPUHaGiocato = false; | ||
| 28 | public static boolean haGiocatoPrima = true; | ||
| 29 | public static Frame frame; | ||
| 30 | public static void main( String args[] ) { | ||
| 31 | frame = new Frame(); | ||
| 32 | frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); | ||
| 33 | frame.setVisible( true ); | ||
| 34 | frame.setResizable( false ); | ||
| 35 | frame.setSize( 600, 550 ); | ||
| 36 | } | ||
| 37 | public void mischia() { | ||
| 38 | mano = 0; | ||
| 39 | cartaDaPescare = 6; | ||
| 40 | ImageIcon aux; | ||
| 41 | for ( int i = 0, k = 0; i < 10; i++ ) | ||
| 42 | for ( int j = 0; j < 4; j++, k++ ) | ||
| 43 | frame.arrayCarteMescolate[k] = frame.arrayCarte[i][j]; | ||
| 44 | for ( int i = 0; i < 391; i++ ) { | ||
| 45 | double a = Math.random() * 40; | ||
| 46 | int x = (int) a; | ||
| 47 | double b = Math.random() * 40; | ||
| 48 | int y = (int) b; | ||
| 49 | aux = frame.arrayCarteMescolate[x]; | ||
| 50 | frame.arrayCarteMescolate[x] = frame.arrayCarteMescolate[y]; | ||
| 51 | frame.arrayCarteMescolate[y] = aux; | ||
| 52 | } | ||
| 53 | char auxChar[] = frame.arrayCarteMescolate[39].toString().toCharArray(); | ||
| 54 | semeBriscola = auxChar[auxChar.length-5] - 49; | ||
| 55 | } | ||
| 56 | public void giocaCPU() { | ||
| 57 | int cartaDaGiocare; | ||
| 58 | /*******************************************/ | ||
| 59 | if ( frame.carteCPU[0] != null ) | ||
| 60 | cartaDaGiocare = 0; | ||
| 61 | else if ( frame.carteCPU[1] != null ) | ||
| 62 | cartaDaGiocare = 1; | ||
| 63 | else | ||
| 64 | cartaDaGiocare = 2; | ||
| 65 | /*******************************************/ | ||
| 66 | frame.giocata[1] = frame.carteCPU[cartaDaGiocare]; | ||
| 67 | frame.carteCPU[cartaDaGiocare] = null; | ||
| 68 | frame.pannello.repaint(); | ||
| 69 | CPUHaGiocato = true; | ||
| 70 | if ( frame.giocata[0] == null ) | ||
| 71 | toccaAllaCPU = false; | ||
| 72 | } | ||
| 73 | public void chiPrende() { | ||
| 74 | char aux[], auxCPU[]; | ||
| 75 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 76 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 77 | giocatorePrende( ( (aux[aux.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) ) | ||
| 78 | || ( (aux[aux.length-5] == auxCPU[auxCPU.length-5]) && laPrimaEPiuAlta( aux[aux.length-7] - 48, auxCPU[auxCPU.length-7] - 48 ) ) | ||
| 79 | || ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (aux[aux.length-5] != auxCPU[auxCPU.length-5]) && haGiocatoPrima ) ); | ||
| 80 | } | ||
| 81 | public boolean laPrimaEPiuAlta( int prima, int seconda ) { | ||
| 82 | int a, b; | ||
| 83 | switch ( prima ) { | ||
| 84 | case 0: | ||
| 85 | a = 10; | ||
| 86 | break; | ||
| 87 | case 1: | ||
| 88 | a = 12; | ||
| 89 | break; | ||
| 90 | case 3: | ||
| 91 | a = 11; | ||
| 92 | break; | ||
| 93 | default: | ||
| 94 | a = prima; | ||
| 95 | break; | ||
| 96 | } | ||
| 97 | switch ( seconda ) { | ||
| 98 | case 0: | ||
| 99 | b = 10; | ||
| 100 | break; | ||
| 101 | case 1: | ||
| 102 | b = 12; | ||
| 103 | break; | ||
| 104 | case 3: | ||
| 105 | b = 11; | ||
| 106 | break; | ||
| 107 | default: | ||
| 108 | b = seconda; | ||
| 109 | break; | ||
| 110 | } | ||
| 111 | return a > b; | ||
| 112 | } | ||
| 113 | public void giocatorePrende( boolean giocatore ) { | ||
| 114 | if ( giocatore ) { | ||
| 115 | toccaAllaCPU = CPUHaGiocato = false; | ||
| 116 | haGiocatoPrima = true; | ||
| 117 | } | ||
| 118 | else { | ||
| 119 | toccaAllaCPU = true; | ||
| 120 | CPUHaGiocato = haGiocatoPrima = false; | ||
| 121 | } | ||
| 122 | daiPunti( giocatore ); | ||
| 123 | if ( toccaAllaCPU ) | ||
| 124 | giocaCPU(); | ||
| 125 | } | ||
| 126 | public void daiPunti( boolean giocatore ) { | ||
| 127 | char aux[], auxCPU[]; | ||
| 128 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 129 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 130 | int punti = 0; | ||
| 131 | switch( aux[aux.length-7] - 48 ) { | ||
| 132 | case 0: | ||
| 133 | punti += 4; | ||
| 134 | break; | ||
| 135 | case 1: | ||
| 136 | punti += 11; | ||
| 137 | break; | ||
| 138 | case 3: | ||
| 139 | punti += 10; | ||
| 140 | break; | ||
| 141 | case 8: | ||
| 142 | punti += 2; | ||
| 143 | break; | ||
| 144 | case 9: | ||
| 145 | punti += 3; | ||
| 146 | break; | ||
| 147 | default: | ||
| 148 | break; | ||
| 149 | } | ||
| 150 | switch( auxCPU[auxCPU.length-7] - 48 ) { | ||
| 151 | case 0: | ||
| 152 | punti += 4; | ||
| 153 | break; | ||
| 154 | case 1: | ||
| 155 | punti += 11; | ||
| 156 | break; | ||
| 157 | case 3: | ||
| 158 | punti += 10; | ||
| 159 | break; | ||
| 160 | case 8: | ||
| 161 | punti += 2; | ||
| 162 | break; | ||
| 163 | case 9: | ||
| 164 | punti += 3; | ||
| 165 | break; | ||
| 166 | default: | ||
| 167 | break; | ||
| 168 | } | ||
| 169 | frame.giocata[0] = frame.giocata[1] = null; | ||
| 170 | if ( giocatore ) { | ||
| 171 | punteggio += punti; | ||
| 172 | if ( mano < 18 ) { | ||
| 173 | if ( frame.carteInMano[0] == null ) | ||
| 174 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 175 | if ( frame.carteInMano[1] == null ) | ||
| 176 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 177 | if ( frame.carteInMano[2] == null ) | ||
| 178 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 179 | cartaDaPescare++; | ||
| 180 | if ( frame.carteCPU[0] == null ) | ||
| 181 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 182 | if ( frame.carteCPU[1] == null ) | ||
| 183 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 184 | if ( frame.carteCPU[2] == null ) | ||
| 185 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 186 | cartaDaPescare++; | ||
| 187 | } | ||
| 188 | } | ||
| 189 | else { | ||
| 190 | punteggioCPU += punti; | ||
| 191 | if ( mano < 18 ) { | ||
| 192 | if ( frame.carteCPU[0] == null ) | ||
| 193 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 194 | if ( frame.carteCPU[1] == null ) | ||
| 195 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 196 | if ( frame.carteCPU[2] == null ) | ||
| 197 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 198 | cartaDaPescare++; | ||
| 199 | if ( frame.carteInMano[0] == null ) | ||
| 200 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 201 | if ( frame.carteInMano[1] == null ) | ||
| 202 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 203 | if ( frame.carteInMano[2] == null ) | ||
| 204 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 205 | cartaDaPescare++; | ||
| 206 | } | ||
| 207 | } | ||
| 208 | frame.pannello.repaint(); | ||
| 209 | frame.repaint(); | ||
| 210 | } | ||
| 211 | } | ||
diff --git a/JBriscola/all_versions/0.1/0.1 Alpha 1/src/Pannello.java b/JBriscola/all_versions/0.1/0.1 Alpha 1/src/Pannello.java new file mode 100755 index 0000000..9e73356 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1 Alpha 1/src/Pannello.java | |||
| @@ -0,0 +1,53 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import java.awt.Graphics; | ||
| 24 | |||
| 25 | public class Pannello extends JPanel { | ||
| 26 | public static Main main; | ||
| 27 | public Pannello() { | ||
| 28 | } | ||
| 29 | public void paint( Graphics g ) { | ||
| 30 | super.paint( g ); | ||
| 31 | if ( main.frame.ultimaCarta != null ) | ||
| 32 | main.frame.ultimaCarta.paintIcon( this, g, 50, 180 ); | ||
| 33 | if ( main.frame.mazzo ) | ||
| 34 | main.frame.retro2.paintIcon( this, g, 17, 256 ); | ||
| 35 | if ( main.frame.carteCPU[0] != null ) | ||
| 36 | main.frame.retro1.paintIcon( this, g, 230, 5 ); | ||
| 37 | if ( main.frame.carteCPU[1] != null ) | ||
| 38 | main.frame.retro1.paintIcon( this, g, 300, 5 ); | ||
| 39 | if ( main.frame.carteCPU[2] != null ) | ||
| 40 | main.frame.retro1.paintIcon( this, g, 370, 5 ); | ||
| 41 | if ( main.frame.carteInMano[0] != null ) | ||
| 42 | main.frame.carteInMano[0].paintIcon( this, g, 230, 340 ); | ||
| 43 | if ( main.frame.carteInMano[1] != null ) | ||
| 44 | main.frame.carteInMano[1].paintIcon( this, g, 300, 340 ); | ||
| 45 | if ( main.frame.carteInMano[2] != null ) | ||
| 46 | main.frame.carteInMano[2].paintIcon( this, g, 370, 340 ); | ||
| 47 | if ( main.frame.giocata[0] != null ) | ||
| 48 | main.frame.giocata[0].paintIcon( this, g, 250, 200 ); | ||
| 49 | if ( main.frame.giocata[1] != null ) | ||
| 50 | main.frame.giocata[1].paintIcon( this, g, 325, 150 ); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
diff --git a/JBriscola/all_versions/0.1/0.1 Beta 1/src/Frame.java b/JBriscola/all_versions/0.1/0.1 Beta 1/src/Frame.java new file mode 100755 index 0000000..452cfe2 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1 Beta 1/src/Frame.java | |||
| @@ -0,0 +1,159 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | import java.awt.event.*; | ||
| 25 | |||
| 26 | public class Frame extends JFrame { | ||
| 27 | public static boolean mazzo; | ||
| 28 | public static Main main; | ||
| 29 | public static Pannello pannello; | ||
| 30 | public static JButton button; | ||
| 31 | public static JMenuBar barraMenu; | ||
| 32 | public static JMenu file; | ||
| 33 | public static JMenuItem nuovaPartita, esci; | ||
| 34 | public static ImageIcon retro1, retro2, ultimaCarta; | ||
| 35 | public static ImageIcon[] giocata = new ImageIcon[2]; | ||
| 36 | public static ImageIcon[] carteInMano = new ImageIcon[3]; | ||
| 37 | public static ImageIcon[] carteCPU = new ImageIcon[3]; | ||
| 38 | public static ImageIcon[] arrayCarteMescolate = new ImageIcon[40]; | ||
| 39 | public static ImageIcon[][] arrayCarte = new ImageIcon[10][4]; | ||
| 40 | public Frame() { | ||
| 41 | super( "Tronto's JBriscola 0.1" ); | ||
| 42 | mazzo = true; | ||
| 43 | main = new Main(); | ||
| 44 | pannello = new Pannello(); | ||
| 45 | button = new JButton( "Prendi/Lascia carte" ); | ||
| 46 | button.addActionListener( new ActionListener() { | ||
| 47 | public void actionPerformed( ActionEvent e ) { | ||
| 48 | if ( giocata[0] != null && giocata[1] != null ) | ||
| 49 | main.mano++; | ||
| 50 | try { | ||
| 51 | main.chiPrende(); | ||
| 52 | } catch ( Exception ex ) { | ||
| 53 | JOptionPane.showMessageDialog( Frame.this, "Prima gioca!" ); | ||
| 54 | } | ||
| 55 | if ( main.mano == 16 ) | ||
| 56 | JOptionPane.showMessageDialog( Frame.this, "Ultime 4 mani - occhio alla briscola!" ); | ||
| 57 | if ( main.mano == 17 ) { | ||
| 58 | mazzo = false; | ||
| 59 | ultimaCarta = null; | ||
| 60 | pannello.repaint(); | ||
| 61 | Frame.this.repaint(); | ||
| 62 | } | ||
| 63 | if ( main.mano == 20 ) { | ||
| 64 | String titolo = "Hai vinto!"; | ||
| 65 | if ( main.punteggio < main.punteggioCPU ) | ||
| 66 | titolo = "Hai perso"; | ||
| 67 | if ( main.punteggio == main.punteggioCPU ) | ||
| 68 | titolo = "Pareggio!"; | ||
| 69 | JOptionPane.showMessageDialog( Frame.this, "Giocatore: " + main.punteggio + "\nComputer: " + main.punteggioCPU, titolo, JOptionPane.PLAIN_MESSAGE ); | ||
| 70 | } | ||
| 71 | } | ||
| 72 | } ); | ||
| 73 | barraMenu = new JMenuBar(); | ||
| 74 | file = new JMenu( "File" ); | ||
| 75 | nuovaPartita = new JMenuItem( "Nuova Partita" ); | ||
| 76 | nuovaPartita.addActionListener( new ActionListener() { | ||
| 77 | public void actionPerformed( ActionEvent e ) { | ||
| 78 | if ( main.mano == 20 ) { | ||
| 79 | main.mischia(); | ||
| 80 | pannello.repaint(); | ||
| 81 | repaint(); | ||
| 82 | } | ||
| 83 | else { | ||
| 84 | int selezione = JOptionPane.showOptionDialog( Frame.this, "Vuoi davvero iniziare una nuova partita?", "JBriscola 0.1", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Si", "No" }, "No" ); | ||
| 85 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 86 | main.mischia(); | ||
| 87 | pannello.repaint(); | ||
| 88 | repaint(); | ||
| 89 | } | ||
| 90 | } | ||
| 91 | } | ||
| 92 | }); | ||
| 93 | esci = new JMenuItem( "Esci" ); | ||
| 94 | esci.addActionListener( new ActionListener() { | ||
| 95 | public void actionPerformed( ActionEvent e ) { | ||
| 96 | int selezione = JOptionPane.showOptionDialog( Frame.this, "Vuoi davvero uscire?", "JBriscola 0.1", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Si", "No" }, "No" ); | ||
| 97 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 98 | Frame.this.dispose(); | ||
| 99 | } | ||
| 100 | }); | ||
| 101 | file.add( nuovaPartita ); | ||
| 102 | file.add( esci ); | ||
| 103 | barraMenu.add( file ); | ||
| 104 | setJMenuBar( barraMenu ); | ||
| 105 | retro1 = new ImageIcon( ClassLoader.getSystemResource( "img/retro1.jpg" ) ); | ||
| 106 | retro2 = new ImageIcon( ClassLoader.getSystemResource( "img/retro2.jpg" ) ); | ||
| 107 | for (int i = 0; i < 10; i++) | ||
| 108 | for (int j = 0; j < 4; j++) | ||
| 109 | arrayCarte[i][j] = new ImageIcon( ClassLoader.getSystemResource( "img/" + (i+1) + "-" + (j+1) + ".jpg" ) ); | ||
| 110 | main.mischia(); | ||
| 111 | setLayout( new BorderLayout() ); | ||
| 112 | add( pannello, BorderLayout.CENTER ); | ||
| 113 | add( button, BorderLayout.SOUTH ); | ||
| 114 | addMouseListener( | ||
| 115 | new MouseAdapter() { | ||
| 116 | public void mouseClicked ( MouseEvent e ) { | ||
| 117 | if ( mettiCarta( e.getX(), e.getY() ) ) { | ||
| 118 | if ( !main.CPUHaGiocato ) | ||
| 119 | main.giocaCPU(); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | } | ||
| 123 | ); | ||
| 124 | addWindowListener( | ||
| 125 | new WindowAdapter() { | ||
| 126 | public void windowClosing( WindowEvent e ) { | ||
| 127 | int selezione = JOptionPane.showOptionDialog( Frame.this, "Vuoi davvero uscire?", "JBriscola 0.1", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { "Si", "No" }, "No" ); | ||
| 128 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 129 | System.exit( 0 ); | ||
| 130 | } | ||
| 131 | } | ||
| 132 | ); | ||
| 133 | } | ||
| 134 | public boolean mettiCarta( int x, int y ) { | ||
| 135 | if ( !main.toccaAllaCPU && giocata[0] == null ) { | ||
| 136 | if ( x > 230 && x < 290 && y > 340 && y < 566 ) { | ||
| 137 | giocata[0] = carteInMano[0]; | ||
| 138 | carteInMano[0] = null; | ||
| 139 | pannello.repaint(); | ||
| 140 | return true; | ||
| 141 | } | ||
| 142 | if ( x > 300 && x < 360 && y > 340 && y < 566 ) { | ||
| 143 | giocata[0] = carteInMano[1]; | ||
| 144 | carteInMano[1] = null; | ||
| 145 | pannello.repaint(); | ||
| 146 | return true; | ||
| 147 | } | ||
| 148 | if ( x > 370 && x < 430 && y > 340 && y < 566 ) { | ||
| 149 | giocata[0] = carteInMano[2]; | ||
| 150 | carteInMano[2] = null; | ||
| 151 | pannello.repaint(); | ||
| 152 | return true; | ||
| 153 | } | ||
| 154 | } | ||
| 155 | return false; | ||
| 156 | } | ||
| 157 | } | ||
| 158 | |||
| 159 | |||
diff --git a/JBriscola/all_versions/0.1/0.1 Beta 1/src/Main.java b/JBriscola/all_versions/0.1/0.1 Beta 1/src/Main.java new file mode 100755 index 0000000..f844dd8 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1 Beta 1/src/Main.java | |||
| @@ -0,0 +1,399 @@ | |||
| 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 javax.swing.*; | ||
| 23 | |||
| 24 | public class Main { | ||
| 25 | public static int semeBriscola, punteggio, punteggioCPU, mano, cartaDaPescare, cartaDaGiocare; | ||
| 26 | public static boolean toccaAllaCPU = false; | ||
| 27 | public static boolean CPUHaGiocato = false; | ||
| 28 | public static boolean haGiocatoPrima = true; | ||
| 29 | public static Frame frame; | ||
| 30 | public static void main( String args[] ) { | ||
| 31 | frame = new Frame(); | ||
| 32 | frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); | ||
| 33 | frame.setVisible( true ); | ||
| 34 | frame.setResizable( false ); | ||
| 35 | frame.setSize( 600, 600 ); | ||
| 36 | } | ||
| 37 | public void mischia() { | ||
| 38 | mano = 0; | ||
| 39 | punteggio = 0; | ||
| 40 | punteggioCPU = 0; | ||
| 41 | cartaDaPescare = 6; | ||
| 42 | ImageIcon aux; | ||
| 43 | frame.mazzo = true; | ||
| 44 | toccaAllaCPU = false; | ||
| 45 | CPUHaGiocato = false; | ||
| 46 | haGiocatoPrima = true; | ||
| 47 | for ( int i = 0, k = 0; i < 10; i++ ) | ||
| 48 | for ( int j = 0; j < 4; j++, k++ ) | ||
| 49 | frame.arrayCarteMescolate[k] = frame.arrayCarte[i][j]; | ||
| 50 | for ( int i = 0; i < 391; i++ ) { | ||
| 51 | double a = Math.random() * 40; | ||
| 52 | int x = (int) a; | ||
| 53 | double b = Math.random() * 40; | ||
| 54 | int y = (int) b; | ||
| 55 | aux = frame.arrayCarteMescolate[x]; | ||
| 56 | frame.arrayCarteMescolate[x] = frame.arrayCarteMescolate[y]; | ||
| 57 | frame.arrayCarteMescolate[y] = aux; | ||
| 58 | } | ||
| 59 | char auxChar[] = frame.arrayCarteMescolate[39].toString().toCharArray(); | ||
| 60 | semeBriscola = auxChar[auxChar.length-5] - 49; | ||
| 61 | frame.carteInMano[0] = frame.arrayCarteMescolate[0]; | ||
| 62 | frame.carteInMano[1] = frame.arrayCarteMescolate[1]; | ||
| 63 | frame.carteInMano[2] = frame.arrayCarteMescolate[2]; | ||
| 64 | frame.carteCPU[0] = frame.arrayCarteMescolate[3]; | ||
| 65 | frame.carteCPU[1] = frame.arrayCarteMescolate[4]; | ||
| 66 | frame.carteCPU[2] = frame.arrayCarteMescolate[5]; | ||
| 67 | frame.ultimaCarta = frame.arrayCarteMescolate[39]; | ||
| 68 | frame.giocata[0] = null; | ||
| 69 | frame.giocata[1] = null; | ||
| 70 | } | ||
| 71 | public void giocaCPU() { | ||
| 72 | if ( frame.giocata[0] == null ) { | ||
| 73 | if ( vaiLiscio() ); | ||
| 74 | else if ( vaiPunti() ); | ||
| 75 | else if ( vaiBriscola() ); | ||
| 76 | else if ( vaiCarico() ); | ||
| 77 | else; | ||
| 78 | } | ||
| 79 | else { | ||
| 80 | if ( haLisciato() || haMessoPunti() ) { | ||
| 81 | if ( vaiSopra() ); | ||
| 82 | else if ( vaiLiscio() ); | ||
| 83 | else if ( vaiPunti() ); | ||
| 84 | else if ( vaiBriscola() ); | ||
| 85 | else if ( vaiCarico() ); | ||
| 86 | else System.out.println("Ha lisciato e non so cosa fare"); | ||
| 87 | } else if ( haMessoBriscola() ) { | ||
| 88 | if ( vaiLiscio() ); | ||
| 89 | else if ( vaiPunti() ); | ||
| 90 | else if ( vaiBriscola() ); | ||
| 91 | else if ( vaiCarico() ); | ||
| 92 | else System.out.println("Ha messo una briscola e non so cosa fare"); | ||
| 93 | } else if ( haCaricato() ) { | ||
| 94 | if ( vaiSopra() ); | ||
| 95 | else if ( vaiBriscola() ); | ||
| 96 | else if ( vaiLiscio() ); | ||
| 97 | else if ( vaiPunti() ); | ||
| 98 | else if ( vaiCarico() ); | ||
| 99 | else System.out.println("Ha caricato e non so cosa fare"); | ||
| 100 | } else System.out.println("Non so cosa ha fatto"); | ||
| 101 | } | ||
| 102 | frame.giocata[1] = frame.carteCPU[cartaDaGiocare]; | ||
| 103 | frame.carteCPU[cartaDaGiocare] = null; | ||
| 104 | frame.pannello.repaint(); | ||
| 105 | CPUHaGiocato = true; | ||
| 106 | if ( frame.giocata[0] == null ) | ||
| 107 | toccaAllaCPU = false; | ||
| 108 | } | ||
| 109 | public void chiPrende() { | ||
| 110 | char aux[], auxCPU[]; | ||
| 111 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 112 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 113 | giocatorePrende( ( (aux[aux.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) ) | ||
| 114 | || ( (aux[aux.length-5] == auxCPU[auxCPU.length-5]) && laPrimaEPiuAlta( aux[aux.length-7] - 48, auxCPU[auxCPU.length-7] - 48 ) ) | ||
| 115 | || ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (aux[aux.length-5] != auxCPU[auxCPU.length-5]) && haGiocatoPrima ) ); | ||
| 116 | } | ||
| 117 | public boolean laPrimaEPiuAlta( int prima, int seconda ) { | ||
| 118 | int a, b; | ||
| 119 | switch ( prima ) { | ||
| 120 | case 0: | ||
| 121 | a = 10; | ||
| 122 | break; | ||
| 123 | case 1: | ||
| 124 | a = 12; | ||
| 125 | break; | ||
| 126 | case 3: | ||
| 127 | a = 11; | ||
| 128 | break; | ||
| 129 | default: | ||
| 130 | a = prima; | ||
| 131 | break; | ||
| 132 | } | ||
| 133 | switch ( seconda ) { | ||
| 134 | case 0: | ||
| 135 | b = 10; | ||
| 136 | break; | ||
| 137 | case 1: | ||
| 138 | b = 12; | ||
| 139 | break; | ||
| 140 | case 3: | ||
| 141 | b = 11; | ||
| 142 | break; | ||
| 143 | default: | ||
| 144 | b = seconda; | ||
| 145 | break; | ||
| 146 | } | ||
| 147 | return a > b; | ||
| 148 | } | ||
| 149 | public void giocatorePrende( boolean giocatore ) { | ||
| 150 | if ( giocatore ) { | ||
| 151 | toccaAllaCPU = CPUHaGiocato = false; | ||
| 152 | haGiocatoPrima = true; | ||
| 153 | } | ||
| 154 | else { | ||
| 155 | toccaAllaCPU = true; | ||
| 156 | CPUHaGiocato = haGiocatoPrima = false; | ||
| 157 | } | ||
| 158 | daiPunti( giocatore ); | ||
| 159 | if ( toccaAllaCPU ) | ||
| 160 | giocaCPU(); | ||
| 161 | } | ||
| 162 | public void daiPunti( boolean giocatore ) { | ||
| 163 | char aux[], auxCPU[]; | ||
| 164 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 165 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 166 | int punti = 0; | ||
| 167 | switch( aux[aux.length-7] - 48 ) { | ||
| 168 | case 0: | ||
| 169 | punti += 4; | ||
| 170 | break; | ||
| 171 | case 1: | ||
| 172 | punti += 11; | ||
| 173 | break; | ||
| 174 | case 3: | ||
| 175 | punti += 10; | ||
| 176 | break; | ||
| 177 | case 8: | ||
| 178 | punti += 2; | ||
| 179 | break; | ||
| 180 | case 9: | ||
| 181 | punti += 3; | ||
| 182 | break; | ||
| 183 | default: | ||
| 184 | break; | ||
| 185 | } | ||
| 186 | switch( auxCPU[auxCPU.length-7] - 48 ) { | ||
| 187 | case 0: | ||
| 188 | punti += 4; | ||
| 189 | break; | ||
| 190 | case 1: | ||
| 191 | punti += 11; | ||
| 192 | break; | ||
| 193 | case 3: | ||
| 194 | punti += 10; | ||
| 195 | break; | ||
| 196 | case 8: | ||
| 197 | punti += 2; | ||
| 198 | break; | ||
| 199 | case 9: | ||
| 200 | punti += 3; | ||
| 201 | break; | ||
| 202 | default: | ||
| 203 | break; | ||
| 204 | } | ||
| 205 | frame.giocata[0] = frame.giocata[1] = null; | ||
| 206 | if ( giocatore ) { | ||
| 207 | punteggio += punti; | ||
| 208 | if ( mano < 18 ) { | ||
| 209 | if ( frame.carteInMano[0] == null ) | ||
| 210 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 211 | if ( frame.carteInMano[1] == null ) | ||
| 212 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 213 | if ( frame.carteInMano[2] == null ) | ||
| 214 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 215 | cartaDaPescare++; | ||
| 216 | if ( frame.carteCPU[0] == null ) | ||
| 217 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 218 | if ( frame.carteCPU[1] == null ) | ||
| 219 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 220 | if ( frame.carteCPU[2] == null ) | ||
| 221 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 222 | cartaDaPescare++; | ||
| 223 | } | ||
| 224 | } | ||
| 225 | else { | ||
| 226 | punteggioCPU += punti; | ||
| 227 | if ( mano < 18 ) { | ||
| 228 | if ( frame.carteCPU[0] == null ) | ||
| 229 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 230 | if ( frame.carteCPU[1] == null ) | ||
| 231 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 232 | if ( frame.carteCPU[2] == null ) | ||
| 233 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 234 | cartaDaPescare++; | ||
| 235 | if ( frame.carteInMano[0] == null ) | ||
| 236 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 237 | if ( frame.carteInMano[1] == null ) | ||
| 238 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 239 | if ( frame.carteInMano[2] == null ) | ||
| 240 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 241 | cartaDaPescare++; | ||
| 242 | } | ||
| 243 | } | ||
| 244 | frame.pannello.repaint(); | ||
| 245 | frame.repaint(); | ||
| 246 | } | ||
| 247 | public boolean haLisciato() { | ||
| 248 | char auxCPU[]; | ||
| 249 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 250 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 251 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 252 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ); | ||
| 253 | } | ||
| 254 | public boolean haMessoPunti() { | ||
| 255 | char auxCPU[]; | ||
| 256 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 257 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 258 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || | ||
| 259 | (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ); | ||
| 260 | } | ||
| 261 | public boolean haMessoBriscola() { | ||
| 262 | char auxCPU[]; | ||
| 263 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 264 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) ); | ||
| 265 | } | ||
| 266 | public boolean haCaricato() { | ||
| 267 | char auxCPU[]; | ||
| 268 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 269 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 270 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ); | ||
| 271 | } | ||
| 272 | public boolean vaiLiscio() { | ||
| 273 | char auxCPU[]; | ||
| 274 | for ( int i = 0; i < 3; i++ ) { | ||
| 275 | if ( frame.carteCPU[i] != null ) { | ||
| 276 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 277 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 278 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 279 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ) { | ||
| 280 | cartaDaGiocare = i; | ||
| 281 | return true; | ||
| 282 | } | ||
| 283 | } | ||
| 284 | } | ||
| 285 | return false; | ||
| 286 | } | ||
| 287 | public boolean vaiPunti() { | ||
| 288 | char auxCPU[]; | ||
| 289 | for ( int i = 0; i < 3; i++ ) { | ||
| 290 | if ( frame.carteCPU[i] != null ) { | ||
| 291 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 292 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 293 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || | ||
| 294 | (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ) { | ||
| 295 | cartaDaGiocare = i; | ||
| 296 | return true; | ||
| 297 | } | ||
| 298 | } | ||
| 299 | } | ||
| 300 | return false; | ||
| 301 | } | ||
| 302 | public boolean vaiBriscola() { | ||
| 303 | char auxCPU[]; | ||
| 304 | for ( int i = 0; i < 3; i++ ) { | ||
| 305 | if ( frame.carteCPU[i] != null ) { | ||
| 306 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 307 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola ) { | ||
| 308 | cartaDaGiocare = i; | ||
| 309 | return true; | ||
| 310 | } | ||
| 311 | } | ||
| 312 | } | ||
| 313 | return false; | ||
| 314 | } | ||
| 315 | public boolean vaiCarico() { | ||
| 316 | char auxCPU[]; | ||
| 317 | for ( int i = 0; i < 3; i++ ) { | ||
| 318 | if ( frame.carteCPU[i] != null ) { | ||
| 319 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 320 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 321 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ) { | ||
| 322 | cartaDaGiocare = i; | ||
| 323 | return true; | ||
| 324 | } | ||
| 325 | } | ||
| 326 | } | ||
| 327 | return false; | ||
| 328 | } | ||
| 329 | public boolean vaiSopra() { | ||
| 330 | if ( frame.giocata[0] == null ) | ||
| 331 | return false; | ||
| 332 | int a = -1; | ||
| 333 | int b = -1; | ||
| 334 | int c = -1; | ||
| 335 | boolean laPrimaPuoAndareSopra = false; | ||
| 336 | boolean laSecondaPuoAndareSopra = false; | ||
| 337 | boolean laTerzaPuoAndareSopra = false; | ||
| 338 | char[] auxCPU1 = new char[1024]; | ||
| 339 | char[] auxCPU2 = new char[1024]; | ||
| 340 | char[] auxCPU3 = new char[1024]; | ||
| 341 | char[] aux = frame.giocata[0].toString().toCharArray(); | ||
| 342 | if ( aux[aux.length-7] - 48 == 1 ) | ||
| 343 | return false; | ||
| 344 | if ( frame.carteCPU[0] != null ) { | ||
| 345 | auxCPU1 = frame.carteCPU[0].toString().toCharArray(); | ||
| 346 | a = auxCPU1[auxCPU1.length-7] - 48; | ||
| 347 | } | ||
| 348 | if ( frame.carteCPU[1] != null ) { | ||
| 349 | auxCPU2 = frame.carteCPU[1].toString().toCharArray(); | ||
| 350 | b = auxCPU2[auxCPU2.length-7] - 48; | ||
| 351 | } | ||
| 352 | if ( frame.carteCPU[2] != null ) { | ||
| 353 | auxCPU3 = frame.carteCPU[2].toString().toCharArray(); | ||
| 354 | c = auxCPU3[auxCPU3.length-7] - 48; | ||
| 355 | } | ||
| 356 | if ( (auxCPU1[auxCPU1.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( a, aux[aux.length-7] - 48 ) ) | ||
| 357 | laPrimaPuoAndareSopra = true; | ||
| 358 | if ( (auxCPU2[auxCPU2.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( b, aux[aux.length-7] - 48 ) ) | ||
| 359 | laSecondaPuoAndareSopra = true; | ||
| 360 | if ( (auxCPU3[auxCPU3.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( c, aux[aux.length-7] - 48 ) ) | ||
| 361 | laTerzaPuoAndareSopra = true; | ||
| 362 | if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 363 | return false; | ||
| 364 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 365 | cartaDaGiocare = 0; | ||
| 366 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 367 | cartaDaGiocare = 1; | ||
| 368 | else if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 369 | cartaDaGiocare = 2; | ||
| 370 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 371 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 372 | cartaDaGiocare = 0; | ||
| 373 | else | ||
| 374 | cartaDaGiocare = 1; | ||
| 375 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 376 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 377 | cartaDaGiocare = 1; | ||
| 378 | else | ||
| 379 | cartaDaGiocare = 2; | ||
| 380 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 381 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 382 | cartaDaGiocare = 0; | ||
| 383 | else | ||
| 384 | cartaDaGiocare = 2; | ||
| 385 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 386 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 387 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 388 | cartaDaGiocare = 0; | ||
| 389 | else | ||
| 390 | cartaDaGiocare = 2; | ||
| 391 | else | ||
| 392 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 393 | cartaDaGiocare = 1; | ||
| 394 | else | ||
| 395 | cartaDaGiocare = 2; | ||
| 396 | else cartaDaGiocare = 55; | ||
| 397 | return true; | ||
| 398 | } | ||
| 399 | } | ||
diff --git a/JBriscola/all_versions/0.1/0.1 Beta 1/src/Pannello.java b/JBriscola/all_versions/0.1/0.1 Beta 1/src/Pannello.java new file mode 100755 index 0000000..9e73356 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1 Beta 1/src/Pannello.java | |||
| @@ -0,0 +1,53 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import java.awt.Graphics; | ||
| 24 | |||
| 25 | public class Pannello extends JPanel { | ||
| 26 | public static Main main; | ||
| 27 | public Pannello() { | ||
| 28 | } | ||
| 29 | public void paint( Graphics g ) { | ||
| 30 | super.paint( g ); | ||
| 31 | if ( main.frame.ultimaCarta != null ) | ||
| 32 | main.frame.ultimaCarta.paintIcon( this, g, 50, 180 ); | ||
| 33 | if ( main.frame.mazzo ) | ||
| 34 | main.frame.retro2.paintIcon( this, g, 17, 256 ); | ||
| 35 | if ( main.frame.carteCPU[0] != null ) | ||
| 36 | main.frame.retro1.paintIcon( this, g, 230, 5 ); | ||
| 37 | if ( main.frame.carteCPU[1] != null ) | ||
| 38 | main.frame.retro1.paintIcon( this, g, 300, 5 ); | ||
| 39 | if ( main.frame.carteCPU[2] != null ) | ||
| 40 | main.frame.retro1.paintIcon( this, g, 370, 5 ); | ||
| 41 | if ( main.frame.carteInMano[0] != null ) | ||
| 42 | main.frame.carteInMano[0].paintIcon( this, g, 230, 340 ); | ||
| 43 | if ( main.frame.carteInMano[1] != null ) | ||
| 44 | main.frame.carteInMano[1].paintIcon( this, g, 300, 340 ); | ||
| 45 | if ( main.frame.carteInMano[2] != null ) | ||
| 46 | main.frame.carteInMano[2].paintIcon( this, g, 370, 340 ); | ||
| 47 | if ( main.frame.giocata[0] != null ) | ||
| 48 | main.frame.giocata[0].paintIcon( this, g, 250, 200 ); | ||
| 49 | if ( main.frame.giocata[1] != null ) | ||
| 50 | main.frame.giocata[1].paintIcon( this, g, 325, 150 ); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
diff --git a/JBriscola/all_versions/0.1/0.1 Beta 2/src/Frame.java b/JBriscola/all_versions/0.1/0.1 Beta 2/src/Frame.java new file mode 100755 index 0000000..36ff831 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1 Beta 2/src/Frame.java | |||
| @@ -0,0 +1,174 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | import java.awt.event.*; | ||
| 25 | |||
| 26 | public class Frame extends JFrame { | ||
| 27 | public static boolean mazzo; | ||
| 28 | public static Main main; | ||
| 29 | public static Pannello pannello; | ||
| 30 | public static JButton button; | ||
| 31 | public static JMenuBar barraMenu; | ||
| 32 | public static JMenu file; | ||
| 33 | public static JMenuItem nuovaPartita, opzioni, esci; | ||
| 34 | public static ImageIcon retro1, retro2, ultimaCarta; | ||
| 35 | public static ImageIcon[] giocata = new ImageIcon[2]; | ||
| 36 | public static ImageIcon[] carteInMano = new ImageIcon[3]; | ||
| 37 | public static ImageIcon[] carteCPU = new ImageIcon[3]; | ||
| 38 | public static ImageIcon[] arrayCarteMescolate = new ImageIcon[40]; | ||
| 39 | public static ImageIcon[][] arrayCarte = new ImageIcon[10][4]; | ||
| 40 | public Frame() { | ||
| 41 | super( "Tronto's JBriscola 0.1 Beta 2" ); | ||
| 42 | mazzo = true; | ||
| 43 | main = new Main(); | ||
| 44 | pannello = new Pannello(); | ||
| 45 | button = new JButton( main.stringaBottonePrendi ); | ||
| 46 | button.addActionListener( new ActionListener() { | ||
| 47 | public void actionPerformed( ActionEvent e ) { | ||
| 48 | if ( giocata[0] != null && giocata[1] != null ) | ||
| 49 | main.mano++; | ||
| 50 | try { | ||
| 51 | main.chiPrende(); | ||
| 52 | } catch ( Exception ex ) { | ||
| 53 | JOptionPane.showMessageDialog( Frame.this, main.stringaPrimaGioca, "JBriscola 0.1", JOptionPane.WARNING_MESSAGE ); | ||
| 54 | } | ||
| 55 | if ( main.mano == 16 ) | ||
| 56 | JOptionPane.showMessageDialog( Frame.this, main.stringaUltime4, "JBriscola 0.1", JOptionPane.INFORMATION_MESSAGE ); | ||
| 57 | if ( main.mano == 17 ) { | ||
| 58 | mazzo = false; | ||
| 59 | ultimaCarta = null; | ||
| 60 | pannello.repaint(); | ||
| 61 | Frame.this.repaint(); | ||
| 62 | } | ||
| 63 | if ( main.mano == 20 ) { | ||
| 64 | String titolo = main.stringaVinto; | ||
| 65 | if ( main.punteggio < main.punteggioCPU ) | ||
| 66 | titolo = main.stringaPerso; | ||
| 67 | if ( main.punteggio == main.punteggioCPU ) | ||
| 68 | titolo = main.stringaPareggio; | ||
| 69 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, titolo, JOptionPane.PLAIN_MESSAGE ); | ||
| 70 | } | ||
| 71 | } | ||
| 72 | } ); | ||
| 73 | barraMenu = new JMenuBar(); | ||
| 74 | file = new JMenu( "File" ); | ||
| 75 | nuovaPartita = new JMenuItem( main.stringaNuovaPartita ); | ||
| 76 | nuovaPartita.addActionListener( new ActionListener() { | ||
| 77 | public void actionPerformed( ActionEvent e ) { | ||
| 78 | if ( main.mano == 20 ) { | ||
| 79 | main.mischia(); | ||
| 80 | pannello.repaint(); | ||
| 81 | repaint(); | ||
| 82 | } | ||
| 83 | else { | ||
| 84 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola 0.1", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 85 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 86 | main.mischia(); | ||
| 87 | pannello.repaint(); | ||
| 88 | repaint(); | ||
| 89 | } | ||
| 90 | } | ||
| 91 | } | ||
| 92 | }); | ||
| 93 | opzioni = new JMenuItem( main.stringaOpzioni ); | ||
| 94 | opzioni.addActionListener( new ActionListener() { | ||
| 95 | public void actionPerformed( ActionEvent e ) { | ||
| 96 | OptionFrame optionFrame = new OptionFrame(); | ||
| 97 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 98 | optionFrame.setResizable( false ); | ||
| 99 | optionFrame.setAlwaysOnTop( true ); | ||
| 100 | optionFrame.setSize( 300, 150 ); | ||
| 101 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, | ||
| 102 | (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 103 | optionFrame.setVisible( true ); | ||
| 104 | } | ||
| 105 | }); | ||
| 106 | esci = new JMenuItem( main.stringaEsci ); | ||
| 107 | esci.addActionListener( new ActionListener() { | ||
| 108 | public void actionPerformed( ActionEvent e ) { | ||
| 109 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola 0.1", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 110 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 111 | Frame.this.dispose(); | ||
| 112 | } | ||
| 113 | }); | ||
| 114 | file.add( nuovaPartita ); | ||
| 115 | file.add( opzioni ); | ||
| 116 | file.addSeparator(); | ||
| 117 | file.add( esci ); | ||
| 118 | barraMenu.add( file ); | ||
| 119 | setJMenuBar( barraMenu ); | ||
| 120 | retro1 = new ImageIcon( ClassLoader.getSystemResource( "img/retro1.jpg" ) ); | ||
| 121 | retro2 = new ImageIcon( ClassLoader.getSystemResource( "img/retro2.jpg" ) ); | ||
| 122 | for (int i = 0; i < 10; i++) | ||
| 123 | for (int j = 0; j < 4; j++) | ||
| 124 | arrayCarte[i][j] = new ImageIcon( ClassLoader.getSystemResource( "img/" + (i+1) + "-" + (j+1) + ".jpg" ) ); | ||
| 125 | main.mischia(); | ||
| 126 | setLayout( new BorderLayout() ); | ||
| 127 | add( pannello, BorderLayout.CENTER ); | ||
| 128 | add( button, BorderLayout.SOUTH ); | ||
| 129 | addMouseListener( | ||
| 130 | new MouseAdapter() { | ||
| 131 | public void mouseClicked ( MouseEvent e ) { | ||
| 132 | if ( mettiCarta( e.getX(), e.getY() ) ) { | ||
| 133 | if ( !main.CPUHaGiocato ) | ||
| 134 | main.giocaCPU(); | ||
| 135 | } | ||
| 136 | } | ||
| 137 | } | ||
| 138 | ); | ||
| 139 | addWindowListener( | ||
| 140 | new WindowAdapter() { | ||
| 141 | public void windowClosing( WindowEvent e ) { | ||
| 142 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola 0.1", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 143 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 144 | System.exit( 0 ); | ||
| 145 | } | ||
| 146 | } | ||
| 147 | ); | ||
| 148 | } | ||
| 149 | public boolean mettiCarta( int x, int y ) { | ||
| 150 | if ( !main.toccaAllaCPU && giocata[0] == null ) { | ||
| 151 | if ( x > 230 && x < 290 && y > 340 && y < 566 ) { | ||
| 152 | giocata[0] = carteInMano[0]; | ||
| 153 | carteInMano[0] = null; | ||
| 154 | pannello.repaint(); | ||
| 155 | return true; | ||
| 156 | } | ||
| 157 | if ( x > 300 && x < 360 && y > 340 && y < 566 ) { | ||
| 158 | giocata[0] = carteInMano[1]; | ||
| 159 | carteInMano[1] = null; | ||
| 160 | pannello.repaint(); | ||
| 161 | return true; | ||
| 162 | } | ||
| 163 | if ( x > 370 && x < 430 && y > 340 && y < 566 ) { | ||
| 164 | giocata[0] = carteInMano[2]; | ||
| 165 | carteInMano[2] = null; | ||
| 166 | pannello.repaint(); | ||
| 167 | return true; | ||
| 168 | } | ||
| 169 | } | ||
| 170 | return false; | ||
| 171 | } | ||
| 172 | } | ||
| 173 | |||
| 174 | |||
diff --git a/JBriscola/all_versions/0.1/0.1 Beta 2/src/Main.java b/JBriscola/all_versions/0.1/0.1 Beta 2/src/Main.java new file mode 100755 index 0000000..2a3191b --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1 Beta 2/src/Main.java | |||
| @@ -0,0 +1,492 @@ | |||
| 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 stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 34 | public static String stringaPrimaGioca = "Prima Gioca!"; | ||
| 35 | public static String stringaUltime4 = "Ultime 4 mani - Occhio alla briscola!"; | ||
| 36 | public static String stringaVinto = "Hai Vinto!"; | ||
| 37 | public static String stringaPerso = "Hai Perso"; | ||
| 38 | public static String stringaPareggio = "Pareggio"; | ||
| 39 | public static String stringaGiocatore = "Giocatore"; | ||
| 40 | public static String stringaComputer = "\nComputer"; | ||
| 41 | public static String stringaNuovaPartita = "Nuova Partita"; | ||
| 42 | public static String stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 43 | public static String stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 44 | public static String stringaSi = "Si"; | ||
| 45 | public static String stringaNo = "No"; | ||
| 46 | public static String stringaOpzioni = "Opzioni..."; | ||
| 47 | public static String stringaEsci = "Esci"; | ||
| 48 | public static String stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 49 | public static String stringaLingua = "Lingua"; | ||
| 50 | public static String stringaAnnulla = "Annulla"; | ||
| 51 | public static String stringaIt = "Italiano"; | ||
| 52 | public static String stringaLa = "Latino"; | ||
| 53 | public static String stringaNecessarioRiavviare = "E' necessario riavviare JBriscola se sono state\nmodificate impostazioni riguardanti la lingua.\nAlcune parti saranno comunque tradotte prima."; | ||
| 54 | public static String stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 55 | public static void main( String args[] ) { | ||
| 56 | settaOpzioni(); | ||
| 57 | frame = new Frame(); | ||
| 58 | frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); | ||
| 59 | frame.setResizable( false ); | ||
| 60 | frame.setSize( 600, 600 ); | ||
| 61 | frame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 600) / 2, | ||
| 62 | (Toolkit.getDefaultToolkit().getScreenSize().height - 600) / 2); | ||
| 63 | |||
| 64 | frame.setVisible( true ); | ||
| 65 | } | ||
| 66 | public void mischia() { | ||
| 67 | mano = 0; | ||
| 68 | punteggio = 0; | ||
| 69 | punteggioCPU = 0; | ||
| 70 | cartaDaPescare = 6; | ||
| 71 | ImageIcon aux; | ||
| 72 | frame.mazzo = true; | ||
| 73 | toccaAllaCPU = false; | ||
| 74 | CPUHaGiocato = false; | ||
| 75 | haGiocatoPrima = true; | ||
| 76 | for ( int i = 0, k = 0; i < 10; i++ ) | ||
| 77 | for ( int j = 0; j < 4; j++, k++ ) | ||
| 78 | frame.arrayCarteMescolate[k] = frame.arrayCarte[i][j]; | ||
| 79 | for ( int i = 0; i < 391; i++ ) { | ||
| 80 | double a = Math.random() * 40; | ||
| 81 | int x = (int) a; | ||
| 82 | double b = Math.random() * 40; | ||
| 83 | int y = (int) b; | ||
| 84 | aux = frame.arrayCarteMescolate[x]; | ||
| 85 | frame.arrayCarteMescolate[x] = frame.arrayCarteMescolate[y]; | ||
| 86 | frame.arrayCarteMescolate[y] = aux; | ||
| 87 | } | ||
| 88 | char auxChar[] = frame.arrayCarteMescolate[39].toString().toCharArray(); | ||
| 89 | semeBriscola = auxChar[auxChar.length-5] - 49; | ||
| 90 | frame.carteInMano[0] = frame.arrayCarteMescolate[0]; | ||
| 91 | frame.carteInMano[1] = frame.arrayCarteMescolate[1]; | ||
| 92 | frame.carteInMano[2] = frame.arrayCarteMescolate[2]; | ||
| 93 | frame.carteCPU[0] = frame.arrayCarteMescolate[3]; | ||
| 94 | frame.carteCPU[1] = frame.arrayCarteMescolate[4]; | ||
| 95 | frame.carteCPU[2] = frame.arrayCarteMescolate[5]; | ||
| 96 | frame.ultimaCarta = frame.arrayCarteMescolate[39]; | ||
| 97 | frame.giocata[0] = null; | ||
| 98 | frame.giocata[1] = null; | ||
| 99 | } | ||
| 100 | public void giocaCPU() { | ||
| 101 | if ( frame.giocata[0] == null ) { | ||
| 102 | if ( vaiLiscio() ); | ||
| 103 | else if ( vaiPunti() ); | ||
| 104 | else if ( vaiBriscola() ); | ||
| 105 | else if ( vaiCarico() ); | ||
| 106 | else; | ||
| 107 | } | ||
| 108 | else { | ||
| 109 | if ( haLisciato() || haMessoPunti() ) { | ||
| 110 | if ( vaiSopra() ); | ||
| 111 | else if ( vaiLiscio() ); | ||
| 112 | else if ( vaiPunti() ); | ||
| 113 | else if ( vaiBriscola() ); | ||
| 114 | else if ( vaiCarico() ); | ||
| 115 | else System.out.println("Ha lisciato e non so cosa fare"); | ||
| 116 | } else if ( haMessoBriscola() ) { | ||
| 117 | if ( vaiLiscio() ); | ||
| 118 | else if ( vaiPunti() ); | ||
| 119 | else if ( vaiBriscola() ); | ||
| 120 | else if ( vaiCarico() ); | ||
| 121 | else System.out.println("Ha messo una briscola e non so cosa fare"); | ||
| 122 | } else if ( haCaricato() ) { | ||
| 123 | if ( vaiSopra() ); | ||
| 124 | else if ( vaiBriscola() ); | ||
| 125 | else if ( vaiLiscio() ); | ||
| 126 | else if ( vaiPunti() ); | ||
| 127 | else if ( vaiCarico() ); | ||
| 128 | else System.out.println("Ha caricato e non so cosa fare"); | ||
| 129 | } else System.out.println("Non so cosa ha fatto"); | ||
| 130 | } | ||
| 131 | frame.giocata[1] = frame.carteCPU[cartaDaGiocare]; | ||
| 132 | frame.carteCPU[cartaDaGiocare] = null; | ||
| 133 | frame.pannello.repaint(); | ||
| 134 | CPUHaGiocato = true; | ||
| 135 | if ( frame.giocata[0] == null ) | ||
| 136 | toccaAllaCPU = false; | ||
| 137 | } | ||
| 138 | public void chiPrende() { | ||
| 139 | char aux[], auxCPU[]; | ||
| 140 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 141 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 142 | giocatorePrende( ( (aux[aux.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) ) | ||
| 143 | || ( (aux[aux.length-5] == auxCPU[auxCPU.length-5]) && laPrimaEPiuAlta( aux[aux.length-7] - 48, auxCPU[auxCPU.length-7] - 48 ) ) | ||
| 144 | || ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (aux[aux.length-5] != auxCPU[auxCPU.length-5]) && haGiocatoPrima ) ); | ||
| 145 | } | ||
| 146 | public boolean laPrimaEPiuAlta( int prima, int seconda ) { | ||
| 147 | int a, b; | ||
| 148 | switch ( prima ) { | ||
| 149 | case 0: | ||
| 150 | a = 10; | ||
| 151 | break; | ||
| 152 | case 1: | ||
| 153 | a = 12; | ||
| 154 | break; | ||
| 155 | case 3: | ||
| 156 | a = 11; | ||
| 157 | break; | ||
| 158 | default: | ||
| 159 | a = prima; | ||
| 160 | break; | ||
| 161 | } | ||
| 162 | switch ( seconda ) { | ||
| 163 | case 0: | ||
| 164 | b = 10; | ||
| 165 | break; | ||
| 166 | case 1: | ||
| 167 | b = 12; | ||
| 168 | break; | ||
| 169 | case 3: | ||
| 170 | b = 11; | ||
| 171 | break; | ||
| 172 | default: | ||
| 173 | b = seconda; | ||
| 174 | break; | ||
| 175 | } | ||
| 176 | return a > b; | ||
| 177 | } | ||
| 178 | public void giocatorePrende( boolean giocatore ) { | ||
| 179 | if ( giocatore ) { | ||
| 180 | toccaAllaCPU = CPUHaGiocato = false; | ||
| 181 | haGiocatoPrima = true; | ||
| 182 | } | ||
| 183 | else { | ||
| 184 | toccaAllaCPU = true; | ||
| 185 | CPUHaGiocato = haGiocatoPrima = false; | ||
| 186 | } | ||
| 187 | daiPunti( giocatore ); | ||
| 188 | if ( toccaAllaCPU ) | ||
| 189 | giocaCPU(); | ||
| 190 | } | ||
| 191 | public void daiPunti( boolean giocatore ) { | ||
| 192 | char aux[], auxCPU[]; | ||
| 193 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 194 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 195 | int punti = 0; | ||
| 196 | switch( aux[aux.length-7] - 48 ) { | ||
| 197 | case 0: | ||
| 198 | punti += 4; | ||
| 199 | break; | ||
| 200 | case 1: | ||
| 201 | punti += 11; | ||
| 202 | break; | ||
| 203 | case 3: | ||
| 204 | punti += 10; | ||
| 205 | break; | ||
| 206 | case 8: | ||
| 207 | punti += 2; | ||
| 208 | break; | ||
| 209 | case 9: | ||
| 210 | punti += 3; | ||
| 211 | break; | ||
| 212 | default: | ||
| 213 | break; | ||
| 214 | } | ||
| 215 | switch( auxCPU[auxCPU.length-7] - 48 ) { | ||
| 216 | case 0: | ||
| 217 | punti += 4; | ||
| 218 | break; | ||
| 219 | case 1: | ||
| 220 | punti += 11; | ||
| 221 | break; | ||
| 222 | case 3: | ||
| 223 | punti += 10; | ||
| 224 | break; | ||
| 225 | case 8: | ||
| 226 | punti += 2; | ||
| 227 | break; | ||
| 228 | case 9: | ||
| 229 | punti += 3; | ||
| 230 | break; | ||
| 231 | default: | ||
| 232 | break; | ||
| 233 | } | ||
| 234 | frame.giocata[0] = frame.giocata[1] = null; | ||
| 235 | if ( giocatore ) { | ||
| 236 | punteggio += punti; | ||
| 237 | if ( mano < 18 ) { | ||
| 238 | if ( frame.carteInMano[0] == null ) | ||
| 239 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 240 | if ( frame.carteInMano[1] == null ) | ||
| 241 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 242 | if ( frame.carteInMano[2] == null ) | ||
| 243 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 244 | cartaDaPescare++; | ||
| 245 | if ( frame.carteCPU[0] == null ) | ||
| 246 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 247 | if ( frame.carteCPU[1] == null ) | ||
| 248 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 249 | if ( frame.carteCPU[2] == null ) | ||
| 250 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 251 | cartaDaPescare++; | ||
| 252 | } | ||
| 253 | } | ||
| 254 | else { | ||
| 255 | punteggioCPU += punti; | ||
| 256 | if ( mano < 18 ) { | ||
| 257 | if ( frame.carteCPU[0] == null ) | ||
| 258 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 259 | if ( frame.carteCPU[1] == null ) | ||
| 260 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 261 | if ( frame.carteCPU[2] == null ) | ||
| 262 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 263 | cartaDaPescare++; | ||
| 264 | if ( frame.carteInMano[0] == null ) | ||
| 265 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 266 | if ( frame.carteInMano[1] == null ) | ||
| 267 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 268 | if ( frame.carteInMano[2] == null ) | ||
| 269 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 270 | cartaDaPescare++; | ||
| 271 | } | ||
| 272 | } | ||
| 273 | frame.pannello.repaint(); | ||
| 274 | frame.repaint(); | ||
| 275 | } | ||
| 276 | public boolean haLisciato() { | ||
| 277 | char auxCPU[]; | ||
| 278 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 279 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 280 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 281 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ); | ||
| 282 | } | ||
| 283 | public boolean haMessoPunti() { | ||
| 284 | char auxCPU[]; | ||
| 285 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 286 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 287 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || | ||
| 288 | (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ); | ||
| 289 | } | ||
| 290 | public boolean haMessoBriscola() { | ||
| 291 | char auxCPU[]; | ||
| 292 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 293 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) ); | ||
| 294 | } | ||
| 295 | public boolean haCaricato() { | ||
| 296 | char auxCPU[]; | ||
| 297 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 298 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 299 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ); | ||
| 300 | } | ||
| 301 | public boolean vaiLiscio() { | ||
| 302 | char auxCPU[]; | ||
| 303 | for ( int i = 0; i < 3; i++ ) { | ||
| 304 | if ( frame.carteCPU[i] != null ) { | ||
| 305 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 306 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 307 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 308 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ) { | ||
| 309 | cartaDaGiocare = i; | ||
| 310 | return true; | ||
| 311 | } | ||
| 312 | } | ||
| 313 | } | ||
| 314 | return false; | ||
| 315 | } | ||
| 316 | public boolean vaiPunti() { | ||
| 317 | char auxCPU[]; | ||
| 318 | for ( int i = 0; i < 3; i++ ) { | ||
| 319 | if ( frame.carteCPU[i] != null ) { | ||
| 320 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 321 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 322 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || | ||
| 323 | (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ) { | ||
| 324 | cartaDaGiocare = i; | ||
| 325 | return true; | ||
| 326 | } | ||
| 327 | } | ||
| 328 | } | ||
| 329 | return false; | ||
| 330 | } | ||
| 331 | public boolean vaiBriscola() { | ||
| 332 | char auxCPU[]; | ||
| 333 | for ( int i = 0; i < 3; i++ ) { | ||
| 334 | if ( frame.carteCPU[i] != null ) { | ||
| 335 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 336 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola ) { | ||
| 337 | cartaDaGiocare = i; | ||
| 338 | return true; | ||
| 339 | } | ||
| 340 | } | ||
| 341 | } | ||
| 342 | return false; | ||
| 343 | } | ||
| 344 | public boolean vaiCarico() { | ||
| 345 | char auxCPU[]; | ||
| 346 | for ( int i = 0; i < 3; i++ ) { | ||
| 347 | if ( frame.carteCPU[i] != null ) { | ||
| 348 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 349 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 350 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ) { | ||
| 351 | cartaDaGiocare = i; | ||
| 352 | return true; | ||
| 353 | } | ||
| 354 | } | ||
| 355 | } | ||
| 356 | return false; | ||
| 357 | } | ||
| 358 | public boolean vaiSopra() { | ||
| 359 | if ( frame.giocata[0] == null ) | ||
| 360 | return false; | ||
| 361 | int a = -1; | ||
| 362 | int b = -1; | ||
| 363 | int c = -1; | ||
| 364 | boolean laPrimaPuoAndareSopra = false; | ||
| 365 | boolean laSecondaPuoAndareSopra = false; | ||
| 366 | boolean laTerzaPuoAndareSopra = false; | ||
| 367 | char[] auxCPU1 = new char[1024]; | ||
| 368 | char[] auxCPU2 = new char[1024]; | ||
| 369 | char[] auxCPU3 = new char[1024]; | ||
| 370 | char[] aux = frame.giocata[0].toString().toCharArray(); | ||
| 371 | if ( aux[aux.length-7] - 48 == 1 ) | ||
| 372 | return false; | ||
| 373 | if ( frame.carteCPU[0] != null ) { | ||
| 374 | auxCPU1 = frame.carteCPU[0].toString().toCharArray(); | ||
| 375 | a = auxCPU1[auxCPU1.length-7] - 48; | ||
| 376 | } | ||
| 377 | if ( frame.carteCPU[1] != null ) { | ||
| 378 | auxCPU2 = frame.carteCPU[1].toString().toCharArray(); | ||
| 379 | b = auxCPU2[auxCPU2.length-7] - 48; | ||
| 380 | } | ||
| 381 | if ( frame.carteCPU[2] != null ) { | ||
| 382 | auxCPU3 = frame.carteCPU[2].toString().toCharArray(); | ||
| 383 | c = auxCPU3[auxCPU3.length-7] - 48; | ||
| 384 | } | ||
| 385 | if ( (auxCPU1[auxCPU1.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( a, aux[aux.length-7] - 48 ) ) | ||
| 386 | laPrimaPuoAndareSopra = true; | ||
| 387 | if ( (auxCPU2[auxCPU2.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( b, aux[aux.length-7] - 48 ) ) | ||
| 388 | laSecondaPuoAndareSopra = true; | ||
| 389 | if ( (auxCPU3[auxCPU3.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( c, aux[aux.length-7] - 48 ) ) | ||
| 390 | laTerzaPuoAndareSopra = true; | ||
| 391 | if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 392 | return false; | ||
| 393 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 394 | cartaDaGiocare = 0; | ||
| 395 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 396 | cartaDaGiocare = 1; | ||
| 397 | else if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 398 | cartaDaGiocare = 2; | ||
| 399 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 400 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 401 | cartaDaGiocare = 0; | ||
| 402 | else | ||
| 403 | cartaDaGiocare = 1; | ||
| 404 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 405 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 406 | cartaDaGiocare = 1; | ||
| 407 | else | ||
| 408 | cartaDaGiocare = 2; | ||
| 409 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 410 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 411 | cartaDaGiocare = 0; | ||
| 412 | else | ||
| 413 | cartaDaGiocare = 2; | ||
| 414 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 415 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 416 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 417 | cartaDaGiocare = 0; | ||
| 418 | else | ||
| 419 | cartaDaGiocare = 2; | ||
| 420 | else | ||
| 421 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 422 | cartaDaGiocare = 1; | ||
| 423 | else | ||
| 424 | cartaDaGiocare = 2; | ||
| 425 | else cartaDaGiocare = 55; | ||
| 426 | return true; | ||
| 427 | } | ||
| 428 | public static void settaOpzioni() { | ||
| 429 | String lang; | ||
| 430 | Scanner scanner = null; | ||
| 431 | File file = new File( "JBriscolaConfig.txt" ); | ||
| 432 | if ( file.exists() ) { | ||
| 433 | try { | ||
| 434 | scanner = new Scanner( file ); | ||
| 435 | } catch ( FileNotFoundException e ) { | ||
| 436 | lang = "it"; | ||
| 437 | } | ||
| 438 | lang = scanner.next(); | ||
| 439 | } | ||
| 440 | else { | ||
| 441 | lang = "it"; | ||
| 442 | } | ||
| 443 | if ( lang.equals( "it" ) ) { | ||
| 444 | stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 445 | stringaPrimaGioca = "Prima Gioca!"; | ||
| 446 | stringaUltime4 = "Ultime 4 mani - Occhio alla briscola!"; | ||
| 447 | stringaVinto = "Hai Vinto!"; | ||
| 448 | stringaPerso = "Hai Perso"; | ||
| 449 | stringaPareggio = "Pareggio"; | ||
| 450 | stringaGiocatore = "Giocatore"; | ||
| 451 | stringaComputer = "\nComputer"; | ||
| 452 | stringaNuovaPartita = "Nuova Partita"; | ||
| 453 | stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 454 | stringaVuoiDavveroUscire = "Vuoi davvero dscire?"; | ||
| 455 | stringaSi = "Si"; | ||
| 456 | stringaNo = "No"; | ||
| 457 | stringaOpzioni = "Opzioni..."; | ||
| 458 | stringaEsci = "Esci"; | ||
| 459 | stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 460 | stringaLingua = "Lingua"; | ||
| 461 | stringaAnnulla = "Annulla"; | ||
| 462 | stringaIt = "Italiano"; | ||
| 463 | stringaLa = "Latino"; | ||
| 464 | stringaNecessarioRiavviare = "E' necessario riavviare JBriscola se sono state\nmodificate impostazioni riguardanti la lingua\nAlcune parti saranno comunque tradotte prima."; | ||
| 465 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 466 | } | ||
| 467 | else if ( lang.equals( "la" ) ) { | ||
| 468 | stringaBottonePrendi = "CAPIS/RELINQVIS CHARTAS"; | ||
| 469 | stringaPrimaGioca = "ANTE CHARTAM PONE!"; | ||
| 470 | stringaUltime4 = "IV MANVS POSTREMAS - INTVERE BRISCOLAM!"; | ||
| 471 | stringaVinto = "VINXISTI!"; | ||
| 472 | stringaPerso = "PERDIDISTI"; | ||
| 473 | stringaPareggio = "AEQVATIO!"; | ||
| 474 | stringaGiocatore = "LVSOR: "; | ||
| 475 | stringaComputer = "\nCOMPVTER: "; | ||
| 476 | stringaNuovaPartita = "NOVA LVSO"; | ||
| 477 | stringaVuoiDavveroIniziare = "NOVAM LVSIONEM INCIPERE?"; | ||
| 478 | stringaVuoiDavveroUscire = "EXIRE?"; | ||
| 479 | stringaSi = "ID VOLO"; | ||
| 480 | stringaNo = "NOLO"; | ||
| 481 | stringaOpzioni = "OPTIONES..."; | ||
| 482 | stringaEsci = "EXIRE"; | ||
| 483 | stringaImpossibileConfigurare = "CONFIGVRATIONIS FILE SCRIBERE NON POTVI.\nERROREM ME CERTIOREM FACITE: sebastiano@luganega.org\n\nEXCEPTIO:\n"; | ||
| 484 | stringaLingua = "LINGVA"; | ||
| 485 | stringaAnnulla = "ABROGA"; | ||
| 486 | stringaIt = "ITALICE"; | ||
| 487 | stringaLa = "LATINE"; | ||
| 488 | stringaNecessarioRiavviare = "JBRISCOLAM RVRSVS INCIPERE NECESSE EST\nSI LINGVA PRAELATIONES NOVATAE SUNT.\nALIQVAE ANTE ID VERSA ERVNT"; | ||
| 489 | stringaModificaOpzioni = "OPTIONES NOVARE"; | ||
| 490 | } | ||
| 491 | } | ||
| 492 | } | ||
diff --git a/JBriscola/all_versions/0.1/0.1 Beta 2/src/OptionFrame.java b/JBriscola/all_versions/0.1/0.1 Beta 2/src/OptionFrame.java new file mode 100755 index 0000000..de6734b --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1 Beta 2/src/OptionFrame.java | |||
| @@ -0,0 +1,83 @@ | |||
| 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.util.Formatter; | ||
| 23 | import javax.swing.*; | ||
| 24 | import java.awt.*; | ||
| 25 | import java.awt.event.*; | ||
| 26 | |||
| 27 | public class OptionFrame extends JFrame { | ||
| 28 | public static Main main = new Main(); | ||
| 29 | public static Formatter formatter; | ||
| 30 | public static JButton ok, annulla; | ||
| 31 | public static JLabel lingua; | ||
| 32 | public static JComboBox selezionaLingua; | ||
| 33 | public static JPanel pannello1, pannello2; | ||
| 34 | public OptionFrame() { | ||
| 35 | super( "JBriscola - " + main.stringaModificaOpzioni ); | ||
| 36 | ok = new JButton( "OK" ); | ||
| 37 | ok.addActionListener( new ActionListener() { | ||
| 38 | public void actionPerformed( ActionEvent e ) { | ||
| 39 | try { | ||
| 40 | formatter = new Formatter( "JBriscolaConfig.txt" ); | ||
| 41 | } catch ( Exception ex ) { | ||
| 42 | JOptionPane.showMessageDialog( OptionFrame.this, main.stringaImpossibileConfigurare + ex ); | ||
| 43 | } | ||
| 44 | String lang; | ||
| 45 | switch ( selezionaLingua.getSelectedIndex() ) { | ||
| 46 | case 0: | ||
| 47 | lang = "it"; | ||
| 48 | break; | ||
| 49 | case 1: | ||
| 50 | lang = "la"; | ||
| 51 | break; | ||
| 52 | default: | ||
| 53 | lang = "it"; | ||
| 54 | break; | ||
| 55 | } | ||
| 56 | formatter.format( lang ); | ||
| 57 | formatter.close(); | ||
| 58 | main.settaOpzioni(); | ||
| 59 | main.frame.pannello.repaint(); | ||
| 60 | main.frame.repaint(); | ||
| 61 | OptionFrame.this.dispose(); | ||
| 62 | JOptionPane.showMessageDialog( OptionFrame.this, main.stringaNecessarioRiavviare, "JBriscola 0.1", JOptionPane.INFORMATION_MESSAGE ); | ||
| 63 | } | ||
| 64 | }); | ||
| 65 | annulla = new JButton( main.stringaAnnulla ); | ||
| 66 | annulla.addActionListener( new ActionListener() { | ||
| 67 | public void actionPerformed( ActionEvent e ) { | ||
| 68 | OptionFrame.this.dispose(); | ||
| 69 | } | ||
| 70 | }); | ||
| 71 | lingua = new JLabel( main.stringaLingua ); | ||
| 72 | String[] lingueDaSelezionare = { main.stringaIt, main.stringaLa }; | ||
| 73 | selezionaLingua = new JComboBox( lingueDaSelezionare ); | ||
| 74 | pannello1 = new JPanel( new FlowLayout() ); | ||
| 75 | pannello1.add( lingua ); | ||
| 76 | pannello1.add( selezionaLingua ); | ||
| 77 | pannello2 = new JPanel( new FlowLayout() ); | ||
| 78 | pannello2.add( ok ); | ||
| 79 | pannello2.add( annulla ); | ||
| 80 | add( pannello1, BorderLayout.CENTER ); | ||
| 81 | add( pannello2, BorderLayout.SOUTH ); | ||
| 82 | } | ||
| 83 | } | ||
diff --git a/JBriscola/all_versions/0.1/0.1 Beta 2/src/Pannello.java b/JBriscola/all_versions/0.1/0.1 Beta 2/src/Pannello.java new file mode 100755 index 0000000..9e73356 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1 Beta 2/src/Pannello.java | |||
| @@ -0,0 +1,53 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import java.awt.Graphics; | ||
| 24 | |||
| 25 | public class Pannello extends JPanel { | ||
| 26 | public static Main main; | ||
| 27 | public Pannello() { | ||
| 28 | } | ||
| 29 | public void paint( Graphics g ) { | ||
| 30 | super.paint( g ); | ||
| 31 | if ( main.frame.ultimaCarta != null ) | ||
| 32 | main.frame.ultimaCarta.paintIcon( this, g, 50, 180 ); | ||
| 33 | if ( main.frame.mazzo ) | ||
| 34 | main.frame.retro2.paintIcon( this, g, 17, 256 ); | ||
| 35 | if ( main.frame.carteCPU[0] != null ) | ||
| 36 | main.frame.retro1.paintIcon( this, g, 230, 5 ); | ||
| 37 | if ( main.frame.carteCPU[1] != null ) | ||
| 38 | main.frame.retro1.paintIcon( this, g, 300, 5 ); | ||
| 39 | if ( main.frame.carteCPU[2] != null ) | ||
| 40 | main.frame.retro1.paintIcon( this, g, 370, 5 ); | ||
| 41 | if ( main.frame.carteInMano[0] != null ) | ||
| 42 | main.frame.carteInMano[0].paintIcon( this, g, 230, 340 ); | ||
| 43 | if ( main.frame.carteInMano[1] != null ) | ||
| 44 | main.frame.carteInMano[1].paintIcon( this, g, 300, 340 ); | ||
| 45 | if ( main.frame.carteInMano[2] != null ) | ||
| 46 | main.frame.carteInMano[2].paintIcon( this, g, 370, 340 ); | ||
| 47 | if ( main.frame.giocata[0] != null ) | ||
| 48 | main.frame.giocata[0].paintIcon( this, g, 250, 200 ); | ||
| 49 | if ( main.frame.giocata[1] != null ) | ||
| 50 | main.frame.giocata[1].paintIcon( this, g, 325, 150 ); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/Frame.java b/JBriscola/all_versions/0.1/0.1.1/src/Frame.java new file mode 100755 index 0000000..ab85a28 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/Frame.java | |||
| @@ -0,0 +1,186 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | import java.awt.event.*; | ||
| 25 | |||
| 26 | public class Frame extends JFrame { | ||
| 27 | public static boolean mazzo; | ||
| 28 | public static Main main; | ||
| 29 | public static Pannello pannello; | ||
| 30 | public static JPanel pannello2; | ||
| 31 | public static JButton button; | ||
| 32 | public static JMenuBar barraMenu; | ||
| 33 | public static JMenu file, puntoInterrogativo; | ||
| 34 | public static JMenuItem nuovaPartita, opzioni, esci, informazioni; | ||
| 35 | public static ImageIcon retro1, retro2, ultimaCarta; | ||
| 36 | public static ImageIcon[] giocata = new ImageIcon[2]; | ||
| 37 | public static ImageIcon[] carteInMano = new ImageIcon[3]; | ||
| 38 | public static ImageIcon[] carteCPU = new ImageIcon[3]; | ||
| 39 | public static ImageIcon[] arrayCarteMescolate = new ImageIcon[40]; | ||
| 40 | public static ImageIcon[][] arrayCarte = new ImageIcon[10][4]; | ||
| 41 | public Frame() { | ||
| 42 | super( "Tronto's JBriscola " + main.version ); | ||
| 43 | mazzo = true; | ||
| 44 | main = new Main(); | ||
| 45 | pannello = new Pannello(); | ||
| 46 | pannello2 = new JPanel( new FlowLayout() ); | ||
| 47 | button = new JButton( main.stringaBottonePrendi ); | ||
| 48 | button.addActionListener( new ActionListener() { | ||
| 49 | public void actionPerformed( ActionEvent e ) { | ||
| 50 | if ( giocata[0] != null && giocata[1] != null ) | ||
| 51 | main.mano++; | ||
| 52 | try { | ||
| 53 | main.chiPrende(); | ||
| 54 | } catch ( Exception ex ) { | ||
| 55 | JOptionPane.showMessageDialog( Frame.this, main.stringaPrimaGioca, "JBriscola " + main.version, JOptionPane.WARNING_MESSAGE ); | ||
| 56 | } | ||
| 57 | if ( main.mano == 16 ) | ||
| 58 | JOptionPane.showMessageDialog( Frame.this, main.stringaUltime4, "JBriscola " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 59 | if ( main.mano == 17 ) { | ||
| 60 | mazzo = false; | ||
| 61 | ultimaCarta = null; | ||
| 62 | pannello.repaint(); | ||
| 63 | Frame.this.repaint(); | ||
| 64 | } | ||
| 65 | if ( main.mano == 20 ) { | ||
| 66 | String titolo = main.stringaVinto; | ||
| 67 | if ( main.punteggio < main.punteggioCPU ) | ||
| 68 | titolo = main.stringaPerso; | ||
| 69 | if ( main.punteggio == main.punteggioCPU ) | ||
| 70 | titolo = main.stringaPareggio; | ||
| 71 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, titolo, JOptionPane.PLAIN_MESSAGE ); | ||
| 72 | } | ||
| 73 | } | ||
| 74 | } ); | ||
| 75 | barraMenu = new JMenuBar(); | ||
| 76 | file = new JMenu( "File" ); | ||
| 77 | nuovaPartita = new JMenuItem( main.stringaNuovaPartita ); | ||
| 78 | nuovaPartita.addActionListener( new ActionListener() { | ||
| 79 | public void actionPerformed( ActionEvent e ) { | ||
| 80 | if ( main.mano == 20 ) { | ||
| 81 | main.mischia(); | ||
| 82 | pannello.repaint(); | ||
| 83 | repaint(); | ||
| 84 | } | ||
| 85 | else { | ||
| 86 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 87 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 88 | main.mischia(); | ||
| 89 | pannello.repaint(); | ||
| 90 | repaint(); | ||
| 91 | } | ||
| 92 | } | ||
| 93 | } | ||
| 94 | }); | ||
| 95 | opzioni = new JMenuItem( main.stringaOpzioni ); | ||
| 96 | opzioni.addActionListener( new ActionListener() { | ||
| 97 | public void actionPerformed( ActionEvent e ) { | ||
| 98 | OptionFrame optionFrame = new OptionFrame(); | ||
| 99 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 100 | optionFrame.setResizable( false ); | ||
| 101 | optionFrame.setAlwaysOnTop( true ); | ||
| 102 | optionFrame.setSize( 300, 150 ); | ||
| 103 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, | ||
| 104 | (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 105 | optionFrame.setVisible( true ); | ||
| 106 | } | ||
| 107 | }); | ||
| 108 | esci = new JMenuItem( main.stringaEsci ); | ||
| 109 | esci.addActionListener( new ActionListener() { | ||
| 110 | public void actionPerformed( ActionEvent e ) { | ||
| 111 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 112 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 113 | Frame.this.dispose(); | ||
| 114 | } | ||
| 115 | }); | ||
| 116 | file.add( nuovaPartita ); | ||
| 117 | file.add( opzioni ); | ||
| 118 | file.addSeparator(); | ||
| 119 | file.add( esci ); | ||
| 120 | puntoInterrogativo = new JMenu( "?" ); | ||
| 121 | informazioni = new JMenuItem( main.stringaInformazioni ); | ||
| 122 | informazioni.addActionListener( new ActionListener() { | ||
| 123 | public void actionPerformed( ActionEvent e ) { | ||
| 124 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 125 | } | ||
| 126 | } ); | ||
| 127 | puntoInterrogativo.add( informazioni ); | ||
| 128 | barraMenu.add( file ); | ||
| 129 | barraMenu.add( puntoInterrogativo ); | ||
| 130 | setJMenuBar( barraMenu ); | ||
| 131 | retro1 = new ImageIcon( ClassLoader.getSystemResource( "img/retro1.jpg" ) ); | ||
| 132 | retro2 = new ImageIcon( ClassLoader.getSystemResource( "img/retro2.jpg" ) ); | ||
| 133 | for (int i = 0; i < 10; i++) | ||
| 134 | for (int j = 0; j < 4; j++) | ||
| 135 | arrayCarte[i][j] = new ImageIcon( ClassLoader.getSystemResource( "img/" + (i+1) + "-" + (j+1) + ".jpg" ) ); | ||
| 136 | main.mischia(); | ||
| 137 | pannello2.add( button ); | ||
| 138 | setLayout( new BorderLayout() ); | ||
| 139 | add( pannello, BorderLayout.CENTER ); | ||
| 140 | add( pannello2, BorderLayout.SOUTH ); | ||
| 141 | addMouseListener( | ||
| 142 | new MouseAdapter() { | ||
| 143 | public void mouseClicked ( MouseEvent e ) { | ||
| 144 | if ( mettiCarta( e.getX(), e.getY() ) ) { | ||
| 145 | if ( !main.CPUHaGiocato ) | ||
| 146 | main.giocaCPU(); | ||
| 147 | } | ||
| 148 | } | ||
| 149 | } | ||
| 150 | ); | ||
| 151 | addWindowListener( | ||
| 152 | new WindowAdapter() { | ||
| 153 | public void windowClosing( WindowEvent e ) { | ||
| 154 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 155 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 156 | System.exit( 0 ); | ||
| 157 | } | ||
| 158 | } | ||
| 159 | ); | ||
| 160 | } | ||
| 161 | public boolean mettiCarta( int x, int y ) { | ||
| 162 | if ( !main.toccaAllaCPU && giocata[0] == null ) { | ||
| 163 | if ( x > 230 && x < 290 && y > 340 && y < 566 ) { | ||
| 164 | giocata[0] = carteInMano[0]; | ||
| 165 | carteInMano[0] = null; | ||
| 166 | pannello.repaint(); | ||
| 167 | return true; | ||
| 168 | } | ||
| 169 | if ( x > 300 && x < 360 && y > 340 && y < 566 ) { | ||
| 170 | giocata[0] = carteInMano[1]; | ||
| 171 | carteInMano[1] = null; | ||
| 172 | pannello.repaint(); | ||
| 173 | return true; | ||
| 174 | } | ||
| 175 | if ( x > 370 && x < 430 && y > 340 && y < 566 ) { | ||
| 176 | giocata[0] = carteInMano[2]; | ||
| 177 | carteInMano[2] = null; | ||
| 178 | pannello.repaint(); | ||
| 179 | return true; | ||
| 180 | } | ||
| 181 | } | ||
| 182 | return false; | ||
| 183 | } | ||
| 184 | } | ||
| 185 | |||
| 186 | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/Main.java b/JBriscola/all_versions/0.1/0.1.1/src/Main.java new file mode 100755 index 0000000..a97b21e --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/Main.java | |||
| @@ -0,0 +1,708 @@ | |||
| 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 | } | ||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/OptionFrame.java b/JBriscola/all_versions/0.1/0.1.1/src/OptionFrame.java new file mode 100755 index 0000000..bd6f0da --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/OptionFrame.java | |||
| @@ -0,0 +1,87 @@ | |||
| 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.util.Formatter; | ||
| 23 | import javax.swing.*; | ||
| 24 | import java.awt.*; | ||
| 25 | import java.awt.event.*; | ||
| 26 | |||
| 27 | public class OptionFrame extends JFrame { | ||
| 28 | public static Main main = new Main(); | ||
| 29 | public static Formatter formatter; | ||
| 30 | public static JButton ok, annulla; | ||
| 31 | public static JLabel lingua; | ||
| 32 | public static JComboBox selezionaLingua; | ||
| 33 | public static JPanel pannello1, pannello2; | ||
| 34 | public OptionFrame() { | ||
| 35 | super( "JBriscola - " + main.stringaModificaOpzioni ); | ||
| 36 | ok = new JButton( "OK" ); | ||
| 37 | ok.addActionListener( new ActionListener() { | ||
| 38 | public void actionPerformed( ActionEvent e ) { | ||
| 39 | try { | ||
| 40 | formatter = new Formatter( "JBriscolaConfig.txt" ); | ||
| 41 | } catch ( Exception ex ) { | ||
| 42 | JOptionPane.showMessageDialog( OptionFrame.this, main.stringaImpossibileConfigurare + ex ); | ||
| 43 | } | ||
| 44 | String lang; | ||
| 45 | switch ( selezionaLingua.getSelectedIndex() ) { | ||
| 46 | case 0: | ||
| 47 | lang = "it"; | ||
| 48 | break; | ||
| 49 | case 1: | ||
| 50 | lang = "la"; | ||
| 51 | break; | ||
| 52 | case 2: | ||
| 53 | lang = "bl"; | ||
| 54 | break; | ||
| 55 | case 3: | ||
| 56 | lang = "bv"; | ||
| 57 | break; | ||
| 58 | default: | ||
| 59 | lang = "it"; | ||
| 60 | break; | ||
| 61 | } | ||
| 62 | formatter.format( lang ); | ||
| 63 | formatter.close(); | ||
| 64 | main.settaOpzioni(); | ||
| 65 | OptionFrame.this.dispose(); | ||
| 66 | JOptionPane.showMessageDialog( OptionFrame.this, main.stringaNecessarioRiavviare, "JBriscola 0.1", JOptionPane.INFORMATION_MESSAGE ); | ||
| 67 | } | ||
| 68 | }); | ||
| 69 | annulla = new JButton( main.stringaAnnulla ); | ||
| 70 | annulla.addActionListener( new ActionListener() { | ||
| 71 | public void actionPerformed( ActionEvent e ) { | ||
| 72 | OptionFrame.this.dispose(); | ||
| 73 | } | ||
| 74 | }); | ||
| 75 | lingua = new JLabel( main.stringaLingua ); | ||
| 76 | String[] lingueDaSelezionare = { main.stringaIt, main.stringaLa, main.stringaBL, main.stringaBV }; | ||
| 77 | selezionaLingua = new JComboBox( lingueDaSelezionare ); | ||
| 78 | pannello1 = new JPanel( new FlowLayout() ); | ||
| 79 | pannello1.add( lingua ); | ||
| 80 | pannello1.add( selezionaLingua ); | ||
| 81 | pannello2 = new JPanel( new FlowLayout() ); | ||
| 82 | pannello2.add( ok ); | ||
| 83 | pannello2.add( annulla ); | ||
| 84 | add( pannello1, BorderLayout.CENTER ); | ||
| 85 | add( pannello2, BorderLayout.SOUTH ); | ||
| 86 | } | ||
| 87 | } | ||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/Pannello.java b/JBriscola/all_versions/0.1/0.1.1/src/Pannello.java new file mode 100755 index 0000000..9e73356 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/Pannello.java | |||
| @@ -0,0 +1,53 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import java.awt.Graphics; | ||
| 24 | |||
| 25 | public class Pannello extends JPanel { | ||
| 26 | public static Main main; | ||
| 27 | public Pannello() { | ||
| 28 | } | ||
| 29 | public void paint( Graphics g ) { | ||
| 30 | super.paint( g ); | ||
| 31 | if ( main.frame.ultimaCarta != null ) | ||
| 32 | main.frame.ultimaCarta.paintIcon( this, g, 50, 180 ); | ||
| 33 | if ( main.frame.mazzo ) | ||
| 34 | main.frame.retro2.paintIcon( this, g, 17, 256 ); | ||
| 35 | if ( main.frame.carteCPU[0] != null ) | ||
| 36 | main.frame.retro1.paintIcon( this, g, 230, 5 ); | ||
| 37 | if ( main.frame.carteCPU[1] != null ) | ||
| 38 | main.frame.retro1.paintIcon( this, g, 300, 5 ); | ||
| 39 | if ( main.frame.carteCPU[2] != null ) | ||
| 40 | main.frame.retro1.paintIcon( this, g, 370, 5 ); | ||
| 41 | if ( main.frame.carteInMano[0] != null ) | ||
| 42 | main.frame.carteInMano[0].paintIcon( this, g, 230, 340 ); | ||
| 43 | if ( main.frame.carteInMano[1] != null ) | ||
| 44 | main.frame.carteInMano[1].paintIcon( this, g, 300, 340 ); | ||
| 45 | if ( main.frame.carteInMano[2] != null ) | ||
| 46 | main.frame.carteInMano[2].paintIcon( this, g, 370, 340 ); | ||
| 47 | if ( main.frame.giocata[0] != null ) | ||
| 48 | main.frame.giocata[0].paintIcon( this, g, 250, 200 ); | ||
| 49 | if ( main.frame.giocata[1] != null ) | ||
| 50 | main.frame.giocata[1].paintIcon( this, g, 325, 150 ); | ||
| 51 | } | ||
| 52 | } | ||
| 53 | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/1-1.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/1-1.jpg new file mode 100755 index 0000000..ae43510 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/1-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/1-2.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/1-2.jpg new file mode 100755 index 0000000..3f7c75a --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/1-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/1-3.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/1-3.jpg new file mode 100755 index 0000000..9e1ead7 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/1-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/1-4.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/1-4.jpg new file mode 100755 index 0000000..710f879 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/1-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/10-1.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/10-1.jpg new file mode 100755 index 0000000..9aba45a --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/10-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/10-2.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/10-2.jpg new file mode 100755 index 0000000..037eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/10-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/10-3.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/10-3.jpg new file mode 100755 index 0000000..8780b72 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/10-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/10-4.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/10-4.jpg new file mode 100755 index 0000000..587dc0f --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/10-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/2-1.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/2-1.jpg new file mode 100755 index 0000000..5dcb7db --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/2-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/2-2.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/2-2.jpg new file mode 100755 index 0000000..ea9eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/2-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/2-3.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/2-3.jpg new file mode 100755 index 0000000..8cb22dd --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/2-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/2-4.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/2-4.jpg new file mode 100755 index 0000000..b3e7898 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/2-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/3-1.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/3-1.jpg new file mode 100755 index 0000000..dcb435c --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/3-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/3-2.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/3-2.jpg new file mode 100755 index 0000000..1e5b6ec --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/3-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/3-3.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/3-3.jpg new file mode 100755 index 0000000..9202cfe --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/3-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/3-4.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/3-4.jpg new file mode 100755 index 0000000..5436a8d --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/3-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/4-1.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/4-1.jpg new file mode 100755 index 0000000..3bab6d5 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/4-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/4-2.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/4-2.jpg new file mode 100755 index 0000000..b4901a6 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/4-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/4-3.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/4-3.jpg new file mode 100755 index 0000000..d754ad8 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/4-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/4-4.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/4-4.jpg new file mode 100755 index 0000000..3a54b96 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/4-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/5-1.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/5-1.jpg new file mode 100755 index 0000000..3f7ba1f --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/5-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/5-2.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/5-2.jpg new file mode 100755 index 0000000..fcacb75 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/5-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/5-3.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/5-3.jpg new file mode 100755 index 0000000..ce32f9f --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/5-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/5-4.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/5-4.jpg new file mode 100755 index 0000000..b86b09a --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/5-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/6-1.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/6-1.jpg new file mode 100755 index 0000000..f90cd81 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/6-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/6-2.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/6-2.jpg new file mode 100755 index 0000000..cf2a67a --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/6-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/6-3.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/6-3.jpg new file mode 100755 index 0000000..2cd2fe2 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/6-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/6-4.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/6-4.jpg new file mode 100755 index 0000000..73f410f --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/6-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/7-1.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/7-1.jpg new file mode 100755 index 0000000..08cd397 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/7-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/7-2.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/7-2.jpg new file mode 100755 index 0000000..a168ff8 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/7-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/7-3.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/7-3.jpg new file mode 100755 index 0000000..5cda411 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/7-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/7-4.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/7-4.jpg new file mode 100755 index 0000000..5d63229 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/7-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/8-1.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/8-1.jpg new file mode 100755 index 0000000..a6faa7b --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/8-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/8-2.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/8-2.jpg new file mode 100755 index 0000000..0d9edbb --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/8-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/8-3.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/8-3.jpg new file mode 100755 index 0000000..91f8354 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/8-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/8-4.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/8-4.jpg new file mode 100755 index 0000000..cc0089c --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/8-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/9-1.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/9-1.jpg new file mode 100755 index 0000000..be9c6bf --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/9-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/9-2.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/9-2.jpg new file mode 100755 index 0000000..e25da4c --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/9-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/9-3.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/9-3.jpg new file mode 100755 index 0000000..cd384f8 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/9-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/9-4.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/9-4.jpg new file mode 100755 index 0000000..441210e --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/9-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/carte.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/carte.jpg new file mode 100755 index 0000000..838ffac --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/carte.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/retro1.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/retro1.jpg new file mode 100755 index 0000000..9651b06 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/retro1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.1/0.1.1/src/img/retro2.jpg b/JBriscola/all_versions/0.1/0.1.1/src/img/retro2.jpg new file mode 100755 index 0000000..c5d3925 --- /dev/null +++ b/JBriscola/all_versions/0.1/0.1.1/src/img/retro2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/Frame.java b/JBriscola/all_versions/0.2/0.2 Beta 1/src/Frame.java new file mode 100755 index 0000000..31aa39b --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/Frame.java | |||
| @@ -0,0 +1,242 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import javax.sound.sampled.*; | ||
| 24 | import java.io.*; | ||
| 25 | import java.awt.*; | ||
| 26 | import java.awt.event.*; | ||
| 27 | |||
| 28 | public class Frame extends JFrame { | ||
| 29 | public static boolean mazzo; | ||
| 30 | public static Main main; | ||
| 31 | public static Pannello pannello; | ||
| 32 | public static JPanel pannello2; | ||
| 33 | public static JButton button; | ||
| 34 | public static JMenuBar barraMenu; | ||
| 35 | public static JMenu file, puntoInterrogativo; | ||
| 36 | public static JMenuItem nuovaPartita, opzioni, esci, informazioni, punti; | ||
| 37 | public static ImageIcon retro1, retro2, ultimaCarta; | ||
| 38 | public static ImageIcon[] giocata = new ImageIcon[2]; | ||
| 39 | public static ImageIcon[] carteInMano = new ImageIcon[3]; | ||
| 40 | public static ImageIcon[] carteCPU = new ImageIcon[3]; | ||
| 41 | public static ImageIcon[] arrayCarteMescolate = new ImageIcon[40]; | ||
| 42 | public static ImageIcon[][] arrayCarte = new ImageIcon[10][4]; | ||
| 43 | public Frame() { | ||
| 44 | super( "Tronto's JBriscola " + main.version ); | ||
| 45 | mazzo = true; | ||
| 46 | main = new Main(); | ||
| 47 | pannello = new Pannello(); | ||
| 48 | pannello2 = new JPanel( new FlowLayout() ); | ||
| 49 | button = new JButton( main.stringaBottonePrendi ); | ||
| 50 | button.addActionListener( new ActionListener() { | ||
| 51 | public void actionPerformed( ActionEvent e ) { | ||
| 52 | if ( giocata[0] != null && giocata[1] != null ) | ||
| 53 | main.mano++; | ||
| 54 | try { | ||
| 55 | main.chiPrende(); | ||
| 56 | } catch ( Exception ex ) { | ||
| 57 | JOptionPane.showMessageDialog( Frame.this, main.stringaPrimaGioca, "JBriscola " + main.version, JOptionPane.WARNING_MESSAGE ); | ||
| 58 | } | ||
| 59 | if ( main.mano == 16 ) | ||
| 60 | JOptionPane.showMessageDialog( Frame.this, main.stringaUltime4, "JBriscola " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 61 | if ( main.mano == 17 ) { | ||
| 62 | mazzo = false; | ||
| 63 | ultimaCarta = null; | ||
| 64 | pannello.repaint(); | ||
| 65 | Frame.this.repaint(); | ||
| 66 | } | ||
| 67 | if ( main.mano == 20 ) { | ||
| 68 | String titolo = ""; | ||
| 69 | String suonoFinale = ""; | ||
| 70 | if ( main.punteggio > main.punteggioCPU ) { | ||
| 71 | titolo = main.stringaVinto; | ||
| 72 | suonoFinale = "sounds/perso.wav"; | ||
| 73 | } | ||
| 74 | if ( main.punteggio < main.punteggioCPU ) { | ||
| 75 | titolo = main.stringaPerso; | ||
| 76 | suonoFinale = "sounds/vinto.wav"; | ||
| 77 | } | ||
| 78 | if ( main.punteggio == main.punteggioCPU ) { | ||
| 79 | titolo = main.stringaPareggio; | ||
| 80 | suonoFinale = "sounds/pareggio.wav"; | ||
| 81 | } | ||
| 82 | if ( main.sound ) { | ||
| 83 | try { | ||
| 84 | File suono = new File( ClassLoader.getSystemResource( suonoFinale ).toURI() ); | ||
| 85 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( suono ); | ||
| 86 | AudioInputStream ais = AudioSystem.getAudioInputStream( suono ); | ||
| 87 | AudioFormat af = aff.getFormat(); | ||
| 88 | DataLine.Info info = new DataLine.Info( | ||
| 89 | Clip.class, | ||
| 90 | ais.getFormat(), | ||
| 91 | ( (int) ais.getFrameLength() * | ||
| 92 | af.getFrameSize() ) ); | ||
| 93 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 94 | ol.open(ais); | ||
| 95 | ol.loop( 0 ); | ||
| 96 | } catch ( Exception ex ) { | ||
| 97 | System.err.println( e ); | ||
| 98 | } | ||
| 99 | } | ||
| 100 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, titolo, JOptionPane.PLAIN_MESSAGE ); | ||
| 101 | } | ||
| 102 | } | ||
| 103 | } ); | ||
| 104 | barraMenu = new JMenuBar(); | ||
| 105 | file = new JMenu( "File" ); | ||
| 106 | nuovaPartita = new JMenuItem( main.stringaNuovaPartita ); | ||
| 107 | nuovaPartita.addActionListener( new ActionListener() { | ||
| 108 | public void actionPerformed( ActionEvent e ) { | ||
| 109 | if ( main.mano == 20 ) { | ||
| 110 | main.mischia(); | ||
| 111 | pannello.repaint(); | ||
| 112 | repaint(); | ||
| 113 | } | ||
| 114 | else { | ||
| 115 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 116 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 117 | main.mischia(); | ||
| 118 | pannello.repaint(); | ||
| 119 | repaint(); | ||
| 120 | } | ||
| 121 | } | ||
| 122 | } | ||
| 123 | }); | ||
| 124 | opzioni = new JMenuItem( main.stringaOpzioni ); | ||
| 125 | opzioni.addActionListener( new ActionListener() { | ||
| 126 | public void actionPerformed( ActionEvent e ) { | ||
| 127 | OptionFrame optionFrame = new OptionFrame(); | ||
| 128 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 129 | optionFrame.setResizable( false ); | ||
| 130 | optionFrame.setAlwaysOnTop( true ); | ||
| 131 | optionFrame.setSize( 300, 150 ); | ||
| 132 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, | ||
| 133 | (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 134 | optionFrame.setVisible( true ); | ||
| 135 | } | ||
| 136 | }); | ||
| 137 | esci = new JMenuItem( main.stringaEsci ); | ||
| 138 | esci.addActionListener( new ActionListener() { | ||
| 139 | public void actionPerformed( ActionEvent e ) { | ||
| 140 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 141 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 142 | Frame.this.dispose(); | ||
| 143 | } | ||
| 144 | }); | ||
| 145 | file.add( nuovaPartita ); | ||
| 146 | file.add( opzioni ); | ||
| 147 | file.addSeparator(); | ||
| 148 | file.add( esci ); | ||
| 149 | puntoInterrogativo = new JMenu( "?" ); | ||
| 150 | informazioni = new JMenuItem( main.stringaInformazioni ); | ||
| 151 | informazioni.addActionListener( new ActionListener() { | ||
| 152 | public void actionPerformed( ActionEvent e ) { | ||
| 153 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 154 | } | ||
| 155 | } ); | ||
| 156 | punti = new JMenuItem( main.stringaPunteggio ); | ||
| 157 | punti.addActionListener( new ActionListener() { | ||
| 158 | public void actionPerformed( ActionEvent e ) { | ||
| 159 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + "\n" + main.stringaComputer + main.punteggioCPU, main.stringaPunteggio, JOptionPane.PLAIN_MESSAGE ); | ||
| 160 | } | ||
| 161 | } ); | ||
| 162 | puntoInterrogativo.add( punti ); | ||
| 163 | puntoInterrogativo.add( informazioni ); | ||
| 164 | barraMenu.add( file ); | ||
| 165 | barraMenu.add( puntoInterrogativo ); | ||
| 166 | setJMenuBar( barraMenu ); | ||
| 167 | retro1 = new ImageIcon( ClassLoader.getSystemResource( "img/retro1.jpg" ) ); | ||
| 168 | retro2 = new ImageIcon( ClassLoader.getSystemResource( "img/retro2.jpg" ) ); | ||
| 169 | for (int i = 0; i < 10; i++) | ||
| 170 | for (int j = 0; j < 4; j++) | ||
| 171 | arrayCarte[i][j] = new ImageIcon( ClassLoader.getSystemResource( "img/" + (i+1) + "-" + (j+1) + ".jpg" ) ); | ||
| 172 | main.mischia(); | ||
| 173 | pannello2.add( button ); | ||
| 174 | setLayout( new BorderLayout() ); | ||
| 175 | add( pannello, BorderLayout.CENTER ); | ||
| 176 | add( pannello2, BorderLayout.SOUTH ); | ||
| 177 | addMouseListener( | ||
| 178 | new MouseAdapter() { | ||
| 179 | public void mouseClicked ( MouseEvent e ) { | ||
| 180 | if ( mettiCarta( e.getX(), e.getY() ) ) { | ||
| 181 | if ( !main.CPUHaGiocato ) | ||
| 182 | main.giocaCPU(); | ||
| 183 | } | ||
| 184 | } | ||
| 185 | } | ||
| 186 | ); | ||
| 187 | addWindowListener( | ||
| 188 | new WindowAdapter() { | ||
| 189 | public void windowClosing( WindowEvent e ) { | ||
| 190 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 191 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 192 | System.exit( 0 ); | ||
| 193 | } | ||
| 194 | } | ||
| 195 | ); | ||
| 196 | } | ||
| 197 | public boolean mettiCarta( int x, int y ) { | ||
| 198 | if ( !main.toccaAllaCPU && giocata[0] == null ) { | ||
| 199 | if ( main.sound ) { | ||
| 200 | try { | ||
| 201 | double a = Math.random() * 6; | ||
| 202 | int i = (int) a; | ||
| 203 | File suono = new File( ClassLoader.getSystemResource( "sounds/" + i + ".wav" ).toURI() ); | ||
| 204 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( suono ); | ||
| 205 | AudioInputStream ais = AudioSystem.getAudioInputStream( suono ); | ||
| 206 | AudioFormat af = aff.getFormat(); | ||
| 207 | DataLine.Info info = new DataLine.Info( | ||
| 208 | Clip.class, | ||
| 209 | ais.getFormat(), | ||
| 210 | ( (int) ais.getFrameLength() * | ||
| 211 | af.getFrameSize() ) ); | ||
| 212 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 213 | ol.open(ais); | ||
| 214 | ol.loop( 0 ); | ||
| 215 | } catch ( Exception e ) { | ||
| 216 | System.err.println( e ); | ||
| 217 | } | ||
| 218 | } | ||
| 219 | if ( x > 230 && x < 290 && y > 340 && y < 566 ) { | ||
| 220 | giocata[0] = carteInMano[0]; | ||
| 221 | carteInMano[0] = null; | ||
| 222 | pannello.repaint(); | ||
| 223 | return true; | ||
| 224 | } | ||
| 225 | if ( x > 300 && x < 360 && y > 340 && y < 566 ) { | ||
| 226 | giocata[0] = carteInMano[1]; | ||
| 227 | carteInMano[1] = null; | ||
| 228 | pannello.repaint(); | ||
| 229 | return true; | ||
| 230 | } | ||
| 231 | if ( x > 370 && x < 430 && y > 340 && y < 566 ) { | ||
| 232 | giocata[0] = carteInMano[2]; | ||
| 233 | carteInMano[2] = null; | ||
| 234 | pannello.repaint(); | ||
| 235 | return true; | ||
| 236 | } | ||
| 237 | } | ||
| 238 | return false; | ||
| 239 | } | ||
| 240 | } | ||
| 241 | |||
| 242 | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/Main.java b/JBriscola/all_versions/0.2/0.2 Beta 1/src/Main.java new file mode 100755 index 0000000..6e09368 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/Main.java | |||
| @@ -0,0 +1,1068 @@ | |||
| 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 Frame frame; | ||
| 34 | public static Color color = new Color( 0, 150, 0 ); | ||
| 35 | public static String version = "0.2 beta 1"; | ||
| 36 | public static String stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 37 | public static String stringaPrimaGioca = "Prima Gioca!"; | ||
| 38 | public static String stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 39 | public static String stringaVinto = "Hai Vinto!"; | ||
| 40 | public static String stringaPerso = "Hai Perso"; | ||
| 41 | public static String stringaPareggio = "Pareggio"; | ||
| 42 | public static String stringaGiocatore = "Giocatore: "; | ||
| 43 | public static String stringaComputer = "\nComputer: "; | ||
| 44 | public static String stringaNuovaPartita = "Nuova Partita"; | ||
| 45 | public static String stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 46 | public static String stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 47 | public static String stringaSi = "Si"; | ||
| 48 | public static String stringaNo = "No"; | ||
| 49 | public static String stringaOpzioni = "Opzioni..."; | ||
| 50 | public static String stringaEsci = "Esci"; | ||
| 51 | public static String stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 52 | public static String stringaLingua = "Lingua"; | ||
| 53 | public static String stringaAnnulla = "Annulla"; | ||
| 54 | public static String stringaIt = "Italiano"; | ||
| 55 | public static String stringaLa = "Latino"; | ||
| 56 | public static String stringaBL = "Dialetto Bellunese"; | ||
| 57 | public static String stringaBV = "Dialetto Basso Veneto"; | ||
| 58 | public static String stringaNecessarioRiavviare = "E' necessario riavviare JBriscola se sono state\nmodificate impostazioni riguardanti la lingua.\nAlcune parti saranno comunque tradotte prima."; | ||
| 59 | public static String stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 60 | public static String stringaInformazioni = "Informazioni"; | ||
| 61 | 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"; | ||
| 62 | public static String stringaSuono = "Effetti Sonori"; | ||
| 63 | public static String stringaPunteggio = "Punteggio"; | ||
| 64 | public static String stringaSfondo = "Sfondo"; | ||
| 65 | public static String lang, soundString; | ||
| 66 | public static void main( String args[] ) { | ||
| 67 | settaOpzioni(); | ||
| 68 | frame = new Frame(); | ||
| 69 | frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); | ||
| 70 | frame.setResizable( false ); | ||
| 71 | frame.setSize( 600, 600 ); | ||
| 72 | frame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 600) / 2, | ||
| 73 | (Toolkit.getDefaultToolkit().getScreenSize().height - 600) / 2); | ||
| 74 | |||
| 75 | frame.setVisible( true ); | ||
| 76 | } | ||
| 77 | public void mischia() { | ||
| 78 | mano = 0; | ||
| 79 | punteggio = 0; | ||
| 80 | punteggioCPU = 0; | ||
| 81 | cartaDaPescare = 6; | ||
| 82 | ImageIcon aux; | ||
| 83 | frame.mazzo = true; | ||
| 84 | toccaAllaCPU = false; | ||
| 85 | CPUHaGiocato = false; | ||
| 86 | haGiocatoPrima = true; | ||
| 87 | for ( int i = 0, k = 0; i < 10; i++ ) | ||
| 88 | for ( int j = 0; j < 4; j++, k++ ) | ||
| 89 | frame.arrayCarteMescolate[k] = frame.arrayCarte[i][j]; | ||
| 90 | for ( int i = 0; i < 391; i++ ) { | ||
| 91 | double a = Math.random() * 40; | ||
| 92 | int x = (int) a; | ||
| 93 | double b = Math.random() * 40; | ||
| 94 | int y = (int) b; | ||
| 95 | aux = frame.arrayCarteMescolate[x]; | ||
| 96 | frame.arrayCarteMescolate[x] = frame.arrayCarteMescolate[y]; | ||
| 97 | frame.arrayCarteMescolate[y] = aux; | ||
| 98 | } | ||
| 99 | char auxChar[] = frame.arrayCarteMescolate[39].toString().toCharArray(); | ||
| 100 | semeBriscola = auxChar[auxChar.length-5] - 49; | ||
| 101 | frame.carteInMano[0] = frame.arrayCarteMescolate[0]; | ||
| 102 | frame.carteInMano[1] = frame.arrayCarteMescolate[1]; | ||
| 103 | frame.carteInMano[2] = frame.arrayCarteMescolate[2]; | ||
| 104 | frame.carteCPU[0] = frame.arrayCarteMescolate[3]; | ||
| 105 | frame.carteCPU[1] = frame.arrayCarteMescolate[4]; | ||
| 106 | frame.carteCPU[2] = frame.arrayCarteMescolate[5]; | ||
| 107 | frame.ultimaCarta = frame.arrayCarteMescolate[39]; | ||
| 108 | frame.giocata[0] = null; | ||
| 109 | frame.giocata[1] = null; | ||
| 110 | } | ||
| 111 | public void giocaCPU() { | ||
| 112 | if ( mano < 16 ) { | ||
| 113 | if ( frame.giocata[0] == null ) { | ||
| 114 | if ( vaiPunti() ); | ||
| 115 | else if ( vaiLiscio() ); | ||
| 116 | else if ( vaiTaglio() ); | ||
| 117 | else if ( vaiBriscolaAlta() ); | ||
| 118 | else if ( vaiCarico() ); | ||
| 119 | else if ( vaiTre() ); | ||
| 120 | else if ( vaiAsso() ); | ||
| 121 | else; | ||
| 122 | } | ||
| 123 | else { | ||
| 124 | if ( haLisciato() ) { | ||
| 125 | if ( vaiSopra() ); | ||
| 126 | else if ( vaiLiscio() ); | ||
| 127 | else if ( vaiPunti() ); | ||
| 128 | else if ( vaiTaglio() ); | ||
| 129 | else if ( vaiTre() ); | ||
| 130 | else if ( vaiBriscolaAlta() ); | ||
| 131 | else if ( vaiCarico() ); | ||
| 132 | else if ( vaiAsso() ); | ||
| 133 | } else if ( haMessoPunti() ) { | ||
| 134 | if ( vaiSopra() ); | ||
| 135 | else if ( vaiLiscio() ); | ||
| 136 | else if ( vaiTaglio() ); | ||
| 137 | else if ( vaiPunti() ); | ||
| 138 | else if ( vaiTre() ); | ||
| 139 | else if ( vaiBriscolaAlta() ); | ||
| 140 | else if ( vaiCarico() ); | ||
| 141 | else if ( vaiAsso() ); | ||
| 142 | } else if ( haTagliato() ) { | ||
| 143 | if ( vaiLiscio() ); | ||
| 144 | else if ( vaiPunti() ); | ||
| 145 | else if ( vaiTaglio() ); | ||
| 146 | else if ( vaiTre() ); | ||
| 147 | else if ( vaiBriscolaAlta() ); | ||
| 148 | else if ( vaiCarico() ); | ||
| 149 | else if ( vaiAsso() ); | ||
| 150 | } else if ( haMessoBriscolaAlta() ) { | ||
| 151 | if ( vaiLiscio() ); | ||
| 152 | else if ( vaiPunti() ); | ||
| 153 | else if ( vaiTre() ); | ||
| 154 | else if ( vaiTaglio() ); | ||
| 155 | else if ( vaiBriscolaAlta() ); | ||
| 156 | else if ( vaiCarico() ); | ||
| 157 | else if ( vaiAsso() ); | ||
| 158 | } else if ( haMessoTre() ) { | ||
| 159 | if ( vaiAsso() ); | ||
| 160 | else if ( vaiLiscio() ); | ||
| 161 | else if ( vaiPunti() ); | ||
| 162 | else if ( vaiTaglio() ); | ||
| 163 | else if ( vaiBriscolaAlta() ); | ||
| 164 | else if ( vaiCarico() ); | ||
| 165 | } else if ( haMessoAsso() ) { | ||
| 166 | if ( vaiLiscio() ); | ||
| 167 | else if ( vaiPunti() ); | ||
| 168 | else if ( vaiTaglio() ); | ||
| 169 | else if ( vaiBriscolaAlta() ); | ||
| 170 | else if ( vaiCarico() ); | ||
| 171 | else if ( vaiTre() ); | ||
| 172 | } else if ( haCaricato() ) { | ||
| 173 | if ( vaiSopra() ); | ||
| 174 | else if ( vaiTre() ); | ||
| 175 | else if ( vaiBriscolaAlta() ); | ||
| 176 | else if ( vaiAsso() ); | ||
| 177 | else if ( vaiTaglio() ); | ||
| 178 | else if ( vaiLiscio() ); | ||
| 179 | else if ( vaiPunti() ); | ||
| 180 | else if ( vaiCarico() ); | ||
| 181 | } | ||
| 182 | } | ||
| 183 | } | ||
| 184 | else if ( mano == 16 ) { | ||
| 185 | if ( frame.giocata[0] == null ) { | ||
| 186 | char aux[]; | ||
| 187 | aux = frame.ultimaCarta.toString().toCharArray(); | ||
| 188 | if ( aux[aux.length-7] - 48 == 3 || aux[aux.length-7] - 48 == 1 ) { | ||
| 189 | if ( vaiCarico() ); | ||
| 190 | else if ( vaiPunti() ); | ||
| 191 | else if ( vaiLiscio() ); | ||
| 192 | else if ( vaiTaglio() ); | ||
| 193 | else if ( vaiBriscolaAlta() ); | ||
| 194 | else if ( vaiTre() ); | ||
| 195 | else if ( vaiAsso() ); | ||
| 196 | else; | ||
| 197 | } else { | ||
| 198 | if ( vaiPunti() ); | ||
| 199 | else if ( vaiLiscio() ); | ||
| 200 | else if ( vaiTaglio() ); | ||
| 201 | else if ( vaiBriscolaAlta() ); | ||
| 202 | else if ( vaiCarico() ); | ||
| 203 | else if ( vaiTre() ); | ||
| 204 | else if ( vaiAsso() ); | ||
| 205 | else; | ||
| 206 | } | ||
| 207 | } | ||
| 208 | else { | ||
| 209 | char aux[]; | ||
| 210 | aux = frame.ultimaCarta.toString().toCharArray(); | ||
| 211 | if ( aux[aux.length-7] - 48 == 3 || aux[aux.length-7] - 48 == 1 ) { | ||
| 212 | if ( haCaricato() ) { | ||
| 213 | if ( vaiSopra() ); | ||
| 214 | else if ( vaiLiscio() ); | ||
| 215 | else if ( vaiPunti() ); | ||
| 216 | else if ( vaiTre() ); | ||
| 217 | else if ( vaiTaglio() ); | ||
| 218 | else if ( vaiBriscolaAlta() ); | ||
| 219 | else if ( vaiAsso() ); | ||
| 220 | else if ( vaiCarico() ); | ||
| 221 | } | ||
| 222 | } else { | ||
| 223 | if ( haLisciato() ) { | ||
| 224 | if ( vaiSopra() ); | ||
| 225 | else if ( vaiLiscio() ); | ||
| 226 | else if ( vaiPunti() ); | ||
| 227 | else if ( vaiTaglio() ); | ||
| 228 | else if ( vaiTre() ); | ||
| 229 | else if ( vaiBriscolaAlta() ); | ||
| 230 | else if ( vaiCarico() ); | ||
| 231 | else if ( vaiAsso() ); | ||
| 232 | } else if ( haMessoPunti() ) { | ||
| 233 | if ( vaiSopra() ); | ||
| 234 | else if ( vaiLiscio() ); | ||
| 235 | else if ( vaiTaglio() ); | ||
| 236 | else if ( vaiPunti() ); | ||
| 237 | else if ( vaiTre() ); | ||
| 238 | else if ( vaiBriscolaAlta() ); | ||
| 239 | else if ( vaiCarico() ); | ||
| 240 | else if ( vaiAsso() ); | ||
| 241 | } else if ( haTagliato() ) { | ||
| 242 | if ( vaiLiscio() ); | ||
| 243 | else if ( vaiPunti() ); | ||
| 244 | else if ( vaiTaglio() ); | ||
| 245 | else if ( vaiTre() ); | ||
| 246 | else if ( vaiBriscolaAlta() ); | ||
| 247 | else if ( vaiCarico() ); | ||
| 248 | else if ( vaiAsso() ); | ||
| 249 | } else if ( haMessoBriscolaAlta() ) { | ||
| 250 | if ( vaiLiscio() ); | ||
| 251 | else if ( vaiPunti() ); | ||
| 252 | else if ( vaiTre() ); | ||
| 253 | else if ( vaiTaglio() ); | ||
| 254 | else if ( vaiBriscolaAlta() ); | ||
| 255 | else if ( vaiCarico() ); | ||
| 256 | else if ( vaiAsso() ); | ||
| 257 | } else if ( haMessoTre() ) { | ||
| 258 | if ( vaiAsso() ); | ||
| 259 | else if ( vaiLiscio() ); | ||
| 260 | else if ( vaiPunti() ); | ||
| 261 | else if ( vaiTaglio() ); | ||
| 262 | else if ( vaiBriscolaAlta() ); | ||
| 263 | else if ( vaiCarico() ); | ||
| 264 | } else if ( haMessoAsso() ) { | ||
| 265 | if ( vaiLiscio() ); | ||
| 266 | else if ( vaiPunti() ); | ||
| 267 | else if ( vaiTaglio() ); | ||
| 268 | else if ( vaiBriscolaAlta() ); | ||
| 269 | else if ( vaiCarico() ); | ||
| 270 | else if ( vaiTre() ); | ||
| 271 | } else if ( haCaricato() ) { | ||
| 272 | if ( vaiSopra() ); | ||
| 273 | else if ( vaiTre() ); | ||
| 274 | else if ( vaiBriscolaAlta() ); | ||
| 275 | else if ( vaiAsso() ); | ||
| 276 | else if ( vaiTaglio() ); | ||
| 277 | else if ( vaiLiscio() ); | ||
| 278 | else if ( vaiPunti() ); | ||
| 279 | else if ( vaiCarico() ); | ||
| 280 | } | ||
| 281 | } | ||
| 282 | } | ||
| 283 | } else if ( mano == 17 ) { | ||
| 284 | if ( frame.giocata[0] == null ) { | ||
| 285 | if ( hoAsso() ) { | ||
| 286 | if ( vaiTre() ); | ||
| 287 | else if ( vaiBriscolaAlta() ); | ||
| 288 | else if ( vaiTaglio() ); | ||
| 289 | else if ( vaiLiscio() ); | ||
| 290 | else if ( vaiPunti() ); | ||
| 291 | else if ( vaiAsso() ); | ||
| 292 | else if ( vaiCarico() ); | ||
| 293 | } else { | ||
| 294 | if ( vaiLiscio() ); | ||
| 295 | else if ( vaiPunti() ); | ||
| 296 | else if ( vaiTaglio() ); | ||
| 297 | else if ( vaiBriscolaAlta() ); | ||
| 298 | else if ( vaiCarico() ); | ||
| 299 | else if ( vaiTre() ); | ||
| 300 | } | ||
| 301 | } | ||
| 302 | else { | ||
| 303 | if ( haLisciato() ) { | ||
| 304 | if ( vaiSopra() ); | ||
| 305 | else if ( vaiLiscio() ); | ||
| 306 | else if ( vaiPunti() ); | ||
| 307 | else if ( vaiTaglio() ); | ||
| 308 | else if ( vaiTre() ); | ||
| 309 | else if ( vaiBriscolaAlta() ); | ||
| 310 | else if ( vaiCarico() ); | ||
| 311 | else if ( vaiAsso() ); | ||
| 312 | } else if ( haMessoPunti() ) { | ||
| 313 | if ( vaiSopra() ); | ||
| 314 | else if ( vaiLiscio() ); | ||
| 315 | else if ( vaiTaglio() ); | ||
| 316 | else if ( vaiPunti() ); | ||
| 317 | else if ( vaiTre() ); | ||
| 318 | else if ( vaiBriscolaAlta() ); | ||
| 319 | else if ( vaiCarico() ); | ||
| 320 | else if ( vaiAsso() ); | ||
| 321 | } else if ( haTagliato() ) { | ||
| 322 | if ( vaiLiscio() ); | ||
| 323 | else if ( vaiPunti() ); | ||
| 324 | else if ( vaiTaglio() ); | ||
| 325 | else if ( vaiTre() ); | ||
| 326 | else if ( vaiBriscolaAlta() ); | ||
| 327 | else if ( vaiCarico() ); | ||
| 328 | else if ( vaiAsso() ); | ||
| 329 | } else if ( haMessoBriscolaAlta() ) { | ||
| 330 | if ( vaiLiscio() ); | ||
| 331 | else if ( vaiPunti() ); | ||
| 332 | else if ( vaiTre() ); | ||
| 333 | else if ( vaiTaglio() ); | ||
| 334 | else if ( vaiBriscolaAlta() ); | ||
| 335 | else if ( vaiCarico() ); | ||
| 336 | else if ( vaiAsso() ); | ||
| 337 | } else if ( haMessoTre() ) { | ||
| 338 | if ( vaiAsso() ); | ||
| 339 | else if ( vaiLiscio() ); | ||
| 340 | else if ( vaiPunti() ); | ||
| 341 | else if ( vaiTaglio() ); | ||
| 342 | else if ( vaiBriscolaAlta() ); | ||
| 343 | else if ( vaiCarico() ); | ||
| 344 | } else if ( haMessoAsso() ) { | ||
| 345 | if ( vaiLiscio() ); | ||
| 346 | else if ( vaiPunti() ); | ||
| 347 | else if ( vaiTaglio() ); | ||
| 348 | else if ( vaiBriscolaAlta() ); | ||
| 349 | else if ( vaiCarico() ); | ||
| 350 | else if ( vaiTre() ); | ||
| 351 | } else if ( haCaricato() ) { | ||
| 352 | if ( vaiSopra() ); | ||
| 353 | else if ( vaiTre() ); | ||
| 354 | else if ( vaiBriscolaAlta() ); | ||
| 355 | else if ( vaiAsso() ); | ||
| 356 | else if ( vaiTaglio() ); | ||
| 357 | else if ( vaiLiscio() ); | ||
| 358 | else if ( vaiPunti() ); | ||
| 359 | else if ( vaiCarico() ); | ||
| 360 | } | ||
| 361 | } | ||
| 362 | } else if ( mano == 18 ) { | ||
| 363 | if ( frame.giocata[0] == null ) { | ||
| 364 | if ( vaiAsso() ); | ||
| 365 | else if ( vaiCarico() ); | ||
| 366 | else if ( vaiBriscolaAlta() ); | ||
| 367 | else if ( vaiTaglio() ); | ||
| 368 | else if ( vaiPunti() ); | ||
| 369 | else if ( vaiLiscio() ); | ||
| 370 | else if ( vaiTre() ); | ||
| 371 | } | ||
| 372 | else { | ||
| 373 | if ( haLisciato() ) { | ||
| 374 | if ( vaiSopra() ); | ||
| 375 | else if ( vaiLiscio() ); | ||
| 376 | else if ( vaiPunti() ); | ||
| 377 | else if ( vaiTaglio() ); | ||
| 378 | else if ( vaiTre() ); | ||
| 379 | else if ( vaiBriscolaAlta() ); | ||
| 380 | else if ( vaiCarico() ); | ||
| 381 | else if ( vaiAsso() ); | ||
| 382 | } else if ( haMessoPunti() ) { | ||
| 383 | if ( vaiSopra() ); | ||
| 384 | else if ( vaiLiscio() ); | ||
| 385 | else if ( vaiTaglio() ); | ||
| 386 | else if ( vaiPunti() ); | ||
| 387 | else if ( vaiTre() ); | ||
| 388 | else if ( vaiBriscolaAlta() ); | ||
| 389 | else if ( vaiCarico() ); | ||
| 390 | else if ( vaiAsso() ); | ||
| 391 | } else if ( haTagliato() ) { | ||
| 392 | if ( vaiLiscio() ); | ||
| 393 | else if ( vaiPunti() ); | ||
| 394 | else if ( vaiTaglio() ); | ||
| 395 | else if ( vaiTre() ); | ||
| 396 | else if ( vaiBriscolaAlta() ); | ||
| 397 | else if ( vaiCarico() ); | ||
| 398 | else if ( vaiAsso() ); | ||
| 399 | } else if ( haMessoBriscolaAlta() ) { | ||
| 400 | if ( vaiLiscio() ); | ||
| 401 | else if ( vaiPunti() ); | ||
| 402 | else if ( vaiTre() ); | ||
| 403 | else if ( vaiTaglio() ); | ||
| 404 | else if ( vaiBriscolaAlta() ); | ||
| 405 | else if ( vaiCarico() ); | ||
| 406 | else if ( vaiAsso() ); | ||
| 407 | } else if ( haMessoTre() ) { | ||
| 408 | if ( vaiAsso() ); | ||
| 409 | else if ( vaiLiscio() ); | ||
| 410 | else if ( vaiPunti() ); | ||
| 411 | else if ( vaiTaglio() ); | ||
| 412 | else if ( vaiBriscolaAlta() ); | ||
| 413 | else if ( vaiCarico() ); | ||
| 414 | } else if ( haMessoAsso() ) { | ||
| 415 | if ( vaiLiscio() ); | ||
| 416 | else if ( vaiPunti() ); | ||
| 417 | else if ( vaiTaglio() ); | ||
| 418 | else if ( vaiBriscolaAlta() ); | ||
| 419 | else if ( vaiCarico() ); | ||
| 420 | else if ( vaiTre() ); | ||
| 421 | } else if ( haCaricato() ) { | ||
| 422 | if ( vaiSopra() ); | ||
| 423 | else if ( vaiTre() ); | ||
| 424 | else if ( vaiBriscolaAlta() ); | ||
| 425 | else if ( vaiAsso() ); | ||
| 426 | else if ( vaiTaglio() ); | ||
| 427 | else if ( vaiLiscio() ); | ||
| 428 | else if ( vaiPunti() ); | ||
| 429 | else if ( vaiCarico() ); | ||
| 430 | } | ||
| 431 | } | ||
| 432 | } else { | ||
| 433 | if ( vaiTre() ); | ||
| 434 | else if ( vaiBriscolaAlta() ); | ||
| 435 | else if ( vaiAsso() ); | ||
| 436 | else if ( vaiTaglio() ); | ||
| 437 | else if ( vaiLiscio() ); | ||
| 438 | else if ( vaiPunti() ); | ||
| 439 | else if ( vaiCarico() ); | ||
| 440 | } | ||
| 441 | frame.giocata[1] = frame.carteCPU[cartaDaGiocare]; | ||
| 442 | frame.carteCPU[cartaDaGiocare] = null; | ||
| 443 | frame.pannello.repaint(); | ||
| 444 | CPUHaGiocato = true; | ||
| 445 | if ( frame.giocata[0] == null ) | ||
| 446 | toccaAllaCPU = false; | ||
| 447 | } | ||
| 448 | public void chiPrende() { | ||
| 449 | char aux[], auxCPU[]; | ||
| 450 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 451 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 452 | giocatorePrende( ( (aux[aux.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) ) | ||
| 453 | || ( (aux[aux.length-5] == auxCPU[auxCPU.length-5]) && laPrimaEPiuAlta( aux[aux.length-7] - 48, auxCPU[auxCPU.length-7] - 48 ) ) | ||
| 454 | || ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (aux[aux.length-5] != auxCPU[auxCPU.length-5]) && haGiocatoPrima ) ); | ||
| 455 | } | ||
| 456 | public boolean laPrimaEPiuAlta( int prima, int seconda ) { | ||
| 457 | int a, b; | ||
| 458 | switch ( prima ) { | ||
| 459 | case 0: | ||
| 460 | a = 10; | ||
| 461 | break; | ||
| 462 | case 1: | ||
| 463 | a = 12; | ||
| 464 | break; | ||
| 465 | case 3: | ||
| 466 | a = 11; | ||
| 467 | break; | ||
| 468 | default: | ||
| 469 | a = prima; | ||
| 470 | break; | ||
| 471 | } | ||
| 472 | switch ( seconda ) { | ||
| 473 | case 0: | ||
| 474 | b = 10; | ||
| 475 | break; | ||
| 476 | case 1: | ||
| 477 | b = 12; | ||
| 478 | break; | ||
| 479 | case 3: | ||
| 480 | b = 11; | ||
| 481 | break; | ||
| 482 | default: | ||
| 483 | b = seconda; | ||
| 484 | break; | ||
| 485 | } | ||
| 486 | return a > b; | ||
| 487 | } | ||
| 488 | public void giocatorePrende( boolean giocatore ) { | ||
| 489 | if ( giocatore ) { | ||
| 490 | toccaAllaCPU = CPUHaGiocato = false; | ||
| 491 | haGiocatoPrima = true; | ||
| 492 | } | ||
| 493 | else { | ||
| 494 | toccaAllaCPU = true; | ||
| 495 | CPUHaGiocato = haGiocatoPrima = false; | ||
| 496 | } | ||
| 497 | daiPunti( giocatore ); | ||
| 498 | if ( toccaAllaCPU ) | ||
| 499 | giocaCPU(); | ||
| 500 | } | ||
| 501 | public void daiPunti( boolean giocatore ) { | ||
| 502 | char aux[], auxCPU[]; | ||
| 503 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 504 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 505 | int punti = 0; | ||
| 506 | switch( aux[aux.length-7] - 48 ) { | ||
| 507 | case 0: | ||
| 508 | punti += 4; | ||
| 509 | break; | ||
| 510 | case 1: | ||
| 511 | punti += 11; | ||
| 512 | break; | ||
| 513 | case 3: | ||
| 514 | punti += 10; | ||
| 515 | break; | ||
| 516 | case 8: | ||
| 517 | punti += 2; | ||
| 518 | break; | ||
| 519 | case 9: | ||
| 520 | punti += 3; | ||
| 521 | break; | ||
| 522 | default: | ||
| 523 | break; | ||
| 524 | } | ||
| 525 | switch( auxCPU[auxCPU.length-7] - 48 ) { | ||
| 526 | case 0: | ||
| 527 | punti += 4; | ||
| 528 | break; | ||
| 529 | case 1: | ||
| 530 | punti += 11; | ||
| 531 | break; | ||
| 532 | case 3: | ||
| 533 | punti += 10; | ||
| 534 | break; | ||
| 535 | case 8: | ||
| 536 | punti += 2; | ||
| 537 | break; | ||
| 538 | case 9: | ||
| 539 | punti += 3; | ||
| 540 | break; | ||
| 541 | default: | ||
| 542 | break; | ||
| 543 | } | ||
| 544 | frame.giocata[0] = frame.giocata[1] = null; | ||
| 545 | if ( giocatore ) { | ||
| 546 | punteggio += punti; | ||
| 547 | if ( mano < 18 ) { | ||
| 548 | if ( frame.carteInMano[0] == null ) | ||
| 549 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 550 | if ( frame.carteInMano[1] == null ) | ||
| 551 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 552 | if ( frame.carteInMano[2] == null ) | ||
| 553 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 554 | cartaDaPescare++; | ||
| 555 | if ( frame.carteCPU[0] == null ) | ||
| 556 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 557 | if ( frame.carteCPU[1] == null ) | ||
| 558 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 559 | if ( frame.carteCPU[2] == null ) | ||
| 560 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 561 | cartaDaPescare++; | ||
| 562 | } | ||
| 563 | } | ||
| 564 | else { | ||
| 565 | punteggioCPU += punti; | ||
| 566 | if ( mano < 18 ) { | ||
| 567 | if ( frame.carteCPU[0] == null ) | ||
| 568 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 569 | if ( frame.carteCPU[1] == null ) | ||
| 570 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 571 | if ( frame.carteCPU[2] == null ) | ||
| 572 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 573 | cartaDaPescare++; | ||
| 574 | if ( frame.carteInMano[0] == null ) | ||
| 575 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 576 | if ( frame.carteInMano[1] == null ) | ||
| 577 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 578 | if ( frame.carteInMano[2] == null ) | ||
| 579 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 580 | cartaDaPescare++; | ||
| 581 | } | ||
| 582 | } | ||
| 583 | frame.pannello.repaint(); | ||
| 584 | frame.repaint(); | ||
| 585 | } | ||
| 586 | public boolean haLisciato() { | ||
| 587 | char auxCPU[]; | ||
| 588 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 589 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 590 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 591 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ); | ||
| 592 | } | ||
| 593 | public boolean haMessoPunti() { | ||
| 594 | char auxCPU[]; | ||
| 595 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 596 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 597 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || | ||
| 598 | (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ); | ||
| 599 | } | ||
| 600 | public boolean haTagliato() { | ||
| 601 | char auxCPU[]; | ||
| 602 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 603 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 604 | (auxCPU[auxCPU.length-7] - 48 != 0) && (auxCPU[auxCPU.length-7] - 48 != 1) && | ||
| 605 | (auxCPU[auxCPU.length-7] - 48 != 3) && (auxCPU[auxCPU.length-7] - 48 <= 7) ); | ||
| 606 | } | ||
| 607 | public boolean haMessoBriscolaAlta() { | ||
| 608 | char auxCPU[]; | ||
| 609 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 610 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 611 | ( (auxCPU[auxCPU.length-7] - 48 == 0) || (auxCPU[auxCPU.length-7] - 48 == 8) || | ||
| 612 | (auxCPU[auxCPU.length-7] - 48 == 9) ) ); | ||
| 613 | } | ||
| 614 | public boolean haMessoTre() { | ||
| 615 | char auxCPU[]; | ||
| 616 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 617 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 618 | (auxCPU[auxCPU.length-7] - 48 == 3) ); | ||
| 619 | } | ||
| 620 | public boolean haMessoAsso() { | ||
| 621 | char auxCPU[]; | ||
| 622 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 623 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 624 | (auxCPU[auxCPU.length-7] - 48 == 1) ); | ||
| 625 | } | ||
| 626 | public boolean haCaricato() { | ||
| 627 | char auxCPU[]; | ||
| 628 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 629 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 630 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ); | ||
| 631 | } | ||
| 632 | public boolean vaiLiscio() { | ||
| 633 | char auxCPU[]; | ||
| 634 | for ( int i = 0; i < 3; i++ ) { | ||
| 635 | if ( frame.carteCPU[i] != null ) { | ||
| 636 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 637 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 638 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 639 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ) { | ||
| 640 | cartaDaGiocare = i; | ||
| 641 | return true; | ||
| 642 | } | ||
| 643 | } | ||
| 644 | } | ||
| 645 | return false; | ||
| 646 | } | ||
| 647 | public boolean vaiPunti() { | ||
| 648 | char[] auxCPU; | ||
| 649 | for ( int i = 0; i < 3; i++ ) { | ||
| 650 | if ( frame.carteCPU[i] != null ) { | ||
| 651 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 652 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 8 ) ) { | ||
| 653 | cartaDaGiocare = i; | ||
| 654 | return true; | ||
| 655 | } | ||
| 656 | } | ||
| 657 | } | ||
| 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 == 9 ) ) { | ||
| 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 == 0 ) ) { | ||
| 671 | cartaDaGiocare = i; | ||
| 672 | return true; | ||
| 673 | } | ||
| 674 | } | ||
| 675 | } | ||
| 676 | return false; | ||
| 677 | } | ||
| 678 | public boolean vaiTaglio() { | ||
| 679 | char auxCPU[]; | ||
| 680 | for ( int i = 0; i < 3; i++ ) { | ||
| 681 | if ( frame.carteCPU[i] != null ) { | ||
| 682 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 683 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && | ||
| 684 | (auxCPU[auxCPU.length-7] - 48 != 0) && (auxCPU[auxCPU.length-7] - 48 != 1) && | ||
| 685 | (auxCPU[auxCPU.length-7] - 48 != 3) && (auxCPU[auxCPU.length-7] - 48 <= 7) ) { | ||
| 686 | cartaDaGiocare = i; | ||
| 687 | return true; | ||
| 688 | } | ||
| 689 | } | ||
| 690 | } | ||
| 691 | return false; | ||
| 692 | } | ||
| 693 | public boolean vaiBriscolaAlta() { | ||
| 694 | char[] auxCPU; | ||
| 695 | for ( int i = 0; i < 3; i++ ) { | ||
| 696 | if ( frame.carteCPU[i] != null ) { | ||
| 697 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 698 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 8 ) ) { | ||
| 699 | cartaDaGiocare = i; | ||
| 700 | return true; | ||
| 701 | } | ||
| 702 | } | ||
| 703 | } | ||
| 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 == 9 ) ) { | ||
| 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 == 0 ) ) { | ||
| 717 | cartaDaGiocare = i; | ||
| 718 | return true; | ||
| 719 | } | ||
| 720 | } | ||
| 721 | } | ||
| 722 | return false; | ||
| 723 | } | ||
| 724 | public boolean vaiTre() { | ||
| 725 | char auxCPU[]; | ||
| 726 | for ( int i = 0; i < 3; i++ ) { | ||
| 727 | if ( frame.carteCPU[i] != null ) { | ||
| 728 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 729 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && (auxCPU[auxCPU.length-7] - 48 == 3) ) { | ||
| 730 | cartaDaGiocare = i; | ||
| 731 | return true; | ||
| 732 | } | ||
| 733 | } | ||
| 734 | } | ||
| 735 | return false; | ||
| 736 | } | ||
| 737 | public boolean vaiAsso() { | ||
| 738 | char auxCPU[]; | ||
| 739 | for ( int i = 0; i < 3; i++ ) { | ||
| 740 | if ( frame.carteCPU[i] != null ) { | ||
| 741 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 742 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && (auxCPU[auxCPU.length-7] - 48 == 1) ) { | ||
| 743 | cartaDaGiocare = i; | ||
| 744 | return true; | ||
| 745 | } | ||
| 746 | } | ||
| 747 | } | ||
| 748 | return false; | ||
| 749 | } | ||
| 750 | public boolean vaiCarico() { | ||
| 751 | char[] auxCPU; | ||
| 752 | for ( int i = 0; i < 3; i++ ) { | ||
| 753 | if ( frame.carteCPU[i] != null ) { | ||
| 754 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 755 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 3 ) ) { | ||
| 756 | cartaDaGiocare = i; | ||
| 757 | return true; | ||
| 758 | } | ||
| 759 | } | ||
| 760 | } | ||
| 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 == 1 ) ) { | ||
| 765 | cartaDaGiocare = i; | ||
| 766 | return true; | ||
| 767 | } | ||
| 768 | } | ||
| 769 | } | ||
| 770 | return false; | ||
| 771 | } | ||
| 772 | public boolean vaiSopra() { | ||
| 773 | if ( frame.giocata[0] == null ) | ||
| 774 | return false; | ||
| 775 | int a = -1; | ||
| 776 | int b = -1; | ||
| 777 | int c = -1; | ||
| 778 | boolean laPrimaPuoAndareSopra = false; | ||
| 779 | boolean laSecondaPuoAndareSopra = false; | ||
| 780 | boolean laTerzaPuoAndareSopra = false; | ||
| 781 | char[] auxCPU1 = new char[1024]; | ||
| 782 | char[] auxCPU2 = new char[1024]; | ||
| 783 | char[] auxCPU3 = new char[1024]; | ||
| 784 | char[] aux = frame.giocata[0].toString().toCharArray(); | ||
| 785 | if ( aux[aux.length-7] - 48 == 1 ) | ||
| 786 | return false; | ||
| 787 | if ( frame.carteCPU[0] != null ) { | ||
| 788 | auxCPU1 = frame.carteCPU[0].toString().toCharArray(); | ||
| 789 | a = auxCPU1[auxCPU1.length-7] - 48; | ||
| 790 | if ( (auxCPU1[auxCPU1.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( a, aux[aux.length-7] - 48 ) ) | ||
| 791 | laPrimaPuoAndareSopra = true; | ||
| 792 | } | ||
| 793 | if ( frame.carteCPU[1] != null ) { | ||
| 794 | auxCPU2 = frame.carteCPU[1].toString().toCharArray(); | ||
| 795 | b = auxCPU2[auxCPU2.length-7] - 48; | ||
| 796 | if ( (auxCPU2[auxCPU2.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( b, aux[aux.length-7] - 48 ) ) | ||
| 797 | laSecondaPuoAndareSopra = true; | ||
| 798 | } | ||
| 799 | if ( frame.carteCPU[2] != null ) { | ||
| 800 | auxCPU3 = frame.carteCPU[2].toString().toCharArray(); | ||
| 801 | c = auxCPU3[auxCPU3.length-7] - 48; | ||
| 802 | if ( (auxCPU3[auxCPU3.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( c, aux[aux.length-7] - 48 ) ) | ||
| 803 | laTerzaPuoAndareSopra = true; | ||
| 804 | } | ||
| 805 | if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 806 | return false; | ||
| 807 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 808 | cartaDaGiocare = 0; | ||
| 809 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 810 | cartaDaGiocare = 1; | ||
| 811 | else if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 812 | cartaDaGiocare = 2; | ||
| 813 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 814 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 815 | cartaDaGiocare = 0; | ||
| 816 | else | ||
| 817 | cartaDaGiocare = 1; | ||
| 818 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 819 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 820 | cartaDaGiocare = 1; | ||
| 821 | else | ||
| 822 | cartaDaGiocare = 2; | ||
| 823 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 824 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 825 | cartaDaGiocare = 0; | ||
| 826 | else | ||
| 827 | cartaDaGiocare = 2; | ||
| 828 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 829 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 830 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 831 | cartaDaGiocare = 0; | ||
| 832 | else | ||
| 833 | cartaDaGiocare = 2; | ||
| 834 | else | ||
| 835 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 836 | cartaDaGiocare = 1; | ||
| 837 | else | ||
| 838 | cartaDaGiocare = 2; | ||
| 839 | aux = frame.carteCPU[cartaDaGiocare].toString().toCharArray(); | ||
| 840 | if ( (aux[aux.length-7] - 48 != 0) && (aux[aux.length-7] - 48 != 1) && | ||
| 841 | (aux[aux.length-7] - 48 != 3) && (aux[aux.length-7] - 48 <= 7) ) | ||
| 842 | return false; | ||
| 843 | return true; | ||
| 844 | } | ||
| 845 | public boolean hoCarico() { | ||
| 846 | char auxCPU[]; | ||
| 847 | for ( int i = 0; i < 3; i++ ) { | ||
| 848 | if ( frame.carteCPU[i] != null ) { | ||
| 849 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 850 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 851 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ) { | ||
| 852 | return true; | ||
| 853 | } | ||
| 854 | } | ||
| 855 | } | ||
| 856 | return false; | ||
| 857 | } | ||
| 858 | public boolean hoAsso() { | ||
| 859 | char auxCPU[]; | ||
| 860 | for ( int i = 0; i < 3; i++ ) { | ||
| 861 | if ( frame.carteCPU[i] != null ) { | ||
| 862 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 863 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 1 ) ) { | ||
| 864 | return true; | ||
| 865 | } | ||
| 866 | } | ||
| 867 | } | ||
| 868 | return false; | ||
| 869 | } | ||
| 870 | public boolean hoTre() { | ||
| 871 | char auxCPU[]; | ||
| 872 | for ( int i = 0; i < 3; i++ ) { | ||
| 873 | if ( frame.carteCPU[i] != null ) { | ||
| 874 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 875 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 3 ) ) { | ||
| 876 | return true; | ||
| 877 | } | ||
| 878 | } | ||
| 879 | } | ||
| 880 | return false; | ||
| 881 | } | ||
| 882 | public boolean hoBriscolaAlta() { | ||
| 883 | char auxCPU[]; | ||
| 884 | for ( int i = 0; i < 3; i++ ) { | ||
| 885 | if ( frame.carteCPU[i] != null ) { | ||
| 886 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 887 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 888 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ) { | ||
| 889 | return true; | ||
| 890 | } | ||
| 891 | } | ||
| 892 | } | ||
| 893 | return false; | ||
| 894 | } | ||
| 895 | public boolean hoTaglio() { | ||
| 896 | char auxCPU[]; | ||
| 897 | for ( int i = 0; i < 3; i++ ) { | ||
| 898 | if ( frame.carteCPU[i] != null ) { | ||
| 899 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 900 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 901 | (auxCPU[auxCPU.length-7] - 48 < 8 ) && (auxCPU[auxCPU.length-7] - 48 != 3 ) | ||
| 902 | && (auxCPU[auxCPU.length-7] - 48 != 1 ) && (auxCPU[auxCPU.length-7] - 48 != 0 ) ) { | ||
| 903 | return true; | ||
| 904 | } | ||
| 905 | } | ||
| 906 | } | ||
| 907 | return false; | ||
| 908 | } | ||
| 909 | public static void settaOpzioni() { | ||
| 910 | lang = "it"; | ||
| 911 | soundString = "suono=si"; | ||
| 912 | int r = 0; | ||
| 913 | int g = 150; | ||
| 914 | int b = 0; | ||
| 915 | Scanner scanner = null; | ||
| 916 | File file = new File( "JBriscolaConfig.txt" ); | ||
| 917 | if ( file.exists() ) { | ||
| 918 | try { | ||
| 919 | scanner = new Scanner( file ); | ||
| 920 | } catch ( FileNotFoundException e ) { } | ||
| 921 | try { | ||
| 922 | lang = scanner.next(); | ||
| 923 | soundString = scanner.next(); | ||
| 924 | r = scanner.nextInt(); | ||
| 925 | g = scanner.nextInt(); | ||
| 926 | b = scanner.nextInt(); | ||
| 927 | } catch ( NoSuchElementException e ) { } | ||
| 928 | } | ||
| 929 | else { | ||
| 930 | lang = "it"; | ||
| 931 | soundString = "suono=si"; | ||
| 932 | r = 0; | ||
| 933 | g = 150; | ||
| 934 | b = 0; | ||
| 935 | } | ||
| 936 | if ( lang.equals( "it" ) ) { | ||
| 937 | stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 938 | stringaPrimaGioca = "Prima Gioca!"; | ||
| 939 | stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 940 | stringaVinto = "Hai Vinto!"; | ||
| 941 | stringaPerso = "Hai Perso"; | ||
| 942 | stringaPareggio = "Pareggio"; | ||
| 943 | stringaGiocatore = "Giocatore: "; | ||
| 944 | stringaComputer = "\nComputer: "; | ||
| 945 | stringaNuovaPartita = "Nuova Partita"; | ||
| 946 | stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 947 | stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 948 | stringaSi = "Si"; | ||
| 949 | stringaNo = "No"; | ||
| 950 | stringaOpzioni = "Opzioni..."; | ||
| 951 | stringaEsci = "Esci"; | ||
| 952 | stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 953 | stringaLingua = "Lingua"; | ||
| 954 | stringaAnnulla = "Annulla"; | ||
| 955 | stringaIt = "Italiano"; | ||
| 956 | stringaLa = "Latino"; | ||
| 957 | stringaBL = "Dialetto Bellunese"; | ||
| 958 | stringaBV = "Dialetto Basso Veneto"; | ||
| 959 | stringaNecessarioRiavviare = "E' necessario riavviare JBriscola se sono state\nmodificate impostazioni riguardanti la lingua\nAlcune parti saranno comunque tradotte prima."; | ||
| 960 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 961 | stringaInformazioni = "Informazioni"; | ||
| 962 | 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"; | ||
| 963 | stringaSuono = "Effetti sonori"; | ||
| 964 | stringaPunteggio = "Punteggio"; | ||
| 965 | stringaSfondo = "Sfondo"; | ||
| 966 | } | ||
| 967 | else if ( lang.equals( "la" ) ) { | ||
| 968 | stringaBottonePrendi = "CAPIS/RELINQVIS CHARTAS"; | ||
| 969 | stringaPrimaGioca = "ANTE CHARTAM PONE!"; | ||
| 970 | stringaUltime4 = "CHARTA POSTREMA - INTVERE BRISCOLAM!"; | ||
| 971 | stringaVinto = "VICISTI!"; | ||
| 972 | stringaPerso = "PERDIDISTI"; | ||
| 973 | stringaPareggio = "AEQVATIO!"; | ||
| 974 | stringaGiocatore = "LVSOR: "; | ||
| 975 | stringaComputer = "\nCOMPVTER: "; | ||
| 976 | stringaNuovaPartita = "NOVA LVSO"; | ||
| 977 | stringaVuoiDavveroIniziare = "NOVAM LVSIONEM INCIPERE?"; | ||
| 978 | stringaVuoiDavveroUscire = "EXIRE?"; | ||
| 979 | stringaSi = "ID VOLO"; | ||
| 980 | stringaNo = "NOLO"; | ||
| 981 | stringaOpzioni = "OPTIONES..."; | ||
| 982 | stringaEsci = "EXIRE"; | ||
| 983 | stringaImpossibileConfigurare = "CONFIGVRATIONIS FILE SCRIBERE NON POTVI.\nERROREM ME CERTIOREM FACITE: sebastiano@luganega.org\n\nEXCEPTIO:\n"; | ||
| 984 | stringaLingua = "LINGVA"; | ||
| 985 | stringaAnnulla = "ABROGA"; | ||
| 986 | stringaIt = "ITALICA"; | ||
| 987 | stringaLa = "LATINA"; | ||
| 988 | stringaBL = "BELLUNI"; | ||
| 989 | stringaBV = "VENETIAE"; | ||
| 990 | stringaNecessarioRiavviare = "JBRISCOLAM RVRSVS INCIPERE NECESSE EST\nSI LINGVA PRAELATIONES NOVATAE SVNT.\nALIQVAE ANTE ID VERSA ERVNT"; | ||
| 991 | stringaModificaOpzioni = "OPTIONES NOVARE"; | ||
| 992 | stringaInformazioni = "INFORMATIONES"; | ||
| 993 | 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"; | ||
| 994 | stringaSuono = "SONUS"; | ||
| 995 | stringaPunteggio = "NUMERI"; | ||
| 996 | stringaSfondo = "COLOR"; | ||
| 997 | } | ||
| 998 | if ( lang.equals( "bl" ) ) { | ||
| 999 | stringaBottonePrendi = "Cio' su/lasa le carte"; | ||
| 1000 | stringaPrimaGioca = "Prima Duga!"; | ||
| 1001 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1002 | stringaVinto = "Te ha vint!"; | ||
| 1003 | stringaPerso = "Te ha pers"; | ||
| 1004 | stringaPareggio = "Pari"; | ||
| 1005 | stringaGiocatore = "Dugador: "; | ||
| 1006 | stringaComputer = "\nComputer: "; | ||
| 1007 | stringaNuovaPartita = "Taca n'altra partida"; | ||
| 1008 | stringaVuoiDavveroIniziare = "Utu sul serio scuminziar n'altra partida?"; | ||
| 1009 | stringaVuoiDavveroUscire = "Utu sul serio stusar su?"; | ||
| 1010 | stringaSi = "Si"; | ||
| 1011 | stringaNo = "No"; | ||
| 1012 | stringaOpzioni = "Opzioni..."; | ||
| 1013 | stringaEsci = "Stusa su"; | ||
| 1014 | stringaImpossibileConfigurare = "No ghe ho riva' a scrivere al file de configurazion.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1015 | stringaLingua = "Lengua"; | ||
| 1016 | stringaAnnulla = "Annulla"; | ||
| 1017 | stringaIt = "Italian"; | ||
| 1018 | stringaLa = "Latin"; | ||
| 1019 | stringaBL = "Dialeto de Belun"; | ||
| 1020 | stringaBV = "Dialeto de la basa"; | ||
| 1021 | stringaNecessarioRiavviare = "Se te ha cambia' la lengua te toca\nstusar su e impizar de novo al dugo\nPero' zerte robe le e' belche tradote."; | ||
| 1022 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1023 | stringaInformazioni = "Informazioni"; | ||
| 1024 | 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"; | ||
| 1025 | stringaSuono = "Efeti sonori"; | ||
| 1026 | stringaPunteggio = "Varda i punti"; | ||
| 1027 | stringaSfondo = "Sfondo"; | ||
| 1028 | } | ||
| 1029 | if ( lang.equals( "bv" ) ) { | ||
| 1030 | stringaBottonePrendi = "Ciapa su/lasa e carte"; | ||
| 1031 | stringaPrimaGioca = "Prima Zuga!"; | ||
| 1032 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1033 | stringaVinto = "Ti ga vinto!"; | ||
| 1034 | stringaPerso = "Ti ga perso"; | ||
| 1035 | stringaPareggio = "Pari"; | ||
| 1036 | stringaGiocatore = "Zugador: "; | ||
| 1037 | stringaComputer = "\nComputer: "; | ||
| 1038 | stringaNuovaPartita = "N'altra Partida"; | ||
| 1039 | stringaVuoiDavveroIniziare = "Ti vol sul serio scuminziar n'altra partida?"; | ||
| 1040 | stringaVuoiDavveroUscire = "Ti vol sul serio stusar su?"; | ||
| 1041 | stringaSi = "Si"; | ||
| 1042 | stringaNo = "No"; | ||
| 1043 | stringaOpzioni = "Opzioni..."; | ||
| 1044 | stringaEsci = "Stusa su"; | ||
| 1045 | stringaImpossibileConfigurare = "No ghe son riusito a scrivere al file de configurazione.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1046 | stringaLingua = "Lengua"; | ||
| 1047 | stringaAnnulla = "Annulla"; | ||
| 1048 | stringaIt = "Italian"; | ||
| 1049 | stringaLa = "Latin"; | ||
| 1050 | stringaBL = "Dialeto Belumat"; | ||
| 1051 | stringaBV = "Dialeto Veneto"; | ||
| 1052 | stringaNecessarioRiavviare = "Se ti ga cambia' la lengua te toca\nstusar su e impizar de novo al zugo\nPero' zerte robe le e' belche tradote."; | ||
| 1053 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1054 | stringaInformazioni = "Informasioni"; | ||
| 1055 | 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"; | ||
| 1056 | stringaSuono = "Efeti sonori"; | ||
| 1057 | stringaPunteggio = "Varda i punti"; | ||
| 1058 | stringaSfondo = "Sfondo"; | ||
| 1059 | } | ||
| 1060 | sound = ( soundString.equals( "suono=si" ) ); | ||
| 1061 | color = new Color( r, g, b ); | ||
| 1062 | if ( frame != null ) { | ||
| 1063 | frame.pannello.repaint(); | ||
| 1064 | frame.pannello2.repaint(); | ||
| 1065 | frame.repaint(); | ||
| 1066 | } | ||
| 1067 | } | ||
| 1068 | } | ||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/OptionFrame.java b/JBriscola/all_versions/0.2/0.2 Beta 1/src/OptionFrame.java new file mode 100755 index 0000000..a93899f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/OptionFrame.java | |||
| @@ -0,0 +1,129 @@ | |||
| 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.util.Formatter; | ||
| 23 | import javax.swing.*; | ||
| 24 | import java.awt.*; | ||
| 25 | import java.awt.event.*; | ||
| 26 | |||
| 27 | public class OptionFrame extends JFrame { | ||
| 28 | public static Main main = new Main(); | ||
| 29 | public static Formatter formatter; | ||
| 30 | public static JButton ok, annulla, scegliColore; | ||
| 31 | public static JLabel lingua, sfondo; | ||
| 32 | public static JComboBox selezionaLingua; | ||
| 33 | public static JCheckBox suono; | ||
| 34 | public static JPanel[] pannello = new JPanel[5]; | ||
| 35 | public OptionFrame() { | ||
| 36 | super( "JBriscola - " + main.stringaModificaOpzioni ); | ||
| 37 | ok = new JButton( "OK" ); | ||
| 38 | ok.addActionListener( new ActionListener() { | ||
| 39 | public void actionPerformed( ActionEvent e ) { | ||
| 40 | try { | ||
| 41 | formatter = new Formatter( "JBriscolaConfig.txt" ); | ||
| 42 | } catch ( Exception ex ) { | ||
| 43 | JOptionPane.showMessageDialog( OptionFrame.this, main.stringaImpossibileConfigurare + ex ); | ||
| 44 | } | ||
| 45 | String lang; | ||
| 46 | switch ( selezionaLingua.getSelectedIndex() ) { | ||
| 47 | case 0: | ||
| 48 | lang = "it"; | ||
| 49 | break; | ||
| 50 | case 1: | ||
| 51 | lang = "la"; | ||
| 52 | break; | ||
| 53 | case 2: | ||
| 54 | lang = "bl"; | ||
| 55 | break; | ||
| 56 | case 3: | ||
| 57 | lang = "bv"; | ||
| 58 | break; | ||
| 59 | default: | ||
| 60 | lang = "it"; | ||
| 61 | break; | ||
| 62 | } | ||
| 63 | String suonosiono; | ||
| 64 | if ( suono.isSelected() ) | ||
| 65 | suonosiono = "suono=si"; | ||
| 66 | else | ||
| 67 | suonosiono = "suono=no"; | ||
| 68 | formatter.format( lang ); | ||
| 69 | formatter.format( "\n" ); | ||
| 70 | formatter.format( suonosiono ); | ||
| 71 | formatter.format( "\n" ); | ||
| 72 | formatter.format( main.color.getRed() + " " + main.color.getGreen() + " " + main.color.getBlue() ); | ||
| 73 | formatter.close(); | ||
| 74 | main.settaOpzioni(); | ||
| 75 | OptionFrame.this.dispose(); | ||
| 76 | //JOptionPane.showMessageDialog( OptionFrame.this, main.stringaNecessarioRiavviare, "JBriscola 0.1", JOptionPane.INFORMATION_MESSAGE ); | ||
| 77 | } | ||
| 78 | }); | ||
| 79 | annulla = new JButton( main.stringaAnnulla ); | ||
| 80 | annulla.addActionListener( new ActionListener() { | ||
| 81 | public void actionPerformed( ActionEvent e ) { | ||
| 82 | OptionFrame.this.dispose(); | ||
| 83 | } | ||
| 84 | }); | ||
| 85 | scegliColore = new JButton( " " ); | ||
| 86 | scegliColore.setBackground( main.color ); | ||
| 87 | scegliColore.addActionListener( new ActionListener() { | ||
| 88 | public void actionPerformed( ActionEvent e ) { | ||
| 89 | Color colore = JColorChooser.showDialog( OptionFrame.this, "JBriscola " + main.version, main.color ); | ||
| 90 | if ( colore != null ) | ||
| 91 | main.color = colore; | ||
| 92 | OptionFrame.scegliColore.setBackground( main.color ); | ||
| 93 | } | ||
| 94 | } ); | ||
| 95 | lingua = new JLabel( main.stringaLingua ); | ||
| 96 | sfondo = new JLabel( main.stringaSfondo ); | ||
| 97 | String[] lingueDaSelezionare = { main.stringaIt, main.stringaLa, main.stringaBL, main.stringaBV }; | ||
| 98 | selezionaLingua = new JComboBox( lingueDaSelezionare ); | ||
| 99 | int linguaPreselezionata = 0; | ||
| 100 | if ( main.lang.equals( "it" ) ) | ||
| 101 | linguaPreselezionata = 0; | ||
| 102 | else if ( main.lang.equals( "la" ) ) | ||
| 103 | linguaPreselezionata = 1; | ||
| 104 | else if ( main.lang.equals( "bl" ) ) | ||
| 105 | linguaPreselezionata = 2; | ||
| 106 | else if ( main.lang.equals( "bv" ) ) | ||
| 107 | linguaPreselezionata = 3; | ||
| 108 | selezionaLingua.setSelectedIndex( linguaPreselezionata ); | ||
| 109 | suono = new JCheckBox( main.stringaSuono ); | ||
| 110 | suono.setSelected( main.sound ); | ||
| 111 | pannello[0] = new JPanel( new GridLayout( 3, 1 ) ); | ||
| 112 | pannello[1] = new JPanel( new FlowLayout() ); | ||
| 113 | pannello[2] = new JPanel( new FlowLayout() ); | ||
| 114 | pannello[3] = new JPanel( new FlowLayout() ); | ||
| 115 | pannello[4] = new JPanel( new FlowLayout() ); | ||
| 116 | pannello[4].add( ok ); | ||
| 117 | pannello[4].add( annulla ); | ||
| 118 | pannello[3].add( sfondo ); | ||
| 119 | pannello[3].add( scegliColore ); | ||
| 120 | pannello[2].add( suono ); | ||
| 121 | pannello[1].add( lingua ); | ||
| 122 | pannello[1].add( selezionaLingua ); | ||
| 123 | pannello[0].add( pannello[1] ); | ||
| 124 | pannello[0].add( pannello[2] ); | ||
| 125 | pannello[0].add( pannello[3] ); | ||
| 126 | add( pannello[0], BorderLayout.CENTER ); | ||
| 127 | add( pannello[4], BorderLayout.SOUTH ); | ||
| 128 | } | ||
| 129 | } | ||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/Pannello.java b/JBriscola/all_versions/0.2/0.2 Beta 1/src/Pannello.java new file mode 100755 index 0000000..24c6596 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/Pannello.java | |||
| @@ -0,0 +1,54 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | |||
| 25 | public class Pannello extends JPanel { | ||
| 26 | public static Main main; | ||
| 27 | public static Color color; | ||
| 28 | public Pannello() { } | ||
| 29 | public void paint( Graphics g ) { | ||
| 30 | super.paint( g ); | ||
| 31 | setBackground( main.color ); | ||
| 32 | if ( main.frame.ultimaCarta != null ) | ||
| 33 | main.frame.ultimaCarta.paintIcon( this, g, 50, 180 ); | ||
| 34 | if ( main.frame.mazzo ) | ||
| 35 | main.frame.retro2.paintIcon( this, g, 17, 256 ); | ||
| 36 | if ( main.frame.carteCPU[0] != null ) | ||
| 37 | main.frame.retro1.paintIcon( this, g, 230, 5 ); | ||
| 38 | if ( main.frame.carteCPU[1] != null ) | ||
| 39 | main.frame.retro1.paintIcon( this, g, 300, 5 ); | ||
| 40 | if ( main.frame.carteCPU[2] != null ) | ||
| 41 | main.frame.retro1.paintIcon( this, g, 370, 5 ); | ||
| 42 | if ( main.frame.carteInMano[0] != null ) | ||
| 43 | main.frame.carteInMano[0].paintIcon( this, g, 230, 340 ); | ||
| 44 | if ( main.frame.carteInMano[1] != null ) | ||
| 45 | main.frame.carteInMano[1].paintIcon( this, g, 300, 340 ); | ||
| 46 | if ( main.frame.carteInMano[2] != null ) | ||
| 47 | main.frame.carteInMano[2].paintIcon( this, g, 370, 340 ); | ||
| 48 | if ( main.frame.giocata[0] != null ) | ||
| 49 | main.frame.giocata[0].paintIcon( this, g, 250, 200 ); | ||
| 50 | if ( main.frame.giocata[1] != null ) | ||
| 51 | main.frame.giocata[1].paintIcon( this, g, 325, 150 ); | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/1-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/1-1.jpg new file mode 100755 index 0000000..ae43510 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/1-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/1-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/1-2.jpg new file mode 100755 index 0000000..3f7c75a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/1-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/1-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/1-3.jpg new file mode 100755 index 0000000..9e1ead7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/1-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/1-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/1-4.jpg new file mode 100755 index 0000000..710f879 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/1-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/10-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/10-1.jpg new file mode 100755 index 0000000..9aba45a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/10-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/10-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/10-2.jpg new file mode 100755 index 0000000..037eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/10-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/10-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/10-3.jpg new file mode 100755 index 0000000..8780b72 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/10-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/10-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/10-4.jpg new file mode 100755 index 0000000..587dc0f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/10-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/2-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/2-1.jpg new file mode 100755 index 0000000..5dcb7db --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/2-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/2-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/2-2.jpg new file mode 100755 index 0000000..ea9eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/2-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/2-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/2-3.jpg new file mode 100755 index 0000000..8cb22dd --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/2-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/2-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/2-4.jpg new file mode 100755 index 0000000..b3e7898 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/2-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/3-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/3-1.jpg new file mode 100755 index 0000000..dcb435c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/3-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/3-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/3-2.jpg new file mode 100755 index 0000000..1e5b6ec --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/3-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/3-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/3-3.jpg new file mode 100755 index 0000000..9202cfe --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/3-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/3-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/3-4.jpg new file mode 100755 index 0000000..5436a8d --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/3-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/4-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/4-1.jpg new file mode 100755 index 0000000..3bab6d5 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/4-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/4-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/4-2.jpg new file mode 100755 index 0000000..b4901a6 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/4-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/4-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/4-3.jpg new file mode 100755 index 0000000..d754ad8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/4-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/4-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/4-4.jpg new file mode 100755 index 0000000..3a54b96 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/4-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/5-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/5-1.jpg new file mode 100755 index 0000000..3f7ba1f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/5-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/5-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/5-2.jpg new file mode 100755 index 0000000..fcacb75 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/5-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/5-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/5-3.jpg new file mode 100755 index 0000000..ce32f9f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/5-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/5-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/5-4.jpg new file mode 100755 index 0000000..b86b09a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/5-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/6-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/6-1.jpg new file mode 100755 index 0000000..f90cd81 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/6-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/6-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/6-2.jpg new file mode 100755 index 0000000..cf2a67a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/6-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/6-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/6-3.jpg new file mode 100755 index 0000000..2cd2fe2 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/6-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/6-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/6-4.jpg new file mode 100755 index 0000000..73f410f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/6-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/7-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/7-1.jpg new file mode 100755 index 0000000..08cd397 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/7-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/7-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/7-2.jpg new file mode 100755 index 0000000..a168ff8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/7-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/7-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/7-3.jpg new file mode 100755 index 0000000..5cda411 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/7-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/7-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/7-4.jpg new file mode 100755 index 0000000..5d63229 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/7-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/8-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/8-1.jpg new file mode 100755 index 0000000..a6faa7b --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/8-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/8-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/8-2.jpg new file mode 100755 index 0000000..0d9edbb --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/8-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/8-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/8-3.jpg new file mode 100755 index 0000000..91f8354 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/8-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/8-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/8-4.jpg new file mode 100755 index 0000000..cc0089c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/8-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/9-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/9-1.jpg new file mode 100755 index 0000000..be9c6bf --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/9-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/9-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/9-2.jpg new file mode 100755 index 0000000..e25da4c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/9-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/9-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/9-3.jpg new file mode 100755 index 0000000..cd384f8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/9-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/9-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/9-4.jpg new file mode 100755 index 0000000..441210e --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/9-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/carte.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/carte.jpg new file mode 100755 index 0000000..838ffac --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/carte.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/retro1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/retro1.jpg new file mode 100755 index 0000000..9651b06 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/retro1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/retro2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/retro2.jpg new file mode 100755 index 0000000..c5d3925 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/img/retro2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/0.wav b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/0.wav new file mode 100755 index 0000000..67d9abd --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/0.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/1.wav b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/1.wav new file mode 100755 index 0000000..9357c97 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/1.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/2.wav b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/2.wav new file mode 100755 index 0000000..92b1541 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/2.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/3.wav b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/3.wav new file mode 100755 index 0000000..45a6e42 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/3.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/4.wav b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/4.wav new file mode 100755 index 0000000..1f7ec90 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/4.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/5.wav b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/5.wav new file mode 100755 index 0000000..3627f96 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/5.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/pareggio.wav b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/pareggio.wav new file mode 100755 index 0000000..ff978e6 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/pareggio.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/perso.wav b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/perso.wav new file mode 100755 index 0000000..a454ba4 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/perso.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/vinto.wav b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/vinto.wav new file mode 100755 index 0000000..a6f3ac5 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 1/src/sounds/vinto.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/Frame.java b/JBriscola/all_versions/0.2/0.2 Beta 2/src/Frame.java new file mode 100755 index 0000000..c7b6c36 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/Frame.java | |||
| @@ -0,0 +1,243 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import javax.sound.sampled.*; | ||
| 24 | import java.io.*; | ||
| 25 | import java.awt.*; | ||
| 26 | import java.awt.event.*; | ||
| 27 | |||
| 28 | public class Frame extends JFrame { | ||
| 29 | public static boolean mazzo; | ||
| 30 | public static Main main; | ||
| 31 | public static Pannello pannello; | ||
| 32 | public static JPanel pannello2; | ||
| 33 | public static JButton button; | ||
| 34 | public static JMenuBar barraMenu; | ||
| 35 | public static JMenu file, puntoInterrogativo; | ||
| 36 | public static JMenuItem nuovaPartita, opzioni, esci, informazioni, punti; | ||
| 37 | public static ImageIcon retro1, retro2, ultimaCarta; | ||
| 38 | public static ImageIcon[] giocata = new ImageIcon[2]; | ||
| 39 | public static ImageIcon[] carteInMano = new ImageIcon[3]; | ||
| 40 | public static ImageIcon[] carteCPU = new ImageIcon[3]; | ||
| 41 | public static ImageIcon[] arrayCarteMescolate = new ImageIcon[40]; | ||
| 42 | public static ImageIcon[][] arrayCarte = new ImageIcon[10][4]; | ||
| 43 | public Frame() { | ||
| 44 | super( "Tronto's JBriscola " + main.version ); | ||
| 45 | mazzo = true; | ||
| 46 | main = new Main(); | ||
| 47 | pannello = new Pannello(); | ||
| 48 | pannello2 = new JPanel( new FlowLayout() ); | ||
| 49 | button = new JButton( main.stringaBottonePrendi ); | ||
| 50 | button.addActionListener( new ActionListener() { | ||
| 51 | public void actionPerformed( ActionEvent e ) { | ||
| 52 | if ( giocata[0] != null && giocata[1] != null ) | ||
| 53 | main.mano++; | ||
| 54 | try { | ||
| 55 | main.chiPrende(); | ||
| 56 | } catch ( Exception ex ) { | ||
| 57 | JOptionPane.showMessageDialog( Frame.this, main.stringaPrimaGioca, "JBriscola " + main.version, JOptionPane.WARNING_MESSAGE ); | ||
| 58 | } | ||
| 59 | if ( main.mano == 16 ) | ||
| 60 | JOptionPane.showMessageDialog( Frame.this, main.stringaUltime4, "JBriscola " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 61 | if ( main.mano == 17 ) { | ||
| 62 | mazzo = false; | ||
| 63 | ultimaCarta = null; | ||
| 64 | pannello.repaint(); | ||
| 65 | Frame.this.repaint(); | ||
| 66 | } | ||
| 67 | if ( main.mano == 20 ) { | ||
| 68 | String titolo = ""; | ||
| 69 | String suonoFinale = ""; | ||
| 70 | if ( main.punteggio > main.punteggioCPU ) { | ||
| 71 | titolo = main.stringaVinto; | ||
| 72 | suonoFinale = "sounds/perso.wav"; | ||
| 73 | } | ||
| 74 | if ( main.punteggio < main.punteggioCPU ) { | ||
| 75 | titolo = main.stringaPerso; | ||
| 76 | suonoFinale = "sounds/vinto.wav"; | ||
| 77 | } | ||
| 78 | if ( main.punteggio == main.punteggioCPU ) { | ||
| 79 | titolo = main.stringaPareggio; | ||
| 80 | suonoFinale = "sounds/pareggio.wav"; | ||
| 81 | } | ||
| 82 | if ( main.sound ) { | ||
| 83 | try { | ||
| 84 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( ClassLoader.getSystemResource( suonoFinale ) ); | ||
| 85 | AudioInputStream ais = AudioSystem.getAudioInputStream( ClassLoader.getSystemResource( suonoFinale ) ); | ||
| 86 | AudioFormat af = aff.getFormat(); | ||
| 87 | DataLine.Info info = new DataLine.Info( | ||
| 88 | Clip.class, | ||
| 89 | ais.getFormat(), | ||
| 90 | ( (int) ais.getFrameLength() * | ||
| 91 | af.getFrameSize() ) ); | ||
| 92 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 93 | ol.open(ais); | ||
| 94 | ol.loop( 0 ); | ||
| 95 | } catch ( Exception ex ) { | ||
| 96 | System.err.println( e ); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, titolo, JOptionPane.PLAIN_MESSAGE ); | ||
| 100 | } | ||
| 101 | } | ||
| 102 | } ); | ||
| 103 | barraMenu = new JMenuBar(); | ||
| 104 | file = new JMenu( "File" ); | ||
| 105 | nuovaPartita = new JMenuItem( main.stringaNuovaPartita ); | ||
| 106 | nuovaPartita.addActionListener( new ActionListener() { | ||
| 107 | public void actionPerformed( ActionEvent e ) { | ||
| 108 | if ( main.mano == 20 ) { | ||
| 109 | main.mischia(); | ||
| 110 | pannello.repaint(); | ||
| 111 | repaint(); | ||
| 112 | } | ||
| 113 | else { | ||
| 114 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 115 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 116 | main.mischia(); | ||
| 117 | pannello.repaint(); | ||
| 118 | repaint(); | ||
| 119 | } | ||
| 120 | } | ||
| 121 | } | ||
| 122 | }); | ||
| 123 | opzioni = new JMenuItem( main.stringaOpzioni ); | ||
| 124 | opzioni.addActionListener( new ActionListener() { | ||
| 125 | public void actionPerformed( ActionEvent e ) { | ||
| 126 | OptionFrame optionFrame = new OptionFrame(); | ||
| 127 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 128 | optionFrame.setResizable( false ); | ||
| 129 | optionFrame.setAlwaysOnTop( true ); | ||
| 130 | optionFrame.setSize( 300, 150 ); | ||
| 131 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, | ||
| 132 | (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 133 | optionFrame.setVisible( true ); | ||
| 134 | } | ||
| 135 | }); | ||
| 136 | esci = new JMenuItem( main.stringaEsci ); | ||
| 137 | esci.addActionListener( new ActionListener() { | ||
| 138 | public void actionPerformed( ActionEvent e ) { | ||
| 139 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 140 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 141 | Frame.this.dispose(); | ||
| 142 | } | ||
| 143 | }); | ||
| 144 | file.add( nuovaPartita ); | ||
| 145 | file.add( opzioni ); | ||
| 146 | file.addSeparator(); | ||
| 147 | file.add( esci ); | ||
| 148 | puntoInterrogativo = new JMenu( "?" ); | ||
| 149 | informazioni = new JMenuItem( main.stringaInformazioni ); | ||
| 150 | informazioni.addActionListener( new ActionListener() { | ||
| 151 | public void actionPerformed( ActionEvent e ) { | ||
| 152 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 153 | } | ||
| 154 | } ); | ||
| 155 | punti = new JMenuItem( main.stringaPunteggio ); | ||
| 156 | punti.addActionListener( new ActionListener() { | ||
| 157 | public void actionPerformed( ActionEvent e ) { | ||
| 158 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + "\n" + main.stringaComputer + main.punteggioCPU, main.stringaPunteggio, JOptionPane.PLAIN_MESSAGE ); | ||
| 159 | } | ||
| 160 | } ); | ||
| 161 | puntoInterrogativo.add( punti ); | ||
| 162 | puntoInterrogativo.add( informazioni ); | ||
| 163 | barraMenu.add( file ); | ||
| 164 | barraMenu.add( puntoInterrogativo ); | ||
| 165 | setJMenuBar( barraMenu ); | ||
| 166 | retro1 = new ImageIcon( ClassLoader.getSystemResource( "img/retro1.jpg" ) ); | ||
| 167 | retro2 = new ImageIcon( ClassLoader.getSystemResource( "img/retro2.jpg" ) ); | ||
| 168 | for (int i = 0; i < 10; i++) | ||
| 169 | for (int j = 0; j < 4; j++) | ||
| 170 | arrayCarte[i][j] = new ImageIcon( ClassLoader.getSystemResource( "img/" + (i+1) + "-" + (j+1) + ".jpg" ) ); | ||
| 171 | main.mischia(); | ||
| 172 | pannello2.add( button ); | ||
| 173 | setLayout( new BorderLayout() ); | ||
| 174 | add( pannello, BorderLayout.CENTER ); | ||
| 175 | add( pannello2, BorderLayout.SOUTH ); | ||
| 176 | addMouseListener( | ||
| 177 | new MouseAdapter() { | ||
| 178 | public void mouseClicked ( MouseEvent e ) { | ||
| 179 | if ( mettiCarta( e.getX(), e.getY() ) ) { | ||
| 180 | if ( !main.CPUHaGiocato ) | ||
| 181 | main.giocaCPU(); | ||
| 182 | } | ||
| 183 | } | ||
| 184 | } | ||
| 185 | ); | ||
| 186 | addWindowListener( | ||
| 187 | new WindowAdapter() { | ||
| 188 | public void windowClosing( WindowEvent e ) { | ||
| 189 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 190 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 191 | System.exit( 0 ); | ||
| 192 | } | ||
| 193 | } | ||
| 194 | ); | ||
| 195 | } | ||
| 196 | public boolean mettiCarta( int x, int y ) { | ||
| 197 | if ( !main.toccaAllaCPU && giocata[0] == null ) { | ||
| 198 | if ( main.sound && | ||
| 199 | ( ( x > 230 && x < 290 && y > 340 && y < 566 ) || | ||
| 200 | ( x > 300 && x < 360 && y > 340 && y < 566 ) || | ||
| 201 | ( x > 370 && x < 430 && y > 340 && y < 566 ) ) ) { | ||
| 202 | try { | ||
| 203 | double a = Math.random() * 6; | ||
| 204 | int i = (int) a; | ||
| 205 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( ClassLoader.getSystemResource("sounds/" + i + ".wav") ); | ||
| 206 | AudioInputStream ais = AudioSystem.getAudioInputStream( ClassLoader.getSystemResource("sounds/" + i + ".wav") ); | ||
| 207 | AudioFormat af = aff.getFormat(); | ||
| 208 | DataLine.Info info = new DataLine.Info( | ||
| 209 | Clip.class, | ||
| 210 | ais.getFormat(), | ||
| 211 | ( (int) ais.getFrameLength() * | ||
| 212 | af.getFrameSize() ) ); | ||
| 213 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 214 | ol.open(ais); | ||
| 215 | ol.loop( 0 ); | ||
| 216 | } catch ( Exception e ) { | ||
| 217 | System.err.println( e ); | ||
| 218 | } | ||
| 219 | } | ||
| 220 | if ( x > 230 && x < 290 && y > 340 && y < 566 ) { | ||
| 221 | giocata[0] = carteInMano[0]; | ||
| 222 | carteInMano[0] = null; | ||
| 223 | pannello.repaint(); | ||
| 224 | return true; | ||
| 225 | } | ||
| 226 | if ( x > 300 && x < 360 && y > 340 && y < 566 ) { | ||
| 227 | giocata[0] = carteInMano[1]; | ||
| 228 | carteInMano[1] = null; | ||
| 229 | pannello.repaint(); | ||
| 230 | return true; | ||
| 231 | } | ||
| 232 | if ( x > 370 && x < 430 && y > 340 && y < 566 ) { | ||
| 233 | giocata[0] = carteInMano[2]; | ||
| 234 | carteInMano[2] = null; | ||
| 235 | pannello.repaint(); | ||
| 236 | return true; | ||
| 237 | } | ||
| 238 | } | ||
| 239 | return false; | ||
| 240 | } | ||
| 241 | } | ||
| 242 | |||
| 243 | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/Main.java b/JBriscola/all_versions/0.2/0.2 Beta 2/src/Main.java new file mode 100755 index 0000000..344fa20 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/Main.java | |||
| @@ -0,0 +1,1069 @@ | |||
| 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 Frame frame; | ||
| 34 | public static Color color = new Color( 0, 150, 0 ); | ||
| 35 | public static String version = "0.2 Beta 2"; | ||
| 36 | public static String stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 37 | public static String stringaPrimaGioca = "Prima Gioca!"; | ||
| 38 | public static String stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 39 | public static String stringaVinto = "Hai Vinto!"; | ||
| 40 | public static String stringaPerso = "Hai Perso"; | ||
| 41 | public static String stringaPareggio = "Pareggio"; | ||
| 42 | public static String stringaGiocatore = "Giocatore: "; | ||
| 43 | public static String stringaComputer = "\nComputer: "; | ||
| 44 | public static String stringaNuovaPartita = "Nuova Partita"; | ||
| 45 | public static String stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 46 | public static String stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 47 | public static String stringaSi = "Si"; | ||
| 48 | public static String stringaNo = "No"; | ||
| 49 | public static String stringaOpzioni = "Opzioni..."; | ||
| 50 | public static String stringaEsci = "Esci"; | ||
| 51 | public static String stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 52 | public static String stringaLingua = "Lingua"; | ||
| 53 | public static String stringaAnnulla = "Annulla"; | ||
| 54 | public static String stringaIt = "Italiano"; | ||
| 55 | public static String stringaLa = "Latino"; | ||
| 56 | public static String stringaBL = "Dialetto Bellunese"; | ||
| 57 | public static String stringaBV = "Dialetto Basso Veneto"; | ||
| 58 | public static String stringaNecessarioRiavviare = "E' necessario riavviare JBriscola se sono state\nmodificate impostazioni riguardanti la lingua.\nAlcune parti saranno comunque tradotte prima."; | ||
| 59 | public static String stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 60 | public static String stringaInformazioni = "Informazioni"; | ||
| 61 | 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"; | ||
| 62 | public static String stringaSuono = "Effetti Sonori"; | ||
| 63 | public static String stringaPunteggio = "Punteggio"; | ||
| 64 | public static String stringaSfondo = "Sfondo"; | ||
| 65 | public static String lang, soundString; | ||
| 66 | public static File[] suoni = new File[6]; | ||
| 67 | public static File suonoVinto, suonoPerso, suonoPareggio; | ||
| 68 | public static void main( String args[] ) { | ||
| 69 | settaOpzioni(); | ||
| 70 | frame = new Frame(); | ||
| 71 | frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); | ||
| 72 | frame.setResizable( false ); | ||
| 73 | frame.setSize( 600, 600 ); | ||
| 74 | frame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 600) / 2, | ||
| 75 | (Toolkit.getDefaultToolkit().getScreenSize().height - 600) / 2); | ||
| 76 | frame.setVisible( true ); | ||
| 77 | } | ||
| 78 | public void mischia() { | ||
| 79 | mano = 0; | ||
| 80 | punteggio = 0; | ||
| 81 | punteggioCPU = 0; | ||
| 82 | cartaDaPescare = 6; | ||
| 83 | ImageIcon aux; | ||
| 84 | frame.mazzo = true; | ||
| 85 | toccaAllaCPU = false; | ||
| 86 | CPUHaGiocato = false; | ||
| 87 | haGiocatoPrima = true; | ||
| 88 | for ( int i = 0, k = 0; i < 10; i++ ) | ||
| 89 | for ( int j = 0; j < 4; j++, k++ ) | ||
| 90 | frame.arrayCarteMescolate[k] = frame.arrayCarte[i][j]; | ||
| 91 | for ( int i = 0; i < 391; i++ ) { | ||
| 92 | double a = Math.random() * 40; | ||
| 93 | int x = (int) a; | ||
| 94 | double b = Math.random() * 40; | ||
| 95 | int y = (int) b; | ||
| 96 | aux = frame.arrayCarteMescolate[x]; | ||
| 97 | frame.arrayCarteMescolate[x] = frame.arrayCarteMescolate[y]; | ||
| 98 | frame.arrayCarteMescolate[y] = aux; | ||
| 99 | } | ||
| 100 | char auxChar[] = frame.arrayCarteMescolate[39].toString().toCharArray(); | ||
| 101 | semeBriscola = auxChar[auxChar.length-5] - 49; | ||
| 102 | frame.carteInMano[0] = frame.arrayCarteMescolate[0]; | ||
| 103 | frame.carteInMano[1] = frame.arrayCarteMescolate[1]; | ||
| 104 | frame.carteInMano[2] = frame.arrayCarteMescolate[2]; | ||
| 105 | frame.carteCPU[0] = frame.arrayCarteMescolate[3]; | ||
| 106 | frame.carteCPU[1] = frame.arrayCarteMescolate[4]; | ||
| 107 | frame.carteCPU[2] = frame.arrayCarteMescolate[5]; | ||
| 108 | frame.ultimaCarta = frame.arrayCarteMescolate[39]; | ||
| 109 | frame.giocata[0] = null; | ||
| 110 | frame.giocata[1] = null; | ||
| 111 | } | ||
| 112 | public void giocaCPU() { | ||
| 113 | if ( mano < 16 ) { | ||
| 114 | if ( frame.giocata[0] == null ) { | ||
| 115 | if ( vaiPunti() ); | ||
| 116 | else if ( vaiLiscio() ); | ||
| 117 | else if ( vaiTaglio() ); | ||
| 118 | else if ( vaiBriscolaAlta() ); | ||
| 119 | else if ( vaiCarico() ); | ||
| 120 | else if ( vaiTre() ); | ||
| 121 | else if ( vaiAsso() ); | ||
| 122 | else; | ||
| 123 | } | ||
| 124 | else { | ||
| 125 | if ( haLisciato() ) { | ||
| 126 | if ( vaiSopra() ); | ||
| 127 | else if ( vaiLiscio() ); | ||
| 128 | else if ( vaiPunti() ); | ||
| 129 | else if ( vaiTaglio() ); | ||
| 130 | else if ( vaiTre() ); | ||
| 131 | else if ( vaiBriscolaAlta() ); | ||
| 132 | else if ( vaiCarico() ); | ||
| 133 | else if ( vaiAsso() ); | ||
| 134 | } else if ( haMessoPunti() ) { | ||
| 135 | if ( vaiSopra() ); | ||
| 136 | else if ( vaiLiscio() ); | ||
| 137 | else if ( vaiTaglio() ); | ||
| 138 | else if ( vaiPunti() ); | ||
| 139 | else if ( vaiTre() ); | ||
| 140 | else if ( vaiBriscolaAlta() ); | ||
| 141 | else if ( vaiCarico() ); | ||
| 142 | else if ( vaiAsso() ); | ||
| 143 | } else if ( haTagliato() ) { | ||
| 144 | if ( vaiLiscio() ); | ||
| 145 | else if ( vaiPunti() ); | ||
| 146 | else if ( vaiTaglio() ); | ||
| 147 | else if ( vaiTre() ); | ||
| 148 | else if ( vaiBriscolaAlta() ); | ||
| 149 | else if ( vaiCarico() ); | ||
| 150 | else if ( vaiAsso() ); | ||
| 151 | } else if ( haMessoBriscolaAlta() ) { | ||
| 152 | if ( vaiLiscio() ); | ||
| 153 | else if ( vaiPunti() ); | ||
| 154 | else if ( vaiTre() ); | ||
| 155 | else if ( vaiTaglio() ); | ||
| 156 | else if ( vaiBriscolaAlta() ); | ||
| 157 | else if ( vaiCarico() ); | ||
| 158 | else if ( vaiAsso() ); | ||
| 159 | } else if ( haMessoTre() ) { | ||
| 160 | if ( vaiAsso() ); | ||
| 161 | else if ( vaiLiscio() ); | ||
| 162 | else if ( vaiPunti() ); | ||
| 163 | else if ( vaiTaglio() ); | ||
| 164 | else if ( vaiBriscolaAlta() ); | ||
| 165 | else if ( vaiCarico() ); | ||
| 166 | } else if ( haMessoAsso() ) { | ||
| 167 | if ( vaiLiscio() ); | ||
| 168 | else if ( vaiPunti() ); | ||
| 169 | else if ( vaiTaglio() ); | ||
| 170 | else if ( vaiBriscolaAlta() ); | ||
| 171 | else if ( vaiCarico() ); | ||
| 172 | else if ( vaiTre() ); | ||
| 173 | } else if ( haCaricato() ) { | ||
| 174 | if ( vaiSopra() ); | ||
| 175 | else if ( vaiTre() ); | ||
| 176 | else if ( vaiBriscolaAlta() ); | ||
| 177 | else if ( vaiAsso() ); | ||
| 178 | else if ( vaiTaglio() ); | ||
| 179 | else if ( vaiLiscio() ); | ||
| 180 | else if ( vaiPunti() ); | ||
| 181 | else if ( vaiCarico() ); | ||
| 182 | } | ||
| 183 | } | ||
| 184 | } | ||
| 185 | else if ( mano == 16 ) { | ||
| 186 | if ( frame.giocata[0] == null ) { | ||
| 187 | char aux[]; | ||
| 188 | aux = frame.ultimaCarta.toString().toCharArray(); | ||
| 189 | if ( aux[aux.length-7] - 48 == 3 || aux[aux.length-7] - 48 == 1 ) { | ||
| 190 | if ( vaiCarico() ); | ||
| 191 | else if ( vaiPunti() ); | ||
| 192 | else if ( vaiLiscio() ); | ||
| 193 | else if ( vaiTaglio() ); | ||
| 194 | else if ( vaiBriscolaAlta() ); | ||
| 195 | else if ( vaiTre() ); | ||
| 196 | else if ( vaiAsso() ); | ||
| 197 | else; | ||
| 198 | } else { | ||
| 199 | if ( vaiPunti() ); | ||
| 200 | else if ( vaiLiscio() ); | ||
| 201 | else if ( vaiTaglio() ); | ||
| 202 | else if ( vaiBriscolaAlta() ); | ||
| 203 | else if ( vaiCarico() ); | ||
| 204 | else if ( vaiTre() ); | ||
| 205 | else if ( vaiAsso() ); | ||
| 206 | else; | ||
| 207 | } | ||
| 208 | } | ||
| 209 | else { | ||
| 210 | char aux[]; | ||
| 211 | aux = frame.ultimaCarta.toString().toCharArray(); | ||
| 212 | if ( aux[aux.length-7] - 48 == 3 || aux[aux.length-7] - 48 == 1 ) { | ||
| 213 | if ( haCaricato() ) { | ||
| 214 | if ( vaiSopra() ); | ||
| 215 | else if ( vaiLiscio() ); | ||
| 216 | else if ( vaiPunti() ); | ||
| 217 | else if ( vaiTre() ); | ||
| 218 | else if ( vaiTaglio() ); | ||
| 219 | else if ( vaiBriscolaAlta() ); | ||
| 220 | else if ( vaiAsso() ); | ||
| 221 | else if ( vaiCarico() ); | ||
| 222 | } | ||
| 223 | } else { | ||
| 224 | if ( haLisciato() ) { | ||
| 225 | if ( vaiSopra() ); | ||
| 226 | else if ( vaiLiscio() ); | ||
| 227 | else if ( vaiPunti() ); | ||
| 228 | else if ( vaiTaglio() ); | ||
| 229 | else if ( vaiTre() ); | ||
| 230 | else if ( vaiBriscolaAlta() ); | ||
| 231 | else if ( vaiCarico() ); | ||
| 232 | else if ( vaiAsso() ); | ||
| 233 | } else if ( haMessoPunti() ) { | ||
| 234 | if ( vaiSopra() ); | ||
| 235 | else if ( vaiLiscio() ); | ||
| 236 | else if ( vaiTaglio() ); | ||
| 237 | else if ( vaiPunti() ); | ||
| 238 | else if ( vaiTre() ); | ||
| 239 | else if ( vaiBriscolaAlta() ); | ||
| 240 | else if ( vaiCarico() ); | ||
| 241 | else if ( vaiAsso() ); | ||
| 242 | } else if ( haTagliato() ) { | ||
| 243 | if ( vaiLiscio() ); | ||
| 244 | else if ( vaiPunti() ); | ||
| 245 | else if ( vaiTaglio() ); | ||
| 246 | else if ( vaiTre() ); | ||
| 247 | else if ( vaiBriscolaAlta() ); | ||
| 248 | else if ( vaiCarico() ); | ||
| 249 | else if ( vaiAsso() ); | ||
| 250 | } else if ( haMessoBriscolaAlta() ) { | ||
| 251 | if ( vaiLiscio() ); | ||
| 252 | else if ( vaiPunti() ); | ||
| 253 | else if ( vaiTre() ); | ||
| 254 | else if ( vaiTaglio() ); | ||
| 255 | else if ( vaiBriscolaAlta() ); | ||
| 256 | else if ( vaiCarico() ); | ||
| 257 | else if ( vaiAsso() ); | ||
| 258 | } else if ( haMessoTre() ) { | ||
| 259 | if ( vaiAsso() ); | ||
| 260 | else if ( vaiLiscio() ); | ||
| 261 | else if ( vaiPunti() ); | ||
| 262 | else if ( vaiTaglio() ); | ||
| 263 | else if ( vaiBriscolaAlta() ); | ||
| 264 | else if ( vaiCarico() ); | ||
| 265 | } else if ( haMessoAsso() ) { | ||
| 266 | if ( vaiLiscio() ); | ||
| 267 | else if ( vaiPunti() ); | ||
| 268 | else if ( vaiTaglio() ); | ||
| 269 | else if ( vaiBriscolaAlta() ); | ||
| 270 | else if ( vaiCarico() ); | ||
| 271 | else if ( vaiTre() ); | ||
| 272 | } else if ( haCaricato() ) { | ||
| 273 | if ( vaiSopra() ); | ||
| 274 | else if ( vaiTre() ); | ||
| 275 | else if ( vaiBriscolaAlta() ); | ||
| 276 | else if ( vaiAsso() ); | ||
| 277 | else if ( vaiTaglio() ); | ||
| 278 | else if ( vaiLiscio() ); | ||
| 279 | else if ( vaiPunti() ); | ||
| 280 | else if ( vaiCarico() ); | ||
| 281 | } | ||
| 282 | } | ||
| 283 | } | ||
| 284 | } else if ( mano == 17 ) { | ||
| 285 | if ( frame.giocata[0] == null ) { | ||
| 286 | if ( hoAsso() ) { | ||
| 287 | if ( vaiTre() ); | ||
| 288 | else if ( vaiBriscolaAlta() ); | ||
| 289 | else if ( vaiTaglio() ); | ||
| 290 | else if ( vaiLiscio() ); | ||
| 291 | else if ( vaiPunti() ); | ||
| 292 | else if ( vaiAsso() ); | ||
| 293 | else if ( vaiCarico() ); | ||
| 294 | } else { | ||
| 295 | if ( vaiLiscio() ); | ||
| 296 | else if ( vaiPunti() ); | ||
| 297 | else if ( vaiTaglio() ); | ||
| 298 | else if ( vaiBriscolaAlta() ); | ||
| 299 | else if ( vaiCarico() ); | ||
| 300 | else if ( vaiTre() ); | ||
| 301 | } | ||
| 302 | } | ||
| 303 | else { | ||
| 304 | if ( haLisciato() ) { | ||
| 305 | if ( vaiSopra() ); | ||
| 306 | else if ( vaiLiscio() ); | ||
| 307 | else if ( vaiPunti() ); | ||
| 308 | else if ( vaiTaglio() ); | ||
| 309 | else if ( vaiTre() ); | ||
| 310 | else if ( vaiBriscolaAlta() ); | ||
| 311 | else if ( vaiCarico() ); | ||
| 312 | else if ( vaiAsso() ); | ||
| 313 | } else if ( haMessoPunti() ) { | ||
| 314 | if ( vaiSopra() ); | ||
| 315 | else if ( vaiLiscio() ); | ||
| 316 | else if ( vaiTaglio() ); | ||
| 317 | else if ( vaiPunti() ); | ||
| 318 | else if ( vaiTre() ); | ||
| 319 | else if ( vaiBriscolaAlta() ); | ||
| 320 | else if ( vaiCarico() ); | ||
| 321 | else if ( vaiAsso() ); | ||
| 322 | } else if ( haTagliato() ) { | ||
| 323 | if ( vaiLiscio() ); | ||
| 324 | else if ( vaiPunti() ); | ||
| 325 | else if ( vaiTaglio() ); | ||
| 326 | else if ( vaiTre() ); | ||
| 327 | else if ( vaiBriscolaAlta() ); | ||
| 328 | else if ( vaiCarico() ); | ||
| 329 | else if ( vaiAsso() ); | ||
| 330 | } else if ( haMessoBriscolaAlta() ) { | ||
| 331 | if ( vaiLiscio() ); | ||
| 332 | else if ( vaiPunti() ); | ||
| 333 | else if ( vaiTre() ); | ||
| 334 | else if ( vaiTaglio() ); | ||
| 335 | else if ( vaiBriscolaAlta() ); | ||
| 336 | else if ( vaiCarico() ); | ||
| 337 | else if ( vaiAsso() ); | ||
| 338 | } else if ( haMessoTre() ) { | ||
| 339 | if ( vaiAsso() ); | ||
| 340 | else if ( vaiLiscio() ); | ||
| 341 | else if ( vaiPunti() ); | ||
| 342 | else if ( vaiTaglio() ); | ||
| 343 | else if ( vaiBriscolaAlta() ); | ||
| 344 | else if ( vaiCarico() ); | ||
| 345 | } else if ( haMessoAsso() ) { | ||
| 346 | if ( vaiLiscio() ); | ||
| 347 | else if ( vaiPunti() ); | ||
| 348 | else if ( vaiTaglio() ); | ||
| 349 | else if ( vaiBriscolaAlta() ); | ||
| 350 | else if ( vaiCarico() ); | ||
| 351 | else if ( vaiTre() ); | ||
| 352 | } else if ( haCaricato() ) { | ||
| 353 | if ( vaiSopra() ); | ||
| 354 | else if ( vaiTre() ); | ||
| 355 | else if ( vaiBriscolaAlta() ); | ||
| 356 | else if ( vaiAsso() ); | ||
| 357 | else if ( vaiTaglio() ); | ||
| 358 | else if ( vaiLiscio() ); | ||
| 359 | else if ( vaiPunti() ); | ||
| 360 | else if ( vaiCarico() ); | ||
| 361 | } | ||
| 362 | } | ||
| 363 | } else if ( mano == 18 ) { | ||
| 364 | if ( frame.giocata[0] == null ) { | ||
| 365 | if ( vaiAsso() ); | ||
| 366 | else if ( vaiCarico() ); | ||
| 367 | else if ( vaiBriscolaAlta() ); | ||
| 368 | else if ( vaiTaglio() ); | ||
| 369 | else if ( vaiPunti() ); | ||
| 370 | else if ( vaiLiscio() ); | ||
| 371 | else if ( vaiTre() ); | ||
| 372 | } | ||
| 373 | else { | ||
| 374 | if ( haLisciato() ) { | ||
| 375 | if ( vaiSopra() ); | ||
| 376 | else if ( vaiLiscio() ); | ||
| 377 | else if ( vaiPunti() ); | ||
| 378 | else if ( vaiTaglio() ); | ||
| 379 | else if ( vaiTre() ); | ||
| 380 | else if ( vaiBriscolaAlta() ); | ||
| 381 | else if ( vaiCarico() ); | ||
| 382 | else if ( vaiAsso() ); | ||
| 383 | } else if ( haMessoPunti() ) { | ||
| 384 | if ( vaiSopra() ); | ||
| 385 | else if ( vaiLiscio() ); | ||
| 386 | else if ( vaiTaglio() ); | ||
| 387 | else if ( vaiPunti() ); | ||
| 388 | else if ( vaiTre() ); | ||
| 389 | else if ( vaiBriscolaAlta() ); | ||
| 390 | else if ( vaiCarico() ); | ||
| 391 | else if ( vaiAsso() ); | ||
| 392 | } else if ( haTagliato() ) { | ||
| 393 | if ( vaiLiscio() ); | ||
| 394 | else if ( vaiPunti() ); | ||
| 395 | else if ( vaiTaglio() ); | ||
| 396 | else if ( vaiTre() ); | ||
| 397 | else if ( vaiBriscolaAlta() ); | ||
| 398 | else if ( vaiCarico() ); | ||
| 399 | else if ( vaiAsso() ); | ||
| 400 | } else if ( haMessoBriscolaAlta() ) { | ||
| 401 | if ( vaiLiscio() ); | ||
| 402 | else if ( vaiPunti() ); | ||
| 403 | else if ( vaiTre() ); | ||
| 404 | else if ( vaiTaglio() ); | ||
| 405 | else if ( vaiBriscolaAlta() ); | ||
| 406 | else if ( vaiCarico() ); | ||
| 407 | else if ( vaiAsso() ); | ||
| 408 | } else if ( haMessoTre() ) { | ||
| 409 | if ( vaiAsso() ); | ||
| 410 | else if ( vaiLiscio() ); | ||
| 411 | else if ( vaiPunti() ); | ||
| 412 | else if ( vaiTaglio() ); | ||
| 413 | else if ( vaiBriscolaAlta() ); | ||
| 414 | else if ( vaiCarico() ); | ||
| 415 | } else if ( haMessoAsso() ) { | ||
| 416 | if ( vaiLiscio() ); | ||
| 417 | else if ( vaiPunti() ); | ||
| 418 | else if ( vaiTaglio() ); | ||
| 419 | else if ( vaiBriscolaAlta() ); | ||
| 420 | else if ( vaiCarico() ); | ||
| 421 | else if ( vaiTre() ); | ||
| 422 | } else if ( haCaricato() ) { | ||
| 423 | if ( vaiSopra() ); | ||
| 424 | else if ( vaiTre() ); | ||
| 425 | else if ( vaiBriscolaAlta() ); | ||
| 426 | else if ( vaiAsso() ); | ||
| 427 | else if ( vaiTaglio() ); | ||
| 428 | else if ( vaiLiscio() ); | ||
| 429 | else if ( vaiPunti() ); | ||
| 430 | else if ( vaiCarico() ); | ||
| 431 | } | ||
| 432 | } | ||
| 433 | } else { | ||
| 434 | if ( vaiTre() ); | ||
| 435 | else if ( vaiBriscolaAlta() ); | ||
| 436 | else if ( vaiAsso() ); | ||
| 437 | else if ( vaiTaglio() ); | ||
| 438 | else if ( vaiLiscio() ); | ||
| 439 | else if ( vaiPunti() ); | ||
| 440 | else if ( vaiCarico() ); | ||
| 441 | } | ||
| 442 | frame.giocata[1] = frame.carteCPU[cartaDaGiocare]; | ||
| 443 | frame.carteCPU[cartaDaGiocare] = null; | ||
| 444 | frame.pannello.repaint(); | ||
| 445 | CPUHaGiocato = true; | ||
| 446 | if ( frame.giocata[0] == null ) | ||
| 447 | toccaAllaCPU = false; | ||
| 448 | } | ||
| 449 | public void chiPrende() { | ||
| 450 | char aux[], auxCPU[]; | ||
| 451 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 452 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 453 | giocatorePrende( ( (aux[aux.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) ) | ||
| 454 | || ( (aux[aux.length-5] == auxCPU[auxCPU.length-5]) && laPrimaEPiuAlta( aux[aux.length-7] - 48, auxCPU[auxCPU.length-7] - 48 ) ) | ||
| 455 | || ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (aux[aux.length-5] != auxCPU[auxCPU.length-5]) && haGiocatoPrima ) ); | ||
| 456 | } | ||
| 457 | public boolean laPrimaEPiuAlta( int prima, int seconda ) { | ||
| 458 | int a, b; | ||
| 459 | switch ( prima ) { | ||
| 460 | case 0: | ||
| 461 | a = 10; | ||
| 462 | break; | ||
| 463 | case 1: | ||
| 464 | a = 12; | ||
| 465 | break; | ||
| 466 | case 3: | ||
| 467 | a = 11; | ||
| 468 | break; | ||
| 469 | default: | ||
| 470 | a = prima; | ||
| 471 | break; | ||
| 472 | } | ||
| 473 | switch ( seconda ) { | ||
| 474 | case 0: | ||
| 475 | b = 10; | ||
| 476 | break; | ||
| 477 | case 1: | ||
| 478 | b = 12; | ||
| 479 | break; | ||
| 480 | case 3: | ||
| 481 | b = 11; | ||
| 482 | break; | ||
| 483 | default: | ||
| 484 | b = seconda; | ||
| 485 | break; | ||
| 486 | } | ||
| 487 | return a > b; | ||
| 488 | } | ||
| 489 | public void giocatorePrende( boolean giocatore ) { | ||
| 490 | if ( giocatore ) { | ||
| 491 | toccaAllaCPU = CPUHaGiocato = false; | ||
| 492 | haGiocatoPrima = true; | ||
| 493 | } | ||
| 494 | else { | ||
| 495 | toccaAllaCPU = true; | ||
| 496 | CPUHaGiocato = haGiocatoPrima = false; | ||
| 497 | } | ||
| 498 | daiPunti( giocatore ); | ||
| 499 | if ( toccaAllaCPU ) | ||
| 500 | giocaCPU(); | ||
| 501 | } | ||
| 502 | public void daiPunti( boolean giocatore ) { | ||
| 503 | char aux[], auxCPU[]; | ||
| 504 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 505 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 506 | int punti = 0; | ||
| 507 | switch( aux[aux.length-7] - 48 ) { | ||
| 508 | case 0: | ||
| 509 | punti += 4; | ||
| 510 | break; | ||
| 511 | case 1: | ||
| 512 | punti += 11; | ||
| 513 | break; | ||
| 514 | case 3: | ||
| 515 | punti += 10; | ||
| 516 | break; | ||
| 517 | case 8: | ||
| 518 | punti += 2; | ||
| 519 | break; | ||
| 520 | case 9: | ||
| 521 | punti += 3; | ||
| 522 | break; | ||
| 523 | default: | ||
| 524 | break; | ||
| 525 | } | ||
| 526 | switch( auxCPU[auxCPU.length-7] - 48 ) { | ||
| 527 | case 0: | ||
| 528 | punti += 4; | ||
| 529 | break; | ||
| 530 | case 1: | ||
| 531 | punti += 11; | ||
| 532 | break; | ||
| 533 | case 3: | ||
| 534 | punti += 10; | ||
| 535 | break; | ||
| 536 | case 8: | ||
| 537 | punti += 2; | ||
| 538 | break; | ||
| 539 | case 9: | ||
| 540 | punti += 3; | ||
| 541 | break; | ||
| 542 | default: | ||
| 543 | break; | ||
| 544 | } | ||
| 545 | frame.giocata[0] = frame.giocata[1] = null; | ||
| 546 | if ( giocatore ) { | ||
| 547 | punteggio += punti; | ||
| 548 | if ( mano < 18 ) { | ||
| 549 | if ( frame.carteInMano[0] == null ) | ||
| 550 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 551 | if ( frame.carteInMano[1] == null ) | ||
| 552 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 553 | if ( frame.carteInMano[2] == null ) | ||
| 554 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 555 | cartaDaPescare++; | ||
| 556 | if ( frame.carteCPU[0] == null ) | ||
| 557 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 558 | if ( frame.carteCPU[1] == null ) | ||
| 559 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 560 | if ( frame.carteCPU[2] == null ) | ||
| 561 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 562 | cartaDaPescare++; | ||
| 563 | } | ||
| 564 | } | ||
| 565 | else { | ||
| 566 | punteggioCPU += punti; | ||
| 567 | if ( mano < 18 ) { | ||
| 568 | if ( frame.carteCPU[0] == null ) | ||
| 569 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 570 | if ( frame.carteCPU[1] == null ) | ||
| 571 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 572 | if ( frame.carteCPU[2] == null ) | ||
| 573 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 574 | cartaDaPescare++; | ||
| 575 | if ( frame.carteInMano[0] == null ) | ||
| 576 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 577 | if ( frame.carteInMano[1] == null ) | ||
| 578 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 579 | if ( frame.carteInMano[2] == null ) | ||
| 580 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 581 | cartaDaPescare++; | ||
| 582 | } | ||
| 583 | } | ||
| 584 | frame.pannello.repaint(); | ||
| 585 | frame.repaint(); | ||
| 586 | } | ||
| 587 | public boolean haLisciato() { | ||
| 588 | char auxCPU[]; | ||
| 589 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 590 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 591 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 592 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ); | ||
| 593 | } | ||
| 594 | public boolean haMessoPunti() { | ||
| 595 | char auxCPU[]; | ||
| 596 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 597 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 598 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || | ||
| 599 | (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ); | ||
| 600 | } | ||
| 601 | public boolean haTagliato() { | ||
| 602 | char auxCPU[]; | ||
| 603 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 604 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 605 | (auxCPU[auxCPU.length-7] - 48 != 0) && (auxCPU[auxCPU.length-7] - 48 != 1) && | ||
| 606 | (auxCPU[auxCPU.length-7] - 48 != 3) && (auxCPU[auxCPU.length-7] - 48 <= 7) ); | ||
| 607 | } | ||
| 608 | public boolean haMessoBriscolaAlta() { | ||
| 609 | char auxCPU[]; | ||
| 610 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 611 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 612 | ( (auxCPU[auxCPU.length-7] - 48 == 0) || (auxCPU[auxCPU.length-7] - 48 == 8) || | ||
| 613 | (auxCPU[auxCPU.length-7] - 48 == 9) ) ); | ||
| 614 | } | ||
| 615 | public boolean haMessoTre() { | ||
| 616 | char auxCPU[]; | ||
| 617 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 618 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 619 | (auxCPU[auxCPU.length-7] - 48 == 3) ); | ||
| 620 | } | ||
| 621 | public boolean haMessoAsso() { | ||
| 622 | char auxCPU[]; | ||
| 623 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 624 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 625 | (auxCPU[auxCPU.length-7] - 48 == 1) ); | ||
| 626 | } | ||
| 627 | public boolean haCaricato() { | ||
| 628 | char auxCPU[]; | ||
| 629 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 630 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 631 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ); | ||
| 632 | } | ||
| 633 | public boolean vaiLiscio() { | ||
| 634 | char auxCPU[]; | ||
| 635 | for ( int i = 0; i < 3; i++ ) { | ||
| 636 | if ( frame.carteCPU[i] != null ) { | ||
| 637 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 638 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 639 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 640 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ) { | ||
| 641 | cartaDaGiocare = i; | ||
| 642 | return true; | ||
| 643 | } | ||
| 644 | } | ||
| 645 | } | ||
| 646 | return false; | ||
| 647 | } | ||
| 648 | public boolean vaiPunti() { | ||
| 649 | char[] auxCPU; | ||
| 650 | for ( int i = 0; i < 3; i++ ) { | ||
| 651 | if ( frame.carteCPU[i] != null ) { | ||
| 652 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 653 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 8 ) ) { | ||
| 654 | cartaDaGiocare = i; | ||
| 655 | return true; | ||
| 656 | } | ||
| 657 | } | ||
| 658 | } | ||
| 659 | for ( int i = 0; i < 3; i++ ) { | ||
| 660 | if ( frame.carteCPU[i] != null ) { | ||
| 661 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 662 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 9 ) ) { | ||
| 663 | cartaDaGiocare = i; | ||
| 664 | return true; | ||
| 665 | } | ||
| 666 | } | ||
| 667 | } | ||
| 668 | for ( int i = 0; i < 3; i++ ) { | ||
| 669 | if ( frame.carteCPU[i] != null ) { | ||
| 670 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 671 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 0 ) ) { | ||
| 672 | cartaDaGiocare = i; | ||
| 673 | return true; | ||
| 674 | } | ||
| 675 | } | ||
| 676 | } | ||
| 677 | return false; | ||
| 678 | } | ||
| 679 | public boolean vaiTaglio() { | ||
| 680 | char auxCPU[]; | ||
| 681 | for ( int i = 0; i < 3; i++ ) { | ||
| 682 | if ( frame.carteCPU[i] != null ) { | ||
| 683 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 684 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && | ||
| 685 | (auxCPU[auxCPU.length-7] - 48 != 0) && (auxCPU[auxCPU.length-7] - 48 != 1) && | ||
| 686 | (auxCPU[auxCPU.length-7] - 48 != 3) && (auxCPU[auxCPU.length-7] - 48 <= 7) ) { | ||
| 687 | cartaDaGiocare = i; | ||
| 688 | return true; | ||
| 689 | } | ||
| 690 | } | ||
| 691 | } | ||
| 692 | return false; | ||
| 693 | } | ||
| 694 | public boolean vaiBriscolaAlta() { | ||
| 695 | char[] auxCPU; | ||
| 696 | for ( int i = 0; i < 3; i++ ) { | ||
| 697 | if ( frame.carteCPU[i] != null ) { | ||
| 698 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 699 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 8 ) ) { | ||
| 700 | cartaDaGiocare = i; | ||
| 701 | return true; | ||
| 702 | } | ||
| 703 | } | ||
| 704 | } | ||
| 705 | for ( int i = 0; i < 3; i++ ) { | ||
| 706 | if ( frame.carteCPU[i] != null ) { | ||
| 707 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 708 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 9 ) ) { | ||
| 709 | cartaDaGiocare = i; | ||
| 710 | return true; | ||
| 711 | } | ||
| 712 | } | ||
| 713 | } | ||
| 714 | for ( int i = 0; i < 3; i++ ) { | ||
| 715 | if ( frame.carteCPU[i] != null ) { | ||
| 716 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 717 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 0 ) ) { | ||
| 718 | cartaDaGiocare = i; | ||
| 719 | return true; | ||
| 720 | } | ||
| 721 | } | ||
| 722 | } | ||
| 723 | return false; | ||
| 724 | } | ||
| 725 | public boolean vaiTre() { | ||
| 726 | char auxCPU[]; | ||
| 727 | for ( int i = 0; i < 3; i++ ) { | ||
| 728 | if ( frame.carteCPU[i] != null ) { | ||
| 729 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 730 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && (auxCPU[auxCPU.length-7] - 48 == 3) ) { | ||
| 731 | cartaDaGiocare = i; | ||
| 732 | return true; | ||
| 733 | } | ||
| 734 | } | ||
| 735 | } | ||
| 736 | return false; | ||
| 737 | } | ||
| 738 | public boolean vaiAsso() { | ||
| 739 | char auxCPU[]; | ||
| 740 | for ( int i = 0; i < 3; i++ ) { | ||
| 741 | if ( frame.carteCPU[i] != null ) { | ||
| 742 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 743 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && (auxCPU[auxCPU.length-7] - 48 == 1) ) { | ||
| 744 | cartaDaGiocare = i; | ||
| 745 | return true; | ||
| 746 | } | ||
| 747 | } | ||
| 748 | } | ||
| 749 | return false; | ||
| 750 | } | ||
| 751 | public boolean vaiCarico() { | ||
| 752 | char[] auxCPU; | ||
| 753 | for ( int i = 0; i < 3; i++ ) { | ||
| 754 | if ( frame.carteCPU[i] != null ) { | ||
| 755 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 756 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 3 ) ) { | ||
| 757 | cartaDaGiocare = i; | ||
| 758 | return true; | ||
| 759 | } | ||
| 760 | } | ||
| 761 | } | ||
| 762 | for ( int i = 0; i < 3; i++ ) { | ||
| 763 | if ( frame.carteCPU[i] != null ) { | ||
| 764 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 765 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 1 ) ) { | ||
| 766 | cartaDaGiocare = i; | ||
| 767 | return true; | ||
| 768 | } | ||
| 769 | } | ||
| 770 | } | ||
| 771 | return false; | ||
| 772 | } | ||
| 773 | public boolean vaiSopra() { | ||
| 774 | if ( frame.giocata[0] == null ) | ||
| 775 | return false; | ||
| 776 | int a = -1; | ||
| 777 | int b = -1; | ||
| 778 | int c = -1; | ||
| 779 | boolean laPrimaPuoAndareSopra = false; | ||
| 780 | boolean laSecondaPuoAndareSopra = false; | ||
| 781 | boolean laTerzaPuoAndareSopra = false; | ||
| 782 | char[] auxCPU1 = new char[1024]; | ||
| 783 | char[] auxCPU2 = new char[1024]; | ||
| 784 | char[] auxCPU3 = new char[1024]; | ||
| 785 | char[] aux = frame.giocata[0].toString().toCharArray(); | ||
| 786 | if ( aux[aux.length-7] - 48 == 1 ) | ||
| 787 | return false; | ||
| 788 | if ( frame.carteCPU[0] != null ) { | ||
| 789 | auxCPU1 = frame.carteCPU[0].toString().toCharArray(); | ||
| 790 | a = auxCPU1[auxCPU1.length-7] - 48; | ||
| 791 | if ( (auxCPU1[auxCPU1.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( a, aux[aux.length-7] - 48 ) ) | ||
| 792 | laPrimaPuoAndareSopra = true; | ||
| 793 | } | ||
| 794 | if ( frame.carteCPU[1] != null ) { | ||
| 795 | auxCPU2 = frame.carteCPU[1].toString().toCharArray(); | ||
| 796 | b = auxCPU2[auxCPU2.length-7] - 48; | ||
| 797 | if ( (auxCPU2[auxCPU2.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( b, aux[aux.length-7] - 48 ) ) | ||
| 798 | laSecondaPuoAndareSopra = true; | ||
| 799 | } | ||
| 800 | if ( frame.carteCPU[2] != null ) { | ||
| 801 | auxCPU3 = frame.carteCPU[2].toString().toCharArray(); | ||
| 802 | c = auxCPU3[auxCPU3.length-7] - 48; | ||
| 803 | if ( (auxCPU3[auxCPU3.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( c, aux[aux.length-7] - 48 ) ) | ||
| 804 | laTerzaPuoAndareSopra = true; | ||
| 805 | } | ||
| 806 | if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 807 | return false; | ||
| 808 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 809 | cartaDaGiocare = 0; | ||
| 810 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 811 | cartaDaGiocare = 1; | ||
| 812 | else if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 813 | cartaDaGiocare = 2; | ||
| 814 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 815 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 816 | cartaDaGiocare = 0; | ||
| 817 | else | ||
| 818 | cartaDaGiocare = 1; | ||
| 819 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 820 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 821 | cartaDaGiocare = 1; | ||
| 822 | else | ||
| 823 | cartaDaGiocare = 2; | ||
| 824 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 825 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 826 | cartaDaGiocare = 0; | ||
| 827 | else | ||
| 828 | cartaDaGiocare = 2; | ||
| 829 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 830 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 831 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 832 | cartaDaGiocare = 0; | ||
| 833 | else | ||
| 834 | cartaDaGiocare = 2; | ||
| 835 | else | ||
| 836 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 837 | cartaDaGiocare = 1; | ||
| 838 | else | ||
| 839 | cartaDaGiocare = 2; | ||
| 840 | aux = frame.carteCPU[cartaDaGiocare].toString().toCharArray(); | ||
| 841 | if ( (aux[aux.length-7] - 48 != 0) && (aux[aux.length-7] - 48 != 1) && | ||
| 842 | (aux[aux.length-7] - 48 != 3) && (aux[aux.length-7] - 48 <= 7) ) | ||
| 843 | return false; | ||
| 844 | return true; | ||
| 845 | } | ||
| 846 | public boolean hoCarico() { | ||
| 847 | char auxCPU[]; | ||
| 848 | for ( int i = 0; i < 3; i++ ) { | ||
| 849 | if ( frame.carteCPU[i] != null ) { | ||
| 850 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 851 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 852 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ) { | ||
| 853 | return true; | ||
| 854 | } | ||
| 855 | } | ||
| 856 | } | ||
| 857 | return false; | ||
| 858 | } | ||
| 859 | public boolean hoAsso() { | ||
| 860 | char auxCPU[]; | ||
| 861 | for ( int i = 0; i < 3; i++ ) { | ||
| 862 | if ( frame.carteCPU[i] != null ) { | ||
| 863 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 864 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 1 ) ) { | ||
| 865 | return true; | ||
| 866 | } | ||
| 867 | } | ||
| 868 | } | ||
| 869 | return false; | ||
| 870 | } | ||
| 871 | public boolean hoTre() { | ||
| 872 | char auxCPU[]; | ||
| 873 | for ( int i = 0; i < 3; i++ ) { | ||
| 874 | if ( frame.carteCPU[i] != null ) { | ||
| 875 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 876 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 3 ) ) { | ||
| 877 | return true; | ||
| 878 | } | ||
| 879 | } | ||
| 880 | } | ||
| 881 | return false; | ||
| 882 | } | ||
| 883 | public boolean hoBriscolaAlta() { | ||
| 884 | char auxCPU[]; | ||
| 885 | for ( int i = 0; i < 3; i++ ) { | ||
| 886 | if ( frame.carteCPU[i] != null ) { | ||
| 887 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 888 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 889 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ) { | ||
| 890 | return true; | ||
| 891 | } | ||
| 892 | } | ||
| 893 | } | ||
| 894 | return false; | ||
| 895 | } | ||
| 896 | public boolean hoTaglio() { | ||
| 897 | char auxCPU[]; | ||
| 898 | for ( int i = 0; i < 3; i++ ) { | ||
| 899 | if ( frame.carteCPU[i] != null ) { | ||
| 900 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 901 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 902 | (auxCPU[auxCPU.length-7] - 48 < 8 ) && (auxCPU[auxCPU.length-7] - 48 != 3 ) | ||
| 903 | && (auxCPU[auxCPU.length-7] - 48 != 1 ) && (auxCPU[auxCPU.length-7] - 48 != 0 ) ) { | ||
| 904 | return true; | ||
| 905 | } | ||
| 906 | } | ||
| 907 | } | ||
| 908 | return false; | ||
| 909 | } | ||
| 910 | public static void settaOpzioni() { | ||
| 911 | lang = "it"; | ||
| 912 | soundString = "suono=si"; | ||
| 913 | int r = 0; | ||
| 914 | int g = 150; | ||
| 915 | int b = 0; | ||
| 916 | Scanner scanner = null; | ||
| 917 | File file = new File( "JBriscolaConfig.txt" ); | ||
| 918 | if ( file.exists() ) { | ||
| 919 | try { | ||
| 920 | scanner = new Scanner( file ); | ||
| 921 | } catch ( FileNotFoundException e ) { } | ||
| 922 | try { | ||
| 923 | lang = scanner.next(); | ||
| 924 | soundString = scanner.next(); | ||
| 925 | r = scanner.nextInt(); | ||
| 926 | g = scanner.nextInt(); | ||
| 927 | b = scanner.nextInt(); | ||
| 928 | } catch ( NoSuchElementException e ) { } | ||
| 929 | } | ||
| 930 | else { | ||
| 931 | lang = "it"; | ||
| 932 | soundString = "suono=si"; | ||
| 933 | r = 0; | ||
| 934 | g = 150; | ||
| 935 | b = 0; | ||
| 936 | } | ||
| 937 | if ( lang.equals( "it" ) ) { | ||
| 938 | stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 939 | stringaPrimaGioca = "Prima Gioca!"; | ||
| 940 | stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 941 | stringaVinto = "Hai Vinto!"; | ||
| 942 | stringaPerso = "Hai Perso"; | ||
| 943 | stringaPareggio = "Pareggio"; | ||
| 944 | stringaGiocatore = "Giocatore: "; | ||
| 945 | stringaComputer = "\nComputer: "; | ||
| 946 | stringaNuovaPartita = "Nuova Partita"; | ||
| 947 | stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 948 | stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 949 | stringaSi = "Si"; | ||
| 950 | stringaNo = "No"; | ||
| 951 | stringaOpzioni = "Opzioni..."; | ||
| 952 | stringaEsci = "Esci"; | ||
| 953 | stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 954 | stringaLingua = "Lingua"; | ||
| 955 | stringaAnnulla = "Annulla"; | ||
| 956 | stringaIt = "Italiano"; | ||
| 957 | stringaLa = "Latino"; | ||
| 958 | stringaBL = "Dialetto Bellunese"; | ||
| 959 | stringaBV = "Dialetto Basso Veneto"; | ||
| 960 | stringaNecessarioRiavviare = "E' necessario riavviare JBriscola se sono state\nmodificate impostazioni riguardanti la lingua\nAlcune parti saranno comunque tradotte prima."; | ||
| 961 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 962 | stringaInformazioni = "Informazioni"; | ||
| 963 | 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"; | ||
| 964 | stringaSuono = "Effetti sonori"; | ||
| 965 | stringaPunteggio = "Punteggio"; | ||
| 966 | stringaSfondo = "Sfondo"; | ||
| 967 | } | ||
| 968 | else if ( lang.equals( "la" ) ) { | ||
| 969 | stringaBottonePrendi = "CAPIS/RELINQVIS CHARTAS"; | ||
| 970 | stringaPrimaGioca = "ANTE CHARTAM PONE!"; | ||
| 971 | stringaUltime4 = "CHARTA POSTREMA - INTVERE BRISCOLAM!"; | ||
| 972 | stringaVinto = "VICISTI!"; | ||
| 973 | stringaPerso = "PERDIDISTI"; | ||
| 974 | stringaPareggio = "AEQVATIO!"; | ||
| 975 | stringaGiocatore = "LVSOR: "; | ||
| 976 | stringaComputer = "\nCOMPVTER: "; | ||
| 977 | stringaNuovaPartita = "NOVA LVSO"; | ||
| 978 | stringaVuoiDavveroIniziare = "NOVAM LVSIONEM INCIPERE?"; | ||
| 979 | stringaVuoiDavveroUscire = "EXIRE?"; | ||
| 980 | stringaSi = "ID VOLO"; | ||
| 981 | stringaNo = "NOLO"; | ||
| 982 | stringaOpzioni = "OPTIONES..."; | ||
| 983 | stringaEsci = "EXIRE"; | ||
| 984 | stringaImpossibileConfigurare = "CONFIGVRATIONIS FILE SCRIBERE NON POTVI.\nERROREM ME CERTIOREM FACITE: sebastiano@luganega.org\n\nEXCEPTIO:\n"; | ||
| 985 | stringaLingua = "LINGVA"; | ||
| 986 | stringaAnnulla = "ABROGA"; | ||
| 987 | stringaIt = "ITALICA"; | ||
| 988 | stringaLa = "LATINA"; | ||
| 989 | stringaBL = "BELLUNI"; | ||
| 990 | stringaBV = "VENETIAE"; | ||
| 991 | stringaNecessarioRiavviare = "JBRISCOLAM RVRSVS INCIPERE NECESSE EST\nSI LINGVA PRAELATIONES NOVATAE SVNT.\nALIQVAE ANTE ID VERSA ERVNT"; | ||
| 992 | stringaModificaOpzioni = "OPTIONES NOVARE"; | ||
| 993 | stringaInformazioni = "INFORMATIONES"; | ||
| 994 | 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"; | ||
| 995 | stringaSuono = "SONUS"; | ||
| 996 | stringaPunteggio = "NUMERI"; | ||
| 997 | stringaSfondo = "COLOR"; | ||
| 998 | } | ||
| 999 | if ( lang.equals( "bl" ) ) { | ||
| 1000 | stringaBottonePrendi = "Cio' su/lasa le carte"; | ||
| 1001 | stringaPrimaGioca = "Prima Duga!"; | ||
| 1002 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1003 | stringaVinto = "Te ha vint!"; | ||
| 1004 | stringaPerso = "Te ha pers"; | ||
| 1005 | stringaPareggio = "Pari"; | ||
| 1006 | stringaGiocatore = "Dugador: "; | ||
| 1007 | stringaComputer = "\nComputer: "; | ||
| 1008 | stringaNuovaPartita = "Taca n'altra partida"; | ||
| 1009 | stringaVuoiDavveroIniziare = "Utu sul serio scuminziar n'altra partida?"; | ||
| 1010 | stringaVuoiDavveroUscire = "Utu sul serio stusar su?"; | ||
| 1011 | stringaSi = "Si"; | ||
| 1012 | stringaNo = "No"; | ||
| 1013 | stringaOpzioni = "Opzioni..."; | ||
| 1014 | stringaEsci = "Stusa su"; | ||
| 1015 | stringaImpossibileConfigurare = "No ghe ho riva' a scrivere al file de configurazion.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1016 | stringaLingua = "Lengua"; | ||
| 1017 | stringaAnnulla = "Annulla"; | ||
| 1018 | stringaIt = "Italian"; | ||
| 1019 | stringaLa = "Latin"; | ||
| 1020 | stringaBL = "Dialeto de Belun"; | ||
| 1021 | stringaBV = "Dialeto de la basa"; | ||
| 1022 | stringaNecessarioRiavviare = "Se te ha cambia' la lengua te toca\nstusar su e impizar de novo al dugo\nPero' zerte robe le e' belche tradote."; | ||
| 1023 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1024 | stringaInformazioni = "Informazioni"; | ||
| 1025 | 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"; | ||
| 1026 | stringaSuono = "Efeti sonori"; | ||
| 1027 | stringaPunteggio = "Varda i punti"; | ||
| 1028 | stringaSfondo = "Sfondo"; | ||
| 1029 | } | ||
| 1030 | if ( lang.equals( "bv" ) ) { | ||
| 1031 | stringaBottonePrendi = "Ciapa su/lasa e carte"; | ||
| 1032 | stringaPrimaGioca = "Prima Zuga!"; | ||
| 1033 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1034 | stringaVinto = "Ti ga vinto!"; | ||
| 1035 | stringaPerso = "Ti ga perso"; | ||
| 1036 | stringaPareggio = "Pari"; | ||
| 1037 | stringaGiocatore = "Zugador: "; | ||
| 1038 | stringaComputer = "\nComputer: "; | ||
| 1039 | stringaNuovaPartita = "N'altra Partida"; | ||
| 1040 | stringaVuoiDavveroIniziare = "Ti vol sul serio scuminziar n'altra partida?"; | ||
| 1041 | stringaVuoiDavveroUscire = "Ti vol sul serio stusar su?"; | ||
| 1042 | stringaSi = "Si"; | ||
| 1043 | stringaNo = "No"; | ||
| 1044 | stringaOpzioni = "Opzioni..."; | ||
| 1045 | stringaEsci = "Stusa su"; | ||
| 1046 | stringaImpossibileConfigurare = "No ghe son riusito a scrivere al file de configurazione.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1047 | stringaLingua = "Lengua"; | ||
| 1048 | stringaAnnulla = "Annulla"; | ||
| 1049 | stringaIt = "Italian"; | ||
| 1050 | stringaLa = "Latin"; | ||
| 1051 | stringaBL = "Dialeto Belumat"; | ||
| 1052 | stringaBV = "Dialeto Veneto"; | ||
| 1053 | stringaNecessarioRiavviare = "Se ti ga cambia' la lengua te toca\nstusar su e impizar de novo al zugo\nPero' zerte robe le e' belche tradote."; | ||
| 1054 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1055 | stringaInformazioni = "Informasioni"; | ||
| 1056 | 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"; | ||
| 1057 | stringaSuono = "Efeti sonori"; | ||
| 1058 | stringaPunteggio = "Varda i punti"; | ||
| 1059 | stringaSfondo = "Sfondo"; | ||
| 1060 | } | ||
| 1061 | sound = ( soundString.equals( "suono=si" ) ); | ||
| 1062 | color = new Color( r, g, b ); | ||
| 1063 | if ( frame != null ) { | ||
| 1064 | frame.pannello.repaint(); | ||
| 1065 | frame.pannello2.repaint(); | ||
| 1066 | frame.repaint(); | ||
| 1067 | } | ||
| 1068 | } | ||
| 1069 | } | ||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/OptionFrame.java b/JBriscola/all_versions/0.2/0.2 Beta 2/src/OptionFrame.java new file mode 100755 index 0000000..a93899f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/OptionFrame.java | |||
| @@ -0,0 +1,129 @@ | |||
| 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.util.Formatter; | ||
| 23 | import javax.swing.*; | ||
| 24 | import java.awt.*; | ||
| 25 | import java.awt.event.*; | ||
| 26 | |||
| 27 | public class OptionFrame extends JFrame { | ||
| 28 | public static Main main = new Main(); | ||
| 29 | public static Formatter formatter; | ||
| 30 | public static JButton ok, annulla, scegliColore; | ||
| 31 | public static JLabel lingua, sfondo; | ||
| 32 | public static JComboBox selezionaLingua; | ||
| 33 | public static JCheckBox suono; | ||
| 34 | public static JPanel[] pannello = new JPanel[5]; | ||
| 35 | public OptionFrame() { | ||
| 36 | super( "JBriscola - " + main.stringaModificaOpzioni ); | ||
| 37 | ok = new JButton( "OK" ); | ||
| 38 | ok.addActionListener( new ActionListener() { | ||
| 39 | public void actionPerformed( ActionEvent e ) { | ||
| 40 | try { | ||
| 41 | formatter = new Formatter( "JBriscolaConfig.txt" ); | ||
| 42 | } catch ( Exception ex ) { | ||
| 43 | JOptionPane.showMessageDialog( OptionFrame.this, main.stringaImpossibileConfigurare + ex ); | ||
| 44 | } | ||
| 45 | String lang; | ||
| 46 | switch ( selezionaLingua.getSelectedIndex() ) { | ||
| 47 | case 0: | ||
| 48 | lang = "it"; | ||
| 49 | break; | ||
| 50 | case 1: | ||
| 51 | lang = "la"; | ||
| 52 | break; | ||
| 53 | case 2: | ||
| 54 | lang = "bl"; | ||
| 55 | break; | ||
| 56 | case 3: | ||
| 57 | lang = "bv"; | ||
| 58 | break; | ||
| 59 | default: | ||
| 60 | lang = "it"; | ||
| 61 | break; | ||
| 62 | } | ||
| 63 | String suonosiono; | ||
| 64 | if ( suono.isSelected() ) | ||
| 65 | suonosiono = "suono=si"; | ||
| 66 | else | ||
| 67 | suonosiono = "suono=no"; | ||
| 68 | formatter.format( lang ); | ||
| 69 | formatter.format( "\n" ); | ||
| 70 | formatter.format( suonosiono ); | ||
| 71 | formatter.format( "\n" ); | ||
| 72 | formatter.format( main.color.getRed() + " " + main.color.getGreen() + " " + main.color.getBlue() ); | ||
| 73 | formatter.close(); | ||
| 74 | main.settaOpzioni(); | ||
| 75 | OptionFrame.this.dispose(); | ||
| 76 | //JOptionPane.showMessageDialog( OptionFrame.this, main.stringaNecessarioRiavviare, "JBriscola 0.1", JOptionPane.INFORMATION_MESSAGE ); | ||
| 77 | } | ||
| 78 | }); | ||
| 79 | annulla = new JButton( main.stringaAnnulla ); | ||
| 80 | annulla.addActionListener( new ActionListener() { | ||
| 81 | public void actionPerformed( ActionEvent e ) { | ||
| 82 | OptionFrame.this.dispose(); | ||
| 83 | } | ||
| 84 | }); | ||
| 85 | scegliColore = new JButton( " " ); | ||
| 86 | scegliColore.setBackground( main.color ); | ||
| 87 | scegliColore.addActionListener( new ActionListener() { | ||
| 88 | public void actionPerformed( ActionEvent e ) { | ||
| 89 | Color colore = JColorChooser.showDialog( OptionFrame.this, "JBriscola " + main.version, main.color ); | ||
| 90 | if ( colore != null ) | ||
| 91 | main.color = colore; | ||
| 92 | OptionFrame.scegliColore.setBackground( main.color ); | ||
| 93 | } | ||
| 94 | } ); | ||
| 95 | lingua = new JLabel( main.stringaLingua ); | ||
| 96 | sfondo = new JLabel( main.stringaSfondo ); | ||
| 97 | String[] lingueDaSelezionare = { main.stringaIt, main.stringaLa, main.stringaBL, main.stringaBV }; | ||
| 98 | selezionaLingua = new JComboBox( lingueDaSelezionare ); | ||
| 99 | int linguaPreselezionata = 0; | ||
| 100 | if ( main.lang.equals( "it" ) ) | ||
| 101 | linguaPreselezionata = 0; | ||
| 102 | else if ( main.lang.equals( "la" ) ) | ||
| 103 | linguaPreselezionata = 1; | ||
| 104 | else if ( main.lang.equals( "bl" ) ) | ||
| 105 | linguaPreselezionata = 2; | ||
| 106 | else if ( main.lang.equals( "bv" ) ) | ||
| 107 | linguaPreselezionata = 3; | ||
| 108 | selezionaLingua.setSelectedIndex( linguaPreselezionata ); | ||
| 109 | suono = new JCheckBox( main.stringaSuono ); | ||
| 110 | suono.setSelected( main.sound ); | ||
| 111 | pannello[0] = new JPanel( new GridLayout( 3, 1 ) ); | ||
| 112 | pannello[1] = new JPanel( new FlowLayout() ); | ||
| 113 | pannello[2] = new JPanel( new FlowLayout() ); | ||
| 114 | pannello[3] = new JPanel( new FlowLayout() ); | ||
| 115 | pannello[4] = new JPanel( new FlowLayout() ); | ||
| 116 | pannello[4].add( ok ); | ||
| 117 | pannello[4].add( annulla ); | ||
| 118 | pannello[3].add( sfondo ); | ||
| 119 | pannello[3].add( scegliColore ); | ||
| 120 | pannello[2].add( suono ); | ||
| 121 | pannello[1].add( lingua ); | ||
| 122 | pannello[1].add( selezionaLingua ); | ||
| 123 | pannello[0].add( pannello[1] ); | ||
| 124 | pannello[0].add( pannello[2] ); | ||
| 125 | pannello[0].add( pannello[3] ); | ||
| 126 | add( pannello[0], BorderLayout.CENTER ); | ||
| 127 | add( pannello[4], BorderLayout.SOUTH ); | ||
| 128 | } | ||
| 129 | } | ||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/Pannello.java b/JBriscola/all_versions/0.2/0.2 Beta 2/src/Pannello.java new file mode 100755 index 0000000..24c6596 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/Pannello.java | |||
| @@ -0,0 +1,54 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | |||
| 25 | public class Pannello extends JPanel { | ||
| 26 | public static Main main; | ||
| 27 | public static Color color; | ||
| 28 | public Pannello() { } | ||
| 29 | public void paint( Graphics g ) { | ||
| 30 | super.paint( g ); | ||
| 31 | setBackground( main.color ); | ||
| 32 | if ( main.frame.ultimaCarta != null ) | ||
| 33 | main.frame.ultimaCarta.paintIcon( this, g, 50, 180 ); | ||
| 34 | if ( main.frame.mazzo ) | ||
| 35 | main.frame.retro2.paintIcon( this, g, 17, 256 ); | ||
| 36 | if ( main.frame.carteCPU[0] != null ) | ||
| 37 | main.frame.retro1.paintIcon( this, g, 230, 5 ); | ||
| 38 | if ( main.frame.carteCPU[1] != null ) | ||
| 39 | main.frame.retro1.paintIcon( this, g, 300, 5 ); | ||
| 40 | if ( main.frame.carteCPU[2] != null ) | ||
| 41 | main.frame.retro1.paintIcon( this, g, 370, 5 ); | ||
| 42 | if ( main.frame.carteInMano[0] != null ) | ||
| 43 | main.frame.carteInMano[0].paintIcon( this, g, 230, 340 ); | ||
| 44 | if ( main.frame.carteInMano[1] != null ) | ||
| 45 | main.frame.carteInMano[1].paintIcon( this, g, 300, 340 ); | ||
| 46 | if ( main.frame.carteInMano[2] != null ) | ||
| 47 | main.frame.carteInMano[2].paintIcon( this, g, 370, 340 ); | ||
| 48 | if ( main.frame.giocata[0] != null ) | ||
| 49 | main.frame.giocata[0].paintIcon( this, g, 250, 200 ); | ||
| 50 | if ( main.frame.giocata[1] != null ) | ||
| 51 | main.frame.giocata[1].paintIcon( this, g, 325, 150 ); | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/1-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/1-1.jpg new file mode 100755 index 0000000..ae43510 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/1-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/1-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/1-2.jpg new file mode 100755 index 0000000..3f7c75a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/1-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/1-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/1-3.jpg new file mode 100755 index 0000000..9e1ead7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/1-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/1-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/1-4.jpg new file mode 100755 index 0000000..710f879 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/1-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/10-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/10-1.jpg new file mode 100755 index 0000000..9aba45a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/10-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/10-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/10-2.jpg new file mode 100755 index 0000000..037eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/10-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/10-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/10-3.jpg new file mode 100755 index 0000000..8780b72 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/10-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/10-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/10-4.jpg new file mode 100755 index 0000000..587dc0f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/10-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/2-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/2-1.jpg new file mode 100755 index 0000000..5dcb7db --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/2-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/2-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/2-2.jpg new file mode 100755 index 0000000..ea9eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/2-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/2-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/2-3.jpg new file mode 100755 index 0000000..8cb22dd --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/2-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/2-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/2-4.jpg new file mode 100755 index 0000000..b3e7898 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/2-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/3-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/3-1.jpg new file mode 100755 index 0000000..dcb435c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/3-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/3-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/3-2.jpg new file mode 100755 index 0000000..1e5b6ec --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/3-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/3-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/3-3.jpg new file mode 100755 index 0000000..9202cfe --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/3-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/3-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/3-4.jpg new file mode 100755 index 0000000..5436a8d --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/3-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/4-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/4-1.jpg new file mode 100755 index 0000000..3bab6d5 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/4-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/4-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/4-2.jpg new file mode 100755 index 0000000..b4901a6 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/4-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/4-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/4-3.jpg new file mode 100755 index 0000000..d754ad8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/4-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/4-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/4-4.jpg new file mode 100755 index 0000000..3a54b96 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/4-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/5-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/5-1.jpg new file mode 100755 index 0000000..3f7ba1f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/5-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/5-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/5-2.jpg new file mode 100755 index 0000000..fcacb75 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/5-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/5-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/5-3.jpg new file mode 100755 index 0000000..ce32f9f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/5-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/5-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/5-4.jpg new file mode 100755 index 0000000..b86b09a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/5-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/6-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/6-1.jpg new file mode 100755 index 0000000..f90cd81 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/6-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/6-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/6-2.jpg new file mode 100755 index 0000000..cf2a67a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/6-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/6-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/6-3.jpg new file mode 100755 index 0000000..2cd2fe2 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/6-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/6-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/6-4.jpg new file mode 100755 index 0000000..73f410f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/6-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/7-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/7-1.jpg new file mode 100755 index 0000000..08cd397 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/7-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/7-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/7-2.jpg new file mode 100755 index 0000000..a168ff8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/7-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/7-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/7-3.jpg new file mode 100755 index 0000000..5cda411 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/7-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/7-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/7-4.jpg new file mode 100755 index 0000000..5d63229 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/7-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/8-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/8-1.jpg new file mode 100755 index 0000000..a6faa7b --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/8-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/8-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/8-2.jpg new file mode 100755 index 0000000..0d9edbb --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/8-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/8-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/8-3.jpg new file mode 100755 index 0000000..91f8354 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/8-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/8-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/8-4.jpg new file mode 100755 index 0000000..cc0089c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/8-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/9-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/9-1.jpg new file mode 100755 index 0000000..be9c6bf --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/9-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/9-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/9-2.jpg new file mode 100755 index 0000000..e25da4c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/9-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/9-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/9-3.jpg new file mode 100755 index 0000000..cd384f8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/9-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/9-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/9-4.jpg new file mode 100755 index 0000000..441210e --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/9-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/carte.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/carte.jpg new file mode 100755 index 0000000..838ffac --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/carte.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/retro1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/retro1.jpg new file mode 100755 index 0000000..9651b06 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/retro1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/retro2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/retro2.jpg new file mode 100755 index 0000000..c5d3925 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/img/retro2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/0.wav b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/0.wav new file mode 100755 index 0000000..67d9abd --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/0.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/1.wav b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/1.wav new file mode 100755 index 0000000..9357c97 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/1.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/2.wav b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/2.wav new file mode 100755 index 0000000..92b1541 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/2.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/3.wav b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/3.wav new file mode 100755 index 0000000..45a6e42 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/3.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/4.wav b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/4.wav new file mode 100755 index 0000000..1f7ec90 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/4.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/5.wav b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/5.wav new file mode 100755 index 0000000..3627f96 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/5.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/pareggio.wav b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/pareggio.wav new file mode 100755 index 0000000..ff978e6 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/pareggio.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/perso.wav b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/perso.wav new file mode 100755 index 0000000..a454ba4 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/perso.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/vinto.wav b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/vinto.wav new file mode 100755 index 0000000..a6f3ac5 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 2/src/sounds/vinto.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/Frame.java b/JBriscola/all_versions/0.2/0.2 Beta 3/src/Frame.java new file mode 100755 index 0000000..7c5efbb --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/Frame.java | |||
| @@ -0,0 +1,306 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import javax.sound.sampled.*; | ||
| 24 | import java.io.*; | ||
| 25 | import java.awt.*; | ||
| 26 | import java.awt.event.*; | ||
| 27 | |||
| 28 | public class Frame extends JFrame { | ||
| 29 | public static boolean mazzo; | ||
| 30 | public static Main main; | ||
| 31 | public static Pannello pannello; | ||
| 32 | public static JPanel pannello2; | ||
| 33 | public static JButton button; | ||
| 34 | public static JMenuBar barraMenu; | ||
| 35 | public static JMenu file, puntoInterrogativo; | ||
| 36 | public static JMenuItem nuovaPartita, opzioni, esci, informazioni, punti; | ||
| 37 | public static ImageIcon retro1, retro2, ultimaCarta; | ||
| 38 | public static ImageIcon[] giocata = new ImageIcon[2]; | ||
| 39 | public static ImageIcon[] carteInMano = new ImageIcon[3]; | ||
| 40 | public static ImageIcon[] carteCPU = new ImageIcon[3]; | ||
| 41 | public static ImageIcon[] arrayCarteMescolate = new ImageIcon[40]; | ||
| 42 | public static ImageIcon[][] arrayCarte = new ImageIcon[10][4]; | ||
| 43 | public Frame() { | ||
| 44 | super( "Tronto's JBriscola " + main.version ); | ||
| 45 | mazzo = true; | ||
| 46 | main = new Main(); | ||
| 47 | pannello = new Pannello(); | ||
| 48 | pannello2 = new JPanel( new FlowLayout() ); | ||
| 49 | button = new JButton( main.stringaBottonePrendi ); | ||
| 50 | button.addActionListener( new ActionListener() { | ||
| 51 | public void actionPerformed( ActionEvent e ) { | ||
| 52 | if ( giocata[0] != null && giocata[1] != null ) | ||
| 53 | main.mano++; | ||
| 54 | try { | ||
| 55 | main.chiPrende(); | ||
| 56 | } catch ( Exception ex ) { | ||
| 57 | JOptionPane.showMessageDialog( Frame.this, main.stringaPrimaGioca, "JBriscola " + main.version, JOptionPane.WARNING_MESSAGE ); | ||
| 58 | } | ||
| 59 | if ( main.mano == 16 ) | ||
| 60 | JOptionPane.showMessageDialog( Frame.this, main.stringaUltime4, "JBriscola " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 61 | if ( main.mano == 17 ) { | ||
| 62 | mazzo = false; | ||
| 63 | ultimaCarta = null; | ||
| 64 | pannello.repaint(); | ||
| 65 | Frame.this.repaint(); | ||
| 66 | } | ||
| 67 | if ( main.mano == 20 ) { | ||
| 68 | String titolo = ""; | ||
| 69 | String suonoFinale = ""; | ||
| 70 | if ( main.punteggio > main.punteggioCPU ) { | ||
| 71 | titolo = main.stringaVinto; | ||
| 72 | suonoFinale = "sounds/perso.wav"; | ||
| 73 | } | ||
| 74 | if ( main.punteggio < main.punteggioCPU ) { | ||
| 75 | titolo = main.stringaPerso; | ||
| 76 | suonoFinale = "sounds/vinto.wav"; | ||
| 77 | } | ||
| 78 | if ( main.punteggio == main.punteggioCPU ) { | ||
| 79 | titolo = main.stringaPareggio; | ||
| 80 | suonoFinale = "sounds/pareggio.wav"; | ||
| 81 | } | ||
| 82 | if ( main.sound ) { | ||
| 83 | try { | ||
| 84 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( ClassLoader.getSystemResource( suonoFinale ) ); | ||
| 85 | AudioInputStream ais = AudioSystem.getAudioInputStream( ClassLoader.getSystemResource( suonoFinale ) ); | ||
| 86 | AudioFormat af = aff.getFormat(); | ||
| 87 | DataLine.Info info = new DataLine.Info( | ||
| 88 | Clip.class, | ||
| 89 | ais.getFormat(), | ||
| 90 | ( (int) ais.getFrameLength() * | ||
| 91 | af.getFrameSize() ) ); | ||
| 92 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 93 | ol.open(ais); | ||
| 94 | ol.loop( 0 ); | ||
| 95 | } catch ( Exception ex ) { | ||
| 96 | System.err.println( e ); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, titolo, JOptionPane.PLAIN_MESSAGE ); | ||
| 100 | } | ||
| 101 | } | ||
| 102 | } ); | ||
| 103 | button.addKeyListener( new KeyAdapter() { | ||
| 104 | public void keyReleased( KeyEvent key ) { | ||
| 105 | switch ( key.getKeyCode() ) { | ||
| 106 | case KeyEvent.VK_1: | ||
| 107 | if ( mettiCarta( 231, 500 ) ) { | ||
| 108 | if ( !main.CPUHaGiocato ) | ||
| 109 | main.giocaCPU(); | ||
| 110 | } | ||
| 111 | break; | ||
| 112 | case KeyEvent.VK_2: | ||
| 113 | if ( mettiCarta( 301, 500 ) ) { | ||
| 114 | if ( !main.CPUHaGiocato ) | ||
| 115 | main.giocaCPU(); | ||
| 116 | } | ||
| 117 | break; | ||
| 118 | case KeyEvent.VK_3: | ||
| 119 | if ( mettiCarta( 371, 500 ) ) { | ||
| 120 | if ( !main.CPUHaGiocato ) | ||
| 121 | main.giocaCPU(); | ||
| 122 | } | ||
| 123 | break; | ||
| 124 | case KeyEvent.VK_F1: | ||
| 125 | JOptionPane.showMessageDialog( Frame.this, main.stringaTasti2, "JBriscola - " + main.stringaTasti, JOptionPane.INFORMATION_MESSAGE ); | ||
| 126 | break; | ||
| 127 | case KeyEvent.VK_F2: | ||
| 128 | if ( main.mano == 20 ) { | ||
| 129 | main.mischia(); | ||
| 130 | pannello.repaint(); | ||
| 131 | repaint(); | ||
| 132 | } | ||
| 133 | else { | ||
| 134 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 135 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 136 | main.mischia(); | ||
| 137 | pannello.repaint(); | ||
| 138 | repaint(); | ||
| 139 | } | ||
| 140 | } | ||
| 141 | break; | ||
| 142 | case KeyEvent.VK_F3: | ||
| 143 | OptionFrame optionFrame = new OptionFrame(); | ||
| 144 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 145 | optionFrame.setResizable( false ); | ||
| 146 | optionFrame.setAlwaysOnTop( true ); | ||
| 147 | optionFrame.setSize( 300, 150 ); | ||
| 148 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, | ||
| 149 | (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 150 | optionFrame.setVisible( true ); | ||
| 151 | break; | ||
| 152 | case KeyEvent.VK_F4: | ||
| 153 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + "\n" + main.stringaComputer + main.punteggioCPU, main.stringaPunteggio, JOptionPane.PLAIN_MESSAGE ); | ||
| 154 | break; | ||
| 155 | case KeyEvent.VK_F5: | ||
| 156 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 157 | break; | ||
| 158 | case KeyEvent.VK_Q: | ||
| 159 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 160 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 161 | Frame.this.dispose(); | ||
| 162 | break; | ||
| 163 | } | ||
| 164 | } | ||
| 165 | }); | ||
| 166 | barraMenu = new JMenuBar(); | ||
| 167 | file = new JMenu( "File" ); | ||
| 168 | nuovaPartita = new JMenuItem( main.stringaNuovaPartita ); | ||
| 169 | nuovaPartita.addActionListener( new ActionListener() { | ||
| 170 | public void actionPerformed( ActionEvent e ) { | ||
| 171 | if ( main.mano == 20 ) { | ||
| 172 | main.mischia(); | ||
| 173 | pannello.repaint(); | ||
| 174 | repaint(); | ||
| 175 | } | ||
| 176 | else { | ||
| 177 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 178 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 179 | main.mischia(); | ||
| 180 | pannello.repaint(); | ||
| 181 | repaint(); | ||
| 182 | } | ||
| 183 | } | ||
| 184 | } | ||
| 185 | }); | ||
| 186 | opzioni = new JMenuItem( main.stringaOpzioni ); | ||
| 187 | opzioni.addActionListener( new ActionListener() { | ||
| 188 | public void actionPerformed( ActionEvent e ) { | ||
| 189 | OptionFrame optionFrame = new OptionFrame(); | ||
| 190 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 191 | optionFrame.setResizable( false ); | ||
| 192 | optionFrame.setAlwaysOnTop( true ); | ||
| 193 | optionFrame.setSize( 300, 150 ); | ||
| 194 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, | ||
| 195 | (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 196 | optionFrame.setVisible( true ); | ||
| 197 | } | ||
| 198 | }); | ||
| 199 | esci = new JMenuItem( main.stringaEsci ); | ||
| 200 | esci.addActionListener( new ActionListener() { | ||
| 201 | public void actionPerformed( ActionEvent e ) { | ||
| 202 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 203 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 204 | Frame.this.dispose(); | ||
| 205 | } | ||
| 206 | }); | ||
| 207 | file.add( nuovaPartita ); | ||
| 208 | file.add( opzioni ); | ||
| 209 | file.addSeparator(); | ||
| 210 | file.add( esci ); | ||
| 211 | puntoInterrogativo = new JMenu( "?" ); | ||
| 212 | informazioni = new JMenuItem( main.stringaInformazioni ); | ||
| 213 | informazioni.addActionListener( new ActionListener() { | ||
| 214 | public void actionPerformed( ActionEvent e ) { | ||
| 215 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 216 | } | ||
| 217 | } ); | ||
| 218 | punti = new JMenuItem( main.stringaPunteggio ); | ||
| 219 | punti.addActionListener( new ActionListener() { | ||
| 220 | public void actionPerformed( ActionEvent e ) { | ||
| 221 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + "\n" + main.stringaComputer + main.punteggioCPU, main.stringaPunteggio, JOptionPane.PLAIN_MESSAGE ); | ||
| 222 | } | ||
| 223 | } ); | ||
| 224 | puntoInterrogativo.add( punti ); | ||
| 225 | puntoInterrogativo.add( informazioni ); | ||
| 226 | barraMenu.add( file ); | ||
| 227 | barraMenu.add( puntoInterrogativo ); | ||
| 228 | setJMenuBar( barraMenu ); | ||
| 229 | retro1 = new ImageIcon( ClassLoader.getSystemResource( "img/retro1.jpg" ) ); | ||
| 230 | retro2 = new ImageIcon( ClassLoader.getSystemResource( "img/retro2.jpg" ) ); | ||
| 231 | for (int i = 0; i < 10; i++) | ||
| 232 | for (int j = 0; j < 4; j++) | ||
| 233 | arrayCarte[i][j] = new ImageIcon( ClassLoader.getSystemResource( "img/" + (i+1) + "-" + (j+1) + ".jpg" ) ); | ||
| 234 | main.mischia(); | ||
| 235 | pannello2.add( button ); | ||
| 236 | setLayout( new BorderLayout() ); | ||
| 237 | add( pannello, BorderLayout.CENTER ); | ||
| 238 | add( pannello2, BorderLayout.SOUTH ); | ||
| 239 | addMouseListener( | ||
| 240 | new MouseAdapter() { | ||
| 241 | public void mouseClicked ( MouseEvent e ) { | ||
| 242 | if ( mettiCarta( e.getX(), e.getY() ) ) { | ||
| 243 | if ( !main.CPUHaGiocato ) | ||
| 244 | main.giocaCPU(); | ||
| 245 | } | ||
| 246 | } | ||
| 247 | } | ||
| 248 | ); | ||
| 249 | addWindowListener( | ||
| 250 | new WindowAdapter() { | ||
| 251 | public void windowClosing( WindowEvent e ) { | ||
| 252 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 253 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 254 | System.exit( 0 ); | ||
| 255 | } | ||
| 256 | } | ||
| 257 | ); | ||
| 258 | } | ||
| 259 | public boolean mettiCarta( int x, int y ) { | ||
| 260 | if ( !main.toccaAllaCPU && giocata[0] == null ) { | ||
| 261 | if ( main.sound && | ||
| 262 | ( ( x > 230 && x < 290 && y > 340 && y < 566 && carteInMano[0] != null ) || | ||
| 263 | ( x > 300 && x < 360 && y > 340 && y < 566 && carteInMano[1] != null ) || | ||
| 264 | ( x > 370 && x < 430 && y > 340 && y < 566 && carteInMano[2] != null ) ) ) { | ||
| 265 | try { | ||
| 266 | double a = Math.random() * 6; | ||
| 267 | int i = (int) a; | ||
| 268 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( ClassLoader.getSystemResource("sounds/" + i + ".wav") ); | ||
| 269 | AudioInputStream ais = AudioSystem.getAudioInputStream( ClassLoader.getSystemResource("sounds/" + i + ".wav") ); | ||
| 270 | AudioFormat af = aff.getFormat(); | ||
| 271 | DataLine.Info info = new DataLine.Info( | ||
| 272 | Clip.class, | ||
| 273 | ais.getFormat(), | ||
| 274 | ( (int) ais.getFrameLength() * | ||
| 275 | af.getFrameSize() ) ); | ||
| 276 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 277 | ol.open(ais); | ||
| 278 | ol.loop( 0 ); | ||
| 279 | } catch ( Exception e ) { | ||
| 280 | System.err.println( e ); | ||
| 281 | } | ||
| 282 | } | ||
| 283 | if ( x > 230 && x < 290 && y > 340 && y < 566 ) { | ||
| 284 | giocata[0] = carteInMano[0]; | ||
| 285 | carteInMano[0] = null; | ||
| 286 | pannello.repaint(); | ||
| 287 | return true; | ||
| 288 | } | ||
| 289 | if ( x > 300 && x < 360 && y > 340 && y < 566 ) { | ||
| 290 | giocata[0] = carteInMano[1]; | ||
| 291 | carteInMano[1] = null; | ||
| 292 | pannello.repaint(); | ||
| 293 | return true; | ||
| 294 | } | ||
| 295 | if ( x > 370 && x < 430 && y > 340 && y < 566 ) { | ||
| 296 | giocata[0] = carteInMano[2]; | ||
| 297 | carteInMano[2] = null; | ||
| 298 | pannello.repaint(); | ||
| 299 | return true; | ||
| 300 | } | ||
| 301 | } | ||
| 302 | return false; | ||
| 303 | } | ||
| 304 | } | ||
| 305 | |||
| 306 | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/Main.java b/JBriscola/all_versions/0.2/0.2 Beta 3/src/Main.java new file mode 100755 index 0000000..0994b6a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/Main.java | |||
| @@ -0,0 +1,1080 @@ | |||
| 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 Frame frame; | ||
| 34 | public static Color color = new Color( 0, 150, 0 ); | ||
| 35 | public static String version = "0.2 Beta 3"; | ||
| 36 | public static String stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 37 | public static String stringaPrimaGioca = "Prima Gioca!"; | ||
| 38 | public static String stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 39 | public static String stringaVinto = "Hai Vinto!"; | ||
| 40 | public static String stringaPerso = "Hai Perso"; | ||
| 41 | public static String stringaPareggio = "Pareggio"; | ||
| 42 | public static String stringaGiocatore = "Giocatore: "; | ||
| 43 | public static String stringaComputer = "\nComputer: "; | ||
| 44 | public static String stringaNuovaPartita = "Nuova Partita"; | ||
| 45 | public static String stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 46 | public static String stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 47 | public static String stringaSi = "Si"; | ||
| 48 | public static String stringaNo = "No"; | ||
| 49 | public static String stringaOpzioni = "Opzioni..."; | ||
| 50 | public static String stringaEsci = "Esci"; | ||
| 51 | public static String stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 52 | public static String stringaLingua = "Lingua"; | ||
| 53 | public static String stringaAnnulla = "Annulla"; | ||
| 54 | public static String stringaIt = "Italiano"; | ||
| 55 | public static String stringaLa = "Latino"; | ||
| 56 | public static String stringaBL = "Dialetto Bellunese"; | ||
| 57 | public static String stringaBV = "Dialetto Basso Veneto"; | ||
| 58 | public static String stringaNecessarioRiavviare = "E' necessario riavviare JBriscola se sono state\nmodificate impostazioni riguardanti la lingua.\nAlcune parti saranno comunque tradotte prima."; | ||
| 59 | public static String stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 60 | public static String stringaInformazioni = "Informazioni"; | ||
| 61 | 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"; | ||
| 62 | public static String stringaSuono = "Effetti Sonori"; | ||
| 63 | public static String stringaPunteggio = "Punteggio"; | ||
| 64 | public static String stringaSfondo = "Sfondo"; | ||
| 65 | public static String stringaTasti = "Tasti rapidi"; | ||
| 66 | public static String stringaTasti2 = "1 Gioca la prima carta\n2 Gioca la seconda carta\n3 Gioca la terza carta\nF1 Visualizza questo messaggio\nF2 Nuova partita\nF3 Opzioni\nF4 Visualizza Punteggio\nF5 Informazioni\nq Esci"; | ||
| 67 | public static String lang, soundString; | ||
| 68 | public static File[] suoni = new File[6]; | ||
| 69 | public static File suonoVinto, suonoPerso, suonoPareggio; | ||
| 70 | public static void main( String args[] ) { | ||
| 71 | settaOpzioni(); | ||
| 72 | frame = new Frame(); | ||
| 73 | frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); | ||
| 74 | frame.setResizable( false ); | ||
| 75 | frame.setSize( 600, 600 ); | ||
| 76 | frame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 600) / 2, | ||
| 77 | (Toolkit.getDefaultToolkit().getScreenSize().height - 600) / 2); | ||
| 78 | frame.setVisible( true ); | ||
| 79 | } | ||
| 80 | public void mischia() { | ||
| 81 | mano = 0; | ||
| 82 | punteggio = 0; | ||
| 83 | punteggioCPU = 0; | ||
| 84 | cartaDaPescare = 6; | ||
| 85 | ImageIcon aux; | ||
| 86 | frame.mazzo = true; | ||
| 87 | toccaAllaCPU = false; | ||
| 88 | CPUHaGiocato = false; | ||
| 89 | haGiocatoPrima = true; | ||
| 90 | for ( int i = 0, k = 0; i < 10; i++ ) | ||
| 91 | for ( int j = 0; j < 4; j++, k++ ) | ||
| 92 | frame.arrayCarteMescolate[k] = frame.arrayCarte[i][j]; | ||
| 93 | for ( int i = 0; i < 391; i++ ) { | ||
| 94 | double a = Math.random() * 40; | ||
| 95 | int x = (int) a; | ||
| 96 | double b = Math.random() * 40; | ||
| 97 | int y = (int) b; | ||
| 98 | aux = frame.arrayCarteMescolate[x]; | ||
| 99 | frame.arrayCarteMescolate[x] = frame.arrayCarteMescolate[y]; | ||
| 100 | frame.arrayCarteMescolate[y] = aux; | ||
| 101 | } | ||
| 102 | char auxChar[] = frame.arrayCarteMescolate[39].toString().toCharArray(); | ||
| 103 | semeBriscola = auxChar[auxChar.length-5] - 49; | ||
| 104 | frame.carteInMano[0] = frame.arrayCarteMescolate[0]; | ||
| 105 | frame.carteInMano[1] = frame.arrayCarteMescolate[1]; | ||
| 106 | frame.carteInMano[2] = frame.arrayCarteMescolate[2]; | ||
| 107 | frame.carteCPU[0] = frame.arrayCarteMescolate[3]; | ||
| 108 | frame.carteCPU[1] = frame.arrayCarteMescolate[4]; | ||
| 109 | frame.carteCPU[2] = frame.arrayCarteMescolate[5]; | ||
| 110 | frame.ultimaCarta = frame.arrayCarteMescolate[39]; | ||
| 111 | frame.giocata[0] = null; | ||
| 112 | frame.giocata[1] = null; | ||
| 113 | } | ||
| 114 | public void giocaCPU() { | ||
| 115 | if ( mano < 16 ) { | ||
| 116 | if ( frame.giocata[0] == null ) { | ||
| 117 | if ( vaiPunti() ); | ||
| 118 | else if ( vaiLiscio() ); | ||
| 119 | else if ( vaiTaglio() ); | ||
| 120 | else if ( vaiBriscolaAlta() ); | ||
| 121 | else if ( vaiCarico() ); | ||
| 122 | else if ( vaiTre() ); | ||
| 123 | else if ( vaiAsso() ); | ||
| 124 | else; | ||
| 125 | } | ||
| 126 | else { | ||
| 127 | if ( haLisciato() ) { | ||
| 128 | if ( vaiSopra() ); | ||
| 129 | else if ( vaiLiscio() ); | ||
| 130 | else if ( vaiPunti() ); | ||
| 131 | else if ( vaiTaglio() ); | ||
| 132 | else if ( vaiTre() ); | ||
| 133 | else if ( vaiBriscolaAlta() ); | ||
| 134 | else if ( vaiCarico() ); | ||
| 135 | else if ( vaiAsso() ); | ||
| 136 | } else if ( haMessoPunti() ) { | ||
| 137 | if ( vaiSopra() ); | ||
| 138 | else if ( vaiLiscio() ); | ||
| 139 | else if ( vaiTaglio() ); | ||
| 140 | else if ( vaiPunti() ); | ||
| 141 | else if ( vaiTre() ); | ||
| 142 | else if ( vaiBriscolaAlta() ); | ||
| 143 | else if ( vaiCarico() ); | ||
| 144 | else if ( vaiAsso() ); | ||
| 145 | } else if ( haTagliato() ) { | ||
| 146 | if ( vaiLiscio() ); | ||
| 147 | else if ( vaiPunti() ); | ||
| 148 | else if ( vaiTaglio() ); | ||
| 149 | else if ( vaiTre() ); | ||
| 150 | else if ( vaiBriscolaAlta() ); | ||
| 151 | else if ( vaiCarico() ); | ||
| 152 | else if ( vaiAsso() ); | ||
| 153 | } else if ( haMessoBriscolaAlta() ) { | ||
| 154 | if ( vaiLiscio() ); | ||
| 155 | else if ( vaiPunti() ); | ||
| 156 | else if ( vaiTre() ); | ||
| 157 | else if ( vaiTaglio() ); | ||
| 158 | else if ( vaiBriscolaAlta() ); | ||
| 159 | else if ( vaiCarico() ); | ||
| 160 | else if ( vaiAsso() ); | ||
| 161 | } else if ( haMessoTre() ) { | ||
| 162 | if ( vaiAsso() ); | ||
| 163 | else if ( vaiLiscio() ); | ||
| 164 | else if ( vaiPunti() ); | ||
| 165 | else if ( vaiTaglio() ); | ||
| 166 | else if ( vaiBriscolaAlta() ); | ||
| 167 | else if ( vaiCarico() ); | ||
| 168 | } else if ( haMessoAsso() ) { | ||
| 169 | if ( vaiLiscio() ); | ||
| 170 | else if ( vaiPunti() ); | ||
| 171 | else if ( vaiTaglio() ); | ||
| 172 | else if ( vaiBriscolaAlta() ); | ||
| 173 | else if ( vaiCarico() ); | ||
| 174 | else if ( vaiTre() ); | ||
| 175 | } else if ( haCaricato() ) { | ||
| 176 | if ( vaiSopra() ); | ||
| 177 | else if ( vaiTre() ); | ||
| 178 | else if ( vaiBriscolaAlta() ); | ||
| 179 | else if ( vaiAsso() ); | ||
| 180 | else if ( vaiTaglio() ); | ||
| 181 | else if ( vaiLiscio() ); | ||
| 182 | else if ( vaiPunti() ); | ||
| 183 | else if ( vaiCarico() ); | ||
| 184 | } | ||
| 185 | } | ||
| 186 | } | ||
| 187 | else if ( mano == 16 ) { | ||
| 188 | if ( frame.giocata[0] == null ) { | ||
| 189 | char aux[]; | ||
| 190 | aux = frame.ultimaCarta.toString().toCharArray(); | ||
| 191 | if ( aux[aux.length-7] - 48 == 3 || aux[aux.length-7] - 48 == 1 ) { | ||
| 192 | if ( vaiCarico() ); | ||
| 193 | else if ( vaiPunti() ); | ||
| 194 | else if ( vaiLiscio() ); | ||
| 195 | else if ( vaiTaglio() ); | ||
| 196 | else if ( vaiBriscolaAlta() ); | ||
| 197 | else if ( vaiTre() ); | ||
| 198 | else if ( vaiAsso() ); | ||
| 199 | else; | ||
| 200 | } else { | ||
| 201 | if ( vaiPunti() ); | ||
| 202 | else if ( vaiLiscio() ); | ||
| 203 | else if ( vaiTaglio() ); | ||
| 204 | else if ( vaiBriscolaAlta() ); | ||
| 205 | else if ( vaiCarico() ); | ||
| 206 | else if ( vaiTre() ); | ||
| 207 | else if ( vaiAsso() ); | ||
| 208 | else; | ||
| 209 | } | ||
| 210 | } | ||
| 211 | else { | ||
| 212 | char aux[]; | ||
| 213 | aux = frame.ultimaCarta.toString().toCharArray(); | ||
| 214 | if ( aux[aux.length-7] - 48 == 3 || aux[aux.length-7] - 48 == 1 ) { | ||
| 215 | if ( haCaricato() ) { | ||
| 216 | if ( vaiSopra() ); | ||
| 217 | else if ( vaiLiscio() ); | ||
| 218 | else if ( vaiPunti() ); | ||
| 219 | else if ( vaiTre() ); | ||
| 220 | else if ( vaiTaglio() ); | ||
| 221 | else if ( vaiBriscolaAlta() ); | ||
| 222 | else if ( vaiAsso() ); | ||
| 223 | else if ( vaiCarico() ); | ||
| 224 | } | ||
| 225 | } else { | ||
| 226 | if ( haLisciato() ) { | ||
| 227 | if ( vaiSopra() ); | ||
| 228 | else if ( vaiLiscio() ); | ||
| 229 | else if ( vaiPunti() ); | ||
| 230 | else if ( vaiTaglio() ); | ||
| 231 | else if ( vaiTre() ); | ||
| 232 | else if ( vaiBriscolaAlta() ); | ||
| 233 | else if ( vaiCarico() ); | ||
| 234 | else if ( vaiAsso() ); | ||
| 235 | } else if ( haMessoPunti() ) { | ||
| 236 | if ( vaiSopra() ); | ||
| 237 | else if ( vaiLiscio() ); | ||
| 238 | else if ( vaiTaglio() ); | ||
| 239 | else if ( vaiPunti() ); | ||
| 240 | else if ( vaiTre() ); | ||
| 241 | else if ( vaiBriscolaAlta() ); | ||
| 242 | else if ( vaiCarico() ); | ||
| 243 | else if ( vaiAsso() ); | ||
| 244 | } else if ( haTagliato() ) { | ||
| 245 | if ( vaiLiscio() ); | ||
| 246 | else if ( vaiPunti() ); | ||
| 247 | else if ( vaiTaglio() ); | ||
| 248 | else if ( vaiTre() ); | ||
| 249 | else if ( vaiBriscolaAlta() ); | ||
| 250 | else if ( vaiCarico() ); | ||
| 251 | else if ( vaiAsso() ); | ||
| 252 | } else if ( haMessoBriscolaAlta() ) { | ||
| 253 | if ( vaiLiscio() ); | ||
| 254 | else if ( vaiPunti() ); | ||
| 255 | else if ( vaiTre() ); | ||
| 256 | else if ( vaiTaglio() ); | ||
| 257 | else if ( vaiBriscolaAlta() ); | ||
| 258 | else if ( vaiCarico() ); | ||
| 259 | else if ( vaiAsso() ); | ||
| 260 | } else if ( haMessoTre() ) { | ||
| 261 | if ( vaiAsso() ); | ||
| 262 | else if ( vaiLiscio() ); | ||
| 263 | else if ( vaiPunti() ); | ||
| 264 | else if ( vaiTaglio() ); | ||
| 265 | else if ( vaiBriscolaAlta() ); | ||
| 266 | else if ( vaiCarico() ); | ||
| 267 | } else if ( haMessoAsso() ) { | ||
| 268 | if ( vaiLiscio() ); | ||
| 269 | else if ( vaiPunti() ); | ||
| 270 | else if ( vaiTaglio() ); | ||
| 271 | else if ( vaiBriscolaAlta() ); | ||
| 272 | else if ( vaiCarico() ); | ||
| 273 | else if ( vaiTre() ); | ||
| 274 | } else if ( haCaricato() ) { | ||
| 275 | if ( vaiSopra() ); | ||
| 276 | else if ( vaiTre() ); | ||
| 277 | else if ( vaiBriscolaAlta() ); | ||
| 278 | else if ( vaiAsso() ); | ||
| 279 | else if ( vaiTaglio() ); | ||
| 280 | else if ( vaiLiscio() ); | ||
| 281 | else if ( vaiPunti() ); | ||
| 282 | else if ( vaiCarico() ); | ||
| 283 | } | ||
| 284 | } | ||
| 285 | } | ||
| 286 | } else if ( mano == 17 ) { | ||
| 287 | if ( frame.giocata[0] == null ) { | ||
| 288 | if ( hoAsso() ) { | ||
| 289 | if ( vaiTre() ); | ||
| 290 | else if ( vaiBriscolaAlta() ); | ||
| 291 | else if ( vaiTaglio() ); | ||
| 292 | else if ( vaiLiscio() ); | ||
| 293 | else if ( vaiPunti() ); | ||
| 294 | else if ( vaiAsso() ); | ||
| 295 | else if ( vaiCarico() ); | ||
| 296 | } else { | ||
| 297 | if ( vaiLiscio() ); | ||
| 298 | else if ( vaiPunti() ); | ||
| 299 | else if ( vaiTaglio() ); | ||
| 300 | else if ( vaiBriscolaAlta() ); | ||
| 301 | else if ( vaiCarico() ); | ||
| 302 | else if ( vaiTre() ); | ||
| 303 | } | ||
| 304 | } | ||
| 305 | else { | ||
| 306 | if ( haLisciato() ) { | ||
| 307 | if ( vaiSopra() ); | ||
| 308 | else if ( vaiLiscio() ); | ||
| 309 | else if ( vaiPunti() ); | ||
| 310 | else if ( vaiTaglio() ); | ||
| 311 | else if ( vaiTre() ); | ||
| 312 | else if ( vaiBriscolaAlta() ); | ||
| 313 | else if ( vaiCarico() ); | ||
| 314 | else if ( vaiAsso() ); | ||
| 315 | } else if ( haMessoPunti() ) { | ||
| 316 | if ( vaiSopra() ); | ||
| 317 | else if ( vaiLiscio() ); | ||
| 318 | else if ( vaiTaglio() ); | ||
| 319 | else if ( vaiPunti() ); | ||
| 320 | else if ( vaiTre() ); | ||
| 321 | else if ( vaiBriscolaAlta() ); | ||
| 322 | else if ( vaiCarico() ); | ||
| 323 | else if ( vaiAsso() ); | ||
| 324 | } else if ( haTagliato() ) { | ||
| 325 | if ( vaiLiscio() ); | ||
| 326 | else if ( vaiPunti() ); | ||
| 327 | else if ( vaiTaglio() ); | ||
| 328 | else if ( vaiTre() ); | ||
| 329 | else if ( vaiBriscolaAlta() ); | ||
| 330 | else if ( vaiCarico() ); | ||
| 331 | else if ( vaiAsso() ); | ||
| 332 | } else if ( haMessoBriscolaAlta() ) { | ||
| 333 | if ( vaiLiscio() ); | ||
| 334 | else if ( vaiPunti() ); | ||
| 335 | else if ( vaiTre() ); | ||
| 336 | else if ( vaiTaglio() ); | ||
| 337 | else if ( vaiBriscolaAlta() ); | ||
| 338 | else if ( vaiCarico() ); | ||
| 339 | else if ( vaiAsso() ); | ||
| 340 | } else if ( haMessoTre() ) { | ||
| 341 | if ( vaiAsso() ); | ||
| 342 | else if ( vaiLiscio() ); | ||
| 343 | else if ( vaiPunti() ); | ||
| 344 | else if ( vaiTaglio() ); | ||
| 345 | else if ( vaiBriscolaAlta() ); | ||
| 346 | else if ( vaiCarico() ); | ||
| 347 | } else if ( haMessoAsso() ) { | ||
| 348 | if ( vaiLiscio() ); | ||
| 349 | else if ( vaiPunti() ); | ||
| 350 | else if ( vaiTaglio() ); | ||
| 351 | else if ( vaiBriscolaAlta() ); | ||
| 352 | else if ( vaiCarico() ); | ||
| 353 | else if ( vaiTre() ); | ||
| 354 | } else if ( haCaricato() ) { | ||
| 355 | if ( vaiSopra() ); | ||
| 356 | else if ( vaiTre() ); | ||
| 357 | else if ( vaiBriscolaAlta() ); | ||
| 358 | else if ( vaiAsso() ); | ||
| 359 | else if ( vaiTaglio() ); | ||
| 360 | else if ( vaiLiscio() ); | ||
| 361 | else if ( vaiPunti() ); | ||
| 362 | else if ( vaiCarico() ); | ||
| 363 | } | ||
| 364 | } | ||
| 365 | } else if ( mano == 18 ) { | ||
| 366 | if ( frame.giocata[0] == null ) { | ||
| 367 | if ( vaiAsso() ); | ||
| 368 | else if ( vaiCarico() ); | ||
| 369 | else if ( vaiBriscolaAlta() ); | ||
| 370 | else if ( vaiTaglio() ); | ||
| 371 | else if ( vaiPunti() ); | ||
| 372 | else if ( vaiLiscio() ); | ||
| 373 | else if ( vaiTre() ); | ||
| 374 | } | ||
| 375 | else { | ||
| 376 | if ( haLisciato() ) { | ||
| 377 | if ( vaiSopra() ); | ||
| 378 | else if ( vaiLiscio() ); | ||
| 379 | else if ( vaiPunti() ); | ||
| 380 | else if ( vaiTaglio() ); | ||
| 381 | else if ( vaiTre() ); | ||
| 382 | else if ( vaiBriscolaAlta() ); | ||
| 383 | else if ( vaiCarico() ); | ||
| 384 | else if ( vaiAsso() ); | ||
| 385 | } else if ( haMessoPunti() ) { | ||
| 386 | if ( vaiSopra() ); | ||
| 387 | else if ( vaiLiscio() ); | ||
| 388 | else if ( vaiTaglio() ); | ||
| 389 | else if ( vaiPunti() ); | ||
| 390 | else if ( vaiTre() ); | ||
| 391 | else if ( vaiBriscolaAlta() ); | ||
| 392 | else if ( vaiCarico() ); | ||
| 393 | else if ( vaiAsso() ); | ||
| 394 | } else if ( haTagliato() ) { | ||
| 395 | if ( vaiLiscio() ); | ||
| 396 | else if ( vaiPunti() ); | ||
| 397 | else if ( vaiTaglio() ); | ||
| 398 | else if ( vaiTre() ); | ||
| 399 | else if ( vaiBriscolaAlta() ); | ||
| 400 | else if ( vaiCarico() ); | ||
| 401 | else if ( vaiAsso() ); | ||
| 402 | } else if ( haMessoBriscolaAlta() ) { | ||
| 403 | if ( vaiLiscio() ); | ||
| 404 | else if ( vaiPunti() ); | ||
| 405 | else if ( vaiTre() ); | ||
| 406 | else if ( vaiTaglio() ); | ||
| 407 | else if ( vaiBriscolaAlta() ); | ||
| 408 | else if ( vaiCarico() ); | ||
| 409 | else if ( vaiAsso() ); | ||
| 410 | } else if ( haMessoTre() ) { | ||
| 411 | if ( vaiAsso() ); | ||
| 412 | else if ( vaiLiscio() ); | ||
| 413 | else if ( vaiPunti() ); | ||
| 414 | else if ( vaiTaglio() ); | ||
| 415 | else if ( vaiBriscolaAlta() ); | ||
| 416 | else if ( vaiCarico() ); | ||
| 417 | } else if ( haMessoAsso() ) { | ||
| 418 | if ( vaiLiscio() ); | ||
| 419 | else if ( vaiPunti() ); | ||
| 420 | else if ( vaiTaglio() ); | ||
| 421 | else if ( vaiBriscolaAlta() ); | ||
| 422 | else if ( vaiCarico() ); | ||
| 423 | else if ( vaiTre() ); | ||
| 424 | } else if ( haCaricato() ) { | ||
| 425 | if ( vaiSopra() ); | ||
| 426 | else if ( vaiTre() ); | ||
| 427 | else if ( vaiBriscolaAlta() ); | ||
| 428 | else if ( vaiAsso() ); | ||
| 429 | else if ( vaiTaglio() ); | ||
| 430 | else if ( vaiLiscio() ); | ||
| 431 | else if ( vaiPunti() ); | ||
| 432 | else if ( vaiCarico() ); | ||
| 433 | } | ||
| 434 | } | ||
| 435 | } else { | ||
| 436 | if ( vaiTre() ); | ||
| 437 | else if ( vaiBriscolaAlta() ); | ||
| 438 | else if ( vaiAsso() ); | ||
| 439 | else if ( vaiTaglio() ); | ||
| 440 | else if ( vaiLiscio() ); | ||
| 441 | else if ( vaiPunti() ); | ||
| 442 | else if ( vaiCarico() ); | ||
| 443 | } | ||
| 444 | frame.giocata[1] = frame.carteCPU[cartaDaGiocare]; | ||
| 445 | frame.carteCPU[cartaDaGiocare] = null; | ||
| 446 | frame.pannello.repaint(); | ||
| 447 | CPUHaGiocato = true; | ||
| 448 | if ( frame.giocata[0] == null ) | ||
| 449 | toccaAllaCPU = false; | ||
| 450 | } | ||
| 451 | public void chiPrende() { | ||
| 452 | char aux[], auxCPU[]; | ||
| 453 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 454 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 455 | giocatorePrende( ( (aux[aux.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) ) | ||
| 456 | || ( (aux[aux.length-5] == auxCPU[auxCPU.length-5]) && laPrimaEPiuAlta( aux[aux.length-7] - 48, auxCPU[auxCPU.length-7] - 48 ) ) | ||
| 457 | || ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (aux[aux.length-5] != auxCPU[auxCPU.length-5]) && haGiocatoPrima ) ); | ||
| 458 | } | ||
| 459 | public boolean laPrimaEPiuAlta( int prima, int seconda ) { | ||
| 460 | int a, b; | ||
| 461 | switch ( prima ) { | ||
| 462 | case 0: | ||
| 463 | a = 10; | ||
| 464 | break; | ||
| 465 | case 1: | ||
| 466 | a = 12; | ||
| 467 | break; | ||
| 468 | case 3: | ||
| 469 | a = 11; | ||
| 470 | break; | ||
| 471 | default: | ||
| 472 | a = prima; | ||
| 473 | break; | ||
| 474 | } | ||
| 475 | switch ( seconda ) { | ||
| 476 | case 0: | ||
| 477 | b = 10; | ||
| 478 | break; | ||
| 479 | case 1: | ||
| 480 | b = 12; | ||
| 481 | break; | ||
| 482 | case 3: | ||
| 483 | b = 11; | ||
| 484 | break; | ||
| 485 | default: | ||
| 486 | b = seconda; | ||
| 487 | break; | ||
| 488 | } | ||
| 489 | return a > b; | ||
| 490 | } | ||
| 491 | public void giocatorePrende( boolean giocatore ) { | ||
| 492 | if ( giocatore ) { | ||
| 493 | toccaAllaCPU = CPUHaGiocato = false; | ||
| 494 | haGiocatoPrima = true; | ||
| 495 | } | ||
| 496 | else { | ||
| 497 | toccaAllaCPU = true; | ||
| 498 | CPUHaGiocato = haGiocatoPrima = false; | ||
| 499 | } | ||
| 500 | daiPunti( giocatore ); | ||
| 501 | if ( toccaAllaCPU ) | ||
| 502 | giocaCPU(); | ||
| 503 | } | ||
| 504 | public void daiPunti( boolean giocatore ) { | ||
| 505 | char aux[], auxCPU[]; | ||
| 506 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 507 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 508 | int punti = 0; | ||
| 509 | switch( aux[aux.length-7] - 48 ) { | ||
| 510 | case 0: | ||
| 511 | punti += 4; | ||
| 512 | break; | ||
| 513 | case 1: | ||
| 514 | punti += 11; | ||
| 515 | break; | ||
| 516 | case 3: | ||
| 517 | punti += 10; | ||
| 518 | break; | ||
| 519 | case 8: | ||
| 520 | punti += 2; | ||
| 521 | break; | ||
| 522 | case 9: | ||
| 523 | punti += 3; | ||
| 524 | break; | ||
| 525 | default: | ||
| 526 | break; | ||
| 527 | } | ||
| 528 | switch( auxCPU[auxCPU.length-7] - 48 ) { | ||
| 529 | case 0: | ||
| 530 | punti += 4; | ||
| 531 | break; | ||
| 532 | case 1: | ||
| 533 | punti += 11; | ||
| 534 | break; | ||
| 535 | case 3: | ||
| 536 | punti += 10; | ||
| 537 | break; | ||
| 538 | case 8: | ||
| 539 | punti += 2; | ||
| 540 | break; | ||
| 541 | case 9: | ||
| 542 | punti += 3; | ||
| 543 | break; | ||
| 544 | default: | ||
| 545 | break; | ||
| 546 | } | ||
| 547 | frame.giocata[0] = frame.giocata[1] = null; | ||
| 548 | if ( giocatore ) { | ||
| 549 | punteggio += punti; | ||
| 550 | if ( mano < 18 ) { | ||
| 551 | if ( frame.carteInMano[0] == null ) | ||
| 552 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 553 | if ( frame.carteInMano[1] == null ) | ||
| 554 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 555 | if ( frame.carteInMano[2] == null ) | ||
| 556 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 557 | cartaDaPescare++; | ||
| 558 | if ( frame.carteCPU[0] == null ) | ||
| 559 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 560 | if ( frame.carteCPU[1] == null ) | ||
| 561 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 562 | if ( frame.carteCPU[2] == null ) | ||
| 563 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 564 | cartaDaPescare++; | ||
| 565 | } | ||
| 566 | } | ||
| 567 | else { | ||
| 568 | punteggioCPU += punti; | ||
| 569 | if ( mano < 18 ) { | ||
| 570 | if ( frame.carteCPU[0] == null ) | ||
| 571 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 572 | if ( frame.carteCPU[1] == null ) | ||
| 573 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 574 | if ( frame.carteCPU[2] == null ) | ||
| 575 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 576 | cartaDaPescare++; | ||
| 577 | if ( frame.carteInMano[0] == null ) | ||
| 578 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 579 | if ( frame.carteInMano[1] == null ) | ||
| 580 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 581 | if ( frame.carteInMano[2] == null ) | ||
| 582 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 583 | cartaDaPescare++; | ||
| 584 | } | ||
| 585 | } | ||
| 586 | frame.pannello.repaint(); | ||
| 587 | frame.repaint(); | ||
| 588 | } | ||
| 589 | public boolean haLisciato() { | ||
| 590 | char auxCPU[]; | ||
| 591 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 592 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 593 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 594 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ); | ||
| 595 | } | ||
| 596 | public boolean haMessoPunti() { | ||
| 597 | char auxCPU[]; | ||
| 598 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 599 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 600 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || | ||
| 601 | (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ); | ||
| 602 | } | ||
| 603 | public boolean haTagliato() { | ||
| 604 | char auxCPU[]; | ||
| 605 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 606 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 607 | (auxCPU[auxCPU.length-7] - 48 != 0) && (auxCPU[auxCPU.length-7] - 48 != 1) && | ||
| 608 | (auxCPU[auxCPU.length-7] - 48 != 3) && (auxCPU[auxCPU.length-7] - 48 <= 7) ); | ||
| 609 | } | ||
| 610 | public boolean haMessoBriscolaAlta() { | ||
| 611 | char auxCPU[]; | ||
| 612 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 613 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 614 | ( (auxCPU[auxCPU.length-7] - 48 == 0) || (auxCPU[auxCPU.length-7] - 48 == 8) || | ||
| 615 | (auxCPU[auxCPU.length-7] - 48 == 9) ) ); | ||
| 616 | } | ||
| 617 | public boolean haMessoTre() { | ||
| 618 | char auxCPU[]; | ||
| 619 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 620 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 621 | (auxCPU[auxCPU.length-7] - 48 == 3) ); | ||
| 622 | } | ||
| 623 | public boolean haMessoAsso() { | ||
| 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 == 1) ); | ||
| 628 | } | ||
| 629 | public boolean haCaricato() { | ||
| 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 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ); | ||
| 634 | } | ||
| 635 | public boolean vaiLiscio() { | ||
| 636 | char auxCPU[]; | ||
| 637 | for ( int i = 0; i < 3; i++ ) { | ||
| 638 | if ( frame.carteCPU[i] != null ) { | ||
| 639 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 640 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 641 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 642 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ) { | ||
| 643 | cartaDaGiocare = i; | ||
| 644 | return true; | ||
| 645 | } | ||
| 646 | } | ||
| 647 | } | ||
| 648 | return false; | ||
| 649 | } | ||
| 650 | public boolean vaiPunti() { | ||
| 651 | char[] auxCPU; | ||
| 652 | for ( int i = 0; i < 3; i++ ) { | ||
| 653 | if ( frame.carteCPU[i] != null ) { | ||
| 654 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 655 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 8 ) ) { | ||
| 656 | cartaDaGiocare = i; | ||
| 657 | return true; | ||
| 658 | } | ||
| 659 | } | ||
| 660 | } | ||
| 661 | for ( int i = 0; i < 3; i++ ) { | ||
| 662 | if ( frame.carteCPU[i] != null ) { | ||
| 663 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 664 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 9 ) ) { | ||
| 665 | cartaDaGiocare = i; | ||
| 666 | return true; | ||
| 667 | } | ||
| 668 | } | ||
| 669 | } | ||
| 670 | for ( int i = 0; i < 3; i++ ) { | ||
| 671 | if ( frame.carteCPU[i] != null ) { | ||
| 672 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 673 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 0 ) ) { | ||
| 674 | cartaDaGiocare = i; | ||
| 675 | return true; | ||
| 676 | } | ||
| 677 | } | ||
| 678 | } | ||
| 679 | return false; | ||
| 680 | } | ||
| 681 | public boolean vaiTaglio() { | ||
| 682 | char auxCPU[]; | ||
| 683 | for ( int i = 0; i < 3; i++ ) { | ||
| 684 | if ( frame.carteCPU[i] != null ) { | ||
| 685 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 686 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && | ||
| 687 | (auxCPU[auxCPU.length-7] - 48 != 0) && (auxCPU[auxCPU.length-7] - 48 != 1) && | ||
| 688 | (auxCPU[auxCPU.length-7] - 48 != 3) && (auxCPU[auxCPU.length-7] - 48 <= 7) ) { | ||
| 689 | cartaDaGiocare = i; | ||
| 690 | return true; | ||
| 691 | } | ||
| 692 | } | ||
| 693 | } | ||
| 694 | return false; | ||
| 695 | } | ||
| 696 | public boolean vaiBriscolaAlta() { | ||
| 697 | char[] auxCPU; | ||
| 698 | for ( int i = 0; i < 3; i++ ) { | ||
| 699 | if ( frame.carteCPU[i] != null ) { | ||
| 700 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 701 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 8 ) ) { | ||
| 702 | cartaDaGiocare = i; | ||
| 703 | return true; | ||
| 704 | } | ||
| 705 | } | ||
| 706 | } | ||
| 707 | for ( int i = 0; i < 3; i++ ) { | ||
| 708 | if ( frame.carteCPU[i] != null ) { | ||
| 709 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 710 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 9 ) ) { | ||
| 711 | cartaDaGiocare = i; | ||
| 712 | return true; | ||
| 713 | } | ||
| 714 | } | ||
| 715 | } | ||
| 716 | for ( int i = 0; i < 3; i++ ) { | ||
| 717 | if ( frame.carteCPU[i] != null ) { | ||
| 718 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 719 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 0 ) ) { | ||
| 720 | cartaDaGiocare = i; | ||
| 721 | return true; | ||
| 722 | } | ||
| 723 | } | ||
| 724 | } | ||
| 725 | return false; | ||
| 726 | } | ||
| 727 | public boolean vaiTre() { | ||
| 728 | char auxCPU[]; | ||
| 729 | for ( int i = 0; i < 3; i++ ) { | ||
| 730 | if ( frame.carteCPU[i] != null ) { | ||
| 731 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 732 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && (auxCPU[auxCPU.length-7] - 48 == 3) ) { | ||
| 733 | cartaDaGiocare = i; | ||
| 734 | return true; | ||
| 735 | } | ||
| 736 | } | ||
| 737 | } | ||
| 738 | return false; | ||
| 739 | } | ||
| 740 | public boolean vaiAsso() { | ||
| 741 | char auxCPU[]; | ||
| 742 | for ( int i = 0; i < 3; i++ ) { | ||
| 743 | if ( frame.carteCPU[i] != null ) { | ||
| 744 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 745 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && (auxCPU[auxCPU.length-7] - 48 == 1) ) { | ||
| 746 | cartaDaGiocare = i; | ||
| 747 | return true; | ||
| 748 | } | ||
| 749 | } | ||
| 750 | } | ||
| 751 | return false; | ||
| 752 | } | ||
| 753 | public boolean vaiCarico() { | ||
| 754 | char[] auxCPU; | ||
| 755 | for ( int i = 0; i < 3; i++ ) { | ||
| 756 | if ( frame.carteCPU[i] != null ) { | ||
| 757 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 758 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 3 ) ) { | ||
| 759 | cartaDaGiocare = i; | ||
| 760 | return true; | ||
| 761 | } | ||
| 762 | } | ||
| 763 | } | ||
| 764 | for ( int i = 0; i < 3; i++ ) { | ||
| 765 | if ( frame.carteCPU[i] != null ) { | ||
| 766 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 767 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 1 ) ) { | ||
| 768 | cartaDaGiocare = i; | ||
| 769 | return true; | ||
| 770 | } | ||
| 771 | } | ||
| 772 | } | ||
| 773 | return false; | ||
| 774 | } | ||
| 775 | public boolean vaiSopra() { | ||
| 776 | if ( frame.giocata[0] == null ) | ||
| 777 | return false; | ||
| 778 | int a = -1; | ||
| 779 | int b = -1; | ||
| 780 | int c = -1; | ||
| 781 | boolean laPrimaPuoAndareSopra = false; | ||
| 782 | boolean laSecondaPuoAndareSopra = false; | ||
| 783 | boolean laTerzaPuoAndareSopra = false; | ||
| 784 | char[] auxCPU1 = new char[1024]; | ||
| 785 | char[] auxCPU2 = new char[1024]; | ||
| 786 | char[] auxCPU3 = new char[1024]; | ||
| 787 | char[] aux = frame.giocata[0].toString().toCharArray(); | ||
| 788 | if ( aux[aux.length-7] - 48 == 1 ) | ||
| 789 | return false; | ||
| 790 | if ( frame.carteCPU[0] != null ) { | ||
| 791 | auxCPU1 = frame.carteCPU[0].toString().toCharArray(); | ||
| 792 | a = auxCPU1[auxCPU1.length-7] - 48; | ||
| 793 | if ( (auxCPU1[auxCPU1.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( a, aux[aux.length-7] - 48 ) ) | ||
| 794 | laPrimaPuoAndareSopra = true; | ||
| 795 | } | ||
| 796 | if ( frame.carteCPU[1] != null ) { | ||
| 797 | auxCPU2 = frame.carteCPU[1].toString().toCharArray(); | ||
| 798 | b = auxCPU2[auxCPU2.length-7] - 48; | ||
| 799 | if ( (auxCPU2[auxCPU2.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( b, aux[aux.length-7] - 48 ) ) | ||
| 800 | laSecondaPuoAndareSopra = true; | ||
| 801 | } | ||
| 802 | if ( frame.carteCPU[2] != null ) { | ||
| 803 | auxCPU3 = frame.carteCPU[2].toString().toCharArray(); | ||
| 804 | c = auxCPU3[auxCPU3.length-7] - 48; | ||
| 805 | if ( (auxCPU3[auxCPU3.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( c, aux[aux.length-7] - 48 ) ) | ||
| 806 | laTerzaPuoAndareSopra = true; | ||
| 807 | } | ||
| 808 | if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 809 | return false; | ||
| 810 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 811 | cartaDaGiocare = 0; | ||
| 812 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 813 | cartaDaGiocare = 1; | ||
| 814 | else if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 815 | cartaDaGiocare = 2; | ||
| 816 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 817 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 818 | cartaDaGiocare = 0; | ||
| 819 | else | ||
| 820 | cartaDaGiocare = 1; | ||
| 821 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 822 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 823 | cartaDaGiocare = 1; | ||
| 824 | else | ||
| 825 | cartaDaGiocare = 2; | ||
| 826 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 827 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 828 | cartaDaGiocare = 0; | ||
| 829 | else | ||
| 830 | cartaDaGiocare = 2; | ||
| 831 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 832 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 833 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 834 | cartaDaGiocare = 0; | ||
| 835 | else | ||
| 836 | cartaDaGiocare = 2; | ||
| 837 | else | ||
| 838 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 839 | cartaDaGiocare = 1; | ||
| 840 | else | ||
| 841 | cartaDaGiocare = 2; | ||
| 842 | aux = frame.carteCPU[cartaDaGiocare].toString().toCharArray(); | ||
| 843 | if ( (aux[aux.length-7] - 48 != 0) && (aux[aux.length-7] - 48 != 1) && | ||
| 844 | (aux[aux.length-7] - 48 != 3) && (aux[aux.length-7] - 48 <= 7) ) | ||
| 845 | return false; | ||
| 846 | return true; | ||
| 847 | } | ||
| 848 | public boolean hoCarico() { | ||
| 849 | char auxCPU[]; | ||
| 850 | for ( int i = 0; i < 3; i++ ) { | ||
| 851 | if ( frame.carteCPU[i] != null ) { | ||
| 852 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 853 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 854 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ) { | ||
| 855 | return true; | ||
| 856 | } | ||
| 857 | } | ||
| 858 | } | ||
| 859 | return false; | ||
| 860 | } | ||
| 861 | public boolean hoAsso() { | ||
| 862 | char auxCPU[]; | ||
| 863 | for ( int i = 0; i < 3; i++ ) { | ||
| 864 | if ( frame.carteCPU[i] != null ) { | ||
| 865 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 866 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 1 ) ) { | ||
| 867 | return true; | ||
| 868 | } | ||
| 869 | } | ||
| 870 | } | ||
| 871 | return false; | ||
| 872 | } | ||
| 873 | public boolean hoTre() { | ||
| 874 | char auxCPU[]; | ||
| 875 | for ( int i = 0; i < 3; i++ ) { | ||
| 876 | if ( frame.carteCPU[i] != null ) { | ||
| 877 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 878 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 3 ) ) { | ||
| 879 | return true; | ||
| 880 | } | ||
| 881 | } | ||
| 882 | } | ||
| 883 | return false; | ||
| 884 | } | ||
| 885 | public boolean hoBriscolaAlta() { | ||
| 886 | char auxCPU[]; | ||
| 887 | for ( int i = 0; i < 3; i++ ) { | ||
| 888 | if ( frame.carteCPU[i] != null ) { | ||
| 889 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 890 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 891 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ) { | ||
| 892 | return true; | ||
| 893 | } | ||
| 894 | } | ||
| 895 | } | ||
| 896 | return false; | ||
| 897 | } | ||
| 898 | public boolean hoTaglio() { | ||
| 899 | char auxCPU[]; | ||
| 900 | for ( int i = 0; i < 3; i++ ) { | ||
| 901 | if ( frame.carteCPU[i] != null ) { | ||
| 902 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 903 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 904 | (auxCPU[auxCPU.length-7] - 48 < 8 ) && (auxCPU[auxCPU.length-7] - 48 != 3 ) | ||
| 905 | && (auxCPU[auxCPU.length-7] - 48 != 1 ) && (auxCPU[auxCPU.length-7] - 48 != 0 ) ) { | ||
| 906 | return true; | ||
| 907 | } | ||
| 908 | } | ||
| 909 | } | ||
| 910 | return false; | ||
| 911 | } | ||
| 912 | public static void settaOpzioni() { | ||
| 913 | lang = "it"; | ||
| 914 | soundString = "suono=si"; | ||
| 915 | int r = 0; | ||
| 916 | int g = 150; | ||
| 917 | int b = 0; | ||
| 918 | Scanner scanner = null; | ||
| 919 | File file = new File( "JBriscolaConfig.txt" ); | ||
| 920 | if ( file.exists() ) { | ||
| 921 | try { | ||
| 922 | scanner = new Scanner( file ); | ||
| 923 | } catch ( FileNotFoundException e ) { } | ||
| 924 | try { | ||
| 925 | lang = scanner.next(); | ||
| 926 | soundString = scanner.next(); | ||
| 927 | r = scanner.nextInt(); | ||
| 928 | g = scanner.nextInt(); | ||
| 929 | b = scanner.nextInt(); | ||
| 930 | } catch ( NoSuchElementException e ) { } | ||
| 931 | } | ||
| 932 | else { | ||
| 933 | lang = "it"; | ||
| 934 | soundString = "suono=si"; | ||
| 935 | r = 0; | ||
| 936 | g = 150; | ||
| 937 | b = 0; | ||
| 938 | } | ||
| 939 | if ( lang.equals( "it" ) ) { | ||
| 940 | stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 941 | stringaPrimaGioca = "Prima Gioca!"; | ||
| 942 | stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 943 | stringaVinto = "Hai Vinto!"; | ||
| 944 | stringaPerso = "Hai Perso"; | ||
| 945 | stringaPareggio = "Pareggio"; | ||
| 946 | stringaGiocatore = "Giocatore: "; | ||
| 947 | stringaComputer = "\nComputer: "; | ||
| 948 | stringaNuovaPartita = "Nuova Partita"; | ||
| 949 | stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 950 | stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 951 | stringaSi = "Si"; | ||
| 952 | stringaNo = "No"; | ||
| 953 | stringaOpzioni = "Opzioni..."; | ||
| 954 | stringaEsci = "Esci"; | ||
| 955 | stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 956 | stringaLingua = "Lingua"; | ||
| 957 | stringaAnnulla = "Annulla"; | ||
| 958 | stringaIt = "Italiano"; | ||
| 959 | stringaLa = "Latino"; | ||
| 960 | stringaBL = "Dialetto Bellunese"; | ||
| 961 | stringaBV = "Dialetto Basso Veneto"; | ||
| 962 | stringaNecessarioRiavviare = "E' necessario riavviare JBriscola se sono state\nmodificate impostazioni riguardanti la lingua\nAlcune parti saranno comunque tradotte prima."; | ||
| 963 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 964 | stringaInformazioni = "Informazioni"; | ||
| 965 | 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"; | ||
| 966 | stringaSuono = "Effetti sonori"; | ||
| 967 | stringaPunteggio = "Punteggio"; | ||
| 968 | stringaSfondo = "Sfondo"; | ||
| 969 | stringaTasti = "Tasti rapidi"; | ||
| 970 | stringaTasti2 = "1 Gioca la prima carta\n2 Gioca la seconda carta\n3 Gioca la terza carta\nF1 Visualizza questo messaggio\nF2 Nuova partita\nF3 Opzioni\nF4 Visualizza Punteggio\nF5 Informazioni\nq Esci"; | ||
| 971 | } | ||
| 972 | else if ( lang.equals( "la" ) ) { | ||
| 973 | stringaBottonePrendi = "CAPIS/RELINQVIS CHARTAS"; | ||
| 974 | stringaPrimaGioca = "ANTE CHARTAM PONE!"; | ||
| 975 | stringaUltime4 = "CHARTA POSTREMA - INTVERE BRISCOLAM!"; | ||
| 976 | stringaVinto = "VICISTI!"; | ||
| 977 | stringaPerso = "PERDIDISTI"; | ||
| 978 | stringaPareggio = "AEQVATIO!"; | ||
| 979 | stringaGiocatore = "LVSOR: "; | ||
| 980 | stringaComputer = "\nCOMPVTER: "; | ||
| 981 | stringaNuovaPartita = "NOVA LVSO"; | ||
| 982 | stringaVuoiDavveroIniziare = "NOVAM LVSIONEM INCIPERE?"; | ||
| 983 | stringaVuoiDavveroUscire = "EXIRE?"; | ||
| 984 | stringaSi = "ID VOLO"; | ||
| 985 | stringaNo = "NOLO"; | ||
| 986 | stringaOpzioni = "OPTIONES..."; | ||
| 987 | stringaEsci = "EXIRE"; | ||
| 988 | stringaImpossibileConfigurare = "CONFIGVRATIONIS FILE SCRIBERE NON POTVI.\nERROREM ME CERTIOREM FACITE: sebastiano@luganega.org\n\nEXCEPTIO:\n"; | ||
| 989 | stringaLingua = "LINGVA"; | ||
| 990 | stringaAnnulla = "ABROGA"; | ||
| 991 | stringaIt = "ITALICA"; | ||
| 992 | stringaLa = "LATINA"; | ||
| 993 | stringaBL = "BELLUNI"; | ||
| 994 | stringaBV = "VENETIAE"; | ||
| 995 | stringaNecessarioRiavviare = "JBRISCOLAM RVRSVS INCIPERE NECESSE EST\nSI LINGVA PRAELATIONES NOVATAE SVNT.\nALIQVAE ANTE ID VERSA ERVNT"; | ||
| 996 | stringaModificaOpzioni = "OPTIONES NOVARE"; | ||
| 997 | stringaInformazioni = "INFORMATIONES"; | ||
| 998 | 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"; | ||
| 999 | stringaSuono = "SONVS"; | ||
| 1000 | stringaPunteggio = "NVMERI"; | ||
| 1001 | stringaSfondo = "COLOR"; | ||
| 1002 | stringaTasti = "TASTI RAPIDI"; | ||
| 1003 | stringaTasti2 = "1 PONE CHARTAM PRIMAM\n2 PONE CHARTAM SECUNDAM\n3 PONE CHARTAM TERTIAM\nF1 HEAC INFORMATIONES\nF2 NOVA LVSO\nF3 OPTIONES\nF4 NVMERI\nF5 INFORMATIONES\nq EXIRE"; | ||
| 1004 | } | ||
| 1005 | if ( lang.equals( "bl" ) ) { | ||
| 1006 | stringaBottonePrendi = "Cio' su/lasa le carte"; | ||
| 1007 | stringaPrimaGioca = "Prima Duga!"; | ||
| 1008 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1009 | stringaVinto = "Te ha vint!"; | ||
| 1010 | stringaPerso = "Te ha pers"; | ||
| 1011 | stringaPareggio = "Pari"; | ||
| 1012 | stringaGiocatore = "Dugador: "; | ||
| 1013 | stringaComputer = "\nComputer: "; | ||
| 1014 | stringaNuovaPartita = "Taca n'altra partida"; | ||
| 1015 | stringaVuoiDavveroIniziare = "Utu sul serio scuminziar n'altra partida?"; | ||
| 1016 | stringaVuoiDavveroUscire = "Utu sul serio stusar su?"; | ||
| 1017 | stringaSi = "Si"; | ||
| 1018 | stringaNo = "No"; | ||
| 1019 | stringaOpzioni = "Opzioni..."; | ||
| 1020 | stringaEsci = "Stusa su"; | ||
| 1021 | stringaImpossibileConfigurare = "No ghe ho riva' a scrivere al file de configurazion.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1022 | stringaLingua = "Lengua"; | ||
| 1023 | stringaAnnulla = "Annulla"; | ||
| 1024 | stringaIt = "Italian"; | ||
| 1025 | stringaLa = "Latin"; | ||
| 1026 | stringaBL = "Dialeto de Belun"; | ||
| 1027 | stringaBV = "Dialeto de la basa"; | ||
| 1028 | stringaNecessarioRiavviare = "Se te ha cambia' la lengua te toca\nstusar su e impizar de novo al dugo\nPero' zerte robe le e' belche tradote."; | ||
| 1029 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1030 | stringaInformazioni = "Informazioni"; | ||
| 1031 | 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"; | ||
| 1032 | stringaSuono = "Efeti sonori"; | ||
| 1033 | stringaPunteggio = "Varda i punti"; | ||
| 1034 | stringaSfondo = "Sfondo"; | ||
| 1035 | stringaTasti = "Tasti rapidi"; | ||
| 1036 | stringaTasti2 = "1 Duga la prima carta\n2 Duga la seconda carta\n3 Duga la terza carta\nF1 Tasti rapidi\nF2 Taca n'altra partida\nF3 Opzioni\nF4 Varda i punti\nF5 Informazioni\nq Stusa su"; | ||
| 1037 | } | ||
| 1038 | if ( lang.equals( "bv" ) ) { | ||
| 1039 | stringaBottonePrendi = "Ciapa su/lasa e carte"; | ||
| 1040 | stringaPrimaGioca = "Prima Zuga!"; | ||
| 1041 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1042 | stringaVinto = "Ti ga vinto!"; | ||
| 1043 | stringaPerso = "Ti ga perso"; | ||
| 1044 | stringaPareggio = "Pari"; | ||
| 1045 | stringaGiocatore = "Zugador: "; | ||
| 1046 | stringaComputer = "\nComputer: "; | ||
| 1047 | stringaNuovaPartita = "N'altra Partida"; | ||
| 1048 | stringaVuoiDavveroIniziare = "Ti vol sul serio scuminziar n'altra partida?"; | ||
| 1049 | stringaVuoiDavveroUscire = "Ti vol sul serio stusar su?"; | ||
| 1050 | stringaSi = "Si"; | ||
| 1051 | stringaNo = "No"; | ||
| 1052 | stringaOpzioni = "Opzioni..."; | ||
| 1053 | stringaEsci = "Stusa su"; | ||
| 1054 | stringaImpossibileConfigurare = "No ghe son riusito a scrivere al file de configurazione.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1055 | stringaLingua = "Lengua"; | ||
| 1056 | stringaAnnulla = "Annulla"; | ||
| 1057 | stringaIt = "Italian"; | ||
| 1058 | stringaLa = "Latin"; | ||
| 1059 | stringaBL = "Dialeto Belumat"; | ||
| 1060 | stringaBV = "Dialeto Veneto"; | ||
| 1061 | stringaNecessarioRiavviare = "Se ti ga cambia' la lengua te toca\nstusar su e impizar de novo al zugo\nPero' zerte robe le e' belche tradote."; | ||
| 1062 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1063 | stringaInformazioni = "Informasioni"; | ||
| 1064 | 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"; | ||
| 1065 | stringaSuono = "Efeti sonori"; | ||
| 1066 | stringaPunteggio = "Varda i punti"; | ||
| 1067 | stringaSfondo = "Sfondo"; | ||
| 1068 | stringaTasti = "Tasti rapidi"; | ||
| 1069 | stringaTasti2 = "1 Zuga la prima carta\n2 Zuga la seconda carta\n3 Zuga la terza carta\nF1 Tasti rapidi\nF2 N'altra partida\nF3 Opzioni\nF4 Varda i punti\nF5 Informazioni\nq Stusa su"; | ||
| 1070 | |||
| 1071 | } | ||
| 1072 | sound = ( soundString.equals( "suono=si" ) ); | ||
| 1073 | color = new Color( r, g, b ); | ||
| 1074 | if ( frame != null ) { | ||
| 1075 | frame.pannello.repaint(); | ||
| 1076 | frame.pannello2.repaint(); | ||
| 1077 | frame.repaint(); | ||
| 1078 | } | ||
| 1079 | } | ||
| 1080 | } | ||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/OptionFrame.java b/JBriscola/all_versions/0.2/0.2 Beta 3/src/OptionFrame.java new file mode 100755 index 0000000..a93899f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/OptionFrame.java | |||
| @@ -0,0 +1,129 @@ | |||
| 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.util.Formatter; | ||
| 23 | import javax.swing.*; | ||
| 24 | import java.awt.*; | ||
| 25 | import java.awt.event.*; | ||
| 26 | |||
| 27 | public class OptionFrame extends JFrame { | ||
| 28 | public static Main main = new Main(); | ||
| 29 | public static Formatter formatter; | ||
| 30 | public static JButton ok, annulla, scegliColore; | ||
| 31 | public static JLabel lingua, sfondo; | ||
| 32 | public static JComboBox selezionaLingua; | ||
| 33 | public static JCheckBox suono; | ||
| 34 | public static JPanel[] pannello = new JPanel[5]; | ||
| 35 | public OptionFrame() { | ||
| 36 | super( "JBriscola - " + main.stringaModificaOpzioni ); | ||
| 37 | ok = new JButton( "OK" ); | ||
| 38 | ok.addActionListener( new ActionListener() { | ||
| 39 | public void actionPerformed( ActionEvent e ) { | ||
| 40 | try { | ||
| 41 | formatter = new Formatter( "JBriscolaConfig.txt" ); | ||
| 42 | } catch ( Exception ex ) { | ||
| 43 | JOptionPane.showMessageDialog( OptionFrame.this, main.stringaImpossibileConfigurare + ex ); | ||
| 44 | } | ||
| 45 | String lang; | ||
| 46 | switch ( selezionaLingua.getSelectedIndex() ) { | ||
| 47 | case 0: | ||
| 48 | lang = "it"; | ||
| 49 | break; | ||
| 50 | case 1: | ||
| 51 | lang = "la"; | ||
| 52 | break; | ||
| 53 | case 2: | ||
| 54 | lang = "bl"; | ||
| 55 | break; | ||
| 56 | case 3: | ||
| 57 | lang = "bv"; | ||
| 58 | break; | ||
| 59 | default: | ||
| 60 | lang = "it"; | ||
| 61 | break; | ||
| 62 | } | ||
| 63 | String suonosiono; | ||
| 64 | if ( suono.isSelected() ) | ||
| 65 | suonosiono = "suono=si"; | ||
| 66 | else | ||
| 67 | suonosiono = "suono=no"; | ||
| 68 | formatter.format( lang ); | ||
| 69 | formatter.format( "\n" ); | ||
| 70 | formatter.format( suonosiono ); | ||
| 71 | formatter.format( "\n" ); | ||
| 72 | formatter.format( main.color.getRed() + " " + main.color.getGreen() + " " + main.color.getBlue() ); | ||
| 73 | formatter.close(); | ||
| 74 | main.settaOpzioni(); | ||
| 75 | OptionFrame.this.dispose(); | ||
| 76 | //JOptionPane.showMessageDialog( OptionFrame.this, main.stringaNecessarioRiavviare, "JBriscola 0.1", JOptionPane.INFORMATION_MESSAGE ); | ||
| 77 | } | ||
| 78 | }); | ||
| 79 | annulla = new JButton( main.stringaAnnulla ); | ||
| 80 | annulla.addActionListener( new ActionListener() { | ||
| 81 | public void actionPerformed( ActionEvent e ) { | ||
| 82 | OptionFrame.this.dispose(); | ||
| 83 | } | ||
| 84 | }); | ||
| 85 | scegliColore = new JButton( " " ); | ||
| 86 | scegliColore.setBackground( main.color ); | ||
| 87 | scegliColore.addActionListener( new ActionListener() { | ||
| 88 | public void actionPerformed( ActionEvent e ) { | ||
| 89 | Color colore = JColorChooser.showDialog( OptionFrame.this, "JBriscola " + main.version, main.color ); | ||
| 90 | if ( colore != null ) | ||
| 91 | main.color = colore; | ||
| 92 | OptionFrame.scegliColore.setBackground( main.color ); | ||
| 93 | } | ||
| 94 | } ); | ||
| 95 | lingua = new JLabel( main.stringaLingua ); | ||
| 96 | sfondo = new JLabel( main.stringaSfondo ); | ||
| 97 | String[] lingueDaSelezionare = { main.stringaIt, main.stringaLa, main.stringaBL, main.stringaBV }; | ||
| 98 | selezionaLingua = new JComboBox( lingueDaSelezionare ); | ||
| 99 | int linguaPreselezionata = 0; | ||
| 100 | if ( main.lang.equals( "it" ) ) | ||
| 101 | linguaPreselezionata = 0; | ||
| 102 | else if ( main.lang.equals( "la" ) ) | ||
| 103 | linguaPreselezionata = 1; | ||
| 104 | else if ( main.lang.equals( "bl" ) ) | ||
| 105 | linguaPreselezionata = 2; | ||
| 106 | else if ( main.lang.equals( "bv" ) ) | ||
| 107 | linguaPreselezionata = 3; | ||
| 108 | selezionaLingua.setSelectedIndex( linguaPreselezionata ); | ||
| 109 | suono = new JCheckBox( main.stringaSuono ); | ||
| 110 | suono.setSelected( main.sound ); | ||
| 111 | pannello[0] = new JPanel( new GridLayout( 3, 1 ) ); | ||
| 112 | pannello[1] = new JPanel( new FlowLayout() ); | ||
| 113 | pannello[2] = new JPanel( new FlowLayout() ); | ||
| 114 | pannello[3] = new JPanel( new FlowLayout() ); | ||
| 115 | pannello[4] = new JPanel( new FlowLayout() ); | ||
| 116 | pannello[4].add( ok ); | ||
| 117 | pannello[4].add( annulla ); | ||
| 118 | pannello[3].add( sfondo ); | ||
| 119 | pannello[3].add( scegliColore ); | ||
| 120 | pannello[2].add( suono ); | ||
| 121 | pannello[1].add( lingua ); | ||
| 122 | pannello[1].add( selezionaLingua ); | ||
| 123 | pannello[0].add( pannello[1] ); | ||
| 124 | pannello[0].add( pannello[2] ); | ||
| 125 | pannello[0].add( pannello[3] ); | ||
| 126 | add( pannello[0], BorderLayout.CENTER ); | ||
| 127 | add( pannello[4], BorderLayout.SOUTH ); | ||
| 128 | } | ||
| 129 | } | ||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/Pannello.java b/JBriscola/all_versions/0.2/0.2 Beta 3/src/Pannello.java new file mode 100755 index 0000000..24c6596 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/Pannello.java | |||
| @@ -0,0 +1,54 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | |||
| 25 | public class Pannello extends JPanel { | ||
| 26 | public static Main main; | ||
| 27 | public static Color color; | ||
| 28 | public Pannello() { } | ||
| 29 | public void paint( Graphics g ) { | ||
| 30 | super.paint( g ); | ||
| 31 | setBackground( main.color ); | ||
| 32 | if ( main.frame.ultimaCarta != null ) | ||
| 33 | main.frame.ultimaCarta.paintIcon( this, g, 50, 180 ); | ||
| 34 | if ( main.frame.mazzo ) | ||
| 35 | main.frame.retro2.paintIcon( this, g, 17, 256 ); | ||
| 36 | if ( main.frame.carteCPU[0] != null ) | ||
| 37 | main.frame.retro1.paintIcon( this, g, 230, 5 ); | ||
| 38 | if ( main.frame.carteCPU[1] != null ) | ||
| 39 | main.frame.retro1.paintIcon( this, g, 300, 5 ); | ||
| 40 | if ( main.frame.carteCPU[2] != null ) | ||
| 41 | main.frame.retro1.paintIcon( this, g, 370, 5 ); | ||
| 42 | if ( main.frame.carteInMano[0] != null ) | ||
| 43 | main.frame.carteInMano[0].paintIcon( this, g, 230, 340 ); | ||
| 44 | if ( main.frame.carteInMano[1] != null ) | ||
| 45 | main.frame.carteInMano[1].paintIcon( this, g, 300, 340 ); | ||
| 46 | if ( main.frame.carteInMano[2] != null ) | ||
| 47 | main.frame.carteInMano[2].paintIcon( this, g, 370, 340 ); | ||
| 48 | if ( main.frame.giocata[0] != null ) | ||
| 49 | main.frame.giocata[0].paintIcon( this, g, 250, 200 ); | ||
| 50 | if ( main.frame.giocata[1] != null ) | ||
| 51 | main.frame.giocata[1].paintIcon( this, g, 325, 150 ); | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/1-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/1-1.jpg new file mode 100755 index 0000000..ae43510 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/1-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/1-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/1-2.jpg new file mode 100755 index 0000000..3f7c75a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/1-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/1-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/1-3.jpg new file mode 100755 index 0000000..9e1ead7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/1-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/1-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/1-4.jpg new file mode 100755 index 0000000..710f879 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/1-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/10-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/10-1.jpg new file mode 100755 index 0000000..9aba45a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/10-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/10-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/10-2.jpg new file mode 100755 index 0000000..037eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/10-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/10-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/10-3.jpg new file mode 100755 index 0000000..8780b72 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/10-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/10-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/10-4.jpg new file mode 100755 index 0000000..587dc0f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/10-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/2-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/2-1.jpg new file mode 100755 index 0000000..5dcb7db --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/2-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/2-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/2-2.jpg new file mode 100755 index 0000000..ea9eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/2-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/2-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/2-3.jpg new file mode 100755 index 0000000..8cb22dd --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/2-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/2-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/2-4.jpg new file mode 100755 index 0000000..b3e7898 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/2-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/3-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/3-1.jpg new file mode 100755 index 0000000..dcb435c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/3-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/3-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/3-2.jpg new file mode 100755 index 0000000..1e5b6ec --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/3-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/3-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/3-3.jpg new file mode 100755 index 0000000..9202cfe --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/3-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/3-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/3-4.jpg new file mode 100755 index 0000000..5436a8d --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/3-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/4-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/4-1.jpg new file mode 100755 index 0000000..3bab6d5 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/4-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/4-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/4-2.jpg new file mode 100755 index 0000000..b4901a6 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/4-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/4-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/4-3.jpg new file mode 100755 index 0000000..d754ad8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/4-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/4-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/4-4.jpg new file mode 100755 index 0000000..3a54b96 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/4-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/5-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/5-1.jpg new file mode 100755 index 0000000..3f7ba1f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/5-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/5-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/5-2.jpg new file mode 100755 index 0000000..fcacb75 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/5-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/5-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/5-3.jpg new file mode 100755 index 0000000..ce32f9f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/5-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/5-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/5-4.jpg new file mode 100755 index 0000000..b86b09a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/5-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/6-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/6-1.jpg new file mode 100755 index 0000000..f90cd81 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/6-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/6-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/6-2.jpg new file mode 100755 index 0000000..cf2a67a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/6-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/6-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/6-3.jpg new file mode 100755 index 0000000..2cd2fe2 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/6-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/6-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/6-4.jpg new file mode 100755 index 0000000..73f410f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/6-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/7-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/7-1.jpg new file mode 100755 index 0000000..08cd397 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/7-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/7-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/7-2.jpg new file mode 100755 index 0000000..a168ff8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/7-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/7-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/7-3.jpg new file mode 100755 index 0000000..5cda411 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/7-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/7-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/7-4.jpg new file mode 100755 index 0000000..5d63229 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/7-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/8-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/8-1.jpg new file mode 100755 index 0000000..a6faa7b --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/8-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/8-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/8-2.jpg new file mode 100755 index 0000000..0d9edbb --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/8-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/8-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/8-3.jpg new file mode 100755 index 0000000..91f8354 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/8-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/8-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/8-4.jpg new file mode 100755 index 0000000..cc0089c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/8-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/9-1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/9-1.jpg new file mode 100755 index 0000000..be9c6bf --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/9-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/9-2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/9-2.jpg new file mode 100755 index 0000000..e25da4c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/9-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/9-3.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/9-3.jpg new file mode 100755 index 0000000..cd384f8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/9-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/9-4.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/9-4.jpg new file mode 100755 index 0000000..441210e --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/9-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/carte.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/carte.jpg new file mode 100755 index 0000000..838ffac --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/carte.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/retro1.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/retro1.jpg new file mode 100755 index 0000000..9651b06 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/retro1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/retro2.jpg b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/retro2.jpg new file mode 100755 index 0000000..c5d3925 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/img/retro2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/0.wav b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/0.wav new file mode 100755 index 0000000..67d9abd --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/0.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/1.wav b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/1.wav new file mode 100755 index 0000000..9357c97 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/1.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/2.wav b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/2.wav new file mode 100755 index 0000000..92b1541 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/2.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/3.wav b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/3.wav new file mode 100755 index 0000000..45a6e42 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/3.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/4.wav b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/4.wav new file mode 100755 index 0000000..1f7ec90 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/4.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/5.wav b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/5.wav new file mode 100755 index 0000000..3627f96 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/5.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/pareggio.wav b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/pareggio.wav new file mode 100755 index 0000000..ff978e6 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/pareggio.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/perso.wav b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/perso.wav new file mode 100755 index 0000000..a454ba4 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/perso.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/vinto.wav b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/vinto.wav new file mode 100755 index 0000000..a6f3ac5 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2 Beta 3/src/sounds/vinto.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/Frame.java b/JBriscola/all_versions/0.2/0.2.1/src/Frame.java new file mode 100755 index 0000000..8379683 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/Frame.java | |||
| @@ -0,0 +1,348 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import javax.sound.sampled.*; | ||
| 24 | import java.io.*; | ||
| 25 | import java.net.*; | ||
| 26 | import java.awt.*; | ||
| 27 | import java.awt.event.*; | ||
| 28 | |||
| 29 | public class Frame extends JFrame { | ||
| 30 | public static boolean mazzo; | ||
| 31 | public static Main main; | ||
| 32 | public static Pannello pannello; | ||
| 33 | public static JPanel pannello2; | ||
| 34 | public static JButton button; | ||
| 35 | public static JMenuBar barraMenu; | ||
| 36 | public static JMenu file, puntoInterrogativo; | ||
| 37 | public static JMenuItem nuovaPartita, opzioni, esci, informazioni, punti, aggiornamenti, tastiRapidi; | ||
| 38 | public static ImageIcon retro1, retro2, ultimaCarta; | ||
| 39 | public static ImageIcon[] giocata = new ImageIcon[2]; | ||
| 40 | public static ImageIcon[] carteInMano = new ImageIcon[3]; | ||
| 41 | public static ImageIcon[] carteCPU = new ImageIcon[3]; | ||
| 42 | public static ImageIcon[] arrayCarteMescolate = new ImageIcon[40]; | ||
| 43 | public static ImageIcon[][] arrayCarte = new ImageIcon[10][4]; | ||
| 44 | public Frame() { | ||
| 45 | super( "Tronto's JBriscola " + main.version ); | ||
| 46 | mazzo = true; | ||
| 47 | main = new Main(); | ||
| 48 | pannello = new Pannello(); | ||
| 49 | pannello2 = new JPanel( new FlowLayout() ); | ||
| 50 | button = new JButton( main.stringaBottonePrendi ); | ||
| 51 | button.addActionListener( new ActionListener() { | ||
| 52 | public void actionPerformed( ActionEvent e ) { | ||
| 53 | if ( giocata[0] != null && giocata[1] != null ) | ||
| 54 | main.mano++; | ||
| 55 | try { | ||
| 56 | main.chiPrende(); | ||
| 57 | } catch ( Exception ex ) { | ||
| 58 | JOptionPane.showMessageDialog( Frame.this, main.stringaPrimaGioca, "JBriscola " + main.version, JOptionPane.WARNING_MESSAGE ); | ||
| 59 | } | ||
| 60 | if ( main.mano == 16 ) | ||
| 61 | JOptionPane.showMessageDialog( Frame.this, main.stringaUltime4, "JBriscola " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 62 | if ( main.mano == 17 ) { | ||
| 63 | mazzo = false; | ||
| 64 | ultimaCarta = null; | ||
| 65 | pannello.repaint(); | ||
| 66 | Frame.this.repaint(); | ||
| 67 | } | ||
| 68 | if ( main.mano == 20 ) { | ||
| 69 | String titolo = ""; | ||
| 70 | String suonoFinale = ""; | ||
| 71 | if ( main.punteggio > main.punteggioCPU ) { | ||
| 72 | titolo = main.stringaVinto; | ||
| 73 | suonoFinale = "sounds/perso.wav"; | ||
| 74 | } | ||
| 75 | if ( main.punteggio < main.punteggioCPU ) { | ||
| 76 | titolo = main.stringaPerso; | ||
| 77 | suonoFinale = "sounds/vinto.wav"; | ||
| 78 | } | ||
| 79 | if ( main.punteggio == main.punteggioCPU ) { | ||
| 80 | titolo = main.stringaPareggio; | ||
| 81 | suonoFinale = "sounds/pareggio.wav"; | ||
| 82 | } | ||
| 83 | if ( main.sound ) { | ||
| 84 | try { | ||
| 85 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( ClassLoader.getSystemResource( suonoFinale ) ); | ||
| 86 | AudioInputStream ais = AudioSystem.getAudioInputStream( ClassLoader.getSystemResource( suonoFinale ) ); | ||
| 87 | AudioFormat af = aff.getFormat(); | ||
| 88 | DataLine.Info info = new DataLine.Info( | ||
| 89 | Clip.class, | ||
| 90 | ais.getFormat(), | ||
| 91 | ( (int) ais.getFrameLength() * | ||
| 92 | af.getFrameSize() ) ); | ||
| 93 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 94 | ol.open(ais); | ||
| 95 | ol.loop( 0 ); | ||
| 96 | } catch ( Exception ex ) { | ||
| 97 | System.err.println( e ); | ||
| 98 | } | ||
| 99 | } | ||
| 100 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, titolo, JOptionPane.PLAIN_MESSAGE ); | ||
| 101 | } | ||
| 102 | } | ||
| 103 | } ); | ||
| 104 | button.addKeyListener( new KeyAdapter() { | ||
| 105 | public void keyReleased( KeyEvent key ) { | ||
| 106 | if ( main.keys ) { | ||
| 107 | switch ( key.getKeyCode() ) { | ||
| 108 | case KeyEvent.VK_1: | ||
| 109 | if ( mettiCarta( 231, 500 ) ) { | ||
| 110 | if ( !main.CPUHaGiocato ) | ||
| 111 | main.giocaCPU(); | ||
| 112 | } | ||
| 113 | break; | ||
| 114 | case KeyEvent.VK_2: | ||
| 115 | if ( mettiCarta( 301, 500 ) ) { | ||
| 116 | if ( !main.CPUHaGiocato ) | ||
| 117 | main.giocaCPU(); | ||
| 118 | } | ||
| 119 | break; | ||
| 120 | case KeyEvent.VK_3: | ||
| 121 | if ( mettiCarta( 371, 500 ) ) { | ||
| 122 | if ( !main.CPUHaGiocato ) | ||
| 123 | main.giocaCPU(); | ||
| 124 | } | ||
| 125 | break; | ||
| 126 | case KeyEvent.VK_F1: | ||
| 127 | JOptionPane.showMessageDialog( Frame.this, main.stringaTasti2, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 128 | break; | ||
| 129 | case KeyEvent.VK_F2: | ||
| 130 | if ( main.mano == 20 ) { | ||
| 131 | main.mischia(); | ||
| 132 | pannello.repaint(); | ||
| 133 | repaint(); | ||
| 134 | } | ||
| 135 | else { | ||
| 136 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 137 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 138 | main.mischia(); | ||
| 139 | pannello.repaint(); | ||
| 140 | repaint(); | ||
| 141 | } | ||
| 142 | } | ||
| 143 | break; | ||
| 144 | case KeyEvent.VK_F3: | ||
| 145 | OptionFrame optionFrame = new OptionFrame(); | ||
| 146 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 147 | optionFrame.setResizable( false ); | ||
| 148 | optionFrame.setAlwaysOnTop( true ); | ||
| 149 | optionFrame.setSize( 300, 200 ); | ||
| 150 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, | ||
| 151 | (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 152 | optionFrame.setVisible( true ); | ||
| 153 | break; | ||
| 154 | case KeyEvent.VK_F4: | ||
| 155 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + "\n" + main.stringaComputer + main.punteggioCPU, main.stringaPunteggio, JOptionPane.PLAIN_MESSAGE ); | ||
| 156 | break; | ||
| 157 | case KeyEvent.VK_F5: | ||
| 158 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 159 | break; | ||
| 160 | case KeyEvent.VK_F6: | ||
| 161 | String latest = main.version; | ||
| 162 | try { | ||
| 163 | URL latestIs = new URL( "http://porkynator.altervista.org/jbriscola-latest.is" ); | ||
| 164 | BufferedReader latestIsReader = new BufferedReader( new InputStreamReader( latestIs.openStream() ) ); | ||
| 165 | latest = latestIsReader.readLine(); | ||
| 166 | } catch ( Exception ex ) { | ||
| 167 | JOptionPane.showMessageDialog( Frame.this, main.stringaNoInternet, "JBriscola - " + main.version, JOptionPane.ERROR_MESSAGE ); | ||
| 168 | } | ||
| 169 | if ( latest.equals( main.version ) ) | ||
| 170 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiNo, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 171 | else | ||
| 172 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiSi + "\n" + main.version + " ==> " + latest + "\n\n" + main.stringaScarica, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 173 | break; | ||
| 174 | case KeyEvent.VK_Q: | ||
| 175 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 176 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 177 | Frame.this.dispose(); | ||
| 178 | break; | ||
| 179 | } | ||
| 180 | } | ||
| 181 | } | ||
| 182 | } ); | ||
| 183 | barraMenu = new JMenuBar(); | ||
| 184 | file = new JMenu( "File" ); | ||
| 185 | nuovaPartita = new JMenuItem( main.stringaNuovaPartita ); | ||
| 186 | nuovaPartita.addActionListener( new ActionListener() { | ||
| 187 | public void actionPerformed( ActionEvent e ) { | ||
| 188 | if ( main.mano == 20 ) { | ||
| 189 | main.mischia(); | ||
| 190 | pannello.repaint(); | ||
| 191 | repaint(); | ||
| 192 | } | ||
| 193 | else { | ||
| 194 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 195 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 196 | main.mischia(); | ||
| 197 | pannello.repaint(); | ||
| 198 | repaint(); | ||
| 199 | } | ||
| 200 | } | ||
| 201 | } | ||
| 202 | }); | ||
| 203 | opzioni = new JMenuItem( main.stringaOpzioni ); | ||
| 204 | opzioni.addActionListener( new ActionListener() { | ||
| 205 | public void actionPerformed( ActionEvent e ) { | ||
| 206 | OptionFrame optionFrame = new OptionFrame(); | ||
| 207 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 208 | optionFrame.setResizable( false ); | ||
| 209 | optionFrame.setAlwaysOnTop( true ); | ||
| 210 | optionFrame.setSize( 300, 200 ); | ||
| 211 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, | ||
| 212 | (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 213 | optionFrame.setVisible( true ); | ||
| 214 | } | ||
| 215 | }); | ||
| 216 | esci = new JMenuItem( main.stringaEsci ); | ||
| 217 | esci.addActionListener( new ActionListener() { | ||
| 218 | public void actionPerformed( ActionEvent e ) { | ||
| 219 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 220 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 221 | Frame.this.dispose(); | ||
| 222 | } | ||
| 223 | }); | ||
| 224 | file.add( nuovaPartita ); | ||
| 225 | file.add( opzioni ); | ||
| 226 | file.addSeparator(); | ||
| 227 | file.add( esci ); | ||
| 228 | puntoInterrogativo = new JMenu( "?" ); | ||
| 229 | informazioni = new JMenuItem( main.stringaInformazioni ); | ||
| 230 | informazioni.addActionListener( new ActionListener() { | ||
| 231 | public void actionPerformed( ActionEvent e ) { | ||
| 232 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 233 | } | ||
| 234 | } ); | ||
| 235 | tastiRapidi = new JMenuItem( main.stringaTasti ); | ||
| 236 | tastiRapidi.addActionListener( new ActionListener() { | ||
| 237 | public void actionPerformed( ActionEvent e ) { | ||
| 238 | JOptionPane.showMessageDialog( Frame.this, main.stringaTasti2, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 239 | } | ||
| 240 | } ); | ||
| 241 | punti = new JMenuItem( main.stringaPunteggio ); | ||
| 242 | punti.addActionListener( new ActionListener() { | ||
| 243 | public void actionPerformed( ActionEvent e ) { | ||
| 244 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + "\n" + main.stringaComputer + main.punteggioCPU, main.stringaPunteggio, JOptionPane.PLAIN_MESSAGE ); | ||
| 245 | } | ||
| 246 | } ); | ||
| 247 | aggiornamenti = new JMenuItem( main.stringaAggiornamenti ); | ||
| 248 | aggiornamenti.addActionListener( new ActionListener() { | ||
| 249 | public void actionPerformed( ActionEvent e ) { | ||
| 250 | String latest = main.version; | ||
| 251 | try { | ||
| 252 | URL latestIs = new URL( "http://porkynator.altervista.org/jbriscola-latest.is" ); | ||
| 253 | BufferedReader latestIsReader = new BufferedReader( new InputStreamReader( latestIs.openStream() ) ); | ||
| 254 | latest = latestIsReader.readLine(); | ||
| 255 | } catch ( Exception ex ) { | ||
| 256 | JOptionPane.showMessageDialog( Frame.this, main.stringaNoInternet, "JBriscola - " + main.version, JOptionPane.ERROR_MESSAGE ); | ||
| 257 | } | ||
| 258 | if ( latest.equals( main.version ) ) | ||
| 259 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiNo, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 260 | else | ||
| 261 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiSi + "\n" + main.version + " ==> " + latest + "\n\n" + main.stringaScarica, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 262 | } | ||
| 263 | } ); | ||
| 264 | puntoInterrogativo.add( punti ); | ||
| 265 | puntoInterrogativo.add( tastiRapidi ); | ||
| 266 | puntoInterrogativo.add( informazioni ); | ||
| 267 | puntoInterrogativo.add( aggiornamenti ); | ||
| 268 | barraMenu.add( file ); | ||
| 269 | barraMenu.add( puntoInterrogativo ); | ||
| 270 | setJMenuBar( barraMenu ); | ||
| 271 | retro1 = new ImageIcon( ClassLoader.getSystemResource( "img/retro1.jpg" ) ); | ||
| 272 | retro2 = new ImageIcon( ClassLoader.getSystemResource( "img/retro2.jpg" ) ); | ||
| 273 | for (int i = 0; i < 10; i++) | ||
| 274 | for (int j = 0; j < 4; j++) | ||
| 275 | arrayCarte[i][j] = new ImageIcon( ClassLoader.getSystemResource( "img/" + (i+1) + "-" + (j+1) + ".jpg" ) ); | ||
| 276 | main.mischia(); | ||
| 277 | pannello2.add( button ); | ||
| 278 | setLayout( new BorderLayout() ); | ||
| 279 | add( pannello, BorderLayout.CENTER ); | ||
| 280 | add( pannello2, BorderLayout.SOUTH ); | ||
| 281 | addMouseListener( | ||
| 282 | new MouseAdapter() { | ||
| 283 | public void mouseClicked ( MouseEvent e ) { | ||
| 284 | if ( mettiCarta( e.getX(), e.getY() ) ) { | ||
| 285 | if ( !main.CPUHaGiocato ) | ||
| 286 | main.giocaCPU(); | ||
| 287 | } | ||
| 288 | } | ||
| 289 | } | ||
| 290 | ); | ||
| 291 | addWindowListener( | ||
| 292 | new WindowAdapter() { | ||
| 293 | public void windowClosing( WindowEvent e ) { | ||
| 294 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 295 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 296 | System.exit( 0 ); | ||
| 297 | } | ||
| 298 | } | ||
| 299 | ); | ||
| 300 | } | ||
| 301 | public boolean mettiCarta( int x, int y ) { | ||
| 302 | if ( !main.toccaAllaCPU && giocata[0] == null ) { | ||
| 303 | if ( main.sound && | ||
| 304 | ( ( x > 230 && x < 290 && y > 340 && y < 566 && carteInMano[0] != null ) || | ||
| 305 | ( x > 300 && x < 360 && y > 340 && y < 566 && carteInMano[1] != null ) || | ||
| 306 | ( x > 370 && x < 430 && y > 340 && y < 566 && carteInMano[2] != null ) ) ) { | ||
| 307 | try { | ||
| 308 | double a = Math.random() * 6; | ||
| 309 | int i = (int) a; | ||
| 310 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( ClassLoader.getSystemResource("sounds/" + i + ".wav") ); | ||
| 311 | AudioInputStream ais = AudioSystem.getAudioInputStream( ClassLoader.getSystemResource("sounds/" + i + ".wav") ); | ||
| 312 | AudioFormat af = aff.getFormat(); | ||
| 313 | DataLine.Info info = new DataLine.Info( | ||
| 314 | Clip.class, | ||
| 315 | ais.getFormat(), | ||
| 316 | ( (int) ais.getFrameLength() * | ||
| 317 | af.getFrameSize() ) ); | ||
| 318 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 319 | ol.open(ais); | ||
| 320 | ol.loop( 0 ); | ||
| 321 | } catch ( Exception e ) { | ||
| 322 | System.err.println( e ); | ||
| 323 | } | ||
| 324 | } | ||
| 325 | if ( x > 230 && x < 290 && y > 340 && y < 566 && carteInMano[0] != null ) { | ||
| 326 | giocata[0] = carteInMano[0]; | ||
| 327 | carteInMano[0] = null; | ||
| 328 | pannello.repaint(); | ||
| 329 | return true; | ||
| 330 | } | ||
| 331 | if ( x > 300 && x < 360 && y > 340 && y < 566 && carteInMano[1] != null ) { | ||
| 332 | giocata[0] = carteInMano[1]; | ||
| 333 | carteInMano[1] = null; | ||
| 334 | pannello.repaint(); | ||
| 335 | return true; | ||
| 336 | } | ||
| 337 | if ( x > 370 && x < 430 && y > 340 && y < 566 && carteInMano[2] != null ) { | ||
| 338 | giocata[0] = carteInMano[2]; | ||
| 339 | carteInMano[2] = null; | ||
| 340 | pannello.repaint(); | ||
| 341 | return true; | ||
| 342 | } | ||
| 343 | } | ||
| 344 | return false; | ||
| 345 | } | ||
| 346 | } | ||
| 347 | |||
| 348 | |||
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 | } | ||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/OptionFrame.java b/JBriscola/all_versions/0.2/0.2.1/src/OptionFrame.java new file mode 100755 index 0000000..f41606e --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/OptionFrame.java | |||
| @@ -0,0 +1,140 @@ | |||
| 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.util.Formatter; | ||
| 23 | import javax.swing.*; | ||
| 24 | import java.awt.*; | ||
| 25 | import java.awt.event.*; | ||
| 26 | |||
| 27 | public class OptionFrame extends JFrame { | ||
| 28 | public static Main main = new Main(); | ||
| 29 | public static Formatter formatter; | ||
| 30 | public static JButton ok, annulla, scegliColore; | ||
| 31 | public static JLabel lingua, sfondo; | ||
| 32 | public static JComboBox selezionaLingua; | ||
| 33 | public static JCheckBox suono, tastiRapidi; | ||
| 34 | public static JPanel[] pannello = new JPanel[6]; | ||
| 35 | public OptionFrame() { | ||
| 36 | super( "JBriscola - " + main.stringaModificaOpzioni ); | ||
| 37 | ok = new JButton( "OK" ); | ||
| 38 | ok.addActionListener( new ActionListener() { | ||
| 39 | public void actionPerformed( ActionEvent e ) { | ||
| 40 | try { | ||
| 41 | formatter = new Formatter( "JBriscolaConfig.txt" ); | ||
| 42 | } catch ( Exception ex ) { | ||
| 43 | JOptionPane.showMessageDialog( OptionFrame.this, main.stringaImpossibileConfigurare + ex, "JBriscola - " + main.version, JOptionPane.ERROR_MESSAGE ); | ||
| 44 | } | ||
| 45 | String lang; | ||
| 46 | switch ( selezionaLingua.getSelectedIndex() ) { | ||
| 47 | case 0: | ||
| 48 | lang = "it"; | ||
| 49 | break; | ||
| 50 | case 1: | ||
| 51 | lang = "la"; | ||
| 52 | break; | ||
| 53 | case 2: | ||
| 54 | lang = "bl"; | ||
| 55 | break; | ||
| 56 | case 3: | ||
| 57 | lang = "bv"; | ||
| 58 | break; | ||
| 59 | default: | ||
| 60 | lang = "it"; | ||
| 61 | break; | ||
| 62 | } | ||
| 63 | String suonosiono, tastisiono; | ||
| 64 | if ( suono.isSelected() ) | ||
| 65 | suonosiono = "suono=si"; | ||
| 66 | else | ||
| 67 | suonosiono = "suono=no"; | ||
| 68 | if ( tastiRapidi.isSelected() ) | ||
| 69 | tastisiono = "tasti=si"; | ||
| 70 | else | ||
| 71 | tastisiono = "tasti=no"; | ||
| 72 | formatter.format( lang ); | ||
| 73 | formatter.format( "\n" ); | ||
| 74 | formatter.format( suonosiono ); | ||
| 75 | formatter.format( "\n" ); | ||
| 76 | formatter.format( tastisiono ); | ||
| 77 | formatter.format( "\n" ); | ||
| 78 | formatter.format( main.color.getRed() + " " + main.color.getGreen() + " " + main.color.getBlue() ); | ||
| 79 | formatter.close(); | ||
| 80 | main.settaOpzioni(); | ||
| 81 | OptionFrame.this.dispose(); | ||
| 82 | //JOptionPane.showMessageDialog( OptionFrame.this, main.stringaNecessarioRiavviare, "JBriscola 0.1", JOptionPane.INFORMATION_MESSAGE ); | ||
| 83 | } | ||
| 84 | }); | ||
| 85 | annulla = new JButton( main.stringaAnnulla ); | ||
| 86 | annulla.addActionListener( new ActionListener() { | ||
| 87 | public void actionPerformed( ActionEvent e ) { | ||
| 88 | OptionFrame.this.dispose(); | ||
| 89 | } | ||
| 90 | }); | ||
| 91 | scegliColore = new JButton( " " ); | ||
| 92 | scegliColore.setBackground( main.color ); | ||
| 93 | scegliColore.addActionListener( new ActionListener() { | ||
| 94 | public void actionPerformed( ActionEvent e ) { | ||
| 95 | Color colore = JColorChooser.showDialog( OptionFrame.this, "JBriscola " + main.version, main.color ); | ||
| 96 | if ( colore != null ) | ||
| 97 | main.color = colore; | ||
| 98 | OptionFrame.scegliColore.setBackground( main.color ); | ||
| 99 | } | ||
| 100 | } ); | ||
| 101 | lingua = new JLabel( main.stringaLingua ); | ||
| 102 | sfondo = new JLabel( main.stringaSfondo ); | ||
| 103 | String[] lingueDaSelezionare = { main.stringaIt, main.stringaLa, main.stringaBL, main.stringaBV }; | ||
| 104 | selezionaLingua = new JComboBox( lingueDaSelezionare ); | ||
| 105 | int linguaPreselezionata = 0; | ||
| 106 | if ( main.lang.equals( "it" ) ) | ||
| 107 | linguaPreselezionata = 0; | ||
| 108 | else if ( main.lang.equals( "la" ) ) | ||
| 109 | linguaPreselezionata = 1; | ||
| 110 | else if ( main.lang.equals( "bl" ) ) | ||
| 111 | linguaPreselezionata = 2; | ||
| 112 | else if ( main.lang.equals( "bv" ) ) | ||
| 113 | linguaPreselezionata = 3; | ||
| 114 | selezionaLingua.setSelectedIndex( linguaPreselezionata ); | ||
| 115 | suono = new JCheckBox( main.stringaSuono ); | ||
| 116 | suono.setSelected( main.sound ); | ||
| 117 | tastiRapidi = new JCheckBox( main.stringaTasti ); | ||
| 118 | tastiRapidi.setSelected( main.keys ); | ||
| 119 | pannello[0] = new JPanel( new GridLayout( 4, 1 ) ); | ||
| 120 | pannello[1] = new JPanel( new FlowLayout() ); | ||
| 121 | pannello[2] = new JPanel( new FlowLayout() ); | ||
| 122 | pannello[3] = new JPanel( new FlowLayout() ); | ||
| 123 | pannello[4] = new JPanel( new FlowLayout() ); | ||
| 124 | pannello[5] = new JPanel( new FlowLayout() ); | ||
| 125 | pannello[5].add( ok ); | ||
| 126 | pannello[5].add( annulla ); | ||
| 127 | pannello[4].add( sfondo ); | ||
| 128 | pannello[4].add( scegliColore ); | ||
| 129 | pannello[3].add( tastiRapidi ); | ||
| 130 | pannello[2].add( suono ); | ||
| 131 | pannello[1].add( lingua ); | ||
| 132 | pannello[1].add( selezionaLingua ); | ||
| 133 | pannello[0].add( pannello[1] ); | ||
| 134 | pannello[0].add( pannello[2] ); | ||
| 135 | pannello[0].add( pannello[3] ); | ||
| 136 | pannello[0].add( pannello[4] ); | ||
| 137 | add( pannello[0], BorderLayout.CENTER ); | ||
| 138 | add( pannello[5], BorderLayout.SOUTH ); | ||
| 139 | } | ||
| 140 | } | ||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/Pannello.java b/JBriscola/all_versions/0.2/0.2.1/src/Pannello.java new file mode 100755 index 0000000..24c6596 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/Pannello.java | |||
| @@ -0,0 +1,54 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | |||
| 25 | public class Pannello extends JPanel { | ||
| 26 | public static Main main; | ||
| 27 | public static Color color; | ||
| 28 | public Pannello() { } | ||
| 29 | public void paint( Graphics g ) { | ||
| 30 | super.paint( g ); | ||
| 31 | setBackground( main.color ); | ||
| 32 | if ( main.frame.ultimaCarta != null ) | ||
| 33 | main.frame.ultimaCarta.paintIcon( this, g, 50, 180 ); | ||
| 34 | if ( main.frame.mazzo ) | ||
| 35 | main.frame.retro2.paintIcon( this, g, 17, 256 ); | ||
| 36 | if ( main.frame.carteCPU[0] != null ) | ||
| 37 | main.frame.retro1.paintIcon( this, g, 230, 5 ); | ||
| 38 | if ( main.frame.carteCPU[1] != null ) | ||
| 39 | main.frame.retro1.paintIcon( this, g, 300, 5 ); | ||
| 40 | if ( main.frame.carteCPU[2] != null ) | ||
| 41 | main.frame.retro1.paintIcon( this, g, 370, 5 ); | ||
| 42 | if ( main.frame.carteInMano[0] != null ) | ||
| 43 | main.frame.carteInMano[0].paintIcon( this, g, 230, 340 ); | ||
| 44 | if ( main.frame.carteInMano[1] != null ) | ||
| 45 | main.frame.carteInMano[1].paintIcon( this, g, 300, 340 ); | ||
| 46 | if ( main.frame.carteInMano[2] != null ) | ||
| 47 | main.frame.carteInMano[2].paintIcon( this, g, 370, 340 ); | ||
| 48 | if ( main.frame.giocata[0] != null ) | ||
| 49 | main.frame.giocata[0].paintIcon( this, g, 250, 200 ); | ||
| 50 | if ( main.frame.giocata[1] != null ) | ||
| 51 | main.frame.giocata[1].paintIcon( this, g, 325, 150 ); | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/1-1.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/1-1.jpg new file mode 100755 index 0000000..ae43510 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/1-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/1-2.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/1-2.jpg new file mode 100755 index 0000000..3f7c75a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/1-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/1-3.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/1-3.jpg new file mode 100755 index 0000000..9e1ead7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/1-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/1-4.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/1-4.jpg new file mode 100755 index 0000000..710f879 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/1-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/10-1.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/10-1.jpg new file mode 100755 index 0000000..9aba45a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/10-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/10-2.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/10-2.jpg new file mode 100755 index 0000000..037eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/10-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/10-3.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/10-3.jpg new file mode 100755 index 0000000..8780b72 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/10-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/10-4.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/10-4.jpg new file mode 100755 index 0000000..587dc0f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/10-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/2-1.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/2-1.jpg new file mode 100755 index 0000000..5dcb7db --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/2-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/2-2.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/2-2.jpg new file mode 100755 index 0000000..ea9eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/2-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/2-3.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/2-3.jpg new file mode 100755 index 0000000..8cb22dd --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/2-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/2-4.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/2-4.jpg new file mode 100755 index 0000000..b3e7898 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/2-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/3-1.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/3-1.jpg new file mode 100755 index 0000000..dcb435c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/3-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/3-2.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/3-2.jpg new file mode 100755 index 0000000..1e5b6ec --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/3-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/3-3.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/3-3.jpg new file mode 100755 index 0000000..9202cfe --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/3-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/3-4.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/3-4.jpg new file mode 100755 index 0000000..5436a8d --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/3-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/4-1.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/4-1.jpg new file mode 100755 index 0000000..3bab6d5 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/4-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/4-2.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/4-2.jpg new file mode 100755 index 0000000..b4901a6 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/4-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/4-3.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/4-3.jpg new file mode 100755 index 0000000..d754ad8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/4-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/4-4.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/4-4.jpg new file mode 100755 index 0000000..3a54b96 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/4-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/5-1.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/5-1.jpg new file mode 100755 index 0000000..3f7ba1f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/5-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/5-2.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/5-2.jpg new file mode 100755 index 0000000..fcacb75 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/5-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/5-3.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/5-3.jpg new file mode 100755 index 0000000..ce32f9f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/5-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/5-4.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/5-4.jpg new file mode 100755 index 0000000..b86b09a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/5-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/6-1.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/6-1.jpg new file mode 100755 index 0000000..f90cd81 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/6-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/6-2.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/6-2.jpg new file mode 100755 index 0000000..cf2a67a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/6-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/6-3.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/6-3.jpg new file mode 100755 index 0000000..2cd2fe2 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/6-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/6-4.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/6-4.jpg new file mode 100755 index 0000000..73f410f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/6-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/7-1.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/7-1.jpg new file mode 100755 index 0000000..08cd397 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/7-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/7-2.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/7-2.jpg new file mode 100755 index 0000000..a168ff8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/7-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/7-3.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/7-3.jpg new file mode 100755 index 0000000..5cda411 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/7-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/7-4.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/7-4.jpg new file mode 100755 index 0000000..5d63229 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/7-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/8-1.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/8-1.jpg new file mode 100755 index 0000000..a6faa7b --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/8-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/8-2.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/8-2.jpg new file mode 100755 index 0000000..0d9edbb --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/8-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/8-3.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/8-3.jpg new file mode 100755 index 0000000..91f8354 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/8-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/8-4.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/8-4.jpg new file mode 100755 index 0000000..cc0089c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/8-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/9-1.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/9-1.jpg new file mode 100755 index 0000000..be9c6bf --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/9-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/9-2.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/9-2.jpg new file mode 100755 index 0000000..e25da4c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/9-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/9-3.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/9-3.jpg new file mode 100755 index 0000000..cd384f8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/9-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/9-4.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/9-4.jpg new file mode 100755 index 0000000..441210e --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/9-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/carte.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/carte.jpg new file mode 100755 index 0000000..838ffac --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/carte.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/retro1.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/retro1.jpg new file mode 100755 index 0000000..9651b06 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/retro1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/img/retro2.jpg b/JBriscola/all_versions/0.2/0.2.1/src/img/retro2.jpg new file mode 100755 index 0000000..c5d3925 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/img/retro2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/sounds/0.wav b/JBriscola/all_versions/0.2/0.2.1/src/sounds/0.wav new file mode 100755 index 0000000..67d9abd --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/sounds/0.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/sounds/1.wav b/JBriscola/all_versions/0.2/0.2.1/src/sounds/1.wav new file mode 100755 index 0000000..9357c97 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/sounds/1.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/sounds/2.wav b/JBriscola/all_versions/0.2/0.2.1/src/sounds/2.wav new file mode 100755 index 0000000..92b1541 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/sounds/2.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/sounds/3.wav b/JBriscola/all_versions/0.2/0.2.1/src/sounds/3.wav new file mode 100755 index 0000000..45a6e42 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/sounds/3.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/sounds/4.wav b/JBriscola/all_versions/0.2/0.2.1/src/sounds/4.wav new file mode 100755 index 0000000..1f7ec90 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/sounds/4.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/sounds/5.wav b/JBriscola/all_versions/0.2/0.2.1/src/sounds/5.wav new file mode 100755 index 0000000..3627f96 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/sounds/5.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/sounds/pareggio.wav b/JBriscola/all_versions/0.2/0.2.1/src/sounds/pareggio.wav new file mode 100755 index 0000000..ff978e6 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/sounds/pareggio.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/sounds/perso.wav b/JBriscola/all_versions/0.2/0.2.1/src/sounds/perso.wav new file mode 100755 index 0000000..a454ba4 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/sounds/perso.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.1/src/sounds/vinto.wav b/JBriscola/all_versions/0.2/0.2.1/src/sounds/vinto.wav new file mode 100755 index 0000000..a6f3ac5 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.1/src/sounds/vinto.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/Frame.java b/JBriscola/all_versions/0.2/0.2.2/src/Frame.java new file mode 100755 index 0000000..bea69a4 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/Frame.java | |||
| @@ -0,0 +1,432 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import javax.sound.sampled.*; | ||
| 24 | import java.io.*; | ||
| 25 | import java.net.*; | ||
| 26 | import java.awt.*; | ||
| 27 | import java.awt.event.*; | ||
| 28 | |||
| 29 | public class Frame extends JFrame { | ||
| 30 | |||
| 31 | /* Booleana per determinare se disegnare il mazzo di carte o no (se | ||
| 32 | * è l'ultima mano). */ | ||
| 33 | public static boolean mazzo; | ||
| 34 | |||
| 35 | public static Main main; | ||
| 36 | |||
| 37 | /* Menu, bottoni, pannelli e componenti vari. */ | ||
| 38 | public static Pannello pannello; | ||
| 39 | public static JPanel pannello2; | ||
| 40 | public static JButton button; | ||
| 41 | public static JMenuBar barraMenu; | ||
| 42 | public static JMenu file, puntoInterrogativo; | ||
| 43 | public static JMenuItem nuovaPartita, opzioni, esci, informazioni, punti, aggiornamenti, tastiRapidi; | ||
| 44 | |||
| 45 | /* Immagini delle carte. */ | ||
| 46 | public static ImageIcon retro1, retro2, ultimaCarta; | ||
| 47 | public static ImageIcon[] giocata = new ImageIcon[2]; | ||
| 48 | public static ImageIcon[] carteInMano = new ImageIcon[3]; | ||
| 49 | public static ImageIcon[] carteCPU = new ImageIcon[3]; | ||
| 50 | public static ImageIcon[] arrayCarteMescolate = new ImageIcon[40]; | ||
| 51 | public static ImageIcon[][] arrayCarte = new ImageIcon[10][4]; | ||
| 52 | |||
| 53 | public Frame() { | ||
| 54 | |||
| 55 | super( "Tronto's JBriscola " + main.version ); | ||
| 56 | |||
| 57 | mazzo = true; | ||
| 58 | main = new Main(); | ||
| 59 | pannello = new Pannello(); | ||
| 60 | pannello2 = new JPanel( new FlowLayout() ); | ||
| 61 | |||
| 62 | button = new JButton( main.stringaBottonePrendi ); | ||
| 63 | button.addActionListener( new ActionListener() { | ||
| 64 | |||
| 65 | /* Quando viene premuto il bottone per prendere/lasciare le carte, | ||
| 66 | * valuta innanzitutto se il giocatore ha giocato, e poi a chi | ||
| 67 | * darle ed eventualmente, se è finita la partita, a caricare | ||
| 68 | * il suono adatto. */ | ||
| 69 | public void actionPerformed( ActionEvent e ) { | ||
| 70 | |||
| 71 | if ( giocata[0] != null && giocata[1] != null ) | ||
| 72 | main.mano++; | ||
| 73 | |||
| 74 | try { | ||
| 75 | main.chiPrende(); | ||
| 76 | } catch ( Exception ex ) { | ||
| 77 | /* Avvisa di giocare una carta. */ | ||
| 78 | JOptionPane.showMessageDialog( Frame.this, main.stringaPrimaGioca, "JBriscola " + main.version, JOptionPane.WARNING_MESSAGE ); | ||
| 79 | } | ||
| 80 | |||
| 81 | if ( main.mano == 16 ) | ||
| 82 | /* Avvisa che si è arrivati alla quartultima mano. */ | ||
| 83 | JOptionPane.showMessageDialog( Frame.this, main.stringaUltime4, "JBriscola " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 84 | |||
| 85 | /* Non disegna più la briscola e il mazzo se sono già state | ||
| 86 | * pescate tutte le carte. */ | ||
| 87 | if ( main.mano == 17 ) { | ||
| 88 | mazzo = false; | ||
| 89 | ultimaCarta = null; | ||
| 90 | pannello.repaint(); | ||
| 91 | Frame.this.repaint(); | ||
| 92 | } | ||
| 93 | |||
| 94 | /* Mostra il punteggio e carica i suoni se è finita la partita. */ | ||
| 95 | if ( main.mano == 20 ) { | ||
| 96 | |||
| 97 | String titolo = ""; | ||
| 98 | String suonoFinale = ""; | ||
| 99 | |||
| 100 | if ( main.punteggio > main.punteggioCPU ) { | ||
| 101 | titolo = main.stringaVinto; | ||
| 102 | suonoFinale = "sounds/perso.wav"; | ||
| 103 | } | ||
| 104 | if ( main.punteggio < main.punteggioCPU ) { | ||
| 105 | titolo = main.stringaPerso; | ||
| 106 | suonoFinale = "sounds/vinto.wav"; | ||
| 107 | } | ||
| 108 | if ( main.punteggio == main.punteggioCPU ) { | ||
| 109 | titolo = main.stringaPareggio; | ||
| 110 | suonoFinale = "sounds/pareggio.wav"; | ||
| 111 | } | ||
| 112 | |||
| 113 | if ( main.sound ) { | ||
| 114 | try { | ||
| 115 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( ClassLoader.getSystemResource( suonoFinale ) ); | ||
| 116 | AudioInputStream ais = AudioSystem.getAudioInputStream( ClassLoader.getSystemResource( suonoFinale ) ); | ||
| 117 | AudioFormat af = aff.getFormat(); | ||
| 118 | DataLine.Info info = new DataLine.Info( Clip.class, ais.getFormat(), ( (int) ais.getFrameLength() * af.getFrameSize() ) ); | ||
| 119 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 120 | ol.open(ais); | ||
| 121 | ol.loop( 0 ); | ||
| 122 | } catch ( Exception ex ) { | ||
| 123 | System.err.println( e ); | ||
| 124 | } | ||
| 125 | } | ||
| 126 | |||
| 127 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, titolo, JOptionPane.PLAIN_MESSAGE ); | ||
| 128 | } | ||
| 129 | } | ||
| 130 | } ); | ||
| 131 | button.addKeyListener( new KeyAdapter() { | ||
| 132 | /* Aggiunge il keyListener per le scorciatoie da tastiera. Dato | ||
| 133 | * che il bottone prendi/lascia è l'unico componente effettivo | ||
| 134 | * della finestra, avrà obbligatoriamente il focus ed è necessario | ||
| 135 | * che sia lui a gestire gli eventi della tastiera. */ | ||
| 136 | public void keyReleased( KeyEvent key ) { | ||
| 137 | |||
| 138 | if ( main.keys ) { | ||
| 139 | switch ( key.getKeyCode() ) { | ||
| 140 | case KeyEvent.VK_1: | ||
| 141 | if ( mettiCarta( 231, 500 ) ) { | ||
| 142 | if ( !main.CPUHaGiocato ) | ||
| 143 | main.giocaCPU(); | ||
| 144 | } | ||
| 145 | break; | ||
| 146 | |||
| 147 | case KeyEvent.VK_2: | ||
| 148 | if ( mettiCarta( 301, 500 ) ) { | ||
| 149 | if ( !main.CPUHaGiocato ) | ||
| 150 | main.giocaCPU(); | ||
| 151 | } | ||
| 152 | break; | ||
| 153 | |||
| 154 | case KeyEvent.VK_3: | ||
| 155 | if ( mettiCarta( 371, 500 ) ) { | ||
| 156 | if ( !main.CPUHaGiocato ) | ||
| 157 | main.giocaCPU(); | ||
| 158 | } | ||
| 159 | break; | ||
| 160 | |||
| 161 | case KeyEvent.VK_F1: | ||
| 162 | JOptionPane.showMessageDialog( Frame.this, main.stringaTasti2, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 163 | break; | ||
| 164 | |||
| 165 | case KeyEvent.VK_F2: | ||
| 166 | if ( main.mano == 20 ) { | ||
| 167 | main.mischia(); | ||
| 168 | pannello.repaint(); | ||
| 169 | repaint(); | ||
| 170 | } | ||
| 171 | else { | ||
| 172 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 173 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 174 | main.mischia(); | ||
| 175 | pannello.repaint(); | ||
| 176 | repaint(); | ||
| 177 | } | ||
| 178 | } | ||
| 179 | break; | ||
| 180 | |||
| 181 | case KeyEvent.VK_F3: | ||
| 182 | OptionFrame optionFrame = new OptionFrame(); | ||
| 183 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 184 | optionFrame.setResizable( false ); | ||
| 185 | optionFrame.setAlwaysOnTop( true ); | ||
| 186 | optionFrame.setSize( 300, 200 ); | ||
| 187 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 188 | optionFrame.setVisible( true ); | ||
| 189 | break; | ||
| 190 | case KeyEvent.VK_F4: | ||
| 191 | |||
| 192 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + "\n" + main.stringaComputer + main.punteggioCPU, main.stringaPunteggio, JOptionPane.PLAIN_MESSAGE ); | ||
| 193 | break; | ||
| 194 | case KeyEvent.VK_F5: | ||
| 195 | |||
| 196 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 197 | break; | ||
| 198 | case KeyEvent.VK_F6: | ||
| 199 | |||
| 200 | String latest = main.version; | ||
| 201 | try { | ||
| 202 | URL latestIs = new URL( "http://porkynator.altervista.org/jbriscola-latest.is" ); | ||
| 203 | BufferedReader latestIsReader = new BufferedReader( new InputStreamReader( latestIs.openStream() ) ); | ||
| 204 | latest = latestIsReader.readLine(); | ||
| 205 | } catch ( Exception ex ) { | ||
| 206 | JOptionPane.showMessageDialog( Frame.this, main.stringaNoInternet, "JBriscola - " + main.version, JOptionPane.ERROR_MESSAGE ); | ||
| 207 | } | ||
| 208 | if ( latest.equals( main.version ) ) | ||
| 209 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiNo, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 210 | else | ||
| 211 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiSi + "\n" + main.version + " ==> " + latest + "\n\n" + main.stringaScarica, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 212 | break; | ||
| 213 | case KeyEvent.VK_Q: | ||
| 214 | |||
| 215 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 216 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 217 | Frame.this.dispose(); | ||
| 218 | break; | ||
| 219 | } | ||
| 220 | } | ||
| 221 | } | ||
| 222 | } ); | ||
| 223 | |||
| 224 | barraMenu = new JMenuBar(); | ||
| 225 | |||
| 226 | file = new JMenu( "File" ); | ||
| 227 | |||
| 228 | nuovaPartita = new JMenuItem( main.stringaNuovaPartita ); | ||
| 229 | nuovaPartita.addActionListener( new ActionListener() { | ||
| 230 | /* Avvia una nuova partita, chiedendo prima conferma se ce n'è | ||
| 231 | * già una in corso. */ | ||
| 232 | public void actionPerformed( ActionEvent e ) { | ||
| 233 | if ( main.mano == 20 ) { | ||
| 234 | main.mischia(); | ||
| 235 | pannello.repaint(); | ||
| 236 | repaint(); | ||
| 237 | } | ||
| 238 | |||
| 239 | else { | ||
| 240 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 241 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 242 | main.mischia(); | ||
| 243 | pannello.repaint(); | ||
| 244 | repaint(); | ||
| 245 | } | ||
| 246 | } | ||
| 247 | } | ||
| 248 | }); | ||
| 249 | |||
| 250 | opzioni = new JMenuItem( main.stringaOpzioni ); | ||
| 251 | opzioni.addActionListener( new ActionListener() { | ||
| 252 | /* Apre una OptionFrame per modificare le opzioni. */ | ||
| 253 | public void actionPerformed( ActionEvent e ) { | ||
| 254 | |||
| 255 | OptionFrame optionFrame = new OptionFrame(); | ||
| 256 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 257 | optionFrame.setResizable( false ); | ||
| 258 | optionFrame.setAlwaysOnTop( true ); | ||
| 259 | optionFrame.setSize( 300, 200 ); | ||
| 260 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 261 | optionFrame.setVisible( true ); | ||
| 262 | } | ||
| 263 | }); | ||
| 264 | |||
| 265 | esci = new JMenuItem( main.stringaEsci ); | ||
| 266 | esci.addActionListener( new ActionListener() { | ||
| 267 | /* Ciede conferma prima di uscire. */ | ||
| 268 | public void actionPerformed( ActionEvent e ) { | ||
| 269 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 270 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 271 | Frame.this.dispose(); | ||
| 272 | } | ||
| 273 | }); | ||
| 274 | |||
| 275 | file.add( nuovaPartita ); | ||
| 276 | file.add( opzioni ); | ||
| 277 | file.addSeparator(); | ||
| 278 | file.add( esci ); | ||
| 279 | |||
| 280 | puntoInterrogativo = new JMenu( "?" ); | ||
| 281 | |||
| 282 | informazioni = new JMenuItem( main.stringaInformazioni ); | ||
| 283 | informazioni.addActionListener( new ActionListener() { | ||
| 284 | /* Visualizza le informazioni. */ | ||
| 285 | public void actionPerformed( ActionEvent e ) { | ||
| 286 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 287 | } | ||
| 288 | } ); | ||
| 289 | |||
| 290 | tastiRapidi = new JMenuItem( main.stringaTasti ); | ||
| 291 | tastiRapidi.addActionListener( new ActionListener() { | ||
| 292 | /* Visualizza i tasti rapidi. */ | ||
| 293 | public void actionPerformed( ActionEvent e ) { | ||
| 294 | JOptionPane.showMessageDialog( Frame.this, main.stringaTasti2, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 295 | } | ||
| 296 | } ); | ||
| 297 | |||
| 298 | punti = new JMenuItem( main.stringaPunteggio ); | ||
| 299 | punti.addActionListener( new ActionListener() { | ||
| 300 | /* Visualizza il punteggio. */ | ||
| 301 | public void actionPerformed( ActionEvent e ) { | ||
| 302 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + "\n" + main.stringaComputer + main.punteggioCPU, main.stringaPunteggio, JOptionPane.PLAIN_MESSAGE ); | ||
| 303 | } | ||
| 304 | } ); | ||
| 305 | |||
| 306 | aggiornamenti = new JMenuItem( main.stringaAggiornamenti ); | ||
| 307 | aggiornamenti.addActionListener( new ActionListener() { | ||
| 308 | /* Cerca aggiornamenti sul sito http://porkynator.altervista.org, | ||
| 309 | * confrontando la versione del programma con quella scritta nel | ||
| 310 | * file jbriscola-latest.is (online). */ | ||
| 311 | public void actionPerformed( ActionEvent e ) { | ||
| 312 | String latest = main.version; | ||
| 313 | try { | ||
| 314 | URL latestIs = new URL( "http://porkynator.altervista.org/jbriscola-latest.is" ); | ||
| 315 | BufferedReader latestIsReader = new BufferedReader( new InputStreamReader( latestIs.openStream() ) ); | ||
| 316 | latest = latestIsReader.readLine(); | ||
| 317 | } catch ( Exception ex ) { | ||
| 318 | JOptionPane.showMessageDialog( Frame.this, main.stringaNoInternet, "JBriscola - " + main.version, JOptionPane.ERROR_MESSAGE ); | ||
| 319 | } | ||
| 320 | if ( latest.equals( main.version ) ) | ||
| 321 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiNo, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 322 | else | ||
| 323 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiSi + "\n" + main.version + " ==> " + latest + "\n\n" + main.stringaScarica, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 324 | } | ||
| 325 | } ); | ||
| 326 | |||
| 327 | puntoInterrogativo.add( punti ); | ||
| 328 | puntoInterrogativo.add( tastiRapidi ); | ||
| 329 | puntoInterrogativo.add( informazioni ); | ||
| 330 | puntoInterrogativo.add( aggiornamenti ); | ||
| 331 | |||
| 332 | barraMenu.add( file ); | ||
| 333 | barraMenu.add( puntoInterrogativo ); | ||
| 334 | |||
| 335 | setJMenuBar( barraMenu ); | ||
| 336 | |||
| 337 | /* Inizializza le immagini del retro delle carte. */ | ||
| 338 | retro1 = new ImageIcon( ClassLoader.getSystemResource( "img/retro1.jpg" ) ); | ||
| 339 | retro2 = new ImageIcon( ClassLoader.getSystemResource( "img/retro2.jpg" ) ); | ||
| 340 | |||
| 341 | /* Inizializza tutte le immagini delle carte scorrendo l'array bidimensionale. */ | ||
| 342 | for (int i = 0; i < 10; i++) | ||
| 343 | for (int j = 0; j < 4; j++) | ||
| 344 | arrayCarte[i][j] = new ImageIcon( ClassLoader.getSystemResource( "img/" + (i+1) + "-" + (j+1) + ".jpg" ) ); | ||
| 345 | |||
| 346 | /* Mischia le carte. */ | ||
| 347 | main.mischia(); | ||
| 348 | |||
| 349 | /* Aggiunge i vari componenti. */ | ||
| 350 | pannello2.add( button ); | ||
| 351 | setLayout( new BorderLayout() ); | ||
| 352 | add( pannello, BorderLayout.CENTER ); | ||
| 353 | add( pannello2, BorderLayout.SOUTH ); | ||
| 354 | |||
| 355 | /* Chiama il metodo mettiCarta se l'utente clicca. */ | ||
| 356 | addMouseListener( | ||
| 357 | new MouseAdapter() { | ||
| 358 | public void mouseClicked ( MouseEvent e ) { | ||
| 359 | if ( mettiCarta( e.getX(), e.getY() ) ) { | ||
| 360 | if ( !main.CPUHaGiocato ) | ||
| 361 | main.giocaCPU(); | ||
| 362 | } | ||
| 363 | } | ||
| 364 | } | ||
| 365 | ); | ||
| 366 | |||
| 367 | /* Chiede conferma prima di uscire quando viene chiusa la finestra. */ | ||
| 368 | addWindowListener( | ||
| 369 | new WindowAdapter() { | ||
| 370 | public void windowClosing( WindowEvent e ) { | ||
| 371 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 372 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 373 | System.exit( 0 ); | ||
| 374 | } | ||
| 375 | } | ||
| 376 | ); | ||
| 377 | } | ||
| 378 | |||
| 379 | /* Se il giocatore ha cliccato su una carta la gioca e riproduce un suono casuale. */ | ||
| 380 | public boolean mettiCarta( int x, int y ) { | ||
| 381 | |||
| 382 | if ( !main.toccaAllaCPU && giocata[0] == null ) { | ||
| 383 | if ( main.sound && | ||
| 384 | ( ( x > 230 && x < 290 && y > 340 && y < 566 && carteInMano[0] != null ) || | ||
| 385 | ( x > 300 && x < 360 && y > 340 && y < 566 && carteInMano[1] != null ) || | ||
| 386 | ( x > 370 && x < 430 && y > 340 && y < 566 && carteInMano[2] != null ) ) ) { | ||
| 387 | try { | ||
| 388 | |||
| 389 | double a = Math.random() * 6; | ||
| 390 | int i = (int) a; | ||
| 391 | |||
| 392 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( ClassLoader.getSystemResource("sounds/" + i + ".wav") ); | ||
| 393 | AudioInputStream ais = AudioSystem.getAudioInputStream( ClassLoader.getSystemResource("sounds/" + i + ".wav") ); | ||
| 394 | AudioFormat af = aff.getFormat(); | ||
| 395 | DataLine.Info info = new DataLine.Info( Clip.class, ais.getFormat(), ( (int) ais.getFrameLength() * af.getFrameSize() ) ); | ||
| 396 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 397 | |||
| 398 | ol.open(ais); | ||
| 399 | ol.loop( 0 ); | ||
| 400 | |||
| 401 | } catch ( Exception e ) { | ||
| 402 | System.err.println( e ); | ||
| 403 | } | ||
| 404 | } | ||
| 405 | |||
| 406 | if ( x > 230 && x < 290 && y > 340 && y < 566 && carteInMano[0] != null ) { | ||
| 407 | giocata[0] = carteInMano[0]; | ||
| 408 | carteInMano[0] = null; | ||
| 409 | pannello.repaint(); | ||
| 410 | return true; | ||
| 411 | } | ||
| 412 | |||
| 413 | if ( x > 300 && x < 360 && y > 340 && y < 566 && carteInMano[1] != null ) { | ||
| 414 | giocata[0] = carteInMano[1]; | ||
| 415 | carteInMano[1] = null; | ||
| 416 | pannello.repaint(); | ||
| 417 | return true; | ||
| 418 | } | ||
| 419 | |||
| 420 | if ( x > 370 && x < 430 && y > 340 && y < 566 && carteInMano[2] != null ) { | ||
| 421 | giocata[0] = carteInMano[2]; | ||
| 422 | carteInMano[2] = null; | ||
| 423 | pannello.repaint(); | ||
| 424 | return true; | ||
| 425 | } | ||
| 426 | } | ||
| 427 | |||
| 428 | return false; | ||
| 429 | } | ||
| 430 | } | ||
| 431 | |||
| 432 | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/Main.java b/JBriscola/all_versions/0.2/0.2.2/src/Main.java new file mode 100755 index 0000000..baf7968 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/Main.java | |||
| @@ -0,0 +1,1317 @@ | |||
| 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 | |||
| 29 | /* semeBriscola serve a determinare quale il seme di briscola (0 coppe, | ||
| 30 | * 1 bastoni, 2 denari, 3 spade). | ||
| 31 | * punteggio è il punteggio del giocatore, punteggioCPU quello della CPU | ||
| 32 | * mano tiene il conto della mano a cui si è arrivati. | ||
| 33 | * cartaDaPescare è la carta che la CPU deve raccogliere dal mazzo | ||
| 34 | * cartaDaGiocare (può assumere valore compraso tra 0 e 2) è la carta | ||
| 35 | * che la cpu deve giocare. */ | ||
| 36 | public static int semeBriscola, punteggio, punteggioCPU, mano, cartaDaPescare, cartaDaGiocare; | ||
| 37 | |||
| 38 | /* toccaAllaCPU determina se è il turno del computer o del giocatore, | ||
| 39 | * CPUHaGiocato se il computer ha già giocato in questo turno e | ||
| 40 | * haGiocatoPrima se la prima mossa del turno è stata del giocatore | ||
| 41 | * (true) o della CPU (false). | ||
| 42 | * sound e keys riguardano le opzioni (souno si o no, tasti rapidi si | ||
| 43 | * o no) salvate nel file di configurazione. */ | ||
| 44 | public static boolean toccaAllaCPU = false; | ||
| 45 | public static boolean CPUHaGiocato = false; | ||
| 46 | public static boolean haGiocatoPrima = true; | ||
| 47 | public static boolean sound = true; | ||
| 48 | public static boolean keys = true; | ||
| 49 | |||
| 50 | /* frame è la finestra principale del gioco, color il colore dello sfondo. | ||
| 51 | * lang, soundString e keysString servono a leggere le opzioni dal file | ||
| 52 | * di configurazione. */ | ||
| 53 | public static Frame frame; | ||
| 54 | public static Color color = new Color( 0, 150, 0 ); | ||
| 55 | public static String lang, soundString, keysString; | ||
| 56 | |||
| 57 | /* Tutte le stringhe che vengono utilizzate durante il gioco sono | ||
| 58 | * inizializzate qui, per poter essere tradotte in altre lingue. */ | ||
| 59 | public static String version = "0.2.2"; | ||
| 60 | public static String stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 61 | public static String stringaPrimaGioca = "Prima Gioca!"; | ||
| 62 | public static String stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 63 | public static String stringaVinto = "Hai Vinto!"; | ||
| 64 | public static String stringaPerso = "Hai Perso"; | ||
| 65 | public static String stringaPareggio = "Pareggio"; | ||
| 66 | public static String stringaGiocatore = "Giocatore: "; | ||
| 67 | public static String stringaComputer = "\nComputer: "; | ||
| 68 | public static String stringaNuovaPartita = "Nuova Partita"; | ||
| 69 | public static String stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 70 | public static String stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 71 | public static String stringaSi = "Si"; | ||
| 72 | public static String stringaNo = "No"; | ||
| 73 | public static String stringaOpzioni = "Opzioni..."; | ||
| 74 | public static String stringaEsci = "Esci"; | ||
| 75 | public static String stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 76 | public static String stringaLingua = "Lingua"; | ||
| 77 | public static String stringaAnnulla = "Annulla"; | ||
| 78 | public static String stringaIt = "Italiano"; | ||
| 79 | public static String stringaLa = "Latino"; | ||
| 80 | public static String stringaBL = "Dialetto Bellunese"; | ||
| 81 | public static String stringaBV = "Dialetto Basso Veneto"; | ||
| 82 | public static String stringaEN = "Inglese"; | ||
| 83 | public static String stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 84 | public static String stringaInformazioni = "Informazioni"; | ||
| 85 | 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"; | ||
| 86 | public static String stringaSuono = "Effetti Sonori"; | ||
| 87 | public static String stringaPunteggio = "Punteggio"; | ||
| 88 | public static String stringaSfondo = "Sfondo"; | ||
| 89 | public static String stringaTasti = "Tasti rapidi"; | ||
| 90 | public static String stringaAggiornamenti = "Cerca aggiornamenti"; | ||
| 91 | public static String stringaAggiornamentiSi = "Aggiornamento disponibile: "; | ||
| 92 | public static String stringaAggiornamentiNo = "Nessun aggiornamento disponibile"; | ||
| 93 | public static String stringaScarica = "E' possibile scaricare la versione più recente\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 94 | public static String stringaNoInternet = "Errore: nessuna connessione internet"; | ||
| 95 | 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; | ||
| 96 | |||
| 97 | public static void main( String args[] ) { | ||
| 98 | |||
| 99 | /* Chiama il metodo settaOpzioni per leggere le impostazioni | ||
| 100 | * dell'utente da un eventuale file di configurazione */ | ||
| 101 | settaOpzioni(); | ||
| 102 | |||
| 103 | /* Crea la finestra principale del gioco e la posiziona al centro | ||
| 104 | * dello schermo. */ | ||
| 105 | frame = new Frame(); | ||
| 106 | frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); | ||
| 107 | frame.setResizable( false ); | ||
| 108 | frame.setSize( 600, 600 ); | ||
| 109 | frame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 600) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - 600) / 2); | ||
| 110 | frame.setVisible( true ); | ||
| 111 | } | ||
| 112 | |||
| 113 | /* Algoritmo per mischiare il mazzo: prende due carte a caso e le | ||
| 114 | * inverte di posto, utilizzando una variabile aux. Ripete il procedimento | ||
| 115 | * per 391 volte. */ | ||
| 116 | public void mischia() { | ||
| 117 | |||
| 118 | mano = 0; | ||
| 119 | punteggio = 0; | ||
| 120 | punteggioCPU = 0; | ||
| 121 | cartaDaPescare = 6; | ||
| 122 | ImageIcon aux; | ||
| 123 | frame.mazzo = true; | ||
| 124 | toccaAllaCPU = false; | ||
| 125 | CPUHaGiocato = false; | ||
| 126 | haGiocatoPrima = true; | ||
| 127 | |||
| 128 | /* Inizializza l'array di carte mescolate ordinato */ | ||
| 129 | for ( int i = 0, k = 0; i < 10; i++ ) | ||
| 130 | for ( int j = 0; j < 4; j++, k++ ) | ||
| 131 | frame.arrayCarteMescolate[k] = frame.arrayCarte[i][j]; | ||
| 132 | |||
| 133 | /* Mescola le carte utilizzando il metodo sopra citato */ | ||
| 134 | for ( int i = 0; i < 391; i++ ) { | ||
| 135 | double a = Math.random() * 40; | ||
| 136 | int x = (int) a; | ||
| 137 | double b = Math.random() * 40; | ||
| 138 | int y = (int) b; | ||
| 139 | aux = frame.arrayCarteMescolate[x]; | ||
| 140 | frame.arrayCarteMescolate[x] = frame.arrayCarteMescolate[y]; | ||
| 141 | frame.arrayCarteMescolate[y] = aux; | ||
| 142 | } | ||
| 143 | |||
| 144 | /* Imposta il seme della briscola leggendo il nome dell'ultima carta | ||
| 145 | * utilizzando un array ausiliare */ | ||
| 146 | char auxChar[] = frame.arrayCarteMescolate[39].toString().toCharArray(); | ||
| 147 | semeBriscola = auxChar[auxChar.length-5] - 49; | ||
| 148 | |||
| 149 | /* Distribuisce le carte */ | ||
| 150 | frame.carteInMano[0] = frame.arrayCarteMescolate[0]; | ||
| 151 | frame.carteInMano[1] = frame.arrayCarteMescolate[1]; | ||
| 152 | frame.carteInMano[2] = frame.arrayCarteMescolate[2]; | ||
| 153 | frame.carteCPU[0] = frame.arrayCarteMescolate[3]; | ||
| 154 | frame.carteCPU[1] = frame.arrayCarteMescolate[4]; | ||
| 155 | frame.carteCPU[2] = frame.arrayCarteMescolate[5]; | ||
| 156 | frame.ultimaCarta = frame.arrayCarteMescolate[39]; | ||
| 157 | frame.giocata[0] = null; | ||
| 158 | frame.giocata[1] = null; | ||
| 159 | } | ||
| 160 | |||
| 161 | /* Fa giocare la CPU. Questo metodo contiene l'iuntelligenza artificiale | ||
| 162 | * del gioco. Ho preferito non commentare il corpo del metodo per due | ||
| 163 | * motivi; il primo è che abbastanza intuitivo: basta sapere che i vari | ||
| 164 | * metodi vaiLiscio(), vaiTaglio() ecc... tentano di fare ciò che | ||
| 165 | * ovviamente dice il loro nome, se ci riescono restituiscono true, | ||
| 166 | * in caso contrario false.*/ | ||
| 167 | public void giocaCPU() { | ||
| 168 | |||
| 169 | if ( mano < 16 ) { | ||
| 170 | |||
| 171 | /* Valuta cosa fare se il giocatore non ha ancora giocato. */ | ||
| 172 | if ( frame.giocata[0] == null ) { | ||
| 173 | if ( vaiPunti() ); | ||
| 174 | else if ( vaiLiscio() ); | ||
| 175 | else if ( vaiTaglio() ); | ||
| 176 | else if ( vaiBriscolaAlta() ); | ||
| 177 | else if ( vaiCarico() ); | ||
| 178 | else if ( vaiTre() ); | ||
| 179 | else if ( vaiAsso() ); | ||
| 180 | else; | ||
| 181 | } | ||
| 182 | |||
| 183 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 184 | else { | ||
| 185 | if ( haLisciato() ) { | ||
| 186 | if ( vaiSopra() ); | ||
| 187 | else if ( vaiLiscio() ); | ||
| 188 | else if ( vaiPunti() ); | ||
| 189 | else if ( vaiTaglio() ); | ||
| 190 | else if ( vaiTre() ); | ||
| 191 | else if ( vaiBriscolaAlta() ); | ||
| 192 | else if ( vaiCarico() ); | ||
| 193 | else if ( vaiAsso() ); | ||
| 194 | } else if ( haMessoPunti() ) { | ||
| 195 | if ( vaiSopra() ); | ||
| 196 | else if ( vaiLiscio() ); | ||
| 197 | else if ( vaiTaglio() ); | ||
| 198 | else if ( vaiPunti() ); | ||
| 199 | else if ( vaiTre() ); | ||
| 200 | else if ( vaiBriscolaAlta() ); | ||
| 201 | else if ( vaiCarico() ); | ||
| 202 | else if ( vaiAsso() ); | ||
| 203 | } else if ( haTagliato() ) { | ||
| 204 | if ( vaiLiscio() ); | ||
| 205 | else if ( vaiPunti() ); | ||
| 206 | else if ( vaiTaglio() ); | ||
| 207 | else if ( vaiTre() ); | ||
| 208 | else if ( vaiBriscolaAlta() ); | ||
| 209 | else if ( vaiCarico() ); | ||
| 210 | else if ( vaiAsso() ); | ||
| 211 | } else if ( haMessoBriscolaAlta() ) { | ||
| 212 | if ( vaiLiscio() ); | ||
| 213 | else if ( vaiPunti() ); | ||
| 214 | else if ( vaiTre() ); | ||
| 215 | else if ( vaiTaglio() ); | ||
| 216 | else if ( vaiBriscolaAlta() ); | ||
| 217 | else if ( vaiCarico() ); | ||
| 218 | else if ( vaiAsso() ); | ||
| 219 | } else if ( haMessoTre() ) { | ||
| 220 | if ( vaiAsso() ); | ||
| 221 | else if ( vaiLiscio() ); | ||
| 222 | else if ( vaiPunti() ); | ||
| 223 | else if ( vaiTaglio() ); | ||
| 224 | else if ( vaiBriscolaAlta() ); | ||
| 225 | else if ( vaiCarico() ); | ||
| 226 | } else if ( haMessoAsso() ) { | ||
| 227 | if ( vaiLiscio() ); | ||
| 228 | else if ( vaiPunti() ); | ||
| 229 | else if ( vaiTaglio() ); | ||
| 230 | else if ( vaiBriscolaAlta() ); | ||
| 231 | else if ( vaiCarico() ); | ||
| 232 | else if ( vaiTre() ); | ||
| 233 | } else if ( haCaricato() ) { | ||
| 234 | if ( vaiSopra() ); | ||
| 235 | else if ( vaiTre() ); | ||
| 236 | else if ( vaiBriscolaAlta() ); | ||
| 237 | else if ( vaiAsso() ); | ||
| 238 | else if ( vaiTaglio() ); | ||
| 239 | else if ( vaiLiscio() ); | ||
| 240 | else if ( vaiPunti() ); | ||
| 241 | else if ( vaiCarico() ); | ||
| 242 | } | ||
| 243 | } | ||
| 244 | } | ||
| 245 | else if ( mano == 16 ) { | ||
| 246 | if ( frame.giocata[0] == null ) { | ||
| 247 | char aux[]; | ||
| 248 | aux = frame.ultimaCarta.toString().toCharArray(); | ||
| 249 | if ( aux[aux.length-7] - 48 == 3 || aux[aux.length-7] - 48 == 1 ) { | ||
| 250 | if ( vaiCarico() ); | ||
| 251 | else if ( vaiPunti() ); | ||
| 252 | else if ( vaiLiscio() ); | ||
| 253 | else if ( vaiTaglio() ); | ||
| 254 | else if ( vaiBriscolaAlta() ); | ||
| 255 | else if ( vaiTre() ); | ||
| 256 | else if ( vaiAsso() ); | ||
| 257 | else; | ||
| 258 | } else { | ||
| 259 | if ( vaiPunti() ); | ||
| 260 | else if ( vaiLiscio() ); | ||
| 261 | else if ( vaiTaglio() ); | ||
| 262 | else if ( vaiBriscolaAlta() ); | ||
| 263 | else if ( vaiCarico() ); | ||
| 264 | else if ( vaiTre() ); | ||
| 265 | else if ( vaiAsso() ); | ||
| 266 | else; | ||
| 267 | } | ||
| 268 | } | ||
| 269 | else { | ||
| 270 | char aux[]; | ||
| 271 | aux = frame.ultimaCarta.toString().toCharArray(); | ||
| 272 | if ( aux[aux.length-7] - 48 == 3 || aux[aux.length-7] - 48 == 1 ) { | ||
| 273 | if ( haCaricato() ) { | ||
| 274 | if ( vaiSopra() ); | ||
| 275 | else if ( vaiLiscio() ); | ||
| 276 | else if ( vaiPunti() ); | ||
| 277 | else if ( vaiTre() ); | ||
| 278 | else if ( vaiTaglio() ); | ||
| 279 | else if ( vaiBriscolaAlta() ); | ||
| 280 | else if ( vaiAsso() ); | ||
| 281 | else if ( vaiCarico() ); | ||
| 282 | } | ||
| 283 | } else { | ||
| 284 | if ( haLisciato() ) { | ||
| 285 | if ( vaiSopra() ); | ||
| 286 | else if ( vaiLiscio() ); | ||
| 287 | else if ( vaiPunti() ); | ||
| 288 | else if ( vaiTaglio() ); | ||
| 289 | else if ( vaiTre() ); | ||
| 290 | else if ( vaiBriscolaAlta() ); | ||
| 291 | else if ( vaiCarico() ); | ||
| 292 | else if ( vaiAsso() ); | ||
| 293 | } else if ( haMessoPunti() ) { | ||
| 294 | if ( vaiSopra() ); | ||
| 295 | else if ( vaiLiscio() ); | ||
| 296 | else if ( vaiTaglio() ); | ||
| 297 | else if ( vaiPunti() ); | ||
| 298 | else if ( vaiTre() ); | ||
| 299 | else if ( vaiBriscolaAlta() ); | ||
| 300 | else if ( vaiCarico() ); | ||
| 301 | else if ( vaiAsso() ); | ||
| 302 | } else if ( haTagliato() ) { | ||
| 303 | if ( vaiLiscio() ); | ||
| 304 | else if ( vaiPunti() ); | ||
| 305 | else if ( vaiTaglio() ); | ||
| 306 | else if ( vaiTre() ); | ||
| 307 | else if ( vaiBriscolaAlta() ); | ||
| 308 | else if ( vaiCarico() ); | ||
| 309 | else if ( vaiAsso() ); | ||
| 310 | } else if ( haMessoBriscolaAlta() ) { | ||
| 311 | if ( vaiLiscio() ); | ||
| 312 | else if ( vaiPunti() ); | ||
| 313 | else if ( vaiTre() ); | ||
| 314 | else if ( vaiTaglio() ); | ||
| 315 | else if ( vaiBriscolaAlta() ); | ||
| 316 | else if ( vaiCarico() ); | ||
| 317 | else if ( vaiAsso() ); | ||
| 318 | } else if ( haMessoTre() ) { | ||
| 319 | if ( vaiAsso() ); | ||
| 320 | else if ( vaiLiscio() ); | ||
| 321 | else if ( vaiPunti() ); | ||
| 322 | else if ( vaiTaglio() ); | ||
| 323 | else if ( vaiBriscolaAlta() ); | ||
| 324 | else if ( vaiCarico() ); | ||
| 325 | } else if ( haMessoAsso() ) { | ||
| 326 | if ( vaiLiscio() ); | ||
| 327 | else if ( vaiPunti() ); | ||
| 328 | else if ( vaiTaglio() ); | ||
| 329 | else if ( vaiBriscolaAlta() ); | ||
| 330 | else if ( vaiCarico() ); | ||
| 331 | else if ( vaiTre() ); | ||
| 332 | } else if ( haCaricato() ) { | ||
| 333 | if ( vaiSopra() ); | ||
| 334 | else if ( vaiTre() ); | ||
| 335 | else if ( vaiBriscolaAlta() ); | ||
| 336 | else if ( vaiAsso() ); | ||
| 337 | else if ( vaiTaglio() ); | ||
| 338 | else if ( vaiLiscio() ); | ||
| 339 | else if ( vaiPunti() ); | ||
| 340 | else if ( vaiCarico() ); | ||
| 341 | } | ||
| 342 | } | ||
| 343 | } | ||
| 344 | } else if ( mano == 17 ) { | ||
| 345 | if ( frame.giocata[0] == null ) { | ||
| 346 | if ( hoAsso() ) { | ||
| 347 | if ( vaiTre() ); | ||
| 348 | else if ( vaiBriscolaAlta() ); | ||
| 349 | else if ( vaiTaglio() ); | ||
| 350 | else if ( vaiLiscio() ); | ||
| 351 | else if ( vaiPunti() ); | ||
| 352 | else if ( vaiAsso() ); | ||
| 353 | else if ( vaiCarico() ); | ||
| 354 | } else { | ||
| 355 | if ( vaiLiscio() ); | ||
| 356 | else if ( vaiPunti() ); | ||
| 357 | else if ( vaiTaglio() ); | ||
| 358 | else if ( vaiBriscolaAlta() ); | ||
| 359 | else if ( vaiCarico() ); | ||
| 360 | else if ( vaiTre() ); | ||
| 361 | } | ||
| 362 | } | ||
| 363 | else { | ||
| 364 | if ( haLisciato() ) { | ||
| 365 | if ( vaiSopra() ); | ||
| 366 | else if ( vaiLiscio() ); | ||
| 367 | else if ( vaiPunti() ); | ||
| 368 | else if ( vaiTaglio() ); | ||
| 369 | else if ( vaiTre() ); | ||
| 370 | else if ( vaiBriscolaAlta() ); | ||
| 371 | else if ( vaiCarico() ); | ||
| 372 | else if ( vaiAsso() ); | ||
| 373 | } else if ( haMessoPunti() ) { | ||
| 374 | if ( vaiSopra() ); | ||
| 375 | else if ( vaiLiscio() ); | ||
| 376 | else if ( vaiTaglio() ); | ||
| 377 | else if ( vaiPunti() ); | ||
| 378 | else if ( vaiTre() ); | ||
| 379 | else if ( vaiBriscolaAlta() ); | ||
| 380 | else if ( vaiCarico() ); | ||
| 381 | else if ( vaiAsso() ); | ||
| 382 | } else if ( haTagliato() ) { | ||
| 383 | if ( vaiLiscio() ); | ||
| 384 | else if ( vaiPunti() ); | ||
| 385 | else if ( vaiTaglio() ); | ||
| 386 | else if ( vaiTre() ); | ||
| 387 | else if ( vaiBriscolaAlta() ); | ||
| 388 | else if ( vaiCarico() ); | ||
| 389 | else if ( vaiAsso() ); | ||
| 390 | } else if ( haMessoBriscolaAlta() ) { | ||
| 391 | if ( vaiLiscio() ); | ||
| 392 | else if ( vaiPunti() ); | ||
| 393 | else if ( vaiTre() ); | ||
| 394 | else if ( vaiTaglio() ); | ||
| 395 | else if ( vaiBriscolaAlta() ); | ||
| 396 | else if ( vaiCarico() ); | ||
| 397 | else if ( vaiAsso() ); | ||
| 398 | } else if ( haMessoTre() ) { | ||
| 399 | if ( vaiAsso() ); | ||
| 400 | else if ( vaiLiscio() ); | ||
| 401 | else if ( vaiPunti() ); | ||
| 402 | else if ( vaiTaglio() ); | ||
| 403 | else if ( vaiBriscolaAlta() ); | ||
| 404 | else if ( vaiCarico() ); | ||
| 405 | } else if ( haMessoAsso() ) { | ||
| 406 | if ( vaiLiscio() ); | ||
| 407 | else if ( vaiPunti() ); | ||
| 408 | else if ( vaiTaglio() ); | ||
| 409 | else if ( vaiBriscolaAlta() ); | ||
| 410 | else if ( vaiCarico() ); | ||
| 411 | else if ( vaiTre() ); | ||
| 412 | } else if ( haCaricato() ) { | ||
| 413 | if ( vaiSopra() ); | ||
| 414 | else if ( vaiTre() ); | ||
| 415 | else if ( vaiBriscolaAlta() ); | ||
| 416 | else if ( vaiAsso() ); | ||
| 417 | else if ( vaiTaglio() ); | ||
| 418 | else if ( vaiLiscio() ); | ||
| 419 | else if ( vaiPunti() ); | ||
| 420 | else if ( vaiCarico() ); | ||
| 421 | } | ||
| 422 | } | ||
| 423 | } else if ( mano == 18 ) { | ||
| 424 | if ( frame.giocata[0] == null ) { | ||
| 425 | if ( vaiAsso() ); | ||
| 426 | else if ( vaiCarico() ); | ||
| 427 | else if ( vaiBriscolaAlta() ); | ||
| 428 | else if ( vaiTaglio() ); | ||
| 429 | else if ( vaiPunti() ); | ||
| 430 | else if ( vaiLiscio() ); | ||
| 431 | else if ( vaiTre() ); | ||
| 432 | } | ||
| 433 | else { | ||
| 434 | if ( haLisciato() ) { | ||
| 435 | if ( vaiSopra() ); | ||
| 436 | else if ( vaiLiscio() ); | ||
| 437 | else if ( vaiPunti() ); | ||
| 438 | else if ( vaiTaglio() ); | ||
| 439 | else if ( vaiTre() ); | ||
| 440 | else if ( vaiBriscolaAlta() ); | ||
| 441 | else if ( vaiCarico() ); | ||
| 442 | else if ( vaiAsso() ); | ||
| 443 | } else if ( haMessoPunti() ) { | ||
| 444 | if ( vaiSopra() ); | ||
| 445 | else if ( vaiLiscio() ); | ||
| 446 | else if ( vaiTaglio() ); | ||
| 447 | else if ( vaiPunti() ); | ||
| 448 | else if ( vaiTre() ); | ||
| 449 | else if ( vaiBriscolaAlta() ); | ||
| 450 | else if ( vaiCarico() ); | ||
| 451 | else if ( vaiAsso() ); | ||
| 452 | } else if ( haTagliato() ) { | ||
| 453 | if ( vaiLiscio() ); | ||
| 454 | else if ( vaiPunti() ); | ||
| 455 | else if ( vaiTaglio() ); | ||
| 456 | else if ( vaiTre() ); | ||
| 457 | else if ( vaiBriscolaAlta() ); | ||
| 458 | else if ( vaiCarico() ); | ||
| 459 | else if ( vaiAsso() ); | ||
| 460 | } else if ( haMessoBriscolaAlta() ) { | ||
| 461 | if ( vaiLiscio() ); | ||
| 462 | else if ( vaiPunti() ); | ||
| 463 | else if ( vaiTre() ); | ||
| 464 | else if ( vaiTaglio() ); | ||
| 465 | else if ( vaiBriscolaAlta() ); | ||
| 466 | else if ( vaiCarico() ); | ||
| 467 | else if ( vaiAsso() ); | ||
| 468 | } else if ( haMessoTre() ) { | ||
| 469 | if ( vaiAsso() ); | ||
| 470 | else if ( vaiLiscio() ); | ||
| 471 | else if ( vaiPunti() ); | ||
| 472 | else if ( vaiTaglio() ); | ||
| 473 | else if ( vaiBriscolaAlta() ); | ||
| 474 | else if ( vaiCarico() ); | ||
| 475 | } else if ( haMessoAsso() ) { | ||
| 476 | if ( vaiLiscio() ); | ||
| 477 | else if ( vaiPunti() ); | ||
| 478 | else if ( vaiTaglio() ); | ||
| 479 | else if ( vaiBriscolaAlta() ); | ||
| 480 | else if ( vaiCarico() ); | ||
| 481 | else if ( vaiTre() ); | ||
| 482 | } else if ( haCaricato() ) { | ||
| 483 | if ( vaiSopra() ); | ||
| 484 | else if ( vaiTre() ); | ||
| 485 | else if ( vaiBriscolaAlta() ); | ||
| 486 | else if ( vaiAsso() ); | ||
| 487 | else if ( vaiTaglio() ); | ||
| 488 | else if ( vaiLiscio() ); | ||
| 489 | else if ( vaiPunti() ); | ||
| 490 | else if ( vaiCarico() ); | ||
| 491 | } | ||
| 492 | } | ||
| 493 | } else { | ||
| 494 | if ( vaiTre() ); | ||
| 495 | else if ( vaiBriscolaAlta() ); | ||
| 496 | else if ( vaiAsso() ); | ||
| 497 | else if ( vaiTaglio() ); | ||
| 498 | else if ( vaiLiscio() ); | ||
| 499 | else if ( vaiPunti() ); | ||
| 500 | else if ( vaiCarico() ); | ||
| 501 | } | ||
| 502 | |||
| 503 | /* Gioca la carta e aggiorna la finestra con il metodo repaint() */ | ||
| 504 | frame.giocata[1] = frame.carteCPU[cartaDaGiocare]; | ||
| 505 | frame.carteCPU[cartaDaGiocare] = null; | ||
| 506 | frame.pannello.repaint(); | ||
| 507 | |||
| 508 | CPUHaGiocato = true; | ||
| 509 | |||
| 510 | if ( frame.giocata[0] == null ) | ||
| 511 | toccaAllaCPU = false; | ||
| 512 | } | ||
| 513 | |||
| 514 | /* Determina se ha preso la CPU o il giocatore */ | ||
| 515 | public void chiPrende() { | ||
| 516 | char aux[], auxCPU[]; | ||
| 517 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 518 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 519 | |||
| 520 | /* Chiama il metodo giocatorePrende( boolean giocatore ) con parametro | ||
| 521 | * true se ha preso il giocatore, false se ha preso la CPU */ | ||
| 522 | giocatorePrende( ( (aux[aux.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) ) | ||
| 523 | || ( (aux[aux.length-5] == auxCPU[auxCPU.length-5]) && laPrimaEPiuAlta( aux[aux.length-7] - 48, auxCPU[auxCPU.length-7] - 48 ) ) | ||
| 524 | || ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (aux[aux.length-5] != auxCPU[auxCPU.length-5]) && haGiocatoPrima ) ); | ||
| 525 | } | ||
| 526 | |||
| 527 | /* Confronta due carte per decidere quale ha più valore di presa. | ||
| 528 | * Restituisce true se è la prima, false se è la seconda */ | ||
| 529 | public boolean laPrimaEPiuAlta( int prima, int seconda ) { | ||
| 530 | int a, b; | ||
| 531 | switch ( prima ) { | ||
| 532 | case 0: | ||
| 533 | a = 10; | ||
| 534 | break; | ||
| 535 | case 1: | ||
| 536 | a = 12; | ||
| 537 | break; | ||
| 538 | case 3: | ||
| 539 | a = 11; | ||
| 540 | break; | ||
| 541 | default: | ||
| 542 | a = prima; | ||
| 543 | break; | ||
| 544 | } | ||
| 545 | switch ( seconda ) { | ||
| 546 | case 0: | ||
| 547 | b = 10; | ||
| 548 | break; | ||
| 549 | case 1: | ||
| 550 | b = 12; | ||
| 551 | break; | ||
| 552 | case 3: | ||
| 553 | b = 11; | ||
| 554 | break; | ||
| 555 | default: | ||
| 556 | b = seconda; | ||
| 557 | break; | ||
| 558 | } | ||
| 559 | return a > b; | ||
| 560 | } | ||
| 561 | |||
| 562 | /* Viene chiamato con parametro true se ha preso il giocatore, false se | ||
| 563 | * ha preso la CPU */ | ||
| 564 | public void giocatorePrende( boolean giocatore ) { | ||
| 565 | if ( giocatore ) { | ||
| 566 | toccaAllaCPU = CPUHaGiocato = false; | ||
| 567 | haGiocatoPrima = true; | ||
| 568 | } | ||
| 569 | else { | ||
| 570 | toccaAllaCPU = true; | ||
| 571 | CPUHaGiocato = haGiocatoPrima = false; | ||
| 572 | } | ||
| 573 | daiPunti( giocatore ); | ||
| 574 | if ( toccaAllaCPU ) | ||
| 575 | giocaCPU(); | ||
| 576 | } | ||
| 577 | |||
| 578 | /* Da i punti (true al giocatore, false alla CPU) e fa pescare le carte*/ | ||
| 579 | public void daiPunti( boolean giocatore ) { | ||
| 580 | |||
| 581 | char aux[], auxCPU[]; | ||
| 582 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 583 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 584 | int punti = 0; | ||
| 585 | |||
| 586 | switch( aux[aux.length-7] - 48 ) { | ||
| 587 | case 0: | ||
| 588 | punti += 4; | ||
| 589 | break; | ||
| 590 | case 1: | ||
| 591 | punti += 11; | ||
| 592 | break; | ||
| 593 | case 3: | ||
| 594 | punti += 10; | ||
| 595 | break; | ||
| 596 | case 8: | ||
| 597 | punti += 2; | ||
| 598 | break; | ||
| 599 | case 9: | ||
| 600 | punti += 3; | ||
| 601 | break; | ||
| 602 | default: | ||
| 603 | break; | ||
| 604 | } | ||
| 605 | switch( auxCPU[auxCPU.length-7] - 48 ) { | ||
| 606 | case 0: | ||
| 607 | punti += 4; | ||
| 608 | break; | ||
| 609 | case 1: | ||
| 610 | punti += 11; | ||
| 611 | break; | ||
| 612 | case 3: | ||
| 613 | punti += 10; | ||
| 614 | break; | ||
| 615 | case 8: | ||
| 616 | punti += 2; | ||
| 617 | break; | ||
| 618 | case 9: | ||
| 619 | punti += 3; | ||
| 620 | break; | ||
| 621 | default: | ||
| 622 | break; | ||
| 623 | } | ||
| 624 | |||
| 625 | frame.giocata[0] = frame.giocata[1] = null; | ||
| 626 | |||
| 627 | if ( giocatore ) { | ||
| 628 | punteggio += punti; | ||
| 629 | if ( mano < 18 ) { | ||
| 630 | if ( frame.carteInMano[0] == null ) | ||
| 631 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 632 | if ( frame.carteInMano[1] == null ) | ||
| 633 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 634 | if ( frame.carteInMano[2] == null ) | ||
| 635 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 636 | cartaDaPescare++; | ||
| 637 | if ( frame.carteCPU[0] == null ) | ||
| 638 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 639 | if ( frame.carteCPU[1] == null ) | ||
| 640 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 641 | if ( frame.carteCPU[2] == null ) | ||
| 642 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 643 | cartaDaPescare++; | ||
| 644 | } | ||
| 645 | } | ||
| 646 | |||
| 647 | else { | ||
| 648 | punteggioCPU += punti; | ||
| 649 | if ( mano < 18 ) { | ||
| 650 | if ( frame.carteCPU[0] == null ) | ||
| 651 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 652 | if ( frame.carteCPU[1] == null ) | ||
| 653 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 654 | if ( frame.carteCPU[2] == null ) | ||
| 655 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 656 | cartaDaPescare++; | ||
| 657 | if ( frame.carteInMano[0] == null ) | ||
| 658 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 659 | if ( frame.carteInMano[1] == null ) | ||
| 660 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 661 | if ( frame.carteInMano[2] == null ) | ||
| 662 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 663 | cartaDaPescare++; | ||
| 664 | } | ||
| 665 | } | ||
| 666 | |||
| 667 | /* Aggiorna la finestra */ | ||
| 668 | frame.pannello.repaint(); | ||
| 669 | frame.repaint(); | ||
| 670 | } | ||
| 671 | |||
| 672 | /* Vari metodi che determinano che tipo di carta ha giocato il giocatore. | ||
| 673 | * Per farlo leggono il nome dell'immagine dal file. Dato che ogni carta | ||
| 674 | * a un nome del tipo 1-1.jpg (asso di coppe) o 10-3 (re di denari) e | ||
| 675 | * così via, è facile riconoscerle. */ | ||
| 676 | public boolean haLisciato() { | ||
| 677 | char auxCPU[]; | ||
| 678 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 679 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 680 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 681 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ); | ||
| 682 | } | ||
| 683 | |||
| 684 | public boolean haMessoPunti() { | ||
| 685 | char auxCPU[]; | ||
| 686 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 687 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 688 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || | ||
| 689 | (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ); | ||
| 690 | } | ||
| 691 | |||
| 692 | public boolean haTagliato() { | ||
| 693 | char auxCPU[]; | ||
| 694 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 695 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 696 | (auxCPU[auxCPU.length-7] - 48 != 0) && (auxCPU[auxCPU.length-7] - 48 != 1) && | ||
| 697 | (auxCPU[auxCPU.length-7] - 48 != 3) && (auxCPU[auxCPU.length-7] - 48 <= 7) ); | ||
| 698 | } | ||
| 699 | |||
| 700 | public boolean haMessoBriscolaAlta() { | ||
| 701 | char auxCPU[]; | ||
| 702 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 703 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 704 | ( (auxCPU[auxCPU.length-7] - 48 == 0) || (auxCPU[auxCPU.length-7] - 48 == 8) || | ||
| 705 | (auxCPU[auxCPU.length-7] - 48 == 9) ) ); | ||
| 706 | } | ||
| 707 | |||
| 708 | public boolean haMessoTre() { | ||
| 709 | char auxCPU[]; | ||
| 710 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 711 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 712 | (auxCPU[auxCPU.length-7] - 48 == 3) ); | ||
| 713 | } | ||
| 714 | |||
| 715 | public boolean haMessoAsso() { | ||
| 716 | char auxCPU[]; | ||
| 717 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 718 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 719 | (auxCPU[auxCPU.length-7] - 48 == 1) ); | ||
| 720 | } | ||
| 721 | |||
| 722 | public boolean haCaricato() { | ||
| 723 | char auxCPU[]; | ||
| 724 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 725 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 726 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ); | ||
| 727 | } | ||
| 728 | |||
| 729 | /* I metodi seguenti cercano di andare liscio - dare punti - mettere | ||
| 730 | * un taglio - ecc... e restituiscono true se hanno avuto successo, | ||
| 731 | * false altrimenti. */ | ||
| 732 | public boolean vaiLiscio() { | ||
| 733 | |||
| 734 | char auxCPU[]; | ||
| 735 | |||
| 736 | for ( int i = 0; i < 3; i++ ) { | ||
| 737 | if ( frame.carteCPU[i] != null ) { | ||
| 738 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 739 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 740 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 741 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ) { | ||
| 742 | cartaDaGiocare = i; | ||
| 743 | return true; | ||
| 744 | } | ||
| 745 | } | ||
| 746 | } | ||
| 747 | |||
| 748 | return false; | ||
| 749 | } | ||
| 750 | |||
| 751 | public boolean vaiPunti() { | ||
| 752 | /* Cerca di dare punti, cercando di darne il meno possibile (meglio | ||
| 753 | * un fante di re). */ | ||
| 754 | |||
| 755 | char[] auxCPU; | ||
| 756 | |||
| 757 | for ( int i = 0; i < 3; i++ ) { | ||
| 758 | if ( frame.carteCPU[i] != null ) { | ||
| 759 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 760 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 8 ) ) { | ||
| 761 | cartaDaGiocare = i; | ||
| 762 | return true; | ||
| 763 | } | ||
| 764 | } | ||
| 765 | } | ||
| 766 | |||
| 767 | for ( int i = 0; i < 3; i++ ) { | ||
| 768 | if ( frame.carteCPU[i] != null ) { | ||
| 769 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 770 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 9 ) ) { | ||
| 771 | cartaDaGiocare = i; | ||
| 772 | return true; | ||
| 773 | } | ||
| 774 | } | ||
| 775 | } | ||
| 776 | |||
| 777 | for ( int i = 0; i < 3; i++ ) { | ||
| 778 | if ( frame.carteCPU[i] != null ) { | ||
| 779 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 780 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 0 ) ) { | ||
| 781 | cartaDaGiocare = i; | ||
| 782 | return true; | ||
| 783 | } | ||
| 784 | } | ||
| 785 | } | ||
| 786 | |||
| 787 | return false; | ||
| 788 | } | ||
| 789 | public boolean vaiTaglio() { | ||
| 790 | |||
| 791 | char auxCPU[]; | ||
| 792 | |||
| 793 | for ( int i = 0; i < 3; i++ ) { | ||
| 794 | if ( frame.carteCPU[i] != null ) { | ||
| 795 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 796 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && | ||
| 797 | (auxCPU[auxCPU.length-7] - 48 != 0) && (auxCPU[auxCPU.length-7] - 48 != 1) && | ||
| 798 | (auxCPU[auxCPU.length-7] - 48 != 3) && (auxCPU[auxCPU.length-7] - 48 <= 7) ) { | ||
| 799 | cartaDaGiocare = i; | ||
| 800 | return true; | ||
| 801 | } | ||
| 802 | } | ||
| 803 | } | ||
| 804 | |||
| 805 | return false; | ||
| 806 | } | ||
| 807 | public boolean vaiBriscolaAlta() { | ||
| 808 | |||
| 809 | char[] auxCPU; | ||
| 810 | |||
| 811 | for ( int i = 0; i < 3; i++ ) { | ||
| 812 | if ( frame.carteCPU[i] != null ) { | ||
| 813 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 814 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 8 ) ) { | ||
| 815 | cartaDaGiocare = i; | ||
| 816 | return true; | ||
| 817 | } | ||
| 818 | } | ||
| 819 | } | ||
| 820 | |||
| 821 | for ( int i = 0; i < 3; i++ ) { | ||
| 822 | if ( frame.carteCPU[i] != null ) { | ||
| 823 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 824 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 9 ) ) { | ||
| 825 | cartaDaGiocare = i; | ||
| 826 | return true; | ||
| 827 | } | ||
| 828 | } | ||
| 829 | } | ||
| 830 | |||
| 831 | for ( int i = 0; i < 3; i++ ) { | ||
| 832 | if ( frame.carteCPU[i] != null ) { | ||
| 833 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 834 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 0 ) ) { | ||
| 835 | cartaDaGiocare = i; | ||
| 836 | return true; | ||
| 837 | } | ||
| 838 | } | ||
| 839 | } | ||
| 840 | |||
| 841 | return false; | ||
| 842 | } | ||
| 843 | public boolean vaiTre() { | ||
| 844 | |||
| 845 | char auxCPU[]; | ||
| 846 | |||
| 847 | for ( int i = 0; i < 3; i++ ) { | ||
| 848 | if ( frame.carteCPU[i] != null ) { | ||
| 849 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 850 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && (auxCPU[auxCPU.length-7] - 48 == 3) ) { | ||
| 851 | cartaDaGiocare = i; | ||
| 852 | return true; | ||
| 853 | } | ||
| 854 | } | ||
| 855 | } | ||
| 856 | |||
| 857 | return false; | ||
| 858 | } | ||
| 859 | public boolean vaiAsso() { | ||
| 860 | |||
| 861 | char auxCPU[]; | ||
| 862 | |||
| 863 | for ( int i = 0; i < 3; i++ ) { | ||
| 864 | if ( frame.carteCPU[i] != null ) { | ||
| 865 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 866 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && (auxCPU[auxCPU.length-7] - 48 == 1) ) { | ||
| 867 | cartaDaGiocare = i; | ||
| 868 | return true; | ||
| 869 | } | ||
| 870 | } | ||
| 871 | } | ||
| 872 | |||
| 873 | return false; | ||
| 874 | } | ||
| 875 | public boolean vaiCarico() { | ||
| 876 | |||
| 877 | char[] auxCPU; | ||
| 878 | |||
| 879 | for ( int i = 0; i < 3; i++ ) { | ||
| 880 | if ( frame.carteCPU[i] != null ) { | ||
| 881 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 882 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 3 ) ) { | ||
| 883 | cartaDaGiocare = i; | ||
| 884 | return true; | ||
| 885 | } | ||
| 886 | } | ||
| 887 | } | ||
| 888 | |||
| 889 | for ( int i = 0; i < 3; i++ ) { | ||
| 890 | if ( frame.carteCPU[i] != null ) { | ||
| 891 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 892 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 1 ) ) { | ||
| 893 | cartaDaGiocare = i; | ||
| 894 | return true; | ||
| 895 | } | ||
| 896 | } | ||
| 897 | } | ||
| 898 | |||
| 899 | return false; | ||
| 900 | } | ||
| 901 | public boolean vaiSopra() { | ||
| 902 | /* Innanzitutto controlla se il giocatore ha giocato (non dovrebbe | ||
| 903 | * essere possibile, in quanto quando questo metodo viene chiamato | ||
| 904 | * tale condizione è già stata verificata, ma è sempre meglio un | ||
| 905 | * controllo in più che uno in meno) e restituisce false in caso | ||
| 906 | * contrario */ | ||
| 907 | if ( frame.giocata[0] == null ) | ||
| 908 | return false; | ||
| 909 | |||
| 910 | /* Tre variabili intere che serviranno a valutare quali delle tre | ||
| 911 | * carte è meglio giocare, se più di una può andare sopra. */ | ||
| 912 | int a = -1; | ||
| 913 | int b = -1; | ||
| 914 | int c = -1; | ||
| 915 | |||
| 916 | /* Tre booleane che verificano quali delle tre carte possono | ||
| 917 | * andare sopra. */ | ||
| 918 | boolean laPrimaPuoAndareSopra = false; | ||
| 919 | boolean laSecondaPuoAndareSopra = false; | ||
| 920 | boolean laTerzaPuoAndareSopra = false; | ||
| 921 | |||
| 922 | /* E tre array di caratteri ausiliari per leggere il nome delle | ||
| 923 | * carte, più quello per la carta giocata dal giocatore.*/ | ||
| 924 | char[] auxCPU1 = new char[1024]; | ||
| 925 | char[] auxCPU2 = new char[1024]; | ||
| 926 | char[] auxCPU3 = new char[1024]; | ||
| 927 | char[] aux = frame.giocata[0].toString().toCharArray(); | ||
| 928 | |||
| 929 | /* Se il giocatore ha giocato un asso, restituisce direttamente false. */ | ||
| 930 | if ( aux[aux.length-7] - 48 == 1 ) | ||
| 931 | return false; | ||
| 932 | |||
| 933 | /* Valuta quali delle tre carte possono andare sopra, dopo essersi | ||
| 934 | * accertato di averle: nelle ultime mani non si hanno tutte le carte | ||
| 935 | * in mano, e noi non vogliamo una NullPointerException sul più bello | ||
| 936 | * di una partita, vero?! */ | ||
| 937 | if ( frame.carteCPU[0] != null ) { | ||
| 938 | auxCPU1 = frame.carteCPU[0].toString().toCharArray(); | ||
| 939 | a = auxCPU1[auxCPU1.length-7] - 48; | ||
| 940 | if ( (auxCPU1[auxCPU1.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( a, aux[aux.length-7] - 48 ) ) | ||
| 941 | laPrimaPuoAndareSopra = true; | ||
| 942 | } | ||
| 943 | |||
| 944 | if ( frame.carteCPU[1] != null ) { | ||
| 945 | auxCPU2 = frame.carteCPU[1].toString().toCharArray(); | ||
| 946 | b = auxCPU2[auxCPU2.length-7] - 48; | ||
| 947 | if ( (auxCPU2[auxCPU2.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( b, aux[aux.length-7] - 48 ) ) | ||
| 948 | laSecondaPuoAndareSopra = true; | ||
| 949 | } | ||
| 950 | |||
| 951 | if ( frame.carteCPU[2] != null ) { | ||
| 952 | auxCPU3 = frame.carteCPU[2].toString().toCharArray(); | ||
| 953 | c = auxCPU3[auxCPU3.length-7] - 48; | ||
| 954 | if ( (auxCPU3[auxCPU3.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( c, aux[aux.length-7] - 48 ) ) | ||
| 955 | laTerzaPuoAndareSopra = true; | ||
| 956 | } | ||
| 957 | |||
| 958 | /* Se nessuna carta può andare sopra, restituisce false. Se una | ||
| 959 | * sola delle tre può andare sopra la imposta come carta da giocare. */ | ||
| 960 | if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 961 | return false; | ||
| 962 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 963 | cartaDaGiocare = 0; | ||
| 964 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 965 | cartaDaGiocare = 1; | ||
| 966 | else if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 967 | cartaDaGiocare = 2; | ||
| 968 | |||
| 969 | /* Se più di una carta può andare sopra, valuta quale è più alta. */ | ||
| 970 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 971 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 972 | cartaDaGiocare = 0; | ||
| 973 | else | ||
| 974 | cartaDaGiocare = 1; | ||
| 975 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 976 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 977 | cartaDaGiocare = 1; | ||
| 978 | else | ||
| 979 | cartaDaGiocare = 2; | ||
| 980 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 981 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 982 | cartaDaGiocare = 0; | ||
| 983 | else | ||
| 984 | cartaDaGiocare = 2; | ||
| 985 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 986 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 987 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 988 | cartaDaGiocare = 0; | ||
| 989 | else | ||
| 990 | cartaDaGiocare = 2; | ||
| 991 | else | ||
| 992 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 993 | cartaDaGiocare = 1; | ||
| 994 | else | ||
| 995 | cartaDaGiocare = 2; | ||
| 996 | |||
| 997 | /* Controlla che la carta con cui sta cercando di andare sopra | ||
| 998 | * sia una figura o un carico. Non vogliamo mica prendere delle | ||
| 999 | * scartelle con delle scartelle, giusto?! */ | ||
| 1000 | aux = frame.carteCPU[cartaDaGiocare].toString().toCharArray(); | ||
| 1001 | if ( (aux[aux.length-7] - 48 != 0) && (aux[aux.length-7] - 48 != 1) && | ||
| 1002 | (aux[aux.length-7] - 48 != 3) && (aux[aux.length-7] - 48 <= 7) ) | ||
| 1003 | return false; | ||
| 1004 | |||
| 1005 | return true; | ||
| 1006 | } | ||
| 1007 | |||
| 1008 | /* I metodi seguenti valutano le carte che la CPU ha in mano. */ | ||
| 1009 | public boolean hoCarico() { | ||
| 1010 | |||
| 1011 | char auxCPU[]; | ||
| 1012 | |||
| 1013 | for ( int i = 0; i < 3; i++ ) { | ||
| 1014 | if ( frame.carteCPU[i] != null ) { | ||
| 1015 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1016 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 1017 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ) { | ||
| 1018 | return true; | ||
| 1019 | } | ||
| 1020 | } | ||
| 1021 | } | ||
| 1022 | |||
| 1023 | return false; | ||
| 1024 | } | ||
| 1025 | public boolean hoAsso() { | ||
| 1026 | |||
| 1027 | char auxCPU[]; | ||
| 1028 | |||
| 1029 | for ( int i = 0; i < 3; i++ ) { | ||
| 1030 | if ( frame.carteCPU[i] != null ) { | ||
| 1031 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1032 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 1 ) ) { | ||
| 1033 | return true; | ||
| 1034 | } | ||
| 1035 | } | ||
| 1036 | } | ||
| 1037 | |||
| 1038 | return false; | ||
| 1039 | } | ||
| 1040 | public boolean hoTre() { | ||
| 1041 | |||
| 1042 | char auxCPU[]; | ||
| 1043 | |||
| 1044 | for ( int i = 0; i < 3; i++ ) { | ||
| 1045 | if ( frame.carteCPU[i] != null ) { | ||
| 1046 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1047 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 3 ) ) { | ||
| 1048 | return true; | ||
| 1049 | } | ||
| 1050 | } | ||
| 1051 | } | ||
| 1052 | |||
| 1053 | return false; | ||
| 1054 | } | ||
| 1055 | public boolean hoBriscolaAlta() { | ||
| 1056 | |||
| 1057 | char auxCPU[]; | ||
| 1058 | |||
| 1059 | for ( int i = 0; i < 3; i++ ) { | ||
| 1060 | if ( frame.carteCPU[i] != null ) { | ||
| 1061 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1062 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 1063 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ) { | ||
| 1064 | return true; | ||
| 1065 | } | ||
| 1066 | } | ||
| 1067 | } | ||
| 1068 | |||
| 1069 | return false; | ||
| 1070 | } | ||
| 1071 | public boolean hoTaglio() { | ||
| 1072 | |||
| 1073 | char auxCPU[]; | ||
| 1074 | |||
| 1075 | for ( int i = 0; i < 3; i++ ) { | ||
| 1076 | if ( frame.carteCPU[i] != null ) { | ||
| 1077 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1078 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 1079 | (auxCPU[auxCPU.length-7] - 48 < 8 ) && (auxCPU[auxCPU.length-7] - 48 != 3 ) | ||
| 1080 | && (auxCPU[auxCPU.length-7] - 48 != 1 ) && (auxCPU[auxCPU.length-7] - 48 != 0 ) ) { | ||
| 1081 | return true; | ||
| 1082 | } | ||
| 1083 | } | ||
| 1084 | } | ||
| 1085 | |||
| 1086 | return false; | ||
| 1087 | } | ||
| 1088 | |||
| 1089 | /* Imposta le opzioni dell'utente cercando di leggerle dal file di configurazione. */ | ||
| 1090 | public static void settaOpzioni() { | ||
| 1091 | |||
| 1092 | /* Impostazioni predefinite. */ | ||
| 1093 | lang = "it"; | ||
| 1094 | soundString = "suono=si"; | ||
| 1095 | keysString = "tasti=si"; | ||
| 1096 | int r = 0; | ||
| 1097 | int g = 150; | ||
| 1098 | int b = 0; | ||
| 1099 | |||
| 1100 | /* Cerca di leggere il file per impostare le opzioni. */ | ||
| 1101 | Scanner scanner = null; | ||
| 1102 | File file = new File( "JBriscolaConfig.txt" ); | ||
| 1103 | if ( file.exists() ) { | ||
| 1104 | try { | ||
| 1105 | scanner = new Scanner( file ); | ||
| 1106 | } catch ( FileNotFoundException e ) { } | ||
| 1107 | try { | ||
| 1108 | lang = scanner.next(); | ||
| 1109 | soundString = scanner.next(); | ||
| 1110 | keysString = scanner.next(); | ||
| 1111 | r = scanner.nextInt(); | ||
| 1112 | g = scanner.nextInt(); | ||
| 1113 | b = scanner.nextInt(); | ||
| 1114 | } catch ( NoSuchElementException e ) { } | ||
| 1115 | } | ||
| 1116 | |||
| 1117 | /* Modifica le opzioni. */ | ||
| 1118 | if ( lang.equals( "it" ) ) { | ||
| 1119 | stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 1120 | stringaPrimaGioca = "Prima Gioca!"; | ||
| 1121 | stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 1122 | stringaVinto = "Hai Vinto!"; | ||
| 1123 | stringaPerso = "Hai Perso"; | ||
| 1124 | stringaPareggio = "Pareggio"; | ||
| 1125 | stringaGiocatore = "Giocatore: "; | ||
| 1126 | stringaComputer = "\nComputer: "; | ||
| 1127 | stringaNuovaPartita = "Nuova Partita"; | ||
| 1128 | stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 1129 | stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 1130 | stringaSi = "Si"; | ||
| 1131 | stringaNo = "No"; | ||
| 1132 | stringaOpzioni = "Opzioni..."; | ||
| 1133 | stringaEsci = "Esci"; | ||
| 1134 | stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 1135 | stringaLingua = "Lingua"; | ||
| 1136 | stringaAnnulla = "Annulla"; | ||
| 1137 | stringaIt = "Italiano"; | ||
| 1138 | stringaLa = "Latino"; | ||
| 1139 | stringaBL = "Dialetto Bellunese"; | ||
| 1140 | stringaBV = "Dialetto Basso Veneto"; | ||
| 1141 | stringaEN = "Inglese"; | ||
| 1142 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1143 | stringaInformazioni = "Informazioni"; | ||
| 1144 | 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"; | ||
| 1145 | stringaSuono = "Effetti sonori"; | ||
| 1146 | stringaPunteggio = "Punteggio"; | ||
| 1147 | stringaSfondo = "Sfondo"; | ||
| 1148 | stringaTasti = "Tasti rapidi"; | ||
| 1149 | stringaAggiornamenti = "Cerca aggiornamenti"; | ||
| 1150 | stringaAggiornamentiSi = "Aggiornamento disponibile: "; | ||
| 1151 | stringaAggiornamentiNo = "Nessun aggiornamento disponibile"; | ||
| 1152 | stringaScarica = "E' possibile scaricare la versione più recente\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 1153 | stringaNoInternet = "Errore: nessuna connessione internet"; | ||
| 1154 | 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; | ||
| 1155 | } | ||
| 1156 | else if ( lang.equals( "la" ) ) { | ||
| 1157 | stringaBottonePrendi = "CAPIS/RELINQVIS CHARTAS"; | ||
| 1158 | stringaPrimaGioca = "ANTE CHARTAM PONE!"; | ||
| 1159 | stringaUltime4 = "CHARTA POSTREMA - INTVERE BRISCOLAM!"; | ||
| 1160 | stringaVinto = "VICISTI!"; | ||
| 1161 | stringaPerso = "PERDIDISTI"; | ||
| 1162 | stringaPareggio = "AEQVATIO!"; | ||
| 1163 | stringaGiocatore = "LVSOR: "; | ||
| 1164 | stringaComputer = "\nCOMPVTER: "; | ||
| 1165 | stringaNuovaPartita = "NOVA LVSO"; | ||
| 1166 | stringaVuoiDavveroIniziare = "NOVAM LVSIONEM INCIPERE?"; | ||
| 1167 | stringaVuoiDavveroUscire = "EXIRE?"; | ||
| 1168 | stringaSi = "ID VOLO"; | ||
| 1169 | stringaNo = "NOLO"; | ||
| 1170 | stringaOpzioni = "OPTIONES..."; | ||
| 1171 | stringaEsci = "EXIRE"; | ||
| 1172 | stringaImpossibileConfigurare = "CONFIGVRATIONIS FILE SCRIBERE NON POTVI.\nERROREM ME CERTIOREM FACITE: sebastiano@luganega.org\n\nEXCEPTIO:\n"; | ||
| 1173 | stringaLingua = "LINGVA"; | ||
| 1174 | stringaAnnulla = "ABROGA"; | ||
| 1175 | stringaIt = "ITALICA"; | ||
| 1176 | stringaLa = "LATINA"; | ||
| 1177 | stringaBL = "BELLUNI"; | ||
| 1178 | stringaBV = "VENETIAE"; | ||
| 1179 | stringaEN = "ANGLICVS"; | ||
| 1180 | stringaModificaOpzioni = "OPTIONES NOVARE"; | ||
| 1181 | stringaInformazioni = "INFORMATIONES"; | ||
| 1182 | 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"; | ||
| 1183 | stringaSuono = "SONVS"; | ||
| 1184 | stringaPunteggio = "NVMERI"; | ||
| 1185 | stringaSfondo = "COLOR"; | ||
| 1186 | stringaTasti = "TASTI RAPIDI"; | ||
| 1187 | stringaAggiornamenti = "VERSIONEM RECENTIOREM QVAERERE"; | ||
| 1188 | stringaNoInternet = "ERROR: INTERNETIS CONIVCTIO NON EST"; | ||
| 1189 | stringaAggiornamentiSi = "VERSIO RECENTIOR EST: "; | ||
| 1190 | stringaAggiornamentiNo = "VERSIO RECENTIOR NON EST"; | ||
| 1191 | stringaScarica = "VERSIONEM RECENTIOREM CEPTA ESSE POTEST:\nhttp://porkynator.altervista.org/programmi.html"; | ||
| 1192 | 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; | ||
| 1193 | } | ||
| 1194 | if ( lang.equals( "bl" ) ) { | ||
| 1195 | stringaBottonePrendi = "Cio' su/lasa le carte"; | ||
| 1196 | stringaPrimaGioca = "Prima Duga!"; | ||
| 1197 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1198 | stringaVinto = "Te ha vint!"; | ||
| 1199 | stringaPerso = "Te ha pers"; | ||
| 1200 | stringaPareggio = "Pari"; | ||
| 1201 | stringaGiocatore = "Dugador: "; | ||
| 1202 | stringaComputer = "\nComputer: "; | ||
| 1203 | stringaNuovaPartita = "Taca n'altra partida"; | ||
| 1204 | stringaVuoiDavveroIniziare = "Utu sul serio scuminziar n'altra partida?"; | ||
| 1205 | stringaVuoiDavveroUscire = "Utu sul serio stusar su?"; | ||
| 1206 | stringaSi = "Si"; | ||
| 1207 | stringaNo = "No"; | ||
| 1208 | stringaOpzioni = "Opzioni..."; | ||
| 1209 | stringaEsci = "Stusa su"; | ||
| 1210 | stringaImpossibileConfigurare = "No ghe ho riva' a scrivere al file de configurazion.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1211 | stringaLingua = "Lengua"; | ||
| 1212 | stringaAnnulla = "Annulla"; | ||
| 1213 | stringaIt = "Italian"; | ||
| 1214 | stringaLa = "Latin"; | ||
| 1215 | stringaBL = "Dialeto de Belun"; | ||
| 1216 | stringaBV = "Dialeto de la basa"; | ||
| 1217 | stringaEN = "Inglese"; | ||
| 1218 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1219 | stringaInformazioni = "Informazioni"; | ||
| 1220 | 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"; | ||
| 1221 | stringaSuono = "Efeti sonori"; | ||
| 1222 | stringaPunteggio = "Varda i punti"; | ||
| 1223 | stringaSfondo = "Sfondo"; | ||
| 1224 | stringaTasti = "Tasti rapidi"; | ||
| 1225 | stringaAggiornamenti = "Varda se ghe ne' na version pi nova"; | ||
| 1226 | stringaAggiornamentiSi = "Ghe ne' na version pi nova: "; | ||
| 1227 | stringaAggiornamentiNo = "No ghe ne na version pi nova"; | ||
| 1228 | stringaScarica = "Te pol scaricar le version pi nova\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 1229 | stringaNoInternet = "Erore: no te se su internet"; | ||
| 1230 | 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; | ||
| 1231 | } | ||
| 1232 | if ( lang.equals( "bv" ) ) { | ||
| 1233 | stringaBottonePrendi = "Ciapa su/lasa e carte"; | ||
| 1234 | stringaPrimaGioca = "Prima Zuga!"; | ||
| 1235 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1236 | stringaVinto = "Ti ga vinto!"; | ||
| 1237 | stringaPerso = "Ti ga perso"; | ||
| 1238 | stringaPareggio = "Pari"; | ||
| 1239 | stringaGiocatore = "Zugador: "; | ||
| 1240 | stringaComputer = "\nComputer: "; | ||
| 1241 | stringaNuovaPartita = "N'altra Partida"; | ||
| 1242 | stringaVuoiDavveroIniziare = "Ti vol sul serio scuminziar n'altra partida?"; | ||
| 1243 | stringaVuoiDavveroUscire = "Ti vol sul serio stusar su?"; | ||
| 1244 | stringaSi = "Si"; | ||
| 1245 | stringaNo = "No"; | ||
| 1246 | stringaOpzioni = "Opzioni..."; | ||
| 1247 | stringaEsci = "Stusa su"; | ||
| 1248 | stringaImpossibileConfigurare = "No ghe son riusito a scrivere al file de configurazione.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1249 | stringaLingua = "Lengua"; | ||
| 1250 | stringaAnnulla = "Annulla"; | ||
| 1251 | stringaIt = "Italian"; | ||
| 1252 | stringaLa = "Latin"; | ||
| 1253 | stringaBL = "Dialeto Belumat"; | ||
| 1254 | stringaBV = "Dialeto Veneto"; | ||
| 1255 | stringaEN = "Inglese"; | ||
| 1256 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1257 | stringaInformazioni = "Informasioni"; | ||
| 1258 | 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"; | ||
| 1259 | stringaSuono = "Efeti sonori"; | ||
| 1260 | stringaPunteggio = "Varda i punti"; | ||
| 1261 | stringaSfondo = "Sfondo"; | ||
| 1262 | stringaTasti = "Tasti rapidi"; | ||
| 1263 | stringaAggiornamenti = "Varda se xe ne' na versione pi nova"; | ||
| 1264 | stringaAggiornamentiSi = "Ghe xe na versione pi nova: "; | ||
| 1265 | stringaAggiornamentiNo = "No ghe xe na versione pi nova"; | ||
| 1266 | stringaScarica = "Te pol scaricar le versione pi nova\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 1267 | stringaNoInternet = "Erore: no ti xe su internet"; | ||
| 1268 | 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; | ||
| 1269 | } | ||
| 1270 | if ( lang.equals( "en" ) ) { | ||
| 1271 | stringaBottonePrendi = "Take/leave cards"; | ||
| 1272 | stringaPrimaGioca = "Play your card before!"; | ||
| 1273 | stringaUltime4 = "Last card - keep your eye on the briscola!"; | ||
| 1274 | stringaVinto = "You won!"; | ||
| 1275 | stringaPerso = "You lost"; | ||
| 1276 | stringaPareggio = "Sixty - sixty!"; | ||
| 1277 | stringaGiocatore = "Palyer: "; | ||
| 1278 | stringaComputer = "\nComputer: "; | ||
| 1279 | stringaNuovaPartita = "New Game"; | ||
| 1280 | stringaVuoiDavveroIniziare = "Do you really want to start a new game?"; | ||
| 1281 | stringaVuoiDavveroUscire = "Do you really want to exit?"; | ||
| 1282 | stringaSi = "Yes"; | ||
| 1283 | stringaNo = "No"; | ||
| 1284 | stringaOpzioni = "Options..."; | ||
| 1285 | stringaEsci = "Exit"; | ||
| 1286 | stringaImpossibileConfigurare = "Couldn't write to the configuration file.\nPlease report the bug to: sebastiano@luganega.org\n\nException:\n"; | ||
| 1287 | stringaLingua = "Lang"; | ||
| 1288 | stringaAnnulla = "Cancel"; | ||
| 1289 | stringaIt = "Italian"; | ||
| 1290 | stringaLa = "Latin"; | ||
| 1291 | stringaBL = "Belluno dialect"; | ||
| 1292 | stringaBV = "Venice dialect"; | ||
| 1293 | stringaEN = "English"; | ||
| 1294 | stringaModificaOpzioni = "Change options"; | ||
| 1295 | stringaInformazioni = "Information"; | ||
| 1296 | stringaInformazioni2 = "JBriscola is a briscola pc game written in java, meant\nand made by Sebastiano Tronto. The game is protected by the GNU/General public licence version 2 or later.\n\nJBriscola version" + version + "\nCopyright 2009 Sebastiano Tronto, license GNU/Gpl 2.0 or later\nE-mail: sebastiano@luganega.org"; | ||
| 1297 | stringaSuono = "Sound"; | ||
| 1298 | stringaPunteggio = "Score"; | ||
| 1299 | stringaSfondo = "Background"; | ||
| 1300 | stringaTasti = "Hot keys"; | ||
| 1301 | stringaAggiornamenti = "Check updates"; | ||
| 1302 | stringaAggiornamentiSi = "Update available: "; | ||
| 1303 | stringaAggiornamentiNo = "No updates available"; | ||
| 1304 | stringaScarica = "You can get the latest version from the site\nhttp://porkynator.altervista.org/programmi.html"; | ||
| 1305 | stringaNoInternet = "Error: no internet connection"; | ||
| 1306 | stringaTasti2 = "1 Play the first card\n2 Play the second card\n3 Play the third card\nF1 Get this message\nF2 " + stringaNuovaPartita + "\nF3 " + stringaOpzioni + "\nF4 " + stringaPunteggio + "\nF5 " + stringaInformazioni + "\nF6 " + stringaAggiornamenti + "\nq " + stringaEsci; | ||
| 1307 | } | ||
| 1308 | sound = ( soundString.equals( "suono=si" ) ); | ||
| 1309 | keys = ( keysString.equals( "tasti=si" ) ); | ||
| 1310 | color = new Color( r, g, b ); | ||
| 1311 | if ( frame != null ) { | ||
| 1312 | frame.pannello.repaint(); | ||
| 1313 | frame.pannello2.repaint(); | ||
| 1314 | frame.repaint(); | ||
| 1315 | } | ||
| 1316 | } | ||
| 1317 | } | ||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/OptionFrame.java b/JBriscola/all_versions/0.2/0.2.2/src/OptionFrame.java new file mode 100755 index 0000000..d89745b --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/OptionFrame.java | |||
| @@ -0,0 +1,169 @@ | |||
| 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.util.Formatter; | ||
| 23 | import javax.swing.*; | ||
| 24 | import java.awt.*; | ||
| 25 | import java.awt.event.*; | ||
| 26 | |||
| 27 | public class OptionFrame extends JFrame { | ||
| 28 | |||
| 29 | public static Main main = new Main(); | ||
| 30 | public static Formatter formatter; | ||
| 31 | public static JButton ok, annulla, scegliColore; | ||
| 32 | public static JLabel lingua, sfondo; | ||
| 33 | public static JComboBox selezionaLingua; | ||
| 34 | public static JCheckBox suono, tastiRapidi; | ||
| 35 | public static JPanel[] pannello = new JPanel[6]; | ||
| 36 | |||
| 37 | public OptionFrame() { | ||
| 38 | |||
| 39 | super( "JBriscola - " + main.stringaModificaOpzioni ); | ||
| 40 | |||
| 41 | ok = new JButton( "OK" ); | ||
| 42 | ok.addActionListener( new ActionListener() { | ||
| 43 | |||
| 44 | /* Quando le modifiche vengono confermate premendo ok, viene scritto | ||
| 45 | * il file di configurazione (o aggiornato) se possibile, e modificate | ||
| 46 | * le impostazioni attuali. */ | ||
| 47 | public void actionPerformed( ActionEvent e ) { | ||
| 48 | |||
| 49 | try { | ||
| 50 | formatter = new Formatter( "JBriscolaConfig.txt" ); | ||
| 51 | } catch ( Exception ex ) { | ||
| 52 | JOptionPane.showMessageDialog( OptionFrame.this, main.stringaImpossibileConfigurare + ex, "JBriscola - " + main.version, JOptionPane.ERROR_MESSAGE ); | ||
| 53 | } | ||
| 54 | |||
| 55 | String lang; | ||
| 56 | |||
| 57 | switch ( selezionaLingua.getSelectedIndex() ) { | ||
| 58 | case 0: | ||
| 59 | lang = "it"; | ||
| 60 | break; | ||
| 61 | case 1: | ||
| 62 | lang = "la"; | ||
| 63 | break; | ||
| 64 | case 2: | ||
| 65 | lang = "bl"; | ||
| 66 | break; | ||
| 67 | case 3: | ||
| 68 | lang = "bv"; | ||
| 69 | break; | ||
| 70 | case 4: | ||
| 71 | lang = "en"; | ||
| 72 | break; | ||
| 73 | default: | ||
| 74 | lang = "it"; | ||
| 75 | break; | ||
| 76 | } | ||
| 77 | |||
| 78 | String suonosiono, tastisiono; | ||
| 79 | |||
| 80 | if ( suono.isSelected() ) | ||
| 81 | suonosiono = "suono=si"; | ||
| 82 | else | ||
| 83 | suonosiono = "suono=no"; | ||
| 84 | if ( tastiRapidi.isSelected() ) | ||
| 85 | tastisiono = "tasti=si"; | ||
| 86 | else | ||
| 87 | tastisiono = "tasti=no"; | ||
| 88 | |||
| 89 | formatter.format( lang ); | ||
| 90 | formatter.format( "\n" ); | ||
| 91 | formatter.format( suonosiono ); | ||
| 92 | formatter.format( "\n" ); | ||
| 93 | formatter.format( tastisiono ); | ||
| 94 | formatter.format( "\n" ); | ||
| 95 | formatter.format( main.color.getRed() + " " + main.color.getGreen() + " " + main.color.getBlue() ); | ||
| 96 | formatter.close(); | ||
| 97 | |||
| 98 | main.settaOpzioni(); | ||
| 99 | |||
| 100 | OptionFrame.this.dispose(); | ||
| 101 | } | ||
| 102 | }); | ||
| 103 | |||
| 104 | annulla = new JButton( main.stringaAnnulla ); | ||
| 105 | annulla.addActionListener( new ActionListener() { | ||
| 106 | /* Se l'utente annulla viene chiusa la finestra senza fare nulla. */ | ||
| 107 | public void actionPerformed( ActionEvent e ) { | ||
| 108 | OptionFrame.this.dispose(); | ||
| 109 | } | ||
| 110 | }); | ||
| 111 | |||
| 112 | scegliColore = new JButton( " " ); | ||
| 113 | scegliColore.setBackground( main.color ); | ||
| 114 | scegliColore.addActionListener( new ActionListener() { | ||
| 115 | /* Permette di scegliere il colore dello sfondo. */ | ||
| 116 | public void actionPerformed( ActionEvent e ) { | ||
| 117 | Color colore = JColorChooser.showDialog( OptionFrame.this, "JBriscola " + main.version, main.color ); | ||
| 118 | if ( colore != null ) | ||
| 119 | main.color = colore; | ||
| 120 | OptionFrame.scegliColore.setBackground( main.color ); | ||
| 121 | } | ||
| 122 | } ); | ||
| 123 | |||
| 124 | /* Vengono impostati e disegnati i vari componenti. */ | ||
| 125 | lingua = new JLabel( main.stringaLingua ); | ||
| 126 | sfondo = new JLabel( main.stringaSfondo ); | ||
| 127 | String[] lingueDaSelezionare = { main.stringaIt, main.stringaLa, main.stringaBL, main.stringaBV, main.stringaEN }; | ||
| 128 | selezionaLingua = new JComboBox( lingueDaSelezionare ); | ||
| 129 | int linguaPreselezionata = 0; | ||
| 130 | |||
| 131 | if ( main.lang.equals( "it" ) ) | ||
| 132 | linguaPreselezionata = 0; | ||
| 133 | else if ( main.lang.equals( "la" ) ) | ||
| 134 | linguaPreselezionata = 1; | ||
| 135 | else if ( main.lang.equals( "bl" ) ) | ||
| 136 | linguaPreselezionata = 2; | ||
| 137 | else if ( main.lang.equals( "bv" ) ) | ||
| 138 | linguaPreselezionata = 3; | ||
| 139 | else if ( main.lang.equals( "en" ) ) | ||
| 140 | linguaPreselezionata = 4; | ||
| 141 | |||
| 142 | selezionaLingua.setSelectedIndex( linguaPreselezionata ); | ||
| 143 | suono = new JCheckBox( main.stringaSuono ); | ||
| 144 | suono.setSelected( main.sound ); | ||
| 145 | tastiRapidi = new JCheckBox( main.stringaTasti ); | ||
| 146 | tastiRapidi.setSelected( main.keys ); | ||
| 147 | |||
| 148 | pannello[0] = new JPanel( new GridLayout( 4, 1 ) ); | ||
| 149 | pannello[1] = new JPanel( new FlowLayout() ); | ||
| 150 | pannello[2] = new JPanel( new FlowLayout() ); | ||
| 151 | pannello[3] = new JPanel( new FlowLayout() ); | ||
| 152 | pannello[4] = new JPanel( new FlowLayout() ); | ||
| 153 | pannello[5] = new JPanel( new FlowLayout() ); | ||
| 154 | pannello[5].add( ok ); | ||
| 155 | pannello[5].add( annulla ); | ||
| 156 | pannello[4].add( sfondo ); | ||
| 157 | pannello[4].add( scegliColore ); | ||
| 158 | pannello[3].add( tastiRapidi ); | ||
| 159 | pannello[2].add( suono ); | ||
| 160 | pannello[1].add( lingua ); | ||
| 161 | pannello[1].add( selezionaLingua ); | ||
| 162 | pannello[0].add( pannello[1] ); | ||
| 163 | pannello[0].add( pannello[2] ); | ||
| 164 | pannello[0].add( pannello[3] ); | ||
| 165 | pannello[0].add( pannello[4] ); | ||
| 166 | add( pannello[0], BorderLayout.CENTER ); | ||
| 167 | add( pannello[5], BorderLayout.SOUTH ); | ||
| 168 | } | ||
| 169 | } | ||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/Pannello.java b/JBriscola/all_versions/0.2/0.2.2/src/Pannello.java new file mode 100755 index 0000000..0de79f6 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/Pannello.java | |||
| @@ -0,0 +1,56 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | |||
| 25 | /* Questa classe dispone semplicemente le carte | ||
| 26 | * sulla finestra e imposta la sfondo. */ | ||
| 27 | public class Pannello extends JPanel { | ||
| 28 | public static Main main; | ||
| 29 | public static Color color; | ||
| 30 | public Pannello() { } | ||
| 31 | public void paint( Graphics g ) { | ||
| 32 | super.paint( g ); | ||
| 33 | setBackground( main.color ); | ||
| 34 | if ( main.frame.ultimaCarta != null ) | ||
| 35 | main.frame.ultimaCarta.paintIcon( this, g, 50, 180 ); | ||
| 36 | if ( main.frame.mazzo ) | ||
| 37 | main.frame.retro2.paintIcon( this, g, 17, 256 ); | ||
| 38 | if ( main.frame.carteCPU[0] != null ) | ||
| 39 | main.frame.retro1.paintIcon( this, g, 230, 5 ); | ||
| 40 | if ( main.frame.carteCPU[1] != null ) | ||
| 41 | main.frame.retro1.paintIcon( this, g, 300, 5 ); | ||
| 42 | if ( main.frame.carteCPU[2] != null ) | ||
| 43 | main.frame.retro1.paintIcon( this, g, 370, 5 ); | ||
| 44 | if ( main.frame.carteInMano[0] != null ) | ||
| 45 | main.frame.carteInMano[0].paintIcon( this, g, 230, 340 ); | ||
| 46 | if ( main.frame.carteInMano[1] != null ) | ||
| 47 | main.frame.carteInMano[1].paintIcon( this, g, 300, 340 ); | ||
| 48 | if ( main.frame.carteInMano[2] != null ) | ||
| 49 | main.frame.carteInMano[2].paintIcon( this, g, 370, 340 ); | ||
| 50 | if ( main.frame.giocata[0] != null ) | ||
| 51 | main.frame.giocata[0].paintIcon( this, g, 250, 200 ); | ||
| 52 | if ( main.frame.giocata[1] != null ) | ||
| 53 | main.frame.giocata[1].paintIcon( this, g, 325, 150 ); | ||
| 54 | } | ||
| 55 | } | ||
| 56 | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/1-1.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/1-1.jpg new file mode 100755 index 0000000..ae43510 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/1-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/1-2.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/1-2.jpg new file mode 100755 index 0000000..3f7c75a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/1-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/1-3.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/1-3.jpg new file mode 100755 index 0000000..9e1ead7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/1-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/1-4.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/1-4.jpg new file mode 100755 index 0000000..710f879 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/1-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/10-1.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/10-1.jpg new file mode 100755 index 0000000..9aba45a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/10-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/10-2.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/10-2.jpg new file mode 100755 index 0000000..037eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/10-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/10-3.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/10-3.jpg new file mode 100755 index 0000000..8780b72 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/10-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/10-4.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/10-4.jpg new file mode 100755 index 0000000..587dc0f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/10-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/2-1.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/2-1.jpg new file mode 100755 index 0000000..5dcb7db --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/2-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/2-2.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/2-2.jpg new file mode 100755 index 0000000..ea9eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/2-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/2-3.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/2-3.jpg new file mode 100755 index 0000000..8cb22dd --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/2-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/2-4.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/2-4.jpg new file mode 100755 index 0000000..b3e7898 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/2-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/3-1.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/3-1.jpg new file mode 100755 index 0000000..dcb435c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/3-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/3-2.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/3-2.jpg new file mode 100755 index 0000000..1e5b6ec --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/3-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/3-3.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/3-3.jpg new file mode 100755 index 0000000..9202cfe --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/3-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/3-4.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/3-4.jpg new file mode 100755 index 0000000..5436a8d --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/3-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/4-1.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/4-1.jpg new file mode 100755 index 0000000..3bab6d5 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/4-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/4-2.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/4-2.jpg new file mode 100755 index 0000000..b4901a6 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/4-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/4-3.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/4-3.jpg new file mode 100755 index 0000000..d754ad8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/4-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/4-4.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/4-4.jpg new file mode 100755 index 0000000..3a54b96 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/4-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/5-1.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/5-1.jpg new file mode 100755 index 0000000..3f7ba1f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/5-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/5-2.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/5-2.jpg new file mode 100755 index 0000000..fcacb75 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/5-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/5-3.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/5-3.jpg new file mode 100755 index 0000000..ce32f9f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/5-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/5-4.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/5-4.jpg new file mode 100755 index 0000000..b86b09a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/5-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/6-1.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/6-1.jpg new file mode 100755 index 0000000..f90cd81 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/6-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/6-2.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/6-2.jpg new file mode 100755 index 0000000..cf2a67a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/6-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/6-3.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/6-3.jpg new file mode 100755 index 0000000..2cd2fe2 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/6-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/6-4.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/6-4.jpg new file mode 100755 index 0000000..73f410f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/6-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/7-1.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/7-1.jpg new file mode 100755 index 0000000..08cd397 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/7-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/7-2.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/7-2.jpg new file mode 100755 index 0000000..a168ff8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/7-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/7-3.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/7-3.jpg new file mode 100755 index 0000000..5cda411 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/7-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/7-4.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/7-4.jpg new file mode 100755 index 0000000..5d63229 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/7-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/8-1.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/8-1.jpg new file mode 100755 index 0000000..a6faa7b --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/8-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/8-2.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/8-2.jpg new file mode 100755 index 0000000..0d9edbb --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/8-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/8-3.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/8-3.jpg new file mode 100755 index 0000000..91f8354 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/8-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/8-4.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/8-4.jpg new file mode 100755 index 0000000..cc0089c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/8-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/9-1.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/9-1.jpg new file mode 100755 index 0000000..be9c6bf --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/9-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/9-2.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/9-2.jpg new file mode 100755 index 0000000..e25da4c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/9-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/9-3.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/9-3.jpg new file mode 100755 index 0000000..cd384f8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/9-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/9-4.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/9-4.jpg new file mode 100755 index 0000000..441210e --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/9-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/carte.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/carte.jpg new file mode 100755 index 0000000..838ffac --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/carte.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/retro1.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/retro1.jpg new file mode 100755 index 0000000..9651b06 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/retro1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/img/retro2.jpg b/JBriscola/all_versions/0.2/0.2.2/src/img/retro2.jpg new file mode 100755 index 0000000..c5d3925 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/img/retro2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/sounds/0.wav b/JBriscola/all_versions/0.2/0.2.2/src/sounds/0.wav new file mode 100755 index 0000000..67d9abd --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/sounds/0.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/sounds/1.wav b/JBriscola/all_versions/0.2/0.2.2/src/sounds/1.wav new file mode 100755 index 0000000..9357c97 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/sounds/1.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/sounds/2.wav b/JBriscola/all_versions/0.2/0.2.2/src/sounds/2.wav new file mode 100755 index 0000000..92b1541 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/sounds/2.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/sounds/3.wav b/JBriscola/all_versions/0.2/0.2.2/src/sounds/3.wav new file mode 100755 index 0000000..45a6e42 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/sounds/3.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/sounds/4.wav b/JBriscola/all_versions/0.2/0.2.2/src/sounds/4.wav new file mode 100755 index 0000000..1f7ec90 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/sounds/4.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/sounds/5.wav b/JBriscola/all_versions/0.2/0.2.2/src/sounds/5.wav new file mode 100755 index 0000000..3627f96 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/sounds/5.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/sounds/pareggio.wav b/JBriscola/all_versions/0.2/0.2.2/src/sounds/pareggio.wav new file mode 100755 index 0000000..ff978e6 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/sounds/pareggio.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/sounds/perso.wav b/JBriscola/all_versions/0.2/0.2.2/src/sounds/perso.wav new file mode 100755 index 0000000..a454ba4 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/sounds/perso.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2.2/src/sounds/vinto.wav b/JBriscola/all_versions/0.2/0.2.2/src/sounds/vinto.wav new file mode 100755 index 0000000..a6f3ac5 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2.2/src/sounds/vinto.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/Frame.java b/JBriscola/all_versions/0.2/0.2/src/Frame.java new file mode 100755 index 0000000..7ae52fe --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/Frame.java | |||
| @@ -0,0 +1,308 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import javax.sound.sampled.*; | ||
| 24 | import java.io.*; | ||
| 25 | import java.awt.*; | ||
| 26 | import java.awt.event.*; | ||
| 27 | |||
| 28 | public class Frame extends JFrame { | ||
| 29 | public static boolean mazzo; | ||
| 30 | public static Main main; | ||
| 31 | public static Pannello pannello; | ||
| 32 | public static JPanel pannello2; | ||
| 33 | public static JButton button; | ||
| 34 | public static JMenuBar barraMenu; | ||
| 35 | public static JMenu file, puntoInterrogativo; | ||
| 36 | public static JMenuItem nuovaPartita, opzioni, esci, informazioni, punti; | ||
| 37 | public static ImageIcon retro1, retro2, ultimaCarta; | ||
| 38 | public static ImageIcon[] giocata = new ImageIcon[2]; | ||
| 39 | public static ImageIcon[] carteInMano = new ImageIcon[3]; | ||
| 40 | public static ImageIcon[] carteCPU = new ImageIcon[3]; | ||
| 41 | public static ImageIcon[] arrayCarteMescolate = new ImageIcon[40]; | ||
| 42 | public static ImageIcon[][] arrayCarte = new ImageIcon[10][4]; | ||
| 43 | public Frame() { | ||
| 44 | super( "Tronto's JBriscola " + main.version ); | ||
| 45 | mazzo = true; | ||
| 46 | main = new Main(); | ||
| 47 | pannello = new Pannello(); | ||
| 48 | pannello2 = new JPanel( new FlowLayout() ); | ||
| 49 | button = new JButton( main.stringaBottonePrendi ); | ||
| 50 | button.addActionListener( new ActionListener() { | ||
| 51 | public void actionPerformed( ActionEvent e ) { | ||
| 52 | if ( giocata[0] != null && giocata[1] != null ) | ||
| 53 | main.mano++; | ||
| 54 | try { | ||
| 55 | main.chiPrende(); | ||
| 56 | } catch ( Exception ex ) { | ||
| 57 | JOptionPane.showMessageDialog( Frame.this, main.stringaPrimaGioca, "JBriscola " + main.version, JOptionPane.WARNING_MESSAGE ); | ||
| 58 | } | ||
| 59 | if ( main.mano == 16 ) | ||
| 60 | JOptionPane.showMessageDialog( Frame.this, main.stringaUltime4, "JBriscola " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 61 | if ( main.mano == 17 ) { | ||
| 62 | mazzo = false; | ||
| 63 | ultimaCarta = null; | ||
| 64 | pannello.repaint(); | ||
| 65 | Frame.this.repaint(); | ||
| 66 | } | ||
| 67 | if ( main.mano == 20 ) { | ||
| 68 | String titolo = ""; | ||
| 69 | String suonoFinale = ""; | ||
| 70 | if ( main.punteggio > main.punteggioCPU ) { | ||
| 71 | titolo = main.stringaVinto; | ||
| 72 | suonoFinale = "sounds/perso.wav"; | ||
| 73 | } | ||
| 74 | if ( main.punteggio < main.punteggioCPU ) { | ||
| 75 | titolo = main.stringaPerso; | ||
| 76 | suonoFinale = "sounds/vinto.wav"; | ||
| 77 | } | ||
| 78 | if ( main.punteggio == main.punteggioCPU ) { | ||
| 79 | titolo = main.stringaPareggio; | ||
| 80 | suonoFinale = "sounds/pareggio.wav"; | ||
| 81 | } | ||
| 82 | if ( main.sound ) { | ||
| 83 | try { | ||
| 84 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( ClassLoader.getSystemResource( suonoFinale ) ); | ||
| 85 | AudioInputStream ais = AudioSystem.getAudioInputStream( ClassLoader.getSystemResource( suonoFinale ) ); | ||
| 86 | AudioFormat af = aff.getFormat(); | ||
| 87 | DataLine.Info info = new DataLine.Info( | ||
| 88 | Clip.class, | ||
| 89 | ais.getFormat(), | ||
| 90 | ( (int) ais.getFrameLength() * | ||
| 91 | af.getFrameSize() ) ); | ||
| 92 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 93 | ol.open(ais); | ||
| 94 | ol.loop( 0 ); | ||
| 95 | } catch ( Exception ex ) { | ||
| 96 | System.err.println( e ); | ||
| 97 | } | ||
| 98 | } | ||
| 99 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, titolo, JOptionPane.PLAIN_MESSAGE ); | ||
| 100 | } | ||
| 101 | } | ||
| 102 | } ); | ||
| 103 | button.addKeyListener( new KeyAdapter() { | ||
| 104 | public void keyReleased( KeyEvent key ) { | ||
| 105 | if ( main.keys ) { | ||
| 106 | switch ( key.getKeyCode() ) { | ||
| 107 | case KeyEvent.VK_1: | ||
| 108 | if ( mettiCarta( 231, 500 ) ) { | ||
| 109 | if ( !main.CPUHaGiocato ) | ||
| 110 | main.giocaCPU(); | ||
| 111 | } | ||
| 112 | break; | ||
| 113 | case KeyEvent.VK_2: | ||
| 114 | if ( mettiCarta( 301, 500 ) ) { | ||
| 115 | if ( !main.CPUHaGiocato ) | ||
| 116 | main.giocaCPU(); | ||
| 117 | } | ||
| 118 | break; | ||
| 119 | case KeyEvent.VK_3: | ||
| 120 | if ( mettiCarta( 371, 500 ) ) { | ||
| 121 | if ( !main.CPUHaGiocato ) | ||
| 122 | main.giocaCPU(); | ||
| 123 | } | ||
| 124 | break; | ||
| 125 | case KeyEvent.VK_F1: | ||
| 126 | JOptionPane.showMessageDialog( Frame.this, main.stringaTasti2, "JBriscola - " + main.stringaTasti, JOptionPane.INFORMATION_MESSAGE ); | ||
| 127 | break; | ||
| 128 | case KeyEvent.VK_F2: | ||
| 129 | if ( main.mano == 20 ) { | ||
| 130 | main.mischia(); | ||
| 131 | pannello.repaint(); | ||
| 132 | repaint(); | ||
| 133 | } | ||
| 134 | else { | ||
| 135 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 136 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 137 | main.mischia(); | ||
| 138 | pannello.repaint(); | ||
| 139 | repaint(); | ||
| 140 | } | ||
| 141 | } | ||
| 142 | break; | ||
| 143 | case KeyEvent.VK_F3: | ||
| 144 | OptionFrame optionFrame = new OptionFrame(); | ||
| 145 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 146 | optionFrame.setResizable( false ); | ||
| 147 | optionFrame.setAlwaysOnTop( true ); | ||
| 148 | optionFrame.setSize( 300, 200 ); | ||
| 149 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, | ||
| 150 | (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 151 | optionFrame.setVisible( true ); | ||
| 152 | break; | ||
| 153 | case KeyEvent.VK_F4: | ||
| 154 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + "\n" + main.stringaComputer + main.punteggioCPU, main.stringaPunteggio, JOptionPane.PLAIN_MESSAGE ); | ||
| 155 | break; | ||
| 156 | case KeyEvent.VK_F5: | ||
| 157 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 158 | break; | ||
| 159 | case KeyEvent.VK_Q: | ||
| 160 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 161 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 162 | Frame.this.dispose(); | ||
| 163 | break; | ||
| 164 | } | ||
| 165 | } | ||
| 166 | } | ||
| 167 | } ); | ||
| 168 | barraMenu = new JMenuBar(); | ||
| 169 | file = new JMenu( "File" ); | ||
| 170 | nuovaPartita = new JMenuItem( main.stringaNuovaPartita ); | ||
| 171 | nuovaPartita.addActionListener( new ActionListener() { | ||
| 172 | public void actionPerformed( ActionEvent e ) { | ||
| 173 | if ( main.mano == 20 ) { | ||
| 174 | main.mischia(); | ||
| 175 | pannello.repaint(); | ||
| 176 | repaint(); | ||
| 177 | } | ||
| 178 | else { | ||
| 179 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 180 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 181 | main.mischia(); | ||
| 182 | pannello.repaint(); | ||
| 183 | repaint(); | ||
| 184 | } | ||
| 185 | } | ||
| 186 | } | ||
| 187 | }); | ||
| 188 | opzioni = new JMenuItem( main.stringaOpzioni ); | ||
| 189 | opzioni.addActionListener( new ActionListener() { | ||
| 190 | public void actionPerformed( ActionEvent e ) { | ||
| 191 | OptionFrame optionFrame = new OptionFrame(); | ||
| 192 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 193 | optionFrame.setResizable( false ); | ||
| 194 | optionFrame.setAlwaysOnTop( true ); | ||
| 195 | optionFrame.setSize( 300, 200 ); | ||
| 196 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, | ||
| 197 | (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 198 | optionFrame.setVisible( true ); | ||
| 199 | } | ||
| 200 | }); | ||
| 201 | esci = new JMenuItem( main.stringaEsci ); | ||
| 202 | esci.addActionListener( new ActionListener() { | ||
| 203 | public void actionPerformed( ActionEvent e ) { | ||
| 204 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 205 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 206 | Frame.this.dispose(); | ||
| 207 | } | ||
| 208 | }); | ||
| 209 | file.add( nuovaPartita ); | ||
| 210 | file.add( opzioni ); | ||
| 211 | file.addSeparator(); | ||
| 212 | file.add( esci ); | ||
| 213 | puntoInterrogativo = new JMenu( "?" ); | ||
| 214 | informazioni = new JMenuItem( main.stringaInformazioni ); | ||
| 215 | informazioni.addActionListener( new ActionListener() { | ||
| 216 | public void actionPerformed( ActionEvent e ) { | ||
| 217 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 218 | } | ||
| 219 | } ); | ||
| 220 | punti = new JMenuItem( main.stringaPunteggio ); | ||
| 221 | punti.addActionListener( new ActionListener() { | ||
| 222 | public void actionPerformed( ActionEvent e ) { | ||
| 223 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + "\n" + main.stringaComputer + main.punteggioCPU, main.stringaPunteggio, JOptionPane.PLAIN_MESSAGE ); | ||
| 224 | } | ||
| 225 | } ); | ||
| 226 | puntoInterrogativo.add( punti ); | ||
| 227 | puntoInterrogativo.add( informazioni ); | ||
| 228 | barraMenu.add( file ); | ||
| 229 | barraMenu.add( puntoInterrogativo ); | ||
| 230 | setJMenuBar( barraMenu ); | ||
| 231 | retro1 = new ImageIcon( ClassLoader.getSystemResource( "img/retro1.jpg" ) ); | ||
| 232 | retro2 = new ImageIcon( ClassLoader.getSystemResource( "img/retro2.jpg" ) ); | ||
| 233 | for (int i = 0; i < 10; i++) | ||
| 234 | for (int j = 0; j < 4; j++) | ||
| 235 | arrayCarte[i][j] = new ImageIcon( ClassLoader.getSystemResource( "img/" + (i+1) + "-" + (j+1) + ".jpg" ) ); | ||
| 236 | main.mischia(); | ||
| 237 | pannello2.add( button ); | ||
| 238 | setLayout( new BorderLayout() ); | ||
| 239 | add( pannello, BorderLayout.CENTER ); | ||
| 240 | add( pannello2, BorderLayout.SOUTH ); | ||
| 241 | addMouseListener( | ||
| 242 | new MouseAdapter() { | ||
| 243 | public void mouseClicked ( MouseEvent e ) { | ||
| 244 | if ( mettiCarta( e.getX(), e.getY() ) ) { | ||
| 245 | if ( !main.CPUHaGiocato ) | ||
| 246 | main.giocaCPU(); | ||
| 247 | } | ||
| 248 | } | ||
| 249 | } | ||
| 250 | ); | ||
| 251 | addWindowListener( | ||
| 252 | new WindowAdapter() { | ||
| 253 | public void windowClosing( WindowEvent e ) { | ||
| 254 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 255 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 256 | System.exit( 0 ); | ||
| 257 | } | ||
| 258 | } | ||
| 259 | ); | ||
| 260 | } | ||
| 261 | public boolean mettiCarta( int x, int y ) { | ||
| 262 | if ( !main.toccaAllaCPU && giocata[0] == null ) { | ||
| 263 | if ( main.sound && | ||
| 264 | ( ( x > 230 && x < 290 && y > 340 && y < 566 && carteInMano[0] != null ) || | ||
| 265 | ( x > 300 && x < 360 && y > 340 && y < 566 && carteInMano[1] != null ) || | ||
| 266 | ( x > 370 && x < 430 && y > 340 && y < 566 && carteInMano[2] != null ) ) ) { | ||
| 267 | try { | ||
| 268 | double a = Math.random() * 6; | ||
| 269 | int i = (int) a; | ||
| 270 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( ClassLoader.getSystemResource("sounds/" + i + ".wav") ); | ||
| 271 | AudioInputStream ais = AudioSystem.getAudioInputStream( ClassLoader.getSystemResource("sounds/" + i + ".wav") ); | ||
| 272 | AudioFormat af = aff.getFormat(); | ||
| 273 | DataLine.Info info = new DataLine.Info( | ||
| 274 | Clip.class, | ||
| 275 | ais.getFormat(), | ||
| 276 | ( (int) ais.getFrameLength() * | ||
| 277 | af.getFrameSize() ) ); | ||
| 278 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 279 | ol.open(ais); | ||
| 280 | ol.loop( 0 ); | ||
| 281 | } catch ( Exception e ) { | ||
| 282 | System.err.println( e ); | ||
| 283 | } | ||
| 284 | } | ||
| 285 | if ( x > 230 && x < 290 && y > 340 && y < 566 ) { | ||
| 286 | giocata[0] = carteInMano[0]; | ||
| 287 | carteInMano[0] = null; | ||
| 288 | pannello.repaint(); | ||
| 289 | return true; | ||
| 290 | } | ||
| 291 | if ( x > 300 && x < 360 && y > 340 && y < 566 ) { | ||
| 292 | giocata[0] = carteInMano[1]; | ||
| 293 | carteInMano[1] = null; | ||
| 294 | pannello.repaint(); | ||
| 295 | return true; | ||
| 296 | } | ||
| 297 | if ( x > 370 && x < 430 && y > 340 && y < 566 ) { | ||
| 298 | giocata[0] = carteInMano[2]; | ||
| 299 | carteInMano[2] = null; | ||
| 300 | pannello.repaint(); | ||
| 301 | return true; | ||
| 302 | } | ||
| 303 | } | ||
| 304 | return false; | ||
| 305 | } | ||
| 306 | } | ||
| 307 | |||
| 308 | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/Main.java b/JBriscola/all_versions/0.2/0.2/src/Main.java new file mode 100755 index 0000000..e0587e1 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/Main.java | |||
| @@ -0,0 +1,1077 @@ | |||
| 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"; | ||
| 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 stringaTasti2 = "1 Gioca la prima carta\n2 Gioca la seconda carta\n3 Gioca la terza carta\nF1 Visualizza questo messaggio\nF2 Nuova partita\nF3 Opzioni\nF4 Visualizza Punteggio\nF5 Informazioni\nq Esci"; | ||
| 68 | public static String lang, soundString, keysString; | ||
| 69 | public static File[] suoni = new File[6]; | ||
| 70 | public static File suonoVinto, suonoPerso, suonoPareggio; | ||
| 71 | public static void main( String args[] ) { | ||
| 72 | settaOpzioni(); | ||
| 73 | frame = new Frame(); | ||
| 74 | frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); | ||
| 75 | frame.setResizable( false ); | ||
| 76 | frame.setSize( 600, 600 ); | ||
| 77 | frame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 600) / 2, | ||
| 78 | (Toolkit.getDefaultToolkit().getScreenSize().height - 600) / 2); | ||
| 79 | frame.setVisible( true ); | ||
| 80 | } | ||
| 81 | public void mischia() { | ||
| 82 | mano = 0; | ||
| 83 | punteggio = 0; | ||
| 84 | punteggioCPU = 0; | ||
| 85 | cartaDaPescare = 6; | ||
| 86 | ImageIcon aux; | ||
| 87 | frame.mazzo = true; | ||
| 88 | toccaAllaCPU = false; | ||
| 89 | CPUHaGiocato = false; | ||
| 90 | haGiocatoPrima = true; | ||
| 91 | for ( int i = 0, k = 0; i < 10; i++ ) | ||
| 92 | for ( int j = 0; j < 4; j++, k++ ) | ||
| 93 | frame.arrayCarteMescolate[k] = frame.arrayCarte[i][j]; | ||
| 94 | for ( int i = 0; i < 391; i++ ) { | ||
| 95 | double a = Math.random() * 40; | ||
| 96 | int x = (int) a; | ||
| 97 | double b = Math.random() * 40; | ||
| 98 | int y = (int) b; | ||
| 99 | aux = frame.arrayCarteMescolate[x]; | ||
| 100 | frame.arrayCarteMescolate[x] = frame.arrayCarteMescolate[y]; | ||
| 101 | frame.arrayCarteMescolate[y] = aux; | ||
| 102 | } | ||
| 103 | char auxChar[] = frame.arrayCarteMescolate[39].toString().toCharArray(); | ||
| 104 | semeBriscola = auxChar[auxChar.length-5] - 49; | ||
| 105 | frame.carteInMano[0] = frame.arrayCarteMescolate[0]; | ||
| 106 | frame.carteInMano[1] = frame.arrayCarteMescolate[1]; | ||
| 107 | frame.carteInMano[2] = frame.arrayCarteMescolate[2]; | ||
| 108 | frame.carteCPU[0] = frame.arrayCarteMescolate[3]; | ||
| 109 | frame.carteCPU[1] = frame.arrayCarteMescolate[4]; | ||
| 110 | frame.carteCPU[2] = frame.arrayCarteMescolate[5]; | ||
| 111 | frame.ultimaCarta = frame.arrayCarteMescolate[39]; | ||
| 112 | frame.giocata[0] = null; | ||
| 113 | frame.giocata[1] = null; | ||
| 114 | } | ||
| 115 | public void giocaCPU() { | ||
| 116 | if ( mano < 16 ) { | ||
| 117 | if ( frame.giocata[0] == null ) { | ||
| 118 | if ( vaiPunti() ); | ||
| 119 | else if ( vaiLiscio() ); | ||
| 120 | else if ( vaiTaglio() ); | ||
| 121 | else if ( vaiBriscolaAlta() ); | ||
| 122 | else if ( vaiCarico() ); | ||
| 123 | else if ( vaiTre() ); | ||
| 124 | else if ( vaiAsso() ); | ||
| 125 | else; | ||
| 126 | } | ||
| 127 | else { | ||
| 128 | if ( haLisciato() ) { | ||
| 129 | if ( vaiSopra() ); | ||
| 130 | else if ( vaiLiscio() ); | ||
| 131 | else if ( vaiPunti() ); | ||
| 132 | else if ( vaiTaglio() ); | ||
| 133 | else if ( vaiTre() ); | ||
| 134 | else if ( vaiBriscolaAlta() ); | ||
| 135 | else if ( vaiCarico() ); | ||
| 136 | else if ( vaiAsso() ); | ||
| 137 | } else if ( haMessoPunti() ) { | ||
| 138 | if ( vaiSopra() ); | ||
| 139 | else if ( vaiLiscio() ); | ||
| 140 | else if ( vaiTaglio() ); | ||
| 141 | else if ( vaiPunti() ); | ||
| 142 | else if ( vaiTre() ); | ||
| 143 | else if ( vaiBriscolaAlta() ); | ||
| 144 | else if ( vaiCarico() ); | ||
| 145 | else if ( vaiAsso() ); | ||
| 146 | } else if ( haTagliato() ) { | ||
| 147 | if ( vaiLiscio() ); | ||
| 148 | else if ( vaiPunti() ); | ||
| 149 | else if ( vaiTaglio() ); | ||
| 150 | else if ( vaiTre() ); | ||
| 151 | else if ( vaiBriscolaAlta() ); | ||
| 152 | else if ( vaiCarico() ); | ||
| 153 | else if ( vaiAsso() ); | ||
| 154 | } else if ( haMessoBriscolaAlta() ) { | ||
| 155 | if ( vaiLiscio() ); | ||
| 156 | else if ( vaiPunti() ); | ||
| 157 | else if ( vaiTre() ); | ||
| 158 | else if ( vaiTaglio() ); | ||
| 159 | else if ( vaiBriscolaAlta() ); | ||
| 160 | else if ( vaiCarico() ); | ||
| 161 | else if ( vaiAsso() ); | ||
| 162 | } else if ( haMessoTre() ) { | ||
| 163 | if ( vaiAsso() ); | ||
| 164 | else if ( vaiLiscio() ); | ||
| 165 | else if ( vaiPunti() ); | ||
| 166 | else if ( vaiTaglio() ); | ||
| 167 | else if ( vaiBriscolaAlta() ); | ||
| 168 | else if ( vaiCarico() ); | ||
| 169 | } else if ( haMessoAsso() ) { | ||
| 170 | if ( vaiLiscio() ); | ||
| 171 | else if ( vaiPunti() ); | ||
| 172 | else if ( vaiTaglio() ); | ||
| 173 | else if ( vaiBriscolaAlta() ); | ||
| 174 | else if ( vaiCarico() ); | ||
| 175 | else if ( vaiTre() ); | ||
| 176 | } else if ( haCaricato() ) { | ||
| 177 | if ( vaiSopra() ); | ||
| 178 | else if ( vaiTre() ); | ||
| 179 | else if ( vaiBriscolaAlta() ); | ||
| 180 | else if ( vaiAsso() ); | ||
| 181 | else if ( vaiTaglio() ); | ||
| 182 | else if ( vaiLiscio() ); | ||
| 183 | else if ( vaiPunti() ); | ||
| 184 | else if ( vaiCarico() ); | ||
| 185 | } | ||
| 186 | } | ||
| 187 | } | ||
| 188 | else if ( mano == 16 ) { | ||
| 189 | if ( frame.giocata[0] == null ) { | ||
| 190 | char aux[]; | ||
| 191 | aux = frame.ultimaCarta.toString().toCharArray(); | ||
| 192 | if ( aux[aux.length-7] - 48 == 3 || aux[aux.length-7] - 48 == 1 ) { | ||
| 193 | if ( vaiCarico() ); | ||
| 194 | else if ( vaiPunti() ); | ||
| 195 | else if ( vaiLiscio() ); | ||
| 196 | else if ( vaiTaglio() ); | ||
| 197 | else if ( vaiBriscolaAlta() ); | ||
| 198 | else if ( vaiTre() ); | ||
| 199 | else if ( vaiAsso() ); | ||
| 200 | else; | ||
| 201 | } else { | ||
| 202 | if ( vaiPunti() ); | ||
| 203 | else if ( vaiLiscio() ); | ||
| 204 | else if ( vaiTaglio() ); | ||
| 205 | else if ( vaiBriscolaAlta() ); | ||
| 206 | else if ( vaiCarico() ); | ||
| 207 | else if ( vaiTre() ); | ||
| 208 | else if ( vaiAsso() ); | ||
| 209 | else; | ||
| 210 | } | ||
| 211 | } | ||
| 212 | else { | ||
| 213 | char aux[]; | ||
| 214 | aux = frame.ultimaCarta.toString().toCharArray(); | ||
| 215 | if ( aux[aux.length-7] - 48 == 3 || aux[aux.length-7] - 48 == 1 ) { | ||
| 216 | if ( haCaricato() ) { | ||
| 217 | if ( vaiSopra() ); | ||
| 218 | else if ( vaiLiscio() ); | ||
| 219 | else if ( vaiPunti() ); | ||
| 220 | else if ( vaiTre() ); | ||
| 221 | else if ( vaiTaglio() ); | ||
| 222 | else if ( vaiBriscolaAlta() ); | ||
| 223 | else if ( vaiAsso() ); | ||
| 224 | else if ( vaiCarico() ); | ||
| 225 | } | ||
| 226 | } else { | ||
| 227 | if ( haLisciato() ) { | ||
| 228 | if ( vaiSopra() ); | ||
| 229 | else if ( vaiLiscio() ); | ||
| 230 | else if ( vaiPunti() ); | ||
| 231 | else if ( vaiTaglio() ); | ||
| 232 | else if ( vaiTre() ); | ||
| 233 | else if ( vaiBriscolaAlta() ); | ||
| 234 | else if ( vaiCarico() ); | ||
| 235 | else if ( vaiAsso() ); | ||
| 236 | } else if ( haMessoPunti() ) { | ||
| 237 | if ( vaiSopra() ); | ||
| 238 | else if ( vaiLiscio() ); | ||
| 239 | else if ( vaiTaglio() ); | ||
| 240 | else if ( vaiPunti() ); | ||
| 241 | else if ( vaiTre() ); | ||
| 242 | else if ( vaiBriscolaAlta() ); | ||
| 243 | else if ( vaiCarico() ); | ||
| 244 | else if ( vaiAsso() ); | ||
| 245 | } else if ( haTagliato() ) { | ||
| 246 | if ( vaiLiscio() ); | ||
| 247 | else if ( vaiPunti() ); | ||
| 248 | else if ( vaiTaglio() ); | ||
| 249 | else if ( vaiTre() ); | ||
| 250 | else if ( vaiBriscolaAlta() ); | ||
| 251 | else if ( vaiCarico() ); | ||
| 252 | else if ( vaiAsso() ); | ||
| 253 | } else if ( haMessoBriscolaAlta() ) { | ||
| 254 | if ( vaiLiscio() ); | ||
| 255 | else if ( vaiPunti() ); | ||
| 256 | else if ( vaiTre() ); | ||
| 257 | else if ( vaiTaglio() ); | ||
| 258 | else if ( vaiBriscolaAlta() ); | ||
| 259 | else if ( vaiCarico() ); | ||
| 260 | else if ( vaiAsso() ); | ||
| 261 | } else if ( haMessoTre() ) { | ||
| 262 | if ( vaiAsso() ); | ||
| 263 | else if ( vaiLiscio() ); | ||
| 264 | else if ( vaiPunti() ); | ||
| 265 | else if ( vaiTaglio() ); | ||
| 266 | else if ( vaiBriscolaAlta() ); | ||
| 267 | else if ( vaiCarico() ); | ||
| 268 | } else if ( haMessoAsso() ) { | ||
| 269 | if ( vaiLiscio() ); | ||
| 270 | else if ( vaiPunti() ); | ||
| 271 | else if ( vaiTaglio() ); | ||
| 272 | else if ( vaiBriscolaAlta() ); | ||
| 273 | else if ( vaiCarico() ); | ||
| 274 | else if ( vaiTre() ); | ||
| 275 | } else if ( haCaricato() ) { | ||
| 276 | if ( vaiSopra() ); | ||
| 277 | else if ( vaiTre() ); | ||
| 278 | else if ( vaiBriscolaAlta() ); | ||
| 279 | else if ( vaiAsso() ); | ||
| 280 | else if ( vaiTaglio() ); | ||
| 281 | else if ( vaiLiscio() ); | ||
| 282 | else if ( vaiPunti() ); | ||
| 283 | else if ( vaiCarico() ); | ||
| 284 | } | ||
| 285 | } | ||
| 286 | } | ||
| 287 | } else if ( mano == 17 ) { | ||
| 288 | if ( frame.giocata[0] == null ) { | ||
| 289 | if ( hoAsso() ) { | ||
| 290 | if ( vaiTre() ); | ||
| 291 | else if ( vaiBriscolaAlta() ); | ||
| 292 | else if ( vaiTaglio() ); | ||
| 293 | else if ( vaiLiscio() ); | ||
| 294 | else if ( vaiPunti() ); | ||
| 295 | else if ( vaiAsso() ); | ||
| 296 | else if ( vaiCarico() ); | ||
| 297 | } else { | ||
| 298 | if ( vaiLiscio() ); | ||
| 299 | else if ( vaiPunti() ); | ||
| 300 | else if ( vaiTaglio() ); | ||
| 301 | else if ( vaiBriscolaAlta() ); | ||
| 302 | else if ( vaiCarico() ); | ||
| 303 | else if ( vaiTre() ); | ||
| 304 | } | ||
| 305 | } | ||
| 306 | else { | ||
| 307 | if ( haLisciato() ) { | ||
| 308 | if ( vaiSopra() ); | ||
| 309 | else if ( vaiLiscio() ); | ||
| 310 | else if ( vaiPunti() ); | ||
| 311 | else if ( vaiTaglio() ); | ||
| 312 | else if ( vaiTre() ); | ||
| 313 | else if ( vaiBriscolaAlta() ); | ||
| 314 | else if ( vaiCarico() ); | ||
| 315 | else if ( vaiAsso() ); | ||
| 316 | } else if ( haMessoPunti() ) { | ||
| 317 | if ( vaiSopra() ); | ||
| 318 | else if ( vaiLiscio() ); | ||
| 319 | else if ( vaiTaglio() ); | ||
| 320 | else if ( vaiPunti() ); | ||
| 321 | else if ( vaiTre() ); | ||
| 322 | else if ( vaiBriscolaAlta() ); | ||
| 323 | else if ( vaiCarico() ); | ||
| 324 | else if ( vaiAsso() ); | ||
| 325 | } else if ( haTagliato() ) { | ||
| 326 | if ( vaiLiscio() ); | ||
| 327 | else if ( vaiPunti() ); | ||
| 328 | else if ( vaiTaglio() ); | ||
| 329 | else if ( vaiTre() ); | ||
| 330 | else if ( vaiBriscolaAlta() ); | ||
| 331 | else if ( vaiCarico() ); | ||
| 332 | else if ( vaiAsso() ); | ||
| 333 | } else if ( haMessoBriscolaAlta() ) { | ||
| 334 | if ( vaiLiscio() ); | ||
| 335 | else if ( vaiPunti() ); | ||
| 336 | else if ( vaiTre() ); | ||
| 337 | else if ( vaiTaglio() ); | ||
| 338 | else if ( vaiBriscolaAlta() ); | ||
| 339 | else if ( vaiCarico() ); | ||
| 340 | else if ( vaiAsso() ); | ||
| 341 | } else if ( haMessoTre() ) { | ||
| 342 | if ( vaiAsso() ); | ||
| 343 | else if ( vaiLiscio() ); | ||
| 344 | else if ( vaiPunti() ); | ||
| 345 | else if ( vaiTaglio() ); | ||
| 346 | else if ( vaiBriscolaAlta() ); | ||
| 347 | else if ( vaiCarico() ); | ||
| 348 | } else if ( haMessoAsso() ) { | ||
| 349 | if ( vaiLiscio() ); | ||
| 350 | else if ( vaiPunti() ); | ||
| 351 | else if ( vaiTaglio() ); | ||
| 352 | else if ( vaiBriscolaAlta() ); | ||
| 353 | else if ( vaiCarico() ); | ||
| 354 | else if ( vaiTre() ); | ||
| 355 | } else if ( haCaricato() ) { | ||
| 356 | if ( vaiSopra() ); | ||
| 357 | else if ( vaiTre() ); | ||
| 358 | else if ( vaiBriscolaAlta() ); | ||
| 359 | else if ( vaiAsso() ); | ||
| 360 | else if ( vaiTaglio() ); | ||
| 361 | else if ( vaiLiscio() ); | ||
| 362 | else if ( vaiPunti() ); | ||
| 363 | else if ( vaiCarico() ); | ||
| 364 | } | ||
| 365 | } | ||
| 366 | } else if ( mano == 18 ) { | ||
| 367 | if ( frame.giocata[0] == null ) { | ||
| 368 | if ( vaiAsso() ); | ||
| 369 | else if ( vaiCarico() ); | ||
| 370 | else if ( vaiBriscolaAlta() ); | ||
| 371 | else if ( vaiTaglio() ); | ||
| 372 | else if ( vaiPunti() ); | ||
| 373 | else if ( vaiLiscio() ); | ||
| 374 | else if ( vaiTre() ); | ||
| 375 | } | ||
| 376 | else { | ||
| 377 | if ( haLisciato() ) { | ||
| 378 | if ( vaiSopra() ); | ||
| 379 | else if ( vaiLiscio() ); | ||
| 380 | else if ( vaiPunti() ); | ||
| 381 | else if ( vaiTaglio() ); | ||
| 382 | else if ( vaiTre() ); | ||
| 383 | else if ( vaiBriscolaAlta() ); | ||
| 384 | else if ( vaiCarico() ); | ||
| 385 | else if ( vaiAsso() ); | ||
| 386 | } else if ( haMessoPunti() ) { | ||
| 387 | if ( vaiSopra() ); | ||
| 388 | else if ( vaiLiscio() ); | ||
| 389 | else if ( vaiTaglio() ); | ||
| 390 | else if ( vaiPunti() ); | ||
| 391 | else if ( vaiTre() ); | ||
| 392 | else if ( vaiBriscolaAlta() ); | ||
| 393 | else if ( vaiCarico() ); | ||
| 394 | else if ( vaiAsso() ); | ||
| 395 | } else if ( haTagliato() ) { | ||
| 396 | if ( vaiLiscio() ); | ||
| 397 | else if ( vaiPunti() ); | ||
| 398 | else if ( vaiTaglio() ); | ||
| 399 | else if ( vaiTre() ); | ||
| 400 | else if ( vaiBriscolaAlta() ); | ||
| 401 | else if ( vaiCarico() ); | ||
| 402 | else if ( vaiAsso() ); | ||
| 403 | } else if ( haMessoBriscolaAlta() ) { | ||
| 404 | if ( vaiLiscio() ); | ||
| 405 | else if ( vaiPunti() ); | ||
| 406 | else if ( vaiTre() ); | ||
| 407 | else if ( vaiTaglio() ); | ||
| 408 | else if ( vaiBriscolaAlta() ); | ||
| 409 | else if ( vaiCarico() ); | ||
| 410 | else if ( vaiAsso() ); | ||
| 411 | } else if ( haMessoTre() ) { | ||
| 412 | if ( vaiAsso() ); | ||
| 413 | else if ( vaiLiscio() ); | ||
| 414 | else if ( vaiPunti() ); | ||
| 415 | else if ( vaiTaglio() ); | ||
| 416 | else if ( vaiBriscolaAlta() ); | ||
| 417 | else if ( vaiCarico() ); | ||
| 418 | } else if ( haMessoAsso() ) { | ||
| 419 | if ( vaiLiscio() ); | ||
| 420 | else if ( vaiPunti() ); | ||
| 421 | else if ( vaiTaglio() ); | ||
| 422 | else if ( vaiBriscolaAlta() ); | ||
| 423 | else if ( vaiCarico() ); | ||
| 424 | else if ( vaiTre() ); | ||
| 425 | } else if ( haCaricato() ) { | ||
| 426 | if ( vaiSopra() ); | ||
| 427 | else if ( vaiTre() ); | ||
| 428 | else if ( vaiBriscolaAlta() ); | ||
| 429 | else if ( vaiAsso() ); | ||
| 430 | else if ( vaiTaglio() ); | ||
| 431 | else if ( vaiLiscio() ); | ||
| 432 | else if ( vaiPunti() ); | ||
| 433 | else if ( vaiCarico() ); | ||
| 434 | } | ||
| 435 | } | ||
| 436 | } else { | ||
| 437 | if ( vaiTre() ); | ||
| 438 | else if ( vaiBriscolaAlta() ); | ||
| 439 | else if ( vaiAsso() ); | ||
| 440 | else if ( vaiTaglio() ); | ||
| 441 | else if ( vaiLiscio() ); | ||
| 442 | else if ( vaiPunti() ); | ||
| 443 | else if ( vaiCarico() ); | ||
| 444 | } | ||
| 445 | frame.giocata[1] = frame.carteCPU[cartaDaGiocare]; | ||
| 446 | frame.carteCPU[cartaDaGiocare] = null; | ||
| 447 | frame.pannello.repaint(); | ||
| 448 | CPUHaGiocato = true; | ||
| 449 | if ( frame.giocata[0] == null ) | ||
| 450 | toccaAllaCPU = false; | ||
| 451 | } | ||
| 452 | public void chiPrende() { | ||
| 453 | char aux[], auxCPU[]; | ||
| 454 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 455 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 456 | giocatorePrende( ( (aux[aux.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) ) | ||
| 457 | || ( (aux[aux.length-5] == auxCPU[auxCPU.length-5]) && laPrimaEPiuAlta( aux[aux.length-7] - 48, auxCPU[auxCPU.length-7] - 48 ) ) | ||
| 458 | || ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (aux[aux.length-5] != auxCPU[auxCPU.length-5]) && haGiocatoPrima ) ); | ||
| 459 | } | ||
| 460 | public boolean laPrimaEPiuAlta( int prima, int seconda ) { | ||
| 461 | int a, b; | ||
| 462 | switch ( prima ) { | ||
| 463 | case 0: | ||
| 464 | a = 10; | ||
| 465 | break; | ||
| 466 | case 1: | ||
| 467 | a = 12; | ||
| 468 | break; | ||
| 469 | case 3: | ||
| 470 | a = 11; | ||
| 471 | break; | ||
| 472 | default: | ||
| 473 | a = prima; | ||
| 474 | break; | ||
| 475 | } | ||
| 476 | switch ( seconda ) { | ||
| 477 | case 0: | ||
| 478 | b = 10; | ||
| 479 | break; | ||
| 480 | case 1: | ||
| 481 | b = 12; | ||
| 482 | break; | ||
| 483 | case 3: | ||
| 484 | b = 11; | ||
| 485 | break; | ||
| 486 | default: | ||
| 487 | b = seconda; | ||
| 488 | break; | ||
| 489 | } | ||
| 490 | return a > b; | ||
| 491 | } | ||
| 492 | public void giocatorePrende( boolean giocatore ) { | ||
| 493 | if ( giocatore ) { | ||
| 494 | toccaAllaCPU = CPUHaGiocato = false; | ||
| 495 | haGiocatoPrima = true; | ||
| 496 | } | ||
| 497 | else { | ||
| 498 | toccaAllaCPU = true; | ||
| 499 | CPUHaGiocato = haGiocatoPrima = false; | ||
| 500 | } | ||
| 501 | daiPunti( giocatore ); | ||
| 502 | if ( toccaAllaCPU ) | ||
| 503 | giocaCPU(); | ||
| 504 | } | ||
| 505 | public void daiPunti( boolean giocatore ) { | ||
| 506 | char aux[], auxCPU[]; | ||
| 507 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 508 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 509 | int punti = 0; | ||
| 510 | switch( aux[aux.length-7] - 48 ) { | ||
| 511 | case 0: | ||
| 512 | punti += 4; | ||
| 513 | break; | ||
| 514 | case 1: | ||
| 515 | punti += 11; | ||
| 516 | break; | ||
| 517 | case 3: | ||
| 518 | punti += 10; | ||
| 519 | break; | ||
| 520 | case 8: | ||
| 521 | punti += 2; | ||
| 522 | break; | ||
| 523 | case 9: | ||
| 524 | punti += 3; | ||
| 525 | break; | ||
| 526 | default: | ||
| 527 | break; | ||
| 528 | } | ||
| 529 | switch( auxCPU[auxCPU.length-7] - 48 ) { | ||
| 530 | case 0: | ||
| 531 | punti += 4; | ||
| 532 | break; | ||
| 533 | case 1: | ||
| 534 | punti += 11; | ||
| 535 | break; | ||
| 536 | case 3: | ||
| 537 | punti += 10; | ||
| 538 | break; | ||
| 539 | case 8: | ||
| 540 | punti += 2; | ||
| 541 | break; | ||
| 542 | case 9: | ||
| 543 | punti += 3; | ||
| 544 | break; | ||
| 545 | default: | ||
| 546 | break; | ||
| 547 | } | ||
| 548 | frame.giocata[0] = frame.giocata[1] = null; | ||
| 549 | if ( giocatore ) { | ||
| 550 | punteggio += punti; | ||
| 551 | if ( mano < 18 ) { | ||
| 552 | if ( frame.carteInMano[0] == null ) | ||
| 553 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 554 | if ( frame.carteInMano[1] == null ) | ||
| 555 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 556 | if ( frame.carteInMano[2] == null ) | ||
| 557 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 558 | cartaDaPescare++; | ||
| 559 | if ( frame.carteCPU[0] == null ) | ||
| 560 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 561 | if ( frame.carteCPU[1] == null ) | ||
| 562 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 563 | if ( frame.carteCPU[2] == null ) | ||
| 564 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 565 | cartaDaPescare++; | ||
| 566 | } | ||
| 567 | } | ||
| 568 | else { | ||
| 569 | punteggioCPU += punti; | ||
| 570 | if ( mano < 18 ) { | ||
| 571 | if ( frame.carteCPU[0] == null ) | ||
| 572 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 573 | if ( frame.carteCPU[1] == null ) | ||
| 574 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 575 | if ( frame.carteCPU[2] == null ) | ||
| 576 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 577 | cartaDaPescare++; | ||
| 578 | if ( frame.carteInMano[0] == null ) | ||
| 579 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 580 | if ( frame.carteInMano[1] == null ) | ||
| 581 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 582 | if ( frame.carteInMano[2] == null ) | ||
| 583 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 584 | cartaDaPescare++; | ||
| 585 | } | ||
| 586 | } | ||
| 587 | frame.pannello.repaint(); | ||
| 588 | frame.repaint(); | ||
| 589 | } | ||
| 590 | public boolean haLisciato() { | ||
| 591 | char auxCPU[]; | ||
| 592 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 593 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 594 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 595 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ); | ||
| 596 | } | ||
| 597 | public boolean haMessoPunti() { | ||
| 598 | char auxCPU[]; | ||
| 599 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 600 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 601 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || | ||
| 602 | (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ); | ||
| 603 | } | ||
| 604 | public boolean haTagliato() { | ||
| 605 | char auxCPU[]; | ||
| 606 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 607 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 608 | (auxCPU[auxCPU.length-7] - 48 != 0) && (auxCPU[auxCPU.length-7] - 48 != 1) && | ||
| 609 | (auxCPU[auxCPU.length-7] - 48 != 3) && (auxCPU[auxCPU.length-7] - 48 <= 7) ); | ||
| 610 | } | ||
| 611 | public boolean haMessoBriscolaAlta() { | ||
| 612 | char auxCPU[]; | ||
| 613 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 614 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 615 | ( (auxCPU[auxCPU.length-7] - 48 == 0) || (auxCPU[auxCPU.length-7] - 48 == 8) || | ||
| 616 | (auxCPU[auxCPU.length-7] - 48 == 9) ) ); | ||
| 617 | } | ||
| 618 | public boolean haMessoTre() { | ||
| 619 | char auxCPU[]; | ||
| 620 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 621 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 622 | (auxCPU[auxCPU.length-7] - 48 == 3) ); | ||
| 623 | } | ||
| 624 | public boolean haMessoAsso() { | ||
| 625 | char auxCPU[]; | ||
| 626 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 627 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 628 | (auxCPU[auxCPU.length-7] - 48 == 1) ); | ||
| 629 | } | ||
| 630 | public boolean haCaricato() { | ||
| 631 | char auxCPU[]; | ||
| 632 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 633 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 634 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ); | ||
| 635 | } | ||
| 636 | public boolean vaiLiscio() { | ||
| 637 | char auxCPU[]; | ||
| 638 | for ( int i = 0; i < 3; i++ ) { | ||
| 639 | if ( frame.carteCPU[i] != null ) { | ||
| 640 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 641 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 642 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 643 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ) { | ||
| 644 | cartaDaGiocare = i; | ||
| 645 | return true; | ||
| 646 | } | ||
| 647 | } | ||
| 648 | } | ||
| 649 | return false; | ||
| 650 | } | ||
| 651 | public boolean vaiPunti() { | ||
| 652 | char[] auxCPU; | ||
| 653 | for ( int i = 0; i < 3; i++ ) { | ||
| 654 | if ( frame.carteCPU[i] != null ) { | ||
| 655 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 656 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 8 ) ) { | ||
| 657 | cartaDaGiocare = i; | ||
| 658 | return true; | ||
| 659 | } | ||
| 660 | } | ||
| 661 | } | ||
| 662 | for ( int i = 0; i < 3; i++ ) { | ||
| 663 | if ( frame.carteCPU[i] != null ) { | ||
| 664 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 665 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 9 ) ) { | ||
| 666 | cartaDaGiocare = i; | ||
| 667 | return true; | ||
| 668 | } | ||
| 669 | } | ||
| 670 | } | ||
| 671 | for ( int i = 0; i < 3; i++ ) { | ||
| 672 | if ( frame.carteCPU[i] != null ) { | ||
| 673 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 674 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 0 ) ) { | ||
| 675 | cartaDaGiocare = i; | ||
| 676 | return true; | ||
| 677 | } | ||
| 678 | } | ||
| 679 | } | ||
| 680 | return false; | ||
| 681 | } | ||
| 682 | public boolean vaiTaglio() { | ||
| 683 | char auxCPU[]; | ||
| 684 | for ( int i = 0; i < 3; i++ ) { | ||
| 685 | if ( frame.carteCPU[i] != null ) { | ||
| 686 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 687 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && | ||
| 688 | (auxCPU[auxCPU.length-7] - 48 != 0) && (auxCPU[auxCPU.length-7] - 48 != 1) && | ||
| 689 | (auxCPU[auxCPU.length-7] - 48 != 3) && (auxCPU[auxCPU.length-7] - 48 <= 7) ) { | ||
| 690 | cartaDaGiocare = i; | ||
| 691 | return true; | ||
| 692 | } | ||
| 693 | } | ||
| 694 | } | ||
| 695 | return false; | ||
| 696 | } | ||
| 697 | public boolean vaiBriscolaAlta() { | ||
| 698 | char[] auxCPU; | ||
| 699 | for ( int i = 0; i < 3; i++ ) { | ||
| 700 | if ( frame.carteCPU[i] != null ) { | ||
| 701 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 702 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 8 ) ) { | ||
| 703 | cartaDaGiocare = i; | ||
| 704 | return true; | ||
| 705 | } | ||
| 706 | } | ||
| 707 | } | ||
| 708 | for ( int i = 0; i < 3; i++ ) { | ||
| 709 | if ( frame.carteCPU[i] != null ) { | ||
| 710 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 711 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 9 ) ) { | ||
| 712 | cartaDaGiocare = i; | ||
| 713 | return true; | ||
| 714 | } | ||
| 715 | } | ||
| 716 | } | ||
| 717 | for ( int i = 0; i < 3; i++ ) { | ||
| 718 | if ( frame.carteCPU[i] != null ) { | ||
| 719 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 720 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 0 ) ) { | ||
| 721 | cartaDaGiocare = i; | ||
| 722 | return true; | ||
| 723 | } | ||
| 724 | } | ||
| 725 | } | ||
| 726 | return false; | ||
| 727 | } | ||
| 728 | public boolean vaiTre() { | ||
| 729 | char auxCPU[]; | ||
| 730 | for ( int i = 0; i < 3; i++ ) { | ||
| 731 | if ( frame.carteCPU[i] != null ) { | ||
| 732 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 733 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && (auxCPU[auxCPU.length-7] - 48 == 3) ) { | ||
| 734 | cartaDaGiocare = i; | ||
| 735 | return true; | ||
| 736 | } | ||
| 737 | } | ||
| 738 | } | ||
| 739 | return false; | ||
| 740 | } | ||
| 741 | public boolean vaiAsso() { | ||
| 742 | char auxCPU[]; | ||
| 743 | for ( int i = 0; i < 3; i++ ) { | ||
| 744 | if ( frame.carteCPU[i] != null ) { | ||
| 745 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 746 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && (auxCPU[auxCPU.length-7] - 48 == 1) ) { | ||
| 747 | cartaDaGiocare = i; | ||
| 748 | return true; | ||
| 749 | } | ||
| 750 | } | ||
| 751 | } | ||
| 752 | return false; | ||
| 753 | } | ||
| 754 | public boolean vaiCarico() { | ||
| 755 | char[] auxCPU; | ||
| 756 | for ( int i = 0; i < 3; i++ ) { | ||
| 757 | if ( frame.carteCPU[i] != null ) { | ||
| 758 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 759 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 3 ) ) { | ||
| 760 | cartaDaGiocare = i; | ||
| 761 | return true; | ||
| 762 | } | ||
| 763 | } | ||
| 764 | } | ||
| 765 | for ( int i = 0; i < 3; i++ ) { | ||
| 766 | if ( frame.carteCPU[i] != null ) { | ||
| 767 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 768 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 1 ) ) { | ||
| 769 | cartaDaGiocare = i; | ||
| 770 | return true; | ||
| 771 | } | ||
| 772 | } | ||
| 773 | } | ||
| 774 | return false; | ||
| 775 | } | ||
| 776 | public boolean vaiSopra() { | ||
| 777 | if ( frame.giocata[0] == null ) | ||
| 778 | return false; | ||
| 779 | int a = -1; | ||
| 780 | int b = -1; | ||
| 781 | int c = -1; | ||
| 782 | boolean laPrimaPuoAndareSopra = false; | ||
| 783 | boolean laSecondaPuoAndareSopra = false; | ||
| 784 | boolean laTerzaPuoAndareSopra = false; | ||
| 785 | char[] auxCPU1 = new char[1024]; | ||
| 786 | char[] auxCPU2 = new char[1024]; | ||
| 787 | char[] auxCPU3 = new char[1024]; | ||
| 788 | char[] aux = frame.giocata[0].toString().toCharArray(); | ||
| 789 | if ( aux[aux.length-7] - 48 == 1 ) | ||
| 790 | return false; | ||
| 791 | if ( frame.carteCPU[0] != null ) { | ||
| 792 | auxCPU1 = frame.carteCPU[0].toString().toCharArray(); | ||
| 793 | a = auxCPU1[auxCPU1.length-7] - 48; | ||
| 794 | if ( (auxCPU1[auxCPU1.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( a, aux[aux.length-7] - 48 ) ) | ||
| 795 | laPrimaPuoAndareSopra = true; | ||
| 796 | } | ||
| 797 | if ( frame.carteCPU[1] != null ) { | ||
| 798 | auxCPU2 = frame.carteCPU[1].toString().toCharArray(); | ||
| 799 | b = auxCPU2[auxCPU2.length-7] - 48; | ||
| 800 | if ( (auxCPU2[auxCPU2.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( b, aux[aux.length-7] - 48 ) ) | ||
| 801 | laSecondaPuoAndareSopra = true; | ||
| 802 | } | ||
| 803 | if ( frame.carteCPU[2] != null ) { | ||
| 804 | auxCPU3 = frame.carteCPU[2].toString().toCharArray(); | ||
| 805 | c = auxCPU3[auxCPU3.length-7] - 48; | ||
| 806 | if ( (auxCPU3[auxCPU3.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( c, aux[aux.length-7] - 48 ) ) | ||
| 807 | laTerzaPuoAndareSopra = true; | ||
| 808 | } | ||
| 809 | if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 810 | return false; | ||
| 811 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 812 | cartaDaGiocare = 0; | ||
| 813 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 814 | cartaDaGiocare = 1; | ||
| 815 | else if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 816 | cartaDaGiocare = 2; | ||
| 817 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 818 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 819 | cartaDaGiocare = 0; | ||
| 820 | else | ||
| 821 | cartaDaGiocare = 1; | ||
| 822 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 823 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 824 | cartaDaGiocare = 1; | ||
| 825 | else | ||
| 826 | cartaDaGiocare = 2; | ||
| 827 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 828 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 829 | cartaDaGiocare = 0; | ||
| 830 | else | ||
| 831 | cartaDaGiocare = 2; | ||
| 832 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 833 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 834 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 835 | cartaDaGiocare = 0; | ||
| 836 | else | ||
| 837 | cartaDaGiocare = 2; | ||
| 838 | else | ||
| 839 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 840 | cartaDaGiocare = 1; | ||
| 841 | else | ||
| 842 | cartaDaGiocare = 2; | ||
| 843 | aux = frame.carteCPU[cartaDaGiocare].toString().toCharArray(); | ||
| 844 | if ( (aux[aux.length-7] - 48 != 0) && (aux[aux.length-7] - 48 != 1) && | ||
| 845 | (aux[aux.length-7] - 48 != 3) && (aux[aux.length-7] - 48 <= 7) ) | ||
| 846 | return false; | ||
| 847 | return true; | ||
| 848 | } | ||
| 849 | public boolean hoCarico() { | ||
| 850 | char auxCPU[]; | ||
| 851 | for ( int i = 0; i < 3; i++ ) { | ||
| 852 | if ( frame.carteCPU[i] != null ) { | ||
| 853 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 854 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 855 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ) { | ||
| 856 | return true; | ||
| 857 | } | ||
| 858 | } | ||
| 859 | } | ||
| 860 | return false; | ||
| 861 | } | ||
| 862 | public boolean hoAsso() { | ||
| 863 | char auxCPU[]; | ||
| 864 | for ( int i = 0; i < 3; i++ ) { | ||
| 865 | if ( frame.carteCPU[i] != null ) { | ||
| 866 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 867 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 1 ) ) { | ||
| 868 | return true; | ||
| 869 | } | ||
| 870 | } | ||
| 871 | } | ||
| 872 | return false; | ||
| 873 | } | ||
| 874 | public boolean hoTre() { | ||
| 875 | char auxCPU[]; | ||
| 876 | for ( int i = 0; i < 3; i++ ) { | ||
| 877 | if ( frame.carteCPU[i] != null ) { | ||
| 878 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 879 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 3 ) ) { | ||
| 880 | return true; | ||
| 881 | } | ||
| 882 | } | ||
| 883 | } | ||
| 884 | return false; | ||
| 885 | } | ||
| 886 | public boolean hoBriscolaAlta() { | ||
| 887 | char auxCPU[]; | ||
| 888 | for ( int i = 0; i < 3; i++ ) { | ||
| 889 | if ( frame.carteCPU[i] != null ) { | ||
| 890 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 891 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 892 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ) { | ||
| 893 | return true; | ||
| 894 | } | ||
| 895 | } | ||
| 896 | } | ||
| 897 | return false; | ||
| 898 | } | ||
| 899 | public boolean hoTaglio() { | ||
| 900 | char auxCPU[]; | ||
| 901 | for ( int i = 0; i < 3; i++ ) { | ||
| 902 | if ( frame.carteCPU[i] != null ) { | ||
| 903 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 904 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 905 | (auxCPU[auxCPU.length-7] - 48 < 8 ) && (auxCPU[auxCPU.length-7] - 48 != 3 ) | ||
| 906 | && (auxCPU[auxCPU.length-7] - 48 != 1 ) && (auxCPU[auxCPU.length-7] - 48 != 0 ) ) { | ||
| 907 | return true; | ||
| 908 | } | ||
| 909 | } | ||
| 910 | } | ||
| 911 | return false; | ||
| 912 | } | ||
| 913 | public static void settaOpzioni() { | ||
| 914 | lang = "it"; | ||
| 915 | soundString = "suono=si"; | ||
| 916 | keysString = "tasti=si"; | ||
| 917 | int r = 0; | ||
| 918 | int g = 150; | ||
| 919 | int b = 0; | ||
| 920 | Scanner scanner = null; | ||
| 921 | File file = new File( "JBriscolaConfig.txt" ); | ||
| 922 | if ( file.exists() ) { | ||
| 923 | try { | ||
| 924 | scanner = new Scanner( file ); | ||
| 925 | } catch ( FileNotFoundException e ) { } | ||
| 926 | try { | ||
| 927 | lang = scanner.next(); | ||
| 928 | soundString = scanner.next(); | ||
| 929 | keysString = scanner.next(); | ||
| 930 | r = scanner.nextInt(); | ||
| 931 | g = scanner.nextInt(); | ||
| 932 | b = scanner.nextInt(); | ||
| 933 | } catch ( NoSuchElementException e ) { } | ||
| 934 | } | ||
| 935 | if ( lang.equals( "it" ) ) { | ||
| 936 | stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 937 | stringaPrimaGioca = "Prima Gioca!"; | ||
| 938 | stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 939 | stringaVinto = "Hai Vinto!"; | ||
| 940 | stringaPerso = "Hai Perso"; | ||
| 941 | stringaPareggio = "Pareggio"; | ||
| 942 | stringaGiocatore = "Giocatore: "; | ||
| 943 | stringaComputer = "\nComputer: "; | ||
| 944 | stringaNuovaPartita = "Nuova Partita"; | ||
| 945 | stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 946 | stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 947 | stringaSi = "Si"; | ||
| 948 | stringaNo = "No"; | ||
| 949 | stringaOpzioni = "Opzioni..."; | ||
| 950 | stringaEsci = "Esci"; | ||
| 951 | stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 952 | stringaLingua = "Lingua"; | ||
| 953 | stringaAnnulla = "Annulla"; | ||
| 954 | stringaIt = "Italiano"; | ||
| 955 | stringaLa = "Latino"; | ||
| 956 | stringaBL = "Dialetto Bellunese"; | ||
| 957 | stringaBV = "Dialetto Basso Veneto"; | ||
| 958 | stringaNecessarioRiavviare = "E' necessario riavviare JBriscola se sono state\nmodificate impostazioni riguardanti la lingua\nAlcune parti saranno comunque tradotte prima."; | ||
| 959 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 960 | stringaInformazioni = "Informazioni"; | ||
| 961 | 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"; | ||
| 962 | stringaSuono = "Effetti sonori"; | ||
| 963 | stringaPunteggio = "Punteggio"; | ||
| 964 | stringaSfondo = "Sfondo"; | ||
| 965 | stringaTasti = "Tasti rapidi"; | ||
| 966 | stringaTasti2 = "1 Gioca la prima carta\n2 Gioca la seconda carta\n3 Gioca la terza carta\nF1 Visualizza questo messaggio\nF2 Nuova partita\nF3 Opzioni\nF4 Visualizza Punteggio\nF5 Informazioni\nq Esci"; | ||
| 967 | } | ||
| 968 | else if ( lang.equals( "la" ) ) { | ||
| 969 | stringaBottonePrendi = "CAPIS/RELINQVIS CHARTAS"; | ||
| 970 | stringaPrimaGioca = "ANTE CHARTAM PONE!"; | ||
| 971 | stringaUltime4 = "CHARTA POSTREMA - INTVERE BRISCOLAM!"; | ||
| 972 | stringaVinto = "VICISTI!"; | ||
| 973 | stringaPerso = "PERDIDISTI"; | ||
| 974 | stringaPareggio = "AEQVATIO!"; | ||
| 975 | stringaGiocatore = "LVSOR: "; | ||
| 976 | stringaComputer = "\nCOMPVTER: "; | ||
| 977 | stringaNuovaPartita = "NOVA LVSO"; | ||
| 978 | stringaVuoiDavveroIniziare = "NOVAM LVSIONEM INCIPERE?"; | ||
| 979 | stringaVuoiDavveroUscire = "EXIRE?"; | ||
| 980 | stringaSi = "ID VOLO"; | ||
| 981 | stringaNo = "NOLO"; | ||
| 982 | stringaOpzioni = "OPTIONES..."; | ||
| 983 | stringaEsci = "EXIRE"; | ||
| 984 | stringaImpossibileConfigurare = "CONFIGVRATIONIS FILE SCRIBERE NON POTVI.\nERROREM ME CERTIOREM FACITE: sebastiano@luganega.org\n\nEXCEPTIO:\n"; | ||
| 985 | stringaLingua = "LINGVA"; | ||
| 986 | stringaAnnulla = "ABROGA"; | ||
| 987 | stringaIt = "ITALICA"; | ||
| 988 | stringaLa = "LATINA"; | ||
| 989 | stringaBL = "BELLUNI"; | ||
| 990 | stringaBV = "VENETIAE"; | ||
| 991 | stringaNecessarioRiavviare = "JBRISCOLAM RVRSVS INCIPERE NECESSE EST\nSI LINGVA PRAELATIONES NOVATAE SVNT.\nALIQVAE ANTE ID VERSA ERVNT"; | ||
| 992 | stringaModificaOpzioni = "OPTIONES NOVARE"; | ||
| 993 | stringaInformazioni = "INFORMATIONES"; | ||
| 994 | 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"; | ||
| 995 | stringaSuono = "SONVS"; | ||
| 996 | stringaPunteggio = "NVMERI"; | ||
| 997 | stringaSfondo = "COLOR"; | ||
| 998 | stringaTasti = "TASTI RAPIDI"; | ||
| 999 | stringaTasti2 = "1 PONE CHARTAM PRIMAM\n2 PONE CHARTAM SECUNDAM\n3 PONE CHARTAM TERTIAM\nF1 HEAC INFORMATIONES\nF2 NOVA LVSO\nF3 OPTIONES\nF4 NVMERI\nF5 INFORMATIONES\nq EXIRE"; | ||
| 1000 | } | ||
| 1001 | if ( lang.equals( "bl" ) ) { | ||
| 1002 | stringaBottonePrendi = "Cio' su/lasa le carte"; | ||
| 1003 | stringaPrimaGioca = "Prima Duga!"; | ||
| 1004 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1005 | stringaVinto = "Te ha vint!"; | ||
| 1006 | stringaPerso = "Te ha pers"; | ||
| 1007 | stringaPareggio = "Pari"; | ||
| 1008 | stringaGiocatore = "Dugador: "; | ||
| 1009 | stringaComputer = "\nComputer: "; | ||
| 1010 | stringaNuovaPartita = "Taca n'altra partida"; | ||
| 1011 | stringaVuoiDavveroIniziare = "Utu sul serio scuminziar n'altra partida?"; | ||
| 1012 | stringaVuoiDavveroUscire = "Utu sul serio stusar su?"; | ||
| 1013 | stringaSi = "Si"; | ||
| 1014 | stringaNo = "No"; | ||
| 1015 | stringaOpzioni = "Opzioni..."; | ||
| 1016 | stringaEsci = "Stusa su"; | ||
| 1017 | stringaImpossibileConfigurare = "No ghe ho riva' a scrivere al file de configurazion.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1018 | stringaLingua = "Lengua"; | ||
| 1019 | stringaAnnulla = "Annulla"; | ||
| 1020 | stringaIt = "Italian"; | ||
| 1021 | stringaLa = "Latin"; | ||
| 1022 | stringaBL = "Dialeto de Belun"; | ||
| 1023 | stringaBV = "Dialeto de la basa"; | ||
| 1024 | stringaNecessarioRiavviare = "Se te ha cambia' la lengua te toca\nstusar su e impizar de novo al dugo\nPero' zerte robe le e' belche tradote."; | ||
| 1025 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1026 | stringaInformazioni = "Informazioni"; | ||
| 1027 | 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"; | ||
| 1028 | stringaSuono = "Efeti sonori"; | ||
| 1029 | stringaPunteggio = "Varda i punti"; | ||
| 1030 | stringaSfondo = "Sfondo"; | ||
| 1031 | stringaTasti = "Tasti rapidi"; | ||
| 1032 | stringaTasti2 = "1 Duga la prima carta\n2 Duga la seconda carta\n3 Duga la terza carta\nF1 Tasti rapidi\nF2 Taca n'altra partida\nF3 Opzioni\nF4 Varda i punti\nF5 Informazioni\nq Stusa su"; | ||
| 1033 | } | ||
| 1034 | if ( lang.equals( "bv" ) ) { | ||
| 1035 | stringaBottonePrendi = "Ciapa su/lasa e carte"; | ||
| 1036 | stringaPrimaGioca = "Prima Zuga!"; | ||
| 1037 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1038 | stringaVinto = "Ti ga vinto!"; | ||
| 1039 | stringaPerso = "Ti ga perso"; | ||
| 1040 | stringaPareggio = "Pari"; | ||
| 1041 | stringaGiocatore = "Zugador: "; | ||
| 1042 | stringaComputer = "\nComputer: "; | ||
| 1043 | stringaNuovaPartita = "N'altra Partida"; | ||
| 1044 | stringaVuoiDavveroIniziare = "Ti vol sul serio scuminziar n'altra partida?"; | ||
| 1045 | stringaVuoiDavveroUscire = "Ti vol sul serio stusar su?"; | ||
| 1046 | stringaSi = "Si"; | ||
| 1047 | stringaNo = "No"; | ||
| 1048 | stringaOpzioni = "Opzioni..."; | ||
| 1049 | stringaEsci = "Stusa su"; | ||
| 1050 | stringaImpossibileConfigurare = "No ghe son riusito a scrivere al file de configurazione.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1051 | stringaLingua = "Lengua"; | ||
| 1052 | stringaAnnulla = "Annulla"; | ||
| 1053 | stringaIt = "Italian"; | ||
| 1054 | stringaLa = "Latin"; | ||
| 1055 | stringaBL = "Dialeto Belumat"; | ||
| 1056 | stringaBV = "Dialeto Veneto"; | ||
| 1057 | stringaNecessarioRiavviare = "Se ti ga cambia' la lengua te toca\nstusar su e impizar de novo al zugo\nPero' zerte robe le e' belche tradote."; | ||
| 1058 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1059 | stringaInformazioni = "Informasioni"; | ||
| 1060 | 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"; | ||
| 1061 | stringaSuono = "Efeti sonori"; | ||
| 1062 | stringaPunteggio = "Varda i punti"; | ||
| 1063 | stringaSfondo = "Sfondo"; | ||
| 1064 | stringaTasti = "Tasti rapidi"; | ||
| 1065 | stringaTasti2 = "1 Zuga la prima carta\n2 Zuga la seconda carta\n3 Zuga la terza carta\nF1 Tasti rapidi\nF2 N'altra partida\nF3 Opzioni\nF4 Varda i punti\nF5 Informazioni\nq Stusa su"; | ||
| 1066 | |||
| 1067 | } | ||
| 1068 | sound = ( soundString.equals( "suono=si" ) ); | ||
| 1069 | keys = ( keysString.equals( "tasti=si" ) ); | ||
| 1070 | color = new Color( r, g, b ); | ||
| 1071 | if ( frame != null ) { | ||
| 1072 | frame.pannello.repaint(); | ||
| 1073 | frame.pannello2.repaint(); | ||
| 1074 | frame.repaint(); | ||
| 1075 | } | ||
| 1076 | } | ||
| 1077 | } | ||
diff --git a/JBriscola/all_versions/0.2/0.2/src/OptionFrame.java b/JBriscola/all_versions/0.2/0.2/src/OptionFrame.java new file mode 100755 index 0000000..9876af8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/OptionFrame.java | |||
| @@ -0,0 +1,140 @@ | |||
| 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.util.Formatter; | ||
| 23 | import javax.swing.*; | ||
| 24 | import java.awt.*; | ||
| 25 | import java.awt.event.*; | ||
| 26 | |||
| 27 | public class OptionFrame extends JFrame { | ||
| 28 | public static Main main = new Main(); | ||
| 29 | public static Formatter formatter; | ||
| 30 | public static JButton ok, annulla, scegliColore; | ||
| 31 | public static JLabel lingua, sfondo; | ||
| 32 | public static JComboBox selezionaLingua; | ||
| 33 | public static JCheckBox suono, tastiRapidi; | ||
| 34 | public static JPanel[] pannello = new JPanel[6]; | ||
| 35 | public OptionFrame() { | ||
| 36 | super( "JBriscola - " + main.stringaModificaOpzioni ); | ||
| 37 | ok = new JButton( "OK" ); | ||
| 38 | ok.addActionListener( new ActionListener() { | ||
| 39 | public void actionPerformed( ActionEvent e ) { | ||
| 40 | try { | ||
| 41 | formatter = new Formatter( "JBriscolaConfig.txt" ); | ||
| 42 | } catch ( Exception ex ) { | ||
| 43 | JOptionPane.showMessageDialog( OptionFrame.this, main.stringaImpossibileConfigurare + ex ); | ||
| 44 | } | ||
| 45 | String lang; | ||
| 46 | switch ( selezionaLingua.getSelectedIndex() ) { | ||
| 47 | case 0: | ||
| 48 | lang = "it"; | ||
| 49 | break; | ||
| 50 | case 1: | ||
| 51 | lang = "la"; | ||
| 52 | break; | ||
| 53 | case 2: | ||
| 54 | lang = "bl"; | ||
| 55 | break; | ||
| 56 | case 3: | ||
| 57 | lang = "bv"; | ||
| 58 | break; | ||
| 59 | default: | ||
| 60 | lang = "it"; | ||
| 61 | break; | ||
| 62 | } | ||
| 63 | String suonosiono, tastisiono; | ||
| 64 | if ( suono.isSelected() ) | ||
| 65 | suonosiono = "suono=si"; | ||
| 66 | else | ||
| 67 | suonosiono = "suono=no"; | ||
| 68 | if ( tastiRapidi.isSelected() ) | ||
| 69 | tastisiono = "tasti=si"; | ||
| 70 | else | ||
| 71 | tastisiono = "tasti=no"; | ||
| 72 | formatter.format( lang ); | ||
| 73 | formatter.format( "\n" ); | ||
| 74 | formatter.format( suonosiono ); | ||
| 75 | formatter.format( "\n" ); | ||
| 76 | formatter.format( tastisiono ); | ||
| 77 | formatter.format( "\n" ); | ||
| 78 | formatter.format( main.color.getRed() + " " + main.color.getGreen() + " " + main.color.getBlue() ); | ||
| 79 | formatter.close(); | ||
| 80 | main.settaOpzioni(); | ||
| 81 | OptionFrame.this.dispose(); | ||
| 82 | //JOptionPane.showMessageDialog( OptionFrame.this, main.stringaNecessarioRiavviare, "JBriscola 0.1", JOptionPane.INFORMATION_MESSAGE ); | ||
| 83 | } | ||
| 84 | }); | ||
| 85 | annulla = new JButton( main.stringaAnnulla ); | ||
| 86 | annulla.addActionListener( new ActionListener() { | ||
| 87 | public void actionPerformed( ActionEvent e ) { | ||
| 88 | OptionFrame.this.dispose(); | ||
| 89 | } | ||
| 90 | }); | ||
| 91 | scegliColore = new JButton( " " ); | ||
| 92 | scegliColore.setBackground( main.color ); | ||
| 93 | scegliColore.addActionListener( new ActionListener() { | ||
| 94 | public void actionPerformed( ActionEvent e ) { | ||
| 95 | Color colore = JColorChooser.showDialog( OptionFrame.this, "JBriscola " + main.version, main.color ); | ||
| 96 | if ( colore != null ) | ||
| 97 | main.color = colore; | ||
| 98 | OptionFrame.scegliColore.setBackground( main.color ); | ||
| 99 | } | ||
| 100 | } ); | ||
| 101 | lingua = new JLabel( main.stringaLingua ); | ||
| 102 | sfondo = new JLabel( main.stringaSfondo ); | ||
| 103 | String[] lingueDaSelezionare = { main.stringaIt, main.stringaLa, main.stringaBL, main.stringaBV }; | ||
| 104 | selezionaLingua = new JComboBox( lingueDaSelezionare ); | ||
| 105 | int linguaPreselezionata = 0; | ||
| 106 | if ( main.lang.equals( "it" ) ) | ||
| 107 | linguaPreselezionata = 0; | ||
| 108 | else if ( main.lang.equals( "la" ) ) | ||
| 109 | linguaPreselezionata = 1; | ||
| 110 | else if ( main.lang.equals( "bl" ) ) | ||
| 111 | linguaPreselezionata = 2; | ||
| 112 | else if ( main.lang.equals( "bv" ) ) | ||
| 113 | linguaPreselezionata = 3; | ||
| 114 | selezionaLingua.setSelectedIndex( linguaPreselezionata ); | ||
| 115 | suono = new JCheckBox( main.stringaSuono ); | ||
| 116 | suono.setSelected( main.sound ); | ||
| 117 | tastiRapidi = new JCheckBox( main.stringaTasti ); | ||
| 118 | tastiRapidi.setSelected( main.keys ); | ||
| 119 | pannello[0] = new JPanel( new GridLayout( 4, 1 ) ); | ||
| 120 | pannello[1] = new JPanel( new FlowLayout() ); | ||
| 121 | pannello[2] = new JPanel( new FlowLayout() ); | ||
| 122 | pannello[3] = new JPanel( new FlowLayout() ); | ||
| 123 | pannello[4] = new JPanel( new FlowLayout() ); | ||
| 124 | pannello[5] = new JPanel( new FlowLayout() ); | ||
| 125 | pannello[5].add( ok ); | ||
| 126 | pannello[5].add( annulla ); | ||
| 127 | pannello[4].add( sfondo ); | ||
| 128 | pannello[4].add( scegliColore ); | ||
| 129 | pannello[3].add( tastiRapidi ); | ||
| 130 | pannello[2].add( suono ); | ||
| 131 | pannello[1].add( lingua ); | ||
| 132 | pannello[1].add( selezionaLingua ); | ||
| 133 | pannello[0].add( pannello[1] ); | ||
| 134 | pannello[0].add( pannello[2] ); | ||
| 135 | pannello[0].add( pannello[3] ); | ||
| 136 | pannello[0].add( pannello[4] ); | ||
| 137 | add( pannello[0], BorderLayout.CENTER ); | ||
| 138 | add( pannello[5], BorderLayout.SOUTH ); | ||
| 139 | } | ||
| 140 | } | ||
diff --git a/JBriscola/all_versions/0.2/0.2/src/Pannello.java b/JBriscola/all_versions/0.2/0.2/src/Pannello.java new file mode 100755 index 0000000..24c6596 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/Pannello.java | |||
| @@ -0,0 +1,54 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | |||
| 25 | public class Pannello extends JPanel { | ||
| 26 | public static Main main; | ||
| 27 | public static Color color; | ||
| 28 | public Pannello() { } | ||
| 29 | public void paint( Graphics g ) { | ||
| 30 | super.paint( g ); | ||
| 31 | setBackground( main.color ); | ||
| 32 | if ( main.frame.ultimaCarta != null ) | ||
| 33 | main.frame.ultimaCarta.paintIcon( this, g, 50, 180 ); | ||
| 34 | if ( main.frame.mazzo ) | ||
| 35 | main.frame.retro2.paintIcon( this, g, 17, 256 ); | ||
| 36 | if ( main.frame.carteCPU[0] != null ) | ||
| 37 | main.frame.retro1.paintIcon( this, g, 230, 5 ); | ||
| 38 | if ( main.frame.carteCPU[1] != null ) | ||
| 39 | main.frame.retro1.paintIcon( this, g, 300, 5 ); | ||
| 40 | if ( main.frame.carteCPU[2] != null ) | ||
| 41 | main.frame.retro1.paintIcon( this, g, 370, 5 ); | ||
| 42 | if ( main.frame.carteInMano[0] != null ) | ||
| 43 | main.frame.carteInMano[0].paintIcon( this, g, 230, 340 ); | ||
| 44 | if ( main.frame.carteInMano[1] != null ) | ||
| 45 | main.frame.carteInMano[1].paintIcon( this, g, 300, 340 ); | ||
| 46 | if ( main.frame.carteInMano[2] != null ) | ||
| 47 | main.frame.carteInMano[2].paintIcon( this, g, 370, 340 ); | ||
| 48 | if ( main.frame.giocata[0] != null ) | ||
| 49 | main.frame.giocata[0].paintIcon( this, g, 250, 200 ); | ||
| 50 | if ( main.frame.giocata[1] != null ) | ||
| 51 | main.frame.giocata[1].paintIcon( this, g, 325, 150 ); | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/1-1.jpg b/JBriscola/all_versions/0.2/0.2/src/img/1-1.jpg new file mode 100755 index 0000000..ae43510 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/1-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/1-2.jpg b/JBriscola/all_versions/0.2/0.2/src/img/1-2.jpg new file mode 100755 index 0000000..3f7c75a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/1-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/1-3.jpg b/JBriscola/all_versions/0.2/0.2/src/img/1-3.jpg new file mode 100755 index 0000000..9e1ead7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/1-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/1-4.jpg b/JBriscola/all_versions/0.2/0.2/src/img/1-4.jpg new file mode 100755 index 0000000..710f879 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/1-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/10-1.jpg b/JBriscola/all_versions/0.2/0.2/src/img/10-1.jpg new file mode 100755 index 0000000..9aba45a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/10-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/10-2.jpg b/JBriscola/all_versions/0.2/0.2/src/img/10-2.jpg new file mode 100755 index 0000000..037eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/10-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/10-3.jpg b/JBriscola/all_versions/0.2/0.2/src/img/10-3.jpg new file mode 100755 index 0000000..8780b72 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/10-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/10-4.jpg b/JBriscola/all_versions/0.2/0.2/src/img/10-4.jpg new file mode 100755 index 0000000..587dc0f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/10-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/2-1.jpg b/JBriscola/all_versions/0.2/0.2/src/img/2-1.jpg new file mode 100755 index 0000000..5dcb7db --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/2-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/2-2.jpg b/JBriscola/all_versions/0.2/0.2/src/img/2-2.jpg new file mode 100755 index 0000000..ea9eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/2-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/2-3.jpg b/JBriscola/all_versions/0.2/0.2/src/img/2-3.jpg new file mode 100755 index 0000000..8cb22dd --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/2-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/2-4.jpg b/JBriscola/all_versions/0.2/0.2/src/img/2-4.jpg new file mode 100755 index 0000000..b3e7898 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/2-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/3-1.jpg b/JBriscola/all_versions/0.2/0.2/src/img/3-1.jpg new file mode 100755 index 0000000..dcb435c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/3-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/3-2.jpg b/JBriscola/all_versions/0.2/0.2/src/img/3-2.jpg new file mode 100755 index 0000000..1e5b6ec --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/3-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/3-3.jpg b/JBriscola/all_versions/0.2/0.2/src/img/3-3.jpg new file mode 100755 index 0000000..9202cfe --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/3-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/3-4.jpg b/JBriscola/all_versions/0.2/0.2/src/img/3-4.jpg new file mode 100755 index 0000000..5436a8d --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/3-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/4-1.jpg b/JBriscola/all_versions/0.2/0.2/src/img/4-1.jpg new file mode 100755 index 0000000..3bab6d5 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/4-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/4-2.jpg b/JBriscola/all_versions/0.2/0.2/src/img/4-2.jpg new file mode 100755 index 0000000..b4901a6 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/4-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/4-3.jpg b/JBriscola/all_versions/0.2/0.2/src/img/4-3.jpg new file mode 100755 index 0000000..d754ad8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/4-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/4-4.jpg b/JBriscola/all_versions/0.2/0.2/src/img/4-4.jpg new file mode 100755 index 0000000..3a54b96 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/4-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/5-1.jpg b/JBriscola/all_versions/0.2/0.2/src/img/5-1.jpg new file mode 100755 index 0000000..3f7ba1f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/5-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/5-2.jpg b/JBriscola/all_versions/0.2/0.2/src/img/5-2.jpg new file mode 100755 index 0000000..fcacb75 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/5-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/5-3.jpg b/JBriscola/all_versions/0.2/0.2/src/img/5-3.jpg new file mode 100755 index 0000000..ce32f9f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/5-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/5-4.jpg b/JBriscola/all_versions/0.2/0.2/src/img/5-4.jpg new file mode 100755 index 0000000..b86b09a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/5-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/6-1.jpg b/JBriscola/all_versions/0.2/0.2/src/img/6-1.jpg new file mode 100755 index 0000000..f90cd81 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/6-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/6-2.jpg b/JBriscola/all_versions/0.2/0.2/src/img/6-2.jpg new file mode 100755 index 0000000..cf2a67a --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/6-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/6-3.jpg b/JBriscola/all_versions/0.2/0.2/src/img/6-3.jpg new file mode 100755 index 0000000..2cd2fe2 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/6-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/6-4.jpg b/JBriscola/all_versions/0.2/0.2/src/img/6-4.jpg new file mode 100755 index 0000000..73f410f --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/6-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/7-1.jpg b/JBriscola/all_versions/0.2/0.2/src/img/7-1.jpg new file mode 100755 index 0000000..08cd397 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/7-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/7-2.jpg b/JBriscola/all_versions/0.2/0.2/src/img/7-2.jpg new file mode 100755 index 0000000..a168ff8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/7-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/7-3.jpg b/JBriscola/all_versions/0.2/0.2/src/img/7-3.jpg new file mode 100755 index 0000000..5cda411 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/7-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/7-4.jpg b/JBriscola/all_versions/0.2/0.2/src/img/7-4.jpg new file mode 100755 index 0000000..5d63229 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/7-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/8-1.jpg b/JBriscola/all_versions/0.2/0.2/src/img/8-1.jpg new file mode 100755 index 0000000..a6faa7b --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/8-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/8-2.jpg b/JBriscola/all_versions/0.2/0.2/src/img/8-2.jpg new file mode 100755 index 0000000..0d9edbb --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/8-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/8-3.jpg b/JBriscola/all_versions/0.2/0.2/src/img/8-3.jpg new file mode 100755 index 0000000..91f8354 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/8-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/8-4.jpg b/JBriscola/all_versions/0.2/0.2/src/img/8-4.jpg new file mode 100755 index 0000000..cc0089c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/8-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/9-1.jpg b/JBriscola/all_versions/0.2/0.2/src/img/9-1.jpg new file mode 100755 index 0000000..be9c6bf --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/9-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/9-2.jpg b/JBriscola/all_versions/0.2/0.2/src/img/9-2.jpg new file mode 100755 index 0000000..e25da4c --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/9-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/9-3.jpg b/JBriscola/all_versions/0.2/0.2/src/img/9-3.jpg new file mode 100755 index 0000000..cd384f8 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/9-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/9-4.jpg b/JBriscola/all_versions/0.2/0.2/src/img/9-4.jpg new file mode 100755 index 0000000..441210e --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/9-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/carte.jpg b/JBriscola/all_versions/0.2/0.2/src/img/carte.jpg new file mode 100755 index 0000000..838ffac --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/carte.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/retro1.jpg b/JBriscola/all_versions/0.2/0.2/src/img/retro1.jpg new file mode 100755 index 0000000..9651b06 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/retro1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/img/retro2.jpg b/JBriscola/all_versions/0.2/0.2/src/img/retro2.jpg new file mode 100755 index 0000000..c5d3925 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/img/retro2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/sounds/0.wav b/JBriscola/all_versions/0.2/0.2/src/sounds/0.wav new file mode 100755 index 0000000..67d9abd --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/sounds/0.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/sounds/1.wav b/JBriscola/all_versions/0.2/0.2/src/sounds/1.wav new file mode 100755 index 0000000..9357c97 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/sounds/1.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/sounds/2.wav b/JBriscola/all_versions/0.2/0.2/src/sounds/2.wav new file mode 100755 index 0000000..92b1541 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/sounds/2.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/sounds/3.wav b/JBriscola/all_versions/0.2/0.2/src/sounds/3.wav new file mode 100755 index 0000000..45a6e42 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/sounds/3.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/sounds/4.wav b/JBriscola/all_versions/0.2/0.2/src/sounds/4.wav new file mode 100755 index 0000000..1f7ec90 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/sounds/4.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/sounds/5.wav b/JBriscola/all_versions/0.2/0.2/src/sounds/5.wav new file mode 100755 index 0000000..3627f96 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/sounds/5.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/sounds/pareggio.wav b/JBriscola/all_versions/0.2/0.2/src/sounds/pareggio.wav new file mode 100755 index 0000000..ff978e6 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/sounds/pareggio.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/sounds/perso.wav b/JBriscola/all_versions/0.2/0.2/src/sounds/perso.wav new file mode 100755 index 0000000..a454ba4 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/sounds/perso.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.2/0.2/src/sounds/vinto.wav b/JBriscola/all_versions/0.2/0.2/src/sounds/vinto.wav new file mode 100755 index 0000000..a6f3ac5 --- /dev/null +++ b/JBriscola/all_versions/0.2/0.2/src/sounds/vinto.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/Frame.java b/JBriscola/all_versions/0.3/0.3.1/src/Frame.java new file mode 100755 index 0000000..21c4858 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/Frame.java | |||
| @@ -0,0 +1,523 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import javax.sound.sampled.*; | ||
| 24 | import java.io.*; | ||
| 25 | import java.net.*; | ||
| 26 | import java.awt.*; | ||
| 27 | import java.awt.event.*; | ||
| 28 | |||
| 29 | public class Frame extends JFrame { | ||
| 30 | |||
| 31 | /* Booleana per determinare se disegnare il mazzo di carte o no (se | ||
| 32 | * è l'ultima mano). */ | ||
| 33 | public static boolean mazzo; | ||
| 34 | |||
| 35 | public static Main main; | ||
| 36 | |||
| 37 | /* Menu, bottoni, pannelli e componenti vari. */ | ||
| 38 | public static Pannello pannello; | ||
| 39 | public static JPanel pannello2; | ||
| 40 | public static JButton button; | ||
| 41 | public static JMenuBar barraMenu; | ||
| 42 | public static JMenu file, puntoInterrogativo; | ||
| 43 | public static JMenuItem nuovaPartita, nuovaPartitaAiTrenta, opzioni, esci, informazioni, punti, aggiornamenti, trucchi, tastiRapidi, briscola; | ||
| 44 | |||
| 45 | /* Immagini delle carte. */ | ||
| 46 | public static ImageIcon retro1, retro2, ultimaCarta; | ||
| 47 | public static ImageIcon[] giocata = new ImageIcon[2]; | ||
| 48 | public static ImageIcon[] carteInMano = new ImageIcon[3]; | ||
| 49 | public static ImageIcon[] carteCPU = new ImageIcon[3]; | ||
| 50 | public static ImageIcon[] arrayCarteMescolate = new ImageIcon[40]; | ||
| 51 | public static ImageIcon[][] arrayCarte = new ImageIcon[10][4]; | ||
| 52 | |||
| 53 | public Frame() { | ||
| 54 | |||
| 55 | super( "Tronto's JBriscola " + main.version ); | ||
| 56 | |||
| 57 | mazzo = true; | ||
| 58 | main = new Main(); | ||
| 59 | pannello = new Pannello(); | ||
| 60 | pannello2 = new JPanel( new FlowLayout() ); | ||
| 61 | |||
| 62 | button = new JButton( main.stringaBottonePrendi ); | ||
| 63 | button.addActionListener( new ActionListener() { | ||
| 64 | |||
| 65 | /* Quando viene premuto il bottone per prendere/lasciare le carte, | ||
| 66 | * valuta innanzitutto se il giocatore ha giocato, poi a chi | ||
| 67 | * darle ed eventualmente, se è finita la partita, a caricare | ||
| 68 | * il suono adatto. */ | ||
| 69 | public void actionPerformed( ActionEvent e ) { | ||
| 70 | |||
| 71 | if ( giocata[0] != null && giocata[1] != null ) | ||
| 72 | main.mano++; | ||
| 73 | |||
| 74 | try { | ||
| 75 | main.chiPrende(); | ||
| 76 | } catch ( Exception ex ) { | ||
| 77 | /* Avvisa di giocare una carta. */ | ||
| 78 | JOptionPane.showMessageDialog( Frame.this, main.stringaPrimaGioca, "JBriscola " + main.version, JOptionPane.WARNING_MESSAGE ); | ||
| 79 | } | ||
| 80 | |||
| 81 | /* Avvisa che si è arrivati alla quartultima mano. */ | ||
| 82 | if ( main.mano == 16 ) | ||
| 83 | JOptionPane.showMessageDialog( Frame.this, main.stringaUltime4, "JBriscola " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 84 | |||
| 85 | /* Non disegna più la briscola e il mazzo se sono già state | ||
| 86 | * pescate tutte le carte. */ | ||
| 87 | if ( main.mano == 17 ) { | ||
| 88 | mazzo = false; | ||
| 89 | ultimaCarta = null; | ||
| 90 | pannello.repaint(); | ||
| 91 | Frame.this.repaint(); | ||
| 92 | } | ||
| 93 | |||
| 94 | /* Mostra il punteggio e carica i suoni se è finita la partita. */ | ||
| 95 | if ( main.mano == 20 || | ||
| 96 | ( main.aiTrenta && | ||
| 97 | ( ( main.punteggio >= 30 || main.punteggioCPU >= 30 ) ) ) ) { | ||
| 98 | |||
| 99 | String titolo = ""; | ||
| 100 | String suonoFinale = ""; | ||
| 101 | |||
| 102 | if ( main.punteggio > main.punteggioCPU ) { | ||
| 103 | titolo = main.stringaVinto; | ||
| 104 | suonoFinale = "sounds/perso.wav"; | ||
| 105 | } | ||
| 106 | if ( main.punteggio < main.punteggioCPU ) { | ||
| 107 | titolo = main.stringaPerso; | ||
| 108 | suonoFinale = "sounds/vinto.wav"; | ||
| 109 | } | ||
| 110 | if ( main.punteggio == main.punteggioCPU ) { | ||
| 111 | titolo = main.stringaPareggio; | ||
| 112 | suonoFinale = "sounds/pareggio.wav"; | ||
| 113 | } | ||
| 114 | |||
| 115 | if ( main.sound ) { | ||
| 116 | try { | ||
| 117 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( ClassLoader.getSystemResource( suonoFinale ) ); | ||
| 118 | AudioInputStream ais = AudioSystem.getAudioInputStream( ClassLoader.getSystemResource( suonoFinale ) ); | ||
| 119 | AudioFormat af = aff.getFormat(); | ||
| 120 | DataLine.Info info = new DataLine.Info( Clip.class, ais.getFormat(), ( (int) ais.getFrameLength() * af.getFrameSize() ) ); | ||
| 121 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 122 | ol.open(ais); | ||
| 123 | ol.loop( 0 ); | ||
| 124 | } catch ( Exception ex ) { | ||
| 125 | System.err.println( e ); | ||
| 126 | } | ||
| 127 | } | ||
| 128 | |||
| 129 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, titolo, JOptionPane.INFORMATION_MESSAGE ); | ||
| 130 | |||
| 131 | main.pulisciTavolo(); | ||
| 132 | |||
| 133 | } | ||
| 134 | if ( main.toccaAllaCPU ) | ||
| 135 | if ( main.aiTrenta ) | ||
| 136 | main.giocaCPUAiTrenta(); | ||
| 137 | else | ||
| 138 | main.giocaCPU(); | ||
| 139 | } | ||
| 140 | } ); | ||
| 141 | button.addKeyListener( new KeyAdapter() { | ||
| 142 | /* Aggiunge il keyListener per le scorciatoie da tastiera. Dato | ||
| 143 | * che il bottone prendi/lascia è l'unico componente effettivo | ||
| 144 | * della finestra, avrà obbligatoriamente il focus ed è necessario | ||
| 145 | * che sia lui a gestire gli eventi della tastiera. */ | ||
| 146 | public void keyReleased( KeyEvent key ) { | ||
| 147 | |||
| 148 | if ( main.keys ) { | ||
| 149 | switch ( key.getKeyCode() ) { | ||
| 150 | case KeyEvent.VK_1: | ||
| 151 | if ( mettiCarta( 231, 500 ) ) { | ||
| 152 | if ( !main.CPUHaGiocato ) | ||
| 153 | if ( main.aiTrenta ) | ||
| 154 | main.giocaCPUAiTrenta(); | ||
| 155 | else | ||
| 156 | main.giocaCPU(); | ||
| 157 | } | ||
| 158 | break; | ||
| 159 | |||
| 160 | case KeyEvent.VK_2: | ||
| 161 | if ( mettiCarta( 301, 500 ) ) { | ||
| 162 | if ( !main.CPUHaGiocato ) | ||
| 163 | if ( main.aiTrenta ) | ||
| 164 | main.giocaCPUAiTrenta(); | ||
| 165 | else | ||
| 166 | main.giocaCPU(); | ||
| 167 | } | ||
| 168 | break; | ||
| 169 | |||
| 170 | case KeyEvent.VK_3: | ||
| 171 | if ( mettiCarta( 371, 500 ) ) { | ||
| 172 | if ( !main.CPUHaGiocato ) | ||
| 173 | if ( main.aiTrenta ) | ||
| 174 | main.giocaCPUAiTrenta(); | ||
| 175 | else | ||
| 176 | main.giocaCPU(); | ||
| 177 | } | ||
| 178 | break; | ||
| 179 | |||
| 180 | case KeyEvent.VK_F1: | ||
| 181 | JOptionPane.showMessageDialog( Frame.this, main.stringaTasti2, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 182 | break; | ||
| 183 | |||
| 184 | case KeyEvent.VK_F2: | ||
| 185 | if ( main.mano == 20 ) { | ||
| 186 | main.aiTrenta = false; | ||
| 187 | main.mischia(); | ||
| 188 | pannello.repaint(); | ||
| 189 | repaint(); | ||
| 190 | } | ||
| 191 | else { | ||
| 192 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 193 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 194 | main.aiTrenta = false; | ||
| 195 | main.mischia(); | ||
| 196 | pannello.repaint(); | ||
| 197 | repaint(); | ||
| 198 | } | ||
| 199 | } | ||
| 200 | break; | ||
| 201 | |||
| 202 | case KeyEvent.VK_F3: | ||
| 203 | OptionFrame optionFrame = new OptionFrame(); | ||
| 204 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 205 | optionFrame.setResizable( false ); | ||
| 206 | optionFrame.setAlwaysOnTop( true ); | ||
| 207 | optionFrame.setSize( 300, 200 ); | ||
| 208 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 209 | optionFrame.setVisible( true ); | ||
| 210 | break; | ||
| 211 | |||
| 212 | case KeyEvent.VK_F4: | ||
| 213 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, main.stringaPunteggio, JOptionPane.INFORMATION_MESSAGE ); | ||
| 214 | break; | ||
| 215 | |||
| 216 | case KeyEvent.VK_F5: | ||
| 217 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 218 | break; | ||
| 219 | |||
| 220 | case KeyEvent.VK_F6: | ||
| 221 | String latest = main.version; | ||
| 222 | try { | ||
| 223 | URL latestIs = new URL( "http://porkynator.altervista.org/jbriscola-latest.is" ); | ||
| 224 | BufferedReader latestIsReader = new BufferedReader( new InputStreamReader( latestIs.openStream() ) ); | ||
| 225 | latest = latestIsReader.readLine(); | ||
| 226 | } catch ( Exception ex ) { | ||
| 227 | JOptionPane.showMessageDialog( Frame.this, main.stringaNoInternet, "JBriscola - " + main.version, JOptionPane.ERROR_MESSAGE ); | ||
| 228 | } | ||
| 229 | if ( latest.equals( main.version ) ) | ||
| 230 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiNo, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 231 | else | ||
| 232 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiSi + "\n" + main.version + " ==> " + latest + "\n\n" + main.stringaScarica, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 233 | break; | ||
| 234 | |||
| 235 | case KeyEvent.VK_F7: | ||
| 236 | if ( main.mano == 20 ) { | ||
| 237 | main.aiTrenta = true; | ||
| 238 | main.mischia(); | ||
| 239 | pannello.repaint(); | ||
| 240 | repaint(); | ||
| 241 | } | ||
| 242 | else { | ||
| 243 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 244 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 245 | main.aiTrenta = true; | ||
| 246 | main.mischia(); | ||
| 247 | pannello.repaint(); | ||
| 248 | repaint(); | ||
| 249 | } | ||
| 250 | } | ||
| 251 | break; | ||
| 252 | |||
| 253 | case KeyEvent.VK_F8: | ||
| 254 | main.trucco( JOptionPane.showInputDialog( Frame.this, main.stringaInserisciCodice, "JBriscola - " + main.version, JOptionPane.PLAIN_MESSAGE ) ); | ||
| 255 | break; | ||
| 256 | |||
| 257 | case KeyEvent.VK_Q: | ||
| 258 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 259 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 260 | Frame.this.dispose(); | ||
| 261 | break; | ||
| 262 | } | ||
| 263 | } | ||
| 264 | } | ||
| 265 | } ); | ||
| 266 | |||
| 267 | barraMenu = new JMenuBar(); | ||
| 268 | |||
| 269 | file = new JMenu( "File" ); | ||
| 270 | |||
| 271 | nuovaPartita = new JMenuItem( main.stringaNuovaPartita ); | ||
| 272 | nuovaPartita.addActionListener( new ActionListener() { | ||
| 273 | /* Avvia una nuova partita, chiedendo prima conferma se ce n'è | ||
| 274 | * già una in corso. */ | ||
| 275 | public void actionPerformed( ActionEvent e ) { | ||
| 276 | if ( main.mano == 20 ) { | ||
| 277 | main.aiTrenta = false; | ||
| 278 | main.mischia(); | ||
| 279 | pannello.repaint(); | ||
| 280 | repaint(); | ||
| 281 | } | ||
| 282 | |||
| 283 | else { | ||
| 284 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 285 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 286 | main.aiTrenta = false; | ||
| 287 | main.mischia(); | ||
| 288 | pannello.repaint(); | ||
| 289 | repaint(); | ||
| 290 | } | ||
| 291 | } | ||
| 292 | } | ||
| 293 | }); | ||
| 294 | |||
| 295 | nuovaPartitaAiTrenta = new JMenuItem( main.stringaNuovaPartitaAiTrenta ); | ||
| 296 | nuovaPartitaAiTrenta.addActionListener( new ActionListener() { | ||
| 297 | /* Avvia una nuova partita ai 30, chiedendo prima conferma se | ||
| 298 | * ce n'è già una in corso. */ | ||
| 299 | public void actionPerformed( ActionEvent e ) { | ||
| 300 | if ( main.mano == 20 ) { | ||
| 301 | main.aiTrenta = true; | ||
| 302 | main.mischia(); | ||
| 303 | pannello.repaint(); | ||
| 304 | repaint(); | ||
| 305 | } | ||
| 306 | |||
| 307 | else { | ||
| 308 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 309 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 310 | main.aiTrenta = true; | ||
| 311 | main.mischia(); | ||
| 312 | pannello.repaint(); | ||
| 313 | repaint(); | ||
| 314 | } | ||
| 315 | } | ||
| 316 | } | ||
| 317 | }); | ||
| 318 | |||
| 319 | trucchi = new JMenuItem( main.stringaTrucchi ); | ||
| 320 | trucchi.addActionListener( new ActionListener() { | ||
| 321 | public void actionPerformed( ActionEvent e ) { | ||
| 322 | /* Esegue il trucco */ | ||
| 323 | main.trucco( JOptionPane.showInputDialog( Frame.this, main.stringaInserisciCodice, "JBriscola - " + main.version, JOptionPane.PLAIN_MESSAGE ) ); | ||
| 324 | } | ||
| 325 | } ); | ||
| 326 | |||
| 327 | opzioni = new JMenuItem( main.stringaOpzioni ); | ||
| 328 | opzioni.addActionListener( new ActionListener() { | ||
| 329 | /* Apre una OptionFrame per modificare le opzioni. */ | ||
| 330 | public void actionPerformed( ActionEvent e ) { | ||
| 331 | |||
| 332 | OptionFrame optionFrame = new OptionFrame(); | ||
| 333 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 334 | optionFrame.setResizable( false ); | ||
| 335 | optionFrame.setAlwaysOnTop( true ); | ||
| 336 | optionFrame.setSize( 300, 200 ); | ||
| 337 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 338 | optionFrame.setVisible( true ); | ||
| 339 | } | ||
| 340 | }); | ||
| 341 | |||
| 342 | esci = new JMenuItem( main.stringaEsci ); | ||
| 343 | esci.addActionListener( new ActionListener() { | ||
| 344 | /* Ciede conferma prima di uscire. */ | ||
| 345 | public void actionPerformed( ActionEvent e ) { | ||
| 346 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 347 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 348 | Frame.this.dispose(); | ||
| 349 | } | ||
| 350 | }); | ||
| 351 | |||
| 352 | file.add( nuovaPartita ); | ||
| 353 | file.add( nuovaPartitaAiTrenta ); | ||
| 354 | file.add( trucchi ); | ||
| 355 | file.add( opzioni ); | ||
| 356 | file.addSeparator(); | ||
| 357 | file.add( esci ); | ||
| 358 | |||
| 359 | puntoInterrogativo = new JMenu( "?" ); | ||
| 360 | |||
| 361 | informazioni = new JMenuItem( main.stringaInformazioni ); | ||
| 362 | informazioni.addActionListener( new ActionListener() { | ||
| 363 | /* Visualizza le informazioni. */ | ||
| 364 | public void actionPerformed( ActionEvent e ) { | ||
| 365 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 366 | } | ||
| 367 | } ); | ||
| 368 | |||
| 369 | tastiRapidi = new JMenuItem( main.stringaTasti ); | ||
| 370 | tastiRapidi.addActionListener( new ActionListener() { | ||
| 371 | /* Visualizza i tasti rapidi. */ | ||
| 372 | public void actionPerformed( ActionEvent e ) { | ||
| 373 | JOptionPane.showMessageDialog( Frame.this, main.stringaTasti2, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 374 | } | ||
| 375 | } ); | ||
| 376 | |||
| 377 | briscola = new JMenuItem( main.stringaBriscola ); | ||
| 378 | briscola.addActionListener( new ActionListener() { | ||
| 379 | /* Visualizza il seme di briscola corrente. */ | ||
| 380 | public void actionPerformed( ActionEvent e ) { | ||
| 381 | JOptionPane.showMessageDialog( Frame.this, main.stringaBriscola + ": " + main.semi[main.semeBriscola], "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 382 | } | ||
| 383 | }); | ||
| 384 | |||
| 385 | punti = new JMenuItem( main.stringaPunteggio ); | ||
| 386 | punti.addActionListener( new ActionListener() { | ||
| 387 | /* Visualizza il punteggio. */ | ||
| 388 | public void actionPerformed( ActionEvent e ) { | ||
| 389 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, main.stringaPunteggio, JOptionPane.INFORMATION_MESSAGE ); | ||
| 390 | } | ||
| 391 | } ); | ||
| 392 | |||
| 393 | aggiornamenti = new JMenuItem( main.stringaAggiornamenti ); | ||
| 394 | aggiornamenti.addActionListener( new ActionListener() { | ||
| 395 | /* Cerca aggiornamenti sul sito http://porkynator.altervista.org, | ||
| 396 | * confrontando la versione del programma con quella scritta nel | ||
| 397 | * file jbriscola-latest.is (online). */ | ||
| 398 | public void actionPerformed( ActionEvent e ) { | ||
| 399 | String latest = main.version; | ||
| 400 | try { | ||
| 401 | URL latestIs = new URL( "http://porkynator.altervista.org/jbriscola-latest.is" ); | ||
| 402 | BufferedReader latestIsReader = new BufferedReader( new InputStreamReader( latestIs.openStream() ) ); | ||
| 403 | latest = latestIsReader.readLine(); | ||
| 404 | } catch ( Exception ex ) { | ||
| 405 | JOptionPane.showMessageDialog( Frame.this, main.stringaNoInternet, "JBriscola - " + main.version, JOptionPane.ERROR_MESSAGE ); | ||
| 406 | } | ||
| 407 | if ( latest.equals( main.version ) ) | ||
| 408 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiNo, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 409 | else | ||
| 410 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiSi + "\n" + main.version + " ==> " + latest + "\n\n" + main.stringaScarica, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 411 | } | ||
| 412 | } ); | ||
| 413 | |||
| 414 | puntoInterrogativo.add( punti ); | ||
| 415 | puntoInterrogativo.add( briscola ); | ||
| 416 | puntoInterrogativo.add( tastiRapidi ); | ||
| 417 | puntoInterrogativo.add( informazioni ); | ||
| 418 | puntoInterrogativo.add( aggiornamenti ); | ||
| 419 | |||
| 420 | barraMenu.add( file ); | ||
| 421 | barraMenu.add( puntoInterrogativo ); | ||
| 422 | |||
| 423 | setJMenuBar( barraMenu ); | ||
| 424 | |||
| 425 | /* Inizializza le immagini del retro delle carte. */ | ||
| 426 | retro1 = new ImageIcon( ClassLoader.getSystemResource( "img/retro1.jpg" ) ); | ||
| 427 | retro2 = new ImageIcon( ClassLoader.getSystemResource( "img/retro2.jpg" ) ); | ||
| 428 | |||
| 429 | /* Inizializza tutte le immagini delle carte scorrendo l'array bidimensionale. */ | ||
| 430 | for (int i = 0; i < 10; i++) | ||
| 431 | for (int j = 0; j < 4; j++) | ||
| 432 | arrayCarte[i][j] = new ImageIcon( ClassLoader.getSystemResource( "img/" + (i+1) + "-" + (j+1) + ".jpg" ) ); | ||
| 433 | |||
| 434 | /* Mischia le carte. */ | ||
| 435 | main.mischia(); | ||
| 436 | |||
| 437 | /* Aggiunge i vari componenti. */ | ||
| 438 | pannello2.add( button ); | ||
| 439 | setLayout( new BorderLayout() ); | ||
| 440 | add( pannello, BorderLayout.CENTER ); | ||
| 441 | add( pannello2, BorderLayout.SOUTH ); | ||
| 442 | |||
| 443 | /* Chiama il metodo mettiCarta se l'utente clicca. */ | ||
| 444 | addMouseListener( | ||
| 445 | new MouseAdapter() { | ||
| 446 | public void mouseClicked ( MouseEvent e ) { | ||
| 447 | if ( mettiCarta( e.getX(), e.getY() ) ) { | ||
| 448 | if ( !main.CPUHaGiocato ) | ||
| 449 | if ( main.aiTrenta ) | ||
| 450 | main.giocaCPUAiTrenta(); | ||
| 451 | else | ||
| 452 | main.giocaCPU(); | ||
| 453 | } | ||
| 454 | } | ||
| 455 | } | ||
| 456 | ); | ||
| 457 | |||
| 458 | /* Chiede conferma prima di uscire quando viene chiusa la finestra. */ | ||
| 459 | addWindowListener( | ||
| 460 | new WindowAdapter() { | ||
| 461 | public void windowClosing( WindowEvent e ) { | ||
| 462 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 463 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 464 | System.exit( 0 ); | ||
| 465 | } | ||
| 466 | } | ||
| 467 | ); | ||
| 468 | } | ||
| 469 | |||
| 470 | /* Se il giocatore ha cliccato su una carta la gioca e riproduce un suono casuale. */ | ||
| 471 | public boolean mettiCarta( int x, int y ) { | ||
| 472 | |||
| 473 | if ( !main.toccaAllaCPU && giocata[0] == null ) { | ||
| 474 | if ( main.sound && | ||
| 475 | ( ( x > 230 && x < 290 && y > 340 && y < 566 && carteInMano[0] != null ) || | ||
| 476 | ( x > 300 && x < 360 && y > 340 && y < 566 && carteInMano[1] != null ) || | ||
| 477 | ( x > 370 && x < 430 && y > 340 && y < 566 && carteInMano[2] != null ) ) ) { | ||
| 478 | try { | ||
| 479 | |||
| 480 | double a = Math.random() * 6; | ||
| 481 | int i = (int) a; | ||
| 482 | |||
| 483 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( ClassLoader.getSystemResource("sounds/" + i + ".wav") ); | ||
| 484 | AudioInputStream ais = AudioSystem.getAudioInputStream( ClassLoader.getSystemResource("sounds/" + i + ".wav") ); | ||
| 485 | AudioFormat af = aff.getFormat(); | ||
| 486 | DataLine.Info info = new DataLine.Info( Clip.class, ais.getFormat(), ( (int) ais.getFrameLength() * af.getFrameSize() ) ); | ||
| 487 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 488 | |||
| 489 | ol.open(ais); | ||
| 490 | ol.loop( 0 ); | ||
| 491 | |||
| 492 | } catch ( Exception e ) { | ||
| 493 | System.err.println( e ); | ||
| 494 | } | ||
| 495 | } | ||
| 496 | |||
| 497 | if ( x > 230 && x < 290 && y > 340 && y < 566 && carteInMano[0] != null ) { | ||
| 498 | giocata[0] = carteInMano[0]; | ||
| 499 | carteInMano[0] = null; | ||
| 500 | pannello.repaint(); | ||
| 501 | return true; | ||
| 502 | } | ||
| 503 | |||
| 504 | if ( x > 300 && x < 360 && y > 340 && y < 566 && carteInMano[1] != null ) { | ||
| 505 | giocata[0] = carteInMano[1]; | ||
| 506 | carteInMano[1] = null; | ||
| 507 | pannello.repaint(); | ||
| 508 | return true; | ||
| 509 | } | ||
| 510 | |||
| 511 | if ( x > 370 && x < 430 && y > 340 && y < 566 && carteInMano[2] != null ) { | ||
| 512 | giocata[0] = carteInMano[2]; | ||
| 513 | carteInMano[2] = null; | ||
| 514 | pannello.repaint(); | ||
| 515 | return true; | ||
| 516 | } | ||
| 517 | } | ||
| 518 | |||
| 519 | return false; | ||
| 520 | } | ||
| 521 | } | ||
| 522 | |||
| 523 | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/Main.java b/JBriscola/all_versions/0.3/0.3.1/src/Main.java new file mode 100755 index 0000000..467e724 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/Main.java | |||
| @@ -0,0 +1,1637 @@ | |||
| 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 | |||
| 29 | /*Costanti per i semi e i valori delle carte*/ | ||
| 30 | public static final int COPPE = 0; | ||
| 31 | public static final int BASTONI = 1; | ||
| 32 | public static final int DENARI = 2; | ||
| 33 | public static final int SPADE = 3; | ||
| 34 | public static final int RE = 0; | ||
| 35 | public static final int ASSO = 1; | ||
| 36 | public static final int DUE = 2; | ||
| 37 | public static final int TRE = 3; | ||
| 38 | public static final int QUATTRO = 4; | ||
| 39 | public static final int CINQUE = 5; | ||
| 40 | public static final int SEI = 6; | ||
| 41 | public static final int SETTE = 7; | ||
| 42 | public static final int FANTE = 8; | ||
| 43 | public static final int CAVALLO = 9; | ||
| 44 | |||
| 45 | /* semeBriscola serve a determinare quale il seme di briscola (0 coppe, | ||
| 46 | * 1 bastoni, 2 denari, 3 spade). | ||
| 47 | * punteggio è il punteggio del giocatore, punteggioCPU quello della CPU | ||
| 48 | * mano tiene il conto della mano a cui si è arrivati. | ||
| 49 | * cartaDaPescare è la carta che la CPU deve raccogliere dal mazzo | ||
| 50 | * cartaDaGiocare (può assumere valore compraso tra 0 e 2) è la carta | ||
| 51 | * che la cpu deve giocare. */ | ||
| 52 | public static int semeBriscola, punteggio, punteggioCPU, mano, cartaDaPescare, cartaDaGiocare; | ||
| 53 | |||
| 54 | /* toccaAllaCPU determina se è il turno del computer o del giocatore, | ||
| 55 | * CPUHaGiocato se il computer ha già giocato in questo turno e | ||
| 56 | * haGiocatoPrima se la prima mossa del turno è stata del giocatore | ||
| 57 | * (true) o della CPU (false). | ||
| 58 | * aiTrenta serve per determinare se la partida che si sta giocando è | ||
| 59 | * normale o ai 30. | ||
| 60 | * carteScoperte serve se viene attivato il trucco per mostrare le | ||
| 61 | * carte della CPU. | ||
| 62 | * sound e keys riguardano le opzioni (souno si o no, tasti rapidi si | ||
| 63 | * o no) salvate nel file di configurazione. */ | ||
| 64 | public static boolean toccaAllaCPU = false; | ||
| 65 | public static boolean CPUHaGiocato = false; | ||
| 66 | public static boolean haGiocatoPrima = true; | ||
| 67 | public static boolean aiTrenta = false; | ||
| 68 | public static boolean carteScoperte = false; | ||
| 69 | public static boolean sound = true; | ||
| 70 | public static boolean keys = true; | ||
| 71 | |||
| 72 | /* frame è la finestra principale del gioco, color il colore dello sfondo. | ||
| 73 | * lang, soundString e keysString servono a leggere le opzioni dal file | ||
| 74 | * di configurazione. */ | ||
| 75 | public static Frame frame; | ||
| 76 | public static Color color = new Color( 0, 150, 0 ); | ||
| 77 | public static String lang, soundString, keysString; | ||
| 78 | |||
| 79 | /* Tutte le stringhe che vengono utilizzate durante il gioco sono | ||
| 80 | * inizializzate qui, per poter essere tradotte in altre lingue. */ | ||
| 81 | public static String version = "0.3.1"; | ||
| 82 | public static String semi[] = { "Bastoni", "Coppe", "Denari", "Spade" }; | ||
| 83 | public static String stringaBriscola = "Briscola"; | ||
| 84 | public static String stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 85 | public static String stringaPrimaGioca = "Prima Gioca!"; | ||
| 86 | public static String stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 87 | public static String stringaVinto = "Hai Vinto!"; | ||
| 88 | public static String stringaPerso = "Hai Perso"; | ||
| 89 | public static String stringaPareggio = "Pareggio"; | ||
| 90 | public static String stringaGiocatore = "Giocatore: "; | ||
| 91 | public static String stringaComputer = "\nComputer: "; | ||
| 92 | public static String stringaNuovaPartita = "Nuova Partita"; | ||
| 93 | public static String stringaNuovaPartitaAiTrenta = "Nuova Partita Ai 30"; | ||
| 94 | public static String stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 95 | public static String stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 96 | public static String stringaSi = "Si"; | ||
| 97 | public static String stringaNo = "No"; | ||
| 98 | public static String stringaOpzioni = "Opzioni..."; | ||
| 99 | public static String stringaEsci = "Esci"; | ||
| 100 | public static String stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 101 | public static String stringaLingua = "Lingua"; | ||
| 102 | public static String stringaAnnulla = "Annulla"; | ||
| 103 | public static String stringaIt = "Italiano"; | ||
| 104 | public static String stringaLa = "Latino"; | ||
| 105 | public static String stringaBL = "Dialetto Bellunese"; | ||
| 106 | public static String stringaBV = "Dialetto Basso Veneto"; | ||
| 107 | public static String stringaEN = "Inglese"; | ||
| 108 | public static String stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 109 | public static String stringaInformazioni = "Informazioni"; | ||
| 110 | 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"; | ||
| 111 | public static String stringaSuono = "Effetti Sonori"; | ||
| 112 | public static String stringaPunteggio = "Punteggio"; | ||
| 113 | public static String stringaSfondo = "Sfondo"; | ||
| 114 | public static String stringaTasti = "Tasti rapidi"; | ||
| 115 | public static String stringaAggiornamenti = "Cerca aggiornamenti"; | ||
| 116 | public static String stringaTrucchi = "Trucchi"; | ||
| 117 | public static String stringaInserisciCodice = "Inserisci il codice:"; | ||
| 118 | public static String stringaTruccoAttivato = "Trucco attivato!"; | ||
| 119 | public static String stringaTruccoSbagliato = "Trucco non valido"; | ||
| 120 | public static String stringaCheCartaVuoi = "E allora che carta vuoi?"; | ||
| 121 | public static String stringaAggiornamentiSi = "Aggiornamento disponibile: "; | ||
| 122 | public static String stringaAggiornamentiNo = "Nessun aggiornamento disponibile"; | ||
| 123 | public static String stringaScarica = "E' possibile scaricare la versione più recente\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 124 | public static String stringaNoInternet = "Errore: nessuna connessione internet"; | ||
| 125 | 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 + "\nF7 " + stringaNuovaPartitaAiTrenta + "\nF8 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 126 | |||
| 127 | public static void main( String args[] ) { | ||
| 128 | |||
| 129 | /* Chiama il metodo settaOpzioni per leggere le impostazioni | ||
| 130 | * dell'utente da un eventuale file di configurazione */ | ||
| 131 | settaOpzioni(); | ||
| 132 | |||
| 133 | /* Crea la finestra principale del gioco e la posiziona al centro | ||
| 134 | * dello schermo. */ | ||
| 135 | frame = new Frame(); | ||
| 136 | frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); | ||
| 137 | frame.setResizable( false ); | ||
| 138 | frame.setSize( 600, 600 ); | ||
| 139 | frame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 600) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - 600) / 2); | ||
| 140 | frame.setVisible( true ); | ||
| 141 | } | ||
| 142 | |||
| 143 | /* Algoritmo per mischiare il mazzo: prende due carte a caso e le | ||
| 144 | * inverte di posto, utilizzando una variabile aux. Ripete il procedimento | ||
| 145 | * per 391 volte. */ | ||
| 146 | public void mischia() { | ||
| 147 | |||
| 148 | ImageIcon aux; | ||
| 149 | |||
| 150 | mano = 0; | ||
| 151 | punteggio = 0; | ||
| 152 | punteggioCPU = 0; | ||
| 153 | cartaDaPescare = 6; | ||
| 154 | frame.mazzo = true; | ||
| 155 | toccaAllaCPU = false; | ||
| 156 | CPUHaGiocato = false; | ||
| 157 | haGiocatoPrima = true; | ||
| 158 | frame.mazzo = true; | ||
| 159 | |||
| 160 | /* Inizializza l'array di carte mescolate ordinato */ | ||
| 161 | for ( int i = 0, k = 0; i < 10; i++ ) | ||
| 162 | for ( int j = 0; j < 4; j++, k++ ) | ||
| 163 | frame.arrayCarteMescolate[k] = frame.arrayCarte[i][j]; | ||
| 164 | |||
| 165 | /* Mescola le carte utilizzando il metodo sopra citato */ | ||
| 166 | for ( int i = 0; i < 391; i++ ) { | ||
| 167 | double a = Math.random() * 40; | ||
| 168 | int x = (int) a; | ||
| 169 | double b = Math.random() * 40; | ||
| 170 | int y = (int) b; | ||
| 171 | aux = frame.arrayCarteMescolate[x]; | ||
| 172 | frame.arrayCarteMescolate[x] = frame.arrayCarteMescolate[y]; | ||
| 173 | frame.arrayCarteMescolate[y] = aux; | ||
| 174 | } | ||
| 175 | |||
| 176 | /* Imposta il seme della briscola */ | ||
| 177 | semeBriscola = seme( frame.arrayCarteMescolate[39] ); | ||
| 178 | |||
| 179 | /* Distribuisce le carte */ | ||
| 180 | frame.carteInMano[0] = frame.arrayCarteMescolate[0]; | ||
| 181 | frame.carteInMano[1] = frame.arrayCarteMescolate[1]; | ||
| 182 | frame.carteInMano[2] = frame.arrayCarteMescolate[2]; | ||
| 183 | frame.carteCPU[0] = frame.arrayCarteMescolate[3]; | ||
| 184 | frame.carteCPU[1] = frame.arrayCarteMescolate[4]; | ||
| 185 | frame.carteCPU[2] = frame.arrayCarteMescolate[5]; | ||
| 186 | frame.ultimaCarta = frame.arrayCarteMescolate[39]; | ||
| 187 | frame.giocata[0] = null; | ||
| 188 | frame.giocata[1] = null; | ||
| 189 | } | ||
| 190 | |||
| 191 | /* Viene chiamato a fine partita. */ | ||
| 192 | public void pulisciTavolo() { | ||
| 193 | |||
| 194 | punteggio = 0; | ||
| 195 | punteggioCPU = 0; | ||
| 196 | cartaDaPescare = 6; | ||
| 197 | toccaAllaCPU = false; | ||
| 198 | CPUHaGiocato = false; | ||
| 199 | haGiocatoPrima = true; | ||
| 200 | |||
| 201 | frame.mazzo = false; | ||
| 202 | frame.ultimaCarta = null; | ||
| 203 | for ( int i = 0; i < 3; i++ ) { | ||
| 204 | frame.carteCPU[i] = null; | ||
| 205 | frame.carteInMano[i] = null; | ||
| 206 | } | ||
| 207 | |||
| 208 | frame.pannello.repaint(); | ||
| 209 | frame.repaint(); | ||
| 210 | |||
| 211 | } | ||
| 212 | |||
| 213 | /* Fa giocare la CPU. Questo metodo contiene l'intelligenza artificiale | ||
| 214 | * del gioco. Ho preferito non commentare molto il corpo del metodo per | ||
| 215 | * due motivi; il primo è che abbastanza intuitivo: basta sapere che i | ||
| 216 | * vari metodi vaiLiscio(), vaiTaglio() ecc... tentano di fare ciò che | ||
| 217 | * ovviamente dice il loro nome, se ci riescono restituiscono true, | ||
| 218 | * in caso contrario false.*/ | ||
| 219 | public void giocaCPU() { | ||
| 220 | |||
| 221 | /* Nelle prime 16 mani ragiona in maniera diversa*/ | ||
| 222 | if ( mano < 16 ) { | ||
| 223 | |||
| 224 | /* Valuta cosa fare se il giocatore non ha ancora giocato. */ | ||
| 225 | if ( frame.giocata[0] == null ) { | ||
| 226 | if ( vaiPunti() ); | ||
| 227 | else if ( vaiLiscio() ); | ||
| 228 | else if ( vaiTaglio() ); | ||
| 229 | else if ( vaiBriscolaAlta() ); | ||
| 230 | else if ( vaiCarico() ); | ||
| 231 | else if ( vaiTre() ); | ||
| 232 | else if ( vaiAsso() ); | ||
| 233 | else; | ||
| 234 | } | ||
| 235 | |||
| 236 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 237 | else { | ||
| 238 | if ( haLisciato() ) { | ||
| 239 | if ( vaiSopra() ); | ||
| 240 | else if ( vaiLiscio() ); | ||
| 241 | else if ( vaiPunti() ); | ||
| 242 | else if ( vaiTaglio() ); | ||
| 243 | else if ( vaiTre() ); | ||
| 244 | else if ( vaiBriscolaAlta() ); | ||
| 245 | else if ( vaiCarico() ); | ||
| 246 | else if ( vaiAsso() ); | ||
| 247 | } else if ( haMessoPunti() ) { | ||
| 248 | if ( vaiSopra() ); | ||
| 249 | else if ( vaiLiscio() ); | ||
| 250 | else if ( vaiTaglio() ); | ||
| 251 | else if ( vaiPunti() ); | ||
| 252 | else if ( vaiTre() ); | ||
| 253 | else if ( vaiBriscolaAlta() ); | ||
| 254 | else if ( vaiCarico() ); | ||
| 255 | else if ( vaiAsso() ); | ||
| 256 | } else if ( haTagliato() ) { | ||
| 257 | if ( vaiLiscio() ); | ||
| 258 | else if ( vaiPunti() ); | ||
| 259 | else if ( vaiTaglio() ); | ||
| 260 | else if ( vaiTre() ); | ||
| 261 | else if ( vaiBriscolaAlta() ); | ||
| 262 | else if ( vaiCarico() ); | ||
| 263 | else if ( vaiAsso() ); | ||
| 264 | } else if ( haMessoBriscolaAlta() ) { | ||
| 265 | if ( vaiLiscio() ); | ||
| 266 | else if ( vaiPunti() ); | ||
| 267 | else if ( vaiTre() ); | ||
| 268 | else if ( vaiTaglio() ); | ||
| 269 | else if ( vaiBriscolaAlta() ); | ||
| 270 | else if ( vaiCarico() ); | ||
| 271 | else if ( vaiAsso() ); | ||
| 272 | } else if ( haMessoTre() ) { | ||
| 273 | if ( vaiAsso() ); | ||
| 274 | else if ( vaiLiscio() ); | ||
| 275 | else if ( vaiPunti() ); | ||
| 276 | else if ( vaiTaglio() ); | ||
| 277 | else if ( vaiBriscolaAlta() ); | ||
| 278 | else if ( vaiCarico() ); | ||
| 279 | } else if ( haMessoAsso() ) { | ||
| 280 | if ( vaiLiscio() ); | ||
| 281 | else if ( vaiPunti() ); | ||
| 282 | else if ( vaiTaglio() ); | ||
| 283 | else if ( vaiBriscolaAlta() ); | ||
| 284 | else if ( vaiCarico() ); | ||
| 285 | else if ( vaiTre() ); | ||
| 286 | } else if ( haCaricato() ) { | ||
| 287 | if ( vaiSopra() ); | ||
| 288 | else if ( vaiTre() ); | ||
| 289 | else if ( vaiBriscolaAlta() ); | ||
| 290 | else if ( vaiTaglio() ); | ||
| 291 | else if ( vaiAsso() ); | ||
| 292 | else if ( vaiLiscio() ); | ||
| 293 | else if ( vaiPunti() ); | ||
| 294 | else if ( vaiCarico() ); | ||
| 295 | } | ||
| 296 | } | ||
| 297 | } | ||
| 298 | |||
| 299 | /* Nella penultima mano (prima di pescare l'ultima carta) */ | ||
| 300 | else if ( mano == 16 ) { | ||
| 301 | |||
| 302 | /* Valuta cosa fare se il giocatore non ha ancora giocato. */ | ||
| 303 | if ( frame.giocata[0] == null ) { | ||
| 304 | if ( valore( frame.ultimaCarta ) == TRE || valore( frame.ultimaCarta ) == ASSO ) { | ||
| 305 | if ( vaiCarico() ); | ||
| 306 | else if ( vaiPunti() ); | ||
| 307 | else if ( vaiLiscio() ); | ||
| 308 | else if ( vaiTaglio() ); | ||
| 309 | else if ( vaiBriscolaAlta() ); | ||
| 310 | else if ( vaiTre() ); | ||
| 311 | else if ( vaiAsso() ); | ||
| 312 | else; | ||
| 313 | } else { | ||
| 314 | if ( vaiPunti() ); | ||
| 315 | else if ( vaiLiscio() ); | ||
| 316 | else if ( vaiTaglio() ); | ||
| 317 | else if ( vaiBriscolaAlta() ); | ||
| 318 | else if ( vaiCarico() ); | ||
| 319 | else if ( vaiTre() ); | ||
| 320 | else if ( vaiAsso() ); | ||
| 321 | else; | ||
| 322 | } | ||
| 323 | } | ||
| 324 | |||
| 325 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 326 | else { | ||
| 327 | if ( valore( frame.ultimaCarta ) == TRE || valore( frame.ultimaCarta ) == ASSO ) { | ||
| 328 | if ( haCaricato() ) { | ||
| 329 | if ( vaiSopra() ); | ||
| 330 | else if ( vaiLiscio() ); | ||
| 331 | else if ( vaiPunti() ); | ||
| 332 | else if ( vaiTre() ); | ||
| 333 | else if ( vaiTaglio() ); | ||
| 334 | else if ( vaiBriscolaAlta() ); | ||
| 335 | else if ( vaiAsso() ); | ||
| 336 | else if ( vaiCarico() ); | ||
| 337 | } | ||
| 338 | } else { | ||
| 339 | if ( haLisciato() ) { | ||
| 340 | if ( vaiSopra() ); | ||
| 341 | else if ( vaiLiscio() ); | ||
| 342 | else if ( vaiPunti() ); | ||
| 343 | else if ( vaiTaglio() ); | ||
| 344 | else if ( vaiTre() ); | ||
| 345 | else if ( vaiBriscolaAlta() ); | ||
| 346 | else if ( vaiCarico() ); | ||
| 347 | else if ( vaiAsso() ); | ||
| 348 | } else if ( haMessoPunti() ) { | ||
| 349 | if ( vaiSopra() ); | ||
| 350 | else if ( vaiLiscio() ); | ||
| 351 | else if ( vaiTaglio() ); | ||
| 352 | else if ( vaiPunti() ); | ||
| 353 | else if ( vaiTre() ); | ||
| 354 | else if ( vaiBriscolaAlta() ); | ||
| 355 | else if ( vaiCarico() ); | ||
| 356 | else if ( vaiAsso() ); | ||
| 357 | } else if ( haTagliato() ) { | ||
| 358 | if ( vaiLiscio() ); | ||
| 359 | else if ( vaiPunti() ); | ||
| 360 | else if ( vaiTaglio() ); | ||
| 361 | else if ( vaiTre() ); | ||
| 362 | else if ( vaiBriscolaAlta() ); | ||
| 363 | else if ( vaiCarico() ); | ||
| 364 | else if ( vaiAsso() ); | ||
| 365 | } else if ( haMessoBriscolaAlta() ) { | ||
| 366 | if ( vaiLiscio() ); | ||
| 367 | else if ( vaiPunti() ); | ||
| 368 | else if ( vaiTre() ); | ||
| 369 | else if ( vaiTaglio() ); | ||
| 370 | else if ( vaiBriscolaAlta() ); | ||
| 371 | else if ( vaiCarico() ); | ||
| 372 | else if ( vaiAsso() ); | ||
| 373 | } else if ( haMessoTre() ) { | ||
| 374 | if ( vaiAsso() ); | ||
| 375 | else if ( vaiLiscio() ); | ||
| 376 | else if ( vaiPunti() ); | ||
| 377 | else if ( vaiTaglio() ); | ||
| 378 | else if ( vaiBriscolaAlta() ); | ||
| 379 | else if ( vaiCarico() ); | ||
| 380 | } else if ( haMessoAsso() ) { | ||
| 381 | if ( vaiLiscio() ); | ||
| 382 | else if ( vaiPunti() ); | ||
| 383 | else if ( vaiTaglio() ); | ||
| 384 | else if ( vaiBriscolaAlta() ); | ||
| 385 | else if ( vaiCarico() ); | ||
| 386 | else if ( vaiTre() ); | ||
| 387 | } else if ( haCaricato() ) { | ||
| 388 | if ( vaiSopra() ); | ||
| 389 | else if ( vaiTre() ); | ||
| 390 | else if ( vaiBriscolaAlta() ); | ||
| 391 | else if ( vaiAsso() ); | ||
| 392 | else if ( vaiTaglio() ); | ||
| 393 | else if ( vaiLiscio() ); | ||
| 394 | else if ( vaiPunti() ); | ||
| 395 | else if ( vaiCarico() ); | ||
| 396 | } | ||
| 397 | } | ||
| 398 | } | ||
| 399 | |||
| 400 | } else if ( mano == 17 ) { | ||
| 401 | |||
| 402 | /* Valuta cosa fare se il giocatore non ha ancora giocato. */ | ||
| 403 | if ( frame.giocata[0] == null ) { | ||
| 404 | if ( hoAsso() ) { | ||
| 405 | if ( vaiTre() ); | ||
| 406 | else if ( vaiBriscolaAlta() ); | ||
| 407 | else if ( vaiTaglio() ); | ||
| 408 | else if ( vaiLiscio() ); | ||
| 409 | else if ( vaiPunti() ); | ||
| 410 | else if ( vaiAsso() ); | ||
| 411 | else if ( vaiCarico() ); | ||
| 412 | } else { | ||
| 413 | if ( vaiLiscio() ); | ||
| 414 | else if ( vaiPunti() ); | ||
| 415 | else if ( vaiTaglio() ); | ||
| 416 | else if ( vaiBriscolaAlta() ); | ||
| 417 | else if ( vaiCarico() ); | ||
| 418 | else if ( vaiTre() ); | ||
| 419 | } | ||
| 420 | } | ||
| 421 | |||
| 422 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 423 | else { | ||
| 424 | if ( haLisciato() ) { | ||
| 425 | if ( vaiSopra() ); | ||
| 426 | else if ( vaiLiscio() ); | ||
| 427 | else if ( vaiPunti() ); | ||
| 428 | else if ( vaiTaglio() ); | ||
| 429 | else if ( vaiTre() ); | ||
| 430 | else if ( vaiBriscolaAlta() ); | ||
| 431 | else if ( vaiCarico() ); | ||
| 432 | else if ( vaiAsso() ); | ||
| 433 | } else if ( haMessoPunti() ) { | ||
| 434 | if ( vaiSopra() ); | ||
| 435 | else if ( vaiLiscio() ); | ||
| 436 | else if ( vaiTaglio() ); | ||
| 437 | else if ( vaiPunti() ); | ||
| 438 | else if ( vaiTre() ); | ||
| 439 | else if ( vaiBriscolaAlta() ); | ||
| 440 | else if ( vaiCarico() ); | ||
| 441 | else if ( vaiAsso() ); | ||
| 442 | } else if ( haTagliato() ) { | ||
| 443 | if ( vaiLiscio() ); | ||
| 444 | else if ( vaiPunti() ); | ||
| 445 | else if ( vaiTaglio() ); | ||
| 446 | else if ( vaiTre() ); | ||
| 447 | else if ( vaiBriscolaAlta() ); | ||
| 448 | else if ( vaiCarico() ); | ||
| 449 | else if ( vaiAsso() ); | ||
| 450 | } else if ( haMessoBriscolaAlta() ) { | ||
| 451 | if ( vaiLiscio() ); | ||
| 452 | else if ( vaiPunti() ); | ||
| 453 | else if ( vaiTre() ); | ||
| 454 | else if ( vaiTaglio() ); | ||
| 455 | else if ( vaiBriscolaAlta() ); | ||
| 456 | else if ( vaiCarico() ); | ||
| 457 | else if ( vaiAsso() ); | ||
| 458 | } else if ( haMessoTre() ) { | ||
| 459 | if ( vaiAsso() ); | ||
| 460 | else if ( vaiLiscio() ); | ||
| 461 | else if ( vaiPunti() ); | ||
| 462 | else if ( vaiTaglio() ); | ||
| 463 | else if ( vaiBriscolaAlta() ); | ||
| 464 | else if ( vaiCarico() ); | ||
| 465 | } else if ( haMessoAsso() ) { | ||
| 466 | if ( vaiLiscio() ); | ||
| 467 | else if ( vaiPunti() ); | ||
| 468 | else if ( vaiTaglio() ); | ||
| 469 | else if ( vaiBriscolaAlta() ); | ||
| 470 | else if ( vaiCarico() ); | ||
| 471 | else if ( vaiTre() ); | ||
| 472 | } else if ( haCaricato() ) { | ||
| 473 | if ( vaiSopra() ); | ||
| 474 | else if ( vaiTre() ); | ||
| 475 | else if ( vaiBriscolaAlta() ); | ||
| 476 | else if ( vaiAsso() ); | ||
| 477 | else if ( vaiTaglio() ); | ||
| 478 | else if ( vaiLiscio() ); | ||
| 479 | else if ( vaiPunti() ); | ||
| 480 | else if ( vaiCarico() ); | ||
| 481 | } | ||
| 482 | } | ||
| 483 | |||
| 484 | } else if ( mano == 18 ) { | ||
| 485 | |||
| 486 | /* Valuta cosa fare se il giocatore non ha ancora giocato. */ | ||
| 487 | if ( frame.giocata[0] == null ) { | ||
| 488 | if ( vaiAsso() ); | ||
| 489 | else if ( vaiCarico() ); | ||
| 490 | else if ( vaiBriscolaAlta() ); | ||
| 491 | else if ( vaiTaglio() ); | ||
| 492 | else if ( vaiPunti() ); | ||
| 493 | else if ( vaiLiscio() ); | ||
| 494 | else if ( vaiTre() ); | ||
| 495 | } | ||
| 496 | |||
| 497 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 498 | else { | ||
| 499 | if ( haLisciato() ) { | ||
| 500 | if ( vaiSopra() ); | ||
| 501 | else if ( vaiLiscio() ); | ||
| 502 | else if ( vaiPunti() ); | ||
| 503 | else if ( vaiTaglio() ); | ||
| 504 | else if ( vaiTre() ); | ||
| 505 | else if ( vaiBriscolaAlta() ); | ||
| 506 | else if ( vaiCarico() ); | ||
| 507 | else if ( vaiAsso() ); | ||
| 508 | } else if ( haMessoPunti() ) { | ||
| 509 | if ( vaiSopra() ); | ||
| 510 | else if ( vaiLiscio() ); | ||
| 511 | else if ( vaiTaglio() ); | ||
| 512 | else if ( vaiPunti() ); | ||
| 513 | else if ( vaiTre() ); | ||
| 514 | else if ( vaiBriscolaAlta() ); | ||
| 515 | else if ( vaiCarico() ); | ||
| 516 | else if ( vaiAsso() ); | ||
| 517 | } else if ( haTagliato() ) { | ||
| 518 | if ( vaiLiscio() ); | ||
| 519 | else if ( vaiPunti() ); | ||
| 520 | else if ( vaiTaglio() ); | ||
| 521 | else if ( vaiTre() ); | ||
| 522 | else if ( vaiBriscolaAlta() ); | ||
| 523 | else if ( vaiCarico() ); | ||
| 524 | else if ( vaiAsso() ); | ||
| 525 | } else if ( haMessoBriscolaAlta() ) { | ||
| 526 | if ( vaiLiscio() ); | ||
| 527 | else if ( vaiPunti() ); | ||
| 528 | else if ( vaiTre() ); | ||
| 529 | else if ( vaiTaglio() ); | ||
| 530 | else if ( vaiBriscolaAlta() ); | ||
| 531 | else if ( vaiCarico() ); | ||
| 532 | else if ( vaiAsso() ); | ||
| 533 | } else if ( haMessoTre() ) { | ||
| 534 | if ( vaiAsso() ); | ||
| 535 | else if ( vaiLiscio() ); | ||
| 536 | else if ( vaiPunti() ); | ||
| 537 | else if ( vaiTaglio() ); | ||
| 538 | else if ( vaiBriscolaAlta() ); | ||
| 539 | else if ( vaiCarico() ); | ||
| 540 | } else if ( haMessoAsso() ) { | ||
| 541 | if ( vaiLiscio() ); | ||
| 542 | else if ( vaiPunti() ); | ||
| 543 | else if ( vaiTaglio() ); | ||
| 544 | else if ( vaiBriscolaAlta() ); | ||
| 545 | else if ( vaiCarico() ); | ||
| 546 | else if ( vaiTre() ); | ||
| 547 | } else if ( haCaricato() ) { | ||
| 548 | if ( vaiSopra() ); | ||
| 549 | else if ( vaiTre() ); | ||
| 550 | else if ( vaiBriscolaAlta() ); | ||
| 551 | else if ( vaiAsso() ); | ||
| 552 | else if ( vaiTaglio() ); | ||
| 553 | else if ( vaiLiscio() ); | ||
| 554 | else if ( vaiPunti() ); | ||
| 555 | else if ( vaiCarico() ); | ||
| 556 | } | ||
| 557 | } | ||
| 558 | |||
| 559 | /* All'ultima mano è inutile ragionare, dato che ha una sola carta */ | ||
| 560 | } else { | ||
| 561 | if ( vaiTre() ); | ||
| 562 | else if ( vaiBriscolaAlta() ); | ||
| 563 | else if ( vaiAsso() ); | ||
| 564 | else if ( vaiTaglio() ); | ||
| 565 | else if ( vaiLiscio() ); | ||
| 566 | else if ( vaiPunti() ); | ||
| 567 | else if ( vaiCarico() ); | ||
| 568 | } | ||
| 569 | |||
| 570 | /* Gioca la carta e aggiorna la finestra con il metodo repaint() */ | ||
| 571 | frame.giocata[1] = frame.carteCPU[cartaDaGiocare]; | ||
| 572 | frame.carteCPU[cartaDaGiocare] = null; | ||
| 573 | frame.pannello.repaint(); | ||
| 574 | |||
| 575 | CPUHaGiocato = true; | ||
| 576 | |||
| 577 | if ( frame.giocata[0] == null ) | ||
| 578 | toccaAllaCPU = false; | ||
| 579 | } | ||
| 580 | |||
| 581 | /* Fa giocare una partita ai 30. È analogo al metodo precedente, cambia | ||
| 582 | * solo la tecnica di gioco, quindi non è commentato. */ | ||
| 583 | public void giocaCPUAiTrenta() { | ||
| 584 | |||
| 585 | if ( punteggio <= 20 ) { | ||
| 586 | |||
| 587 | if ( frame.giocata[0] == null ) { | ||
| 588 | if ( vaiPunti() ); | ||
| 589 | else if ( vaiLiscio() ); | ||
| 590 | else if ( vaiTaglio() ); | ||
| 591 | else if ( vaiBriscolaAlta() ); | ||
| 592 | else if ( vaiCarico() ); | ||
| 593 | else if ( vaiTre() ); | ||
| 594 | else if ( vaiAsso() ); | ||
| 595 | else; | ||
| 596 | } | ||
| 597 | |||
| 598 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 599 | else { | ||
| 600 | if ( haLisciato() ) { | ||
| 601 | if ( vaiSopra() ); | ||
| 602 | else if ( vaiLiscio() ); | ||
| 603 | else if ( vaiTre() ); | ||
| 604 | else if ( vaiBriscolaAlta() ); | ||
| 605 | else if ( vaiTaglio() ); | ||
| 606 | else if ( vaiPunti() ); | ||
| 607 | else if ( vaiAsso() ); | ||
| 608 | else if ( vaiCarico() ); | ||
| 609 | } else if ( haMessoPunti() ) { | ||
| 610 | if ( vaiSopra() ); | ||
| 611 | else if ( vaiTre() ); | ||
| 612 | else if ( vaiBriscolaAlta() ); | ||
| 613 | else if ( vaiTaglio() ); | ||
| 614 | else if ( vaiLiscio() ); | ||
| 615 | else if ( vaiPunti() ); | ||
| 616 | else if ( vaiAsso() ); | ||
| 617 | else if ( vaiCarico() ); | ||
| 618 | } else if ( haTagliato() ) { | ||
| 619 | if ( vaiLiscio() ); | ||
| 620 | else if ( vaiPunti() ); | ||
| 621 | else if ( vaiTaglio() ); | ||
| 622 | else if ( vaiTre() ); | ||
| 623 | else if ( vaiBriscolaAlta() ); | ||
| 624 | else if ( vaiAsso() ); | ||
| 625 | else if ( vaiCarico() ); | ||
| 626 | } else if ( haMessoBriscolaAlta() ) { | ||
| 627 | if ( vaiLiscio() ); | ||
| 628 | else if ( vaiPunti() ); | ||
| 629 | else if ( vaiTre() ); | ||
| 630 | else if ( vaiTaglio() ); | ||
| 631 | else if ( vaiBriscolaAlta() ); | ||
| 632 | else if ( vaiAsso() ); | ||
| 633 | else if ( vaiCarico() ); | ||
| 634 | } else if ( haMessoTre() ) { | ||
| 635 | if ( vaiAsso() ); | ||
| 636 | else if ( vaiLiscio() ); | ||
| 637 | else if ( vaiPunti() ); | ||
| 638 | else if ( vaiTaglio() ); | ||
| 639 | else if ( vaiBriscolaAlta() ); | ||
| 640 | else if ( vaiCarico() ); | ||
| 641 | } else if ( haMessoAsso() ) { | ||
| 642 | if ( vaiLiscio() ); | ||
| 643 | else if ( vaiPunti() ); | ||
| 644 | else if ( vaiTaglio() ); | ||
| 645 | else if ( vaiBriscolaAlta() ); | ||
| 646 | else if ( vaiCarico() ); | ||
| 647 | else if ( vaiTre() ); | ||
| 648 | } else if ( haCaricato() ) { | ||
| 649 | if ( vaiSopra() ); | ||
| 650 | else if ( vaiTre() ); | ||
| 651 | else if ( vaiBriscolaAlta() ); | ||
| 652 | else if ( vaiTaglio() ); | ||
| 653 | else if ( vaiAsso() ); | ||
| 654 | else if ( vaiLiscio() ); | ||
| 655 | else if ( vaiPunti() ); | ||
| 656 | else if ( vaiCarico() ); | ||
| 657 | } | ||
| 658 | } | ||
| 659 | } | ||
| 660 | |||
| 661 | else { | ||
| 662 | |||
| 663 | if ( frame.giocata[0] == null ) { | ||
| 664 | if ( vaiLiscio() ); | ||
| 665 | else if ( vaiPunti() ); | ||
| 666 | else if ( vaiTaglio() ); | ||
| 667 | else if ( vaiBriscolaAlta() ); | ||
| 668 | else if ( vaiAsso() ); | ||
| 669 | else if ( vaiTre() ); | ||
| 670 | else if ( vaiCarico() ); | ||
| 671 | else; | ||
| 672 | } | ||
| 673 | |||
| 674 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 675 | else { | ||
| 676 | if ( haLisciato() ) { | ||
| 677 | if ( vaiSopra() ); | ||
| 678 | else if ( vaiLiscio() ); | ||
| 679 | else if ( vaiTre() ); | ||
| 680 | else if ( vaiBriscolaAlta() ); | ||
| 681 | else if ( vaiTaglio() ); | ||
| 682 | else if ( vaiAsso() ); | ||
| 683 | else if ( vaiPunti() ); | ||
| 684 | else if ( vaiCarico() ); | ||
| 685 | } else if ( haMessoPunti() ) { | ||
| 686 | if ( vaiSopra() ); | ||
| 687 | else if ( vaiTre() ); | ||
| 688 | else if ( vaiBriscolaAlta() ); | ||
| 689 | else if ( vaiTaglio() ); | ||
| 690 | else if ( vaiAsso() ); | ||
| 691 | else if ( vaiLiscio() ); | ||
| 692 | else if ( vaiPunti() ); | ||
| 693 | else if ( vaiCarico() ); | ||
| 694 | } else if ( haTagliato() ) { | ||
| 695 | if ( vaiLiscio() ); | ||
| 696 | else if ( vaiTaglio() ); | ||
| 697 | else if ( vaiTre() ); | ||
| 698 | else if ( vaiBriscolaAlta() ); | ||
| 699 | else if ( vaiAsso() ); | ||
| 700 | else if ( vaiPunti() ); | ||
| 701 | else if ( vaiCarico() ); | ||
| 702 | } else if ( haMessoBriscolaAlta() ) { | ||
| 703 | if ( vaiLiscio() ); | ||
| 704 | else if ( vaiTre() ); | ||
| 705 | else if ( vaiTaglio() ); | ||
| 706 | else if ( vaiAsso() ); | ||
| 707 | else if ( vaiBriscolaAlta() ); | ||
| 708 | else if ( vaiPunti() ); | ||
| 709 | else if ( vaiCarico() ); | ||
| 710 | } else if ( haMessoTre() ) { | ||
| 711 | if ( vaiAsso() ); | ||
| 712 | else if ( vaiLiscio() ); | ||
| 713 | else if ( vaiPunti() ); | ||
| 714 | else if ( vaiTaglio() ); | ||
| 715 | else if ( vaiBriscolaAlta() ); | ||
| 716 | else if ( vaiCarico() ); | ||
| 717 | } else if ( haMessoAsso() ) { | ||
| 718 | if ( vaiLiscio() ); | ||
| 719 | else if ( vaiTaglio() ); | ||
| 720 | else if ( vaiPunti() ); | ||
| 721 | else if ( vaiBriscolaAlta() ); | ||
| 722 | else if ( vaiCarico() ); | ||
| 723 | else if ( vaiTre() ); | ||
| 724 | } else if ( haCaricato() ) { | ||
| 725 | if ( vaiSopra() ); | ||
| 726 | else if ( vaiTre() ); | ||
| 727 | else if ( vaiBriscolaAlta() ); | ||
| 728 | else if ( vaiTaglio() ); | ||
| 729 | else if ( vaiAsso() ); | ||
| 730 | else if ( vaiLiscio() ); | ||
| 731 | else if ( vaiPunti() ); | ||
| 732 | else if ( vaiCarico() ); | ||
| 733 | } | ||
| 734 | } | ||
| 735 | } | ||
| 736 | |||
| 737 | /* Gioca la carta e aggiorna la finestra con il metodo repaint() */ | ||
| 738 | frame.giocata[1] = frame.carteCPU[cartaDaGiocare]; | ||
| 739 | frame.carteCPU[cartaDaGiocare] = null; | ||
| 740 | frame.pannello.repaint(); | ||
| 741 | |||
| 742 | CPUHaGiocato = true; | ||
| 743 | |||
| 744 | if ( frame.giocata[0] == null ) | ||
| 745 | toccaAllaCPU = false; | ||
| 746 | } | ||
| 747 | |||
| 748 | /* Determina se ha preso la CPU o il giocatore */ | ||
| 749 | public void chiPrende() { | ||
| 750 | |||
| 751 | /* Chiama il metodo giocatorePrende( boolean giocatore ) con parametro | ||
| 752 | * true se ha preso il giocatore, false se ha preso la CPU */ | ||
| 753 | giocatorePrende( ( (seme( frame.giocata[0] ) == semeBriscola) && (seme( frame.giocata[1] ) != semeBriscola) ) | ||
| 754 | || ( (seme( frame.giocata[0] ) == seme( frame.giocata[1] )) && laPrimaEPiuAlta( valore( frame.giocata[0] ), valore( frame.giocata[1] )) ) | ||
| 755 | || ( (seme( frame.giocata[1] ) != semeBriscola) && (seme( frame.giocata[0] ) != seme( frame.giocata[1] )) && haGiocatoPrima ) ); | ||
| 756 | } | ||
| 757 | |||
| 758 | /* Confronta due carte per decidere quale ha più valore di presa. | ||
| 759 | * Restituisce true se è la prima, false se è la seconda */ | ||
| 760 | public boolean laPrimaEPiuAlta( int prima, int seconda ) { | ||
| 761 | int a, b; | ||
| 762 | switch ( prima ) { | ||
| 763 | case 0: | ||
| 764 | a = 10; | ||
| 765 | break; | ||
| 766 | case 1: | ||
| 767 | a = 12; | ||
| 768 | break; | ||
| 769 | case 3: | ||
| 770 | a = 11; | ||
| 771 | break; | ||
| 772 | default: | ||
| 773 | a = prima; | ||
| 774 | break; | ||
| 775 | } | ||
| 776 | switch ( seconda ) { | ||
| 777 | case 0: | ||
| 778 | b = 10; | ||
| 779 | break; | ||
| 780 | case 1: | ||
| 781 | b = 12; | ||
| 782 | break; | ||
| 783 | case 3: | ||
| 784 | b = 11; | ||
| 785 | break; | ||
| 786 | default: | ||
| 787 | b = seconda; | ||
| 788 | break; | ||
| 789 | } | ||
| 790 | return a > b; | ||
| 791 | } | ||
| 792 | |||
| 793 | /* Viene chiamato con parametro true se ha preso il giocatore, false se | ||
| 794 | * ha preso la CPU */ | ||
| 795 | public void giocatorePrende( boolean giocatore ) { | ||
| 796 | if ( giocatore ) { | ||
| 797 | toccaAllaCPU = CPUHaGiocato = false; | ||
| 798 | haGiocatoPrima = true; | ||
| 799 | } | ||
| 800 | else { | ||
| 801 | toccaAllaCPU = true; | ||
| 802 | CPUHaGiocato = haGiocatoPrima = false; | ||
| 803 | } | ||
| 804 | daiPunti( giocatore ); | ||
| 805 | } | ||
| 806 | |||
| 807 | /* Da i punti (true al giocatore, false alla CPU) e fa pescare le carte*/ | ||
| 808 | public void daiPunti( boolean giocatore ) { | ||
| 809 | |||
| 810 | int punti = 0; | ||
| 811 | |||
| 812 | switch( valore( frame.giocata[0] ) ) { | ||
| 813 | case 0: | ||
| 814 | punti += 4; | ||
| 815 | break; | ||
| 816 | case 1: | ||
| 817 | punti += 11; | ||
| 818 | break; | ||
| 819 | case 3: | ||
| 820 | punti += 10; | ||
| 821 | break; | ||
| 822 | case 8: | ||
| 823 | punti += 2; | ||
| 824 | break; | ||
| 825 | case 9: | ||
| 826 | punti += 3; | ||
| 827 | break; | ||
| 828 | default: | ||
| 829 | break; | ||
| 830 | } | ||
| 831 | switch( valore( frame.giocata[1] ) ) { | ||
| 832 | case 0: | ||
| 833 | punti += 4; | ||
| 834 | break; | ||
| 835 | case 1: | ||
| 836 | punti += 11; | ||
| 837 | break; | ||
| 838 | case 3: | ||
| 839 | punti += 10; | ||
| 840 | break; | ||
| 841 | case 8: | ||
| 842 | punti += 2; | ||
| 843 | break; | ||
| 844 | case 9: | ||
| 845 | punti += 3; | ||
| 846 | break; | ||
| 847 | default: | ||
| 848 | break; | ||
| 849 | } | ||
| 850 | |||
| 851 | frame.giocata[0] = frame.giocata[1] = null; | ||
| 852 | |||
| 853 | if ( giocatore ) { | ||
| 854 | punteggio += punti; | ||
| 855 | if ( mano < 18 ) { | ||
| 856 | if ( frame.carteInMano[0] == null ) | ||
| 857 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 858 | if ( frame.carteInMano[1] == null ) | ||
| 859 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 860 | if ( frame.carteInMano[2] == null ) | ||
| 861 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 862 | cartaDaPescare++; | ||
| 863 | if ( frame.carteCPU[0] == null ) | ||
| 864 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 865 | if ( frame.carteCPU[1] == null ) | ||
| 866 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 867 | if ( frame.carteCPU[2] == null ) | ||
| 868 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 869 | cartaDaPescare++; | ||
| 870 | } | ||
| 871 | } | ||
| 872 | |||
| 873 | else { | ||
| 874 | punteggioCPU += punti; | ||
| 875 | if ( mano < 18 ) { | ||
| 876 | if ( frame.carteCPU[0] == null ) | ||
| 877 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 878 | if ( frame.carteCPU[1] == null ) | ||
| 879 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 880 | if ( frame.carteCPU[2] == null ) | ||
| 881 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 882 | cartaDaPescare++; | ||
| 883 | if ( frame.carteInMano[0] == null ) | ||
| 884 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 885 | if ( frame.carteInMano[1] == null ) | ||
| 886 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 887 | if ( frame.carteInMano[2] == null ) | ||
| 888 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 889 | cartaDaPescare++; | ||
| 890 | } | ||
| 891 | } | ||
| 892 | |||
| 893 | /* Aggiorna la finestra */ | ||
| 894 | frame.pannello.repaint(); | ||
| 895 | frame.repaint(); | ||
| 896 | } | ||
| 897 | |||
| 898 | /* Vari metodi che determinano che tipo di carta ha giocato il giocatore.*/ | ||
| 899 | public boolean haLisciato() { | ||
| 900 | return ( (frame.giocata[0] != null) && (seme( frame.giocata[0] ) != semeBriscola) && | ||
| 901 | (valore( frame.giocata[0] ) != RE ) && (valore( frame.giocata[0] ) != ASSO ) && | ||
| 902 | (valore( frame.giocata[0] ) != TRE ) && (valore( frame.giocata[0] ) < FANTE ) ); | ||
| 903 | } | ||
| 904 | |||
| 905 | public boolean haMessoPunti() { | ||
| 906 | return ( (frame.giocata[0] != null) && (seme( frame.giocata[0] ) != semeBriscola) && | ||
| 907 | ( (valore( frame.giocata[0] ) == RE ) || (valore( frame.giocata[0] ) == FANTE ) || | ||
| 908 | (valore( frame.giocata[0] ) == CAVALLO ) ) ); | ||
| 909 | } | ||
| 910 | |||
| 911 | public boolean haTagliato() { | ||
| 912 | return ( (frame.giocata[0] != null) && (seme( frame.giocata[0] ) == semeBriscola) && | ||
| 913 | (valore( frame.giocata[0] ) == RE) && (valore( frame.giocata[0] ) != ASSO) && | ||
| 914 | (valore( frame.giocata[0] ) == TRE) && (valore( frame.giocata[0] ) <= SETTE) ); | ||
| 915 | } | ||
| 916 | |||
| 917 | public boolean haMessoBriscolaAlta() { | ||
| 918 | return ( (frame.giocata[0] != null) && (seme( frame.giocata[0] ) == semeBriscola) && | ||
| 919 | ( (valore( frame.giocata[0] ) == RE ) || (valore( frame.giocata[0] ) == FANTE ) || | ||
| 920 | (valore( frame.giocata[0] ) == CAVALLO ) ) ); | ||
| 921 | } | ||
| 922 | |||
| 923 | public boolean haMessoTre() { | ||
| 924 | return ( (frame.giocata[0] != null) && (seme( frame.giocata[0] ) == semeBriscola) && | ||
| 925 | (valore( frame.giocata[0] ) == TRE) ); | ||
| 926 | } | ||
| 927 | |||
| 928 | public boolean haMessoAsso() { | ||
| 929 | return ( (frame.giocata[0] != null) && (seme( frame.giocata[0] ) == semeBriscola) && | ||
| 930 | (valore( frame.giocata[0] ) == ASSO) ); | ||
| 931 | } | ||
| 932 | |||
| 933 | public boolean haCaricato() { | ||
| 934 | return ( (frame.giocata[0] != null) && (seme( frame.giocata[0] ) != semeBriscola) && | ||
| 935 | ( (valore( frame.giocata[0] ) == ASSO) || (valore( frame.giocata[0] ) == TRE) ) ); | ||
| 936 | } | ||
| 937 | |||
| 938 | /* I metodi seguenti cercano di andare liscio - dare punti - mettere | ||
| 939 | * un taglio - ecc... e restituiscono true se hanno avuto successo, | ||
| 940 | * false altrimenti. */ | ||
| 941 | public boolean vaiLiscio() { | ||
| 942 | for ( int i = 0; i < 3; i++ ) { | ||
| 943 | if ( frame.carteCPU[i] != null ) { | ||
| 944 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && | ||
| 945 | (valore( frame.carteCPU[i] ) != RE) && (valore( frame.carteCPU[i] ) != ASSO) && | ||
| 946 | (valore( frame.carteCPU[i] ) != TRE) && (valore( frame.carteCPU[i] ) < FANTE) ) { | ||
| 947 | cartaDaGiocare = i; | ||
| 948 | return true; | ||
| 949 | } | ||
| 950 | } | ||
| 951 | } | ||
| 952 | |||
| 953 | return false; | ||
| 954 | } | ||
| 955 | |||
| 956 | public boolean vaiPunti() { | ||
| 957 | /* Cerca di dare punti, cercando di darne il meno possibile (meglio | ||
| 958 | * un fante di re). */ | ||
| 959 | for ( int i = 0; i < 3; i++ ) { | ||
| 960 | if ( frame.carteCPU[i] != null ) { | ||
| 961 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == FANTE ) ) { | ||
| 962 | cartaDaGiocare = i; | ||
| 963 | return true; | ||
| 964 | } | ||
| 965 | } | ||
| 966 | } | ||
| 967 | |||
| 968 | for ( int i = 0; i < 3; i++ ) { | ||
| 969 | if ( frame.carteCPU[i] != null ) { | ||
| 970 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == CAVALLO ) ) { | ||
| 971 | cartaDaGiocare = i; | ||
| 972 | return true; | ||
| 973 | } | ||
| 974 | } | ||
| 975 | } | ||
| 976 | |||
| 977 | for ( int i = 0; i < 3; i++ ) { | ||
| 978 | if ( frame.carteCPU[i] != null ) { | ||
| 979 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == RE ) ) { | ||
| 980 | cartaDaGiocare = i; | ||
| 981 | return true; | ||
| 982 | } | ||
| 983 | } | ||
| 984 | } | ||
| 985 | |||
| 986 | return false; | ||
| 987 | } | ||
| 988 | public boolean vaiTaglio() { | ||
| 989 | for ( int i = 0; i < 3; i++ ) { | ||
| 990 | if ( frame.carteCPU[i] != null ) { | ||
| 991 | if ( seme( frame.carteCPU[i] ) == semeBriscola && | ||
| 992 | (valore( frame.carteCPU[i] ) != RE) && (valore( frame.carteCPU[i] ) != ASSO) && | ||
| 993 | (valore( frame.carteCPU[i] ) != TRE) && (valore( frame.carteCPU[i] ) < FANTE) ) { | ||
| 994 | cartaDaGiocare = i; | ||
| 995 | return true; | ||
| 996 | } | ||
| 997 | } | ||
| 998 | } | ||
| 999 | |||
| 1000 | return false; | ||
| 1001 | } | ||
| 1002 | public boolean vaiBriscolaAlta() { | ||
| 1003 | for ( int i = 0; i < 3; i++ ) { | ||
| 1004 | if ( frame.carteCPU[i] != null ) { | ||
| 1005 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && (valore( frame.carteCPU[i] ) == FANTE) ) { | ||
| 1006 | cartaDaGiocare = i; | ||
| 1007 | return true; | ||
| 1008 | } | ||
| 1009 | } | ||
| 1010 | } | ||
| 1011 | |||
| 1012 | for ( int i = 0; i < 3; i++ ) { | ||
| 1013 | if ( frame.carteCPU[i] != null ) { | ||
| 1014 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && (valore( frame.carteCPU[i] ) == CAVALLO) ) { | ||
| 1015 | cartaDaGiocare = i; | ||
| 1016 | return true; | ||
| 1017 | } | ||
| 1018 | } | ||
| 1019 | } | ||
| 1020 | |||
| 1021 | for ( int i = 0; i < 3; i++ ) { | ||
| 1022 | if ( frame.carteCPU[i] != null ) { | ||
| 1023 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && (valore( frame.carteCPU[i] ) == RE) ) { | ||
| 1024 | cartaDaGiocare = i; | ||
| 1025 | return true; | ||
| 1026 | } | ||
| 1027 | } | ||
| 1028 | } | ||
| 1029 | |||
| 1030 | return false; | ||
| 1031 | } | ||
| 1032 | public boolean vaiTre() { | ||
| 1033 | for ( int i = 0; i < 3; i++ ) { | ||
| 1034 | if ( frame.carteCPU[i] != null ) { | ||
| 1035 | if ( seme( frame.carteCPU[i] ) == semeBriscola && (valore( frame.carteCPU[i] ) == TRE) ) { | ||
| 1036 | cartaDaGiocare = i; | ||
| 1037 | return true; | ||
| 1038 | } | ||
| 1039 | } | ||
| 1040 | } | ||
| 1041 | |||
| 1042 | return false; | ||
| 1043 | } | ||
| 1044 | public boolean vaiAsso() { | ||
| 1045 | for ( int i = 0; i < 3; i++ ) { | ||
| 1046 | if ( frame.carteCPU[i] != null ) { | ||
| 1047 | if ( seme( frame.carteCPU[i] ) == semeBriscola && (valore( frame.carteCPU[i] ) == ASSO) ) { | ||
| 1048 | cartaDaGiocare = i; | ||
| 1049 | return true; | ||
| 1050 | } | ||
| 1051 | } | ||
| 1052 | } | ||
| 1053 | |||
| 1054 | return false; | ||
| 1055 | } | ||
| 1056 | public boolean vaiCarico() { | ||
| 1057 | for ( int i = 0; i < 3; i++ ) { | ||
| 1058 | if ( frame.carteCPU[i] != null ) { | ||
| 1059 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == TRE) ) { | ||
| 1060 | cartaDaGiocare = i; | ||
| 1061 | return true; | ||
| 1062 | } | ||
| 1063 | } | ||
| 1064 | } | ||
| 1065 | |||
| 1066 | for ( int i = 0; i < 3; i++ ) { | ||
| 1067 | if ( frame.carteCPU[i] != null ) { | ||
| 1068 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == ASSO) ) { | ||
| 1069 | cartaDaGiocare = i; | ||
| 1070 | return true; | ||
| 1071 | } | ||
| 1072 | } | ||
| 1073 | } | ||
| 1074 | |||
| 1075 | return false; | ||
| 1076 | } | ||
| 1077 | public boolean vaiSopra() { | ||
| 1078 | /* Innanzitutto controlla se il giocatore ha giocato (non dovrebbe | ||
| 1079 | * essere possibile, in quanto quando questo metodo viene chiamato | ||
| 1080 | * tale condizione è già stata verificata, ma è sempre meglio un | ||
| 1081 | * controllo in più che uno in meno) e restituisce false in caso | ||
| 1082 | * contrario */ | ||
| 1083 | if ( frame.giocata[0] == null ) | ||
| 1084 | return false; | ||
| 1085 | |||
| 1086 | /* Tre variabili intere che serviranno a valutare quali delle tre | ||
| 1087 | * carte è meglio giocare, se più di una può andare sopra. */ | ||
| 1088 | int a = -1; | ||
| 1089 | int b = -1; | ||
| 1090 | int c = -1; | ||
| 1091 | |||
| 1092 | /* Tre booleane che verificano quali delle tre carte possono | ||
| 1093 | * andare sopra. */ | ||
| 1094 | boolean laPrimaPuoAndareSopra = false; | ||
| 1095 | boolean laSecondaPuoAndareSopra = false; | ||
| 1096 | boolean laTerzaPuoAndareSopra = false; | ||
| 1097 | |||
| 1098 | /* Se il giocatore ha giocato un asso, restituisce direttamente false. */ | ||
| 1099 | if ( valore( frame.giocata[0] ) == ASSO ) | ||
| 1100 | return false; | ||
| 1101 | |||
| 1102 | /* Valuta quali delle tre carte possono andare sopra, dopo essersi | ||
| 1103 | * accertato di averle: nelle ultime mani non si hanno tutte le carte | ||
| 1104 | * in mano, e noi non vogliamo una NullPointerException sul più bello | ||
| 1105 | * di una partita, vero?! */ | ||
| 1106 | if ( frame.carteCPU[0] != null ) { | ||
| 1107 | a = valore( frame.carteCPU[0] ); | ||
| 1108 | if ( (seme( frame.carteCPU[0] ) == seme( frame.giocata[0] )) && laPrimaEPiuAlta( a, valore( frame.giocata[0] ) ) ) | ||
| 1109 | laPrimaPuoAndareSopra = true; | ||
| 1110 | } | ||
| 1111 | |||
| 1112 | if ( frame.carteCPU[1] != null ) { | ||
| 1113 | b = valore( frame.carteCPU[1] ); | ||
| 1114 | if ( (seme( frame.carteCPU[1] ) == seme( frame.giocata[0] )) && laPrimaEPiuAlta( b, valore( frame.giocata[0] ) ) ) | ||
| 1115 | laSecondaPuoAndareSopra = true; | ||
| 1116 | } | ||
| 1117 | |||
| 1118 | if ( frame.carteCPU[2] != null ) { | ||
| 1119 | c = valore( frame.carteCPU[2] ); | ||
| 1120 | if ( (seme( frame.carteCPU[2] ) == seme( frame.giocata[0] )) && laPrimaEPiuAlta( c, valore( frame.giocata[0] ) ) ) | ||
| 1121 | laTerzaPuoAndareSopra = true; | ||
| 1122 | } | ||
| 1123 | |||
| 1124 | /* Se nessuna carta può andare sopra, restituisce false. Se una | ||
| 1125 | * sola delle tre può andare sopra la imposta come carta da giocare. */ | ||
| 1126 | if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 1127 | return false; | ||
| 1128 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 1129 | cartaDaGiocare = 0; | ||
| 1130 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 1131 | cartaDaGiocare = 1; | ||
| 1132 | else if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 1133 | cartaDaGiocare = 2; | ||
| 1134 | |||
| 1135 | /* Se più di una carta può andare sopra, valuta quale è più alta. */ | ||
| 1136 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 1137 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 1138 | cartaDaGiocare = 0; | ||
| 1139 | else | ||
| 1140 | cartaDaGiocare = 1; | ||
| 1141 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 1142 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 1143 | cartaDaGiocare = 1; | ||
| 1144 | else | ||
| 1145 | cartaDaGiocare = 2; | ||
| 1146 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 1147 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 1148 | cartaDaGiocare = 0; | ||
| 1149 | else | ||
| 1150 | cartaDaGiocare = 2; | ||
| 1151 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 1152 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 1153 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 1154 | cartaDaGiocare = 0; | ||
| 1155 | else | ||
| 1156 | cartaDaGiocare = 2; | ||
| 1157 | else | ||
| 1158 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 1159 | cartaDaGiocare = 1; | ||
| 1160 | else | ||
| 1161 | cartaDaGiocare = 2; | ||
| 1162 | |||
| 1163 | /* Controlla che la carta con cui sta cercando di andare sopra | ||
| 1164 | * sia una figura o un carico. Non vogliamo mica prendere delle | ||
| 1165 | * scartelle con delle scartelle, giusto?! */ | ||
| 1166 | if ( ( valore( frame.carteCPU[cartaDaGiocare] ) != RE ) && ( valore( frame.carteCPU[cartaDaGiocare] ) != ASSO ) && | ||
| 1167 | ( valore( frame.carteCPU[cartaDaGiocare] ) != TRE ) && ( valore( frame.carteCPU[cartaDaGiocare] ) <= SETTE ) ) | ||
| 1168 | return false; | ||
| 1169 | |||
| 1170 | return true; | ||
| 1171 | } | ||
| 1172 | |||
| 1173 | /* I metodi seguenti valutano le carte che la CPU ha in mano. */ | ||
| 1174 | public boolean hoCarico() { | ||
| 1175 | for ( int i = 0; i < 3; i++ ) { | ||
| 1176 | if ( frame.carteCPU[i] != null ) { | ||
| 1177 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && | ||
| 1178 | ( ( valore( frame.carteCPU[i] ) == ASSO ) || ( valore( frame.carteCPU[i] ) == TRE ) ) ) { | ||
| 1179 | return true; | ||
| 1180 | } | ||
| 1181 | } | ||
| 1182 | } | ||
| 1183 | |||
| 1184 | return false; | ||
| 1185 | } | ||
| 1186 | public boolean hoAsso() { | ||
| 1187 | for ( int i = 0; i < 3; i++ ) { | ||
| 1188 | if ( frame.carteCPU[i] != null ) { | ||
| 1189 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && (valore( frame.carteCPU[i] ) == ASSO ) ) { | ||
| 1190 | return true; | ||
| 1191 | } | ||
| 1192 | } | ||
| 1193 | } | ||
| 1194 | |||
| 1195 | return false; | ||
| 1196 | } | ||
| 1197 | public boolean hoTre() { | ||
| 1198 | for ( int i = 0; i < 3; i++ ) { | ||
| 1199 | if ( frame.carteCPU[i] != null ) { | ||
| 1200 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && (valore( frame.carteCPU[i] ) == TRE ) ) { | ||
| 1201 | return true; | ||
| 1202 | } | ||
| 1203 | } | ||
| 1204 | } | ||
| 1205 | |||
| 1206 | return false; | ||
| 1207 | } | ||
| 1208 | public boolean hoBriscolaAlta() { | ||
| 1209 | for ( int i = 0; i < 3; i++ ) { | ||
| 1210 | if ( frame.carteCPU[i] != null ) { | ||
| 1211 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && | ||
| 1212 | ( (valore( frame.carteCPU[i] ) == RE) || (valore( frame.carteCPU[i] ) == FANTE) || (valore( frame.carteCPU[i] ) == CAVALLO) ) ) { | ||
| 1213 | return true; | ||
| 1214 | } | ||
| 1215 | } | ||
| 1216 | } | ||
| 1217 | |||
| 1218 | return false; | ||
| 1219 | } | ||
| 1220 | public boolean hoTaglio() { | ||
| 1221 | for ( int i = 0; i < 3; i++ ) { | ||
| 1222 | if ( frame.carteCPU[i] != null ) { | ||
| 1223 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && | ||
| 1224 | (valore( frame.carteCPU[i] ) < FANTE ) && (valore( frame.carteCPU[i] ) != TRE ) | ||
| 1225 | && (valore( frame.carteCPU[i] ) != ASSO ) && (valore( frame.carteCPU[i] ) != RE ) ) { | ||
| 1226 | return true; | ||
| 1227 | } | ||
| 1228 | } | ||
| 1229 | } | ||
| 1230 | |||
| 1231 | return false; | ||
| 1232 | } | ||
| 1233 | |||
| 1234 | /* Restituisce il seme della carta passata come parametro */ | ||
| 1235 | public static int seme( ImageIcon carta ) { | ||
| 1236 | char aux[] = carta.toString().toCharArray(); | ||
| 1237 | return aux[aux.length-5] - 49; | ||
| 1238 | } | ||
| 1239 | |||
| 1240 | /* Restituisce il valore della carta */ | ||
| 1241 | public static int valore( ImageIcon carta ) { | ||
| 1242 | char aux[] = carta.toString().toCharArray(); | ||
| 1243 | return aux[aux.length-7] - 48; | ||
| 1244 | } | ||
| 1245 | |||
| 1246 | /* I vari trucchi del gioco. */ | ||
| 1247 | public static void trucco( String trucco ) { | ||
| 1248 | |||
| 1249 | byte[] truccoByte = trucco.getBytes(); | ||
| 1250 | char[] truccoChar = new char[ truccoByte.length ]; | ||
| 1251 | for ( int i = 0; i < truccoChar.length; i++ ) | ||
| 1252 | truccoChar[i] = (char)truccoByte[i]; | ||
| 1253 | |||
| 1254 | String attivato = stringaTruccoSbagliato; | ||
| 1255 | |||
| 1256 | /* Carta che vuoi dove vuoi. Esempio: x251 sostituisce | ||
| 1257 | * la terza carta (2) con il 6 (5) di coppe (1). */ | ||
| 1258 | if ( truccoChar[0] == 'x' && truccoChar.length == 4 ) { | ||
| 1259 | |||
| 1260 | attivato = stringaTruccoAttivato; | ||
| 1261 | |||
| 1262 | String aS = "" + truccoChar[1]; | ||
| 1263 | String xS = "" + truccoChar[2]; | ||
| 1264 | String yS = "" + truccoChar[3]; | ||
| 1265 | |||
| 1266 | int a, x, y; | ||
| 1267 | |||
| 1268 | try { | ||
| 1269 | |||
| 1270 | a = Integer.parseInt( aS ); | ||
| 1271 | x = Integer.parseInt( xS ); | ||
| 1272 | y = Integer.parseInt( yS ); | ||
| 1273 | |||
| 1274 | frame.carteInMano[a] = frame.arrayCarte[x][y]; | ||
| 1275 | |||
| 1276 | } catch ( Exception e ) { | ||
| 1277 | attivato = stringaTruccoSbagliato; | ||
| 1278 | } | ||
| 1279 | } | ||
| 1280 | |||
| 1281 | /* Mostra le carte del computer. */ | ||
| 1282 | if ( trucco.equalsIgnoreCase( "Kill Devil Hill" ) ) { | ||
| 1283 | |||
| 1284 | attivato = stringaTruccoAttivato; | ||
| 1285 | |||
| 1286 | carteScoperte = true; | ||
| 1287 | |||
| 1288 | } | ||
| 1289 | |||
| 1290 | /* Scambia le carte con il computer. */ | ||
| 1291 | if ( trucco.equalsIgnoreCase( "Darkside of Aquarius" ) ) { | ||
| 1292 | |||
| 1293 | attivato = stringaTruccoAttivato; | ||
| 1294 | |||
| 1295 | ImageIcon aux = null; | ||
| 1296 | |||
| 1297 | for ( int i = 0; i < 3; i++ ) { | ||
| 1298 | |||
| 1299 | aux = frame.carteInMano[i]; | ||
| 1300 | frame.carteInMano[i] = frame.carteCPU[i]; | ||
| 1301 | frame.carteCPU[i] = aux; | ||
| 1302 | |||
| 1303 | } | ||
| 1304 | } | ||
| 1305 | |||
| 1306 | /* Cambia il seme di briscola con uno a caso, senza dire quale. | ||
| 1307 | * L'ultima carta non cambia. È possibile comunque capire | ||
| 1308 | * qual'è la briscola dal menu ?->Briscola*/ | ||
| 1309 | if ( trucco.equalsIgnoreCase( "Change of Heart" ) ) { | ||
| 1310 | |||
| 1311 | attivato = stringaTruccoAttivato; | ||
| 1312 | |||
| 1313 | semeBriscola = (int) ( Math.random() * 4 ); | ||
| 1314 | |||
| 1315 | } | ||
| 1316 | |||
| 1317 | /* Asso Tre e Re di Briscola tutti in mano (anche in caso di doppioni). */ | ||
| 1318 | if ( trucco.equalsIgnoreCase( "Tears of The Dragon" ) ) { | ||
| 1319 | |||
| 1320 | attivato = stringaTruccoAttivato; | ||
| 1321 | |||
| 1322 | frame.carteInMano[0] = frame.arrayCarte[9][semeBriscola]; | ||
| 1323 | frame.carteInMano[1] = frame.arrayCarte[2][semeBriscola]; | ||
| 1324 | frame.carteInMano[2] = frame.arrayCarte[0][semeBriscola]; | ||
| 1325 | |||
| 1326 | } | ||
| 1327 | |||
| 1328 | /* Tre assi di briscola. */ | ||
| 1329 | if ( trucco.equalsIgnoreCase( "Navigate The Seas of The Sun" ) ) { | ||
| 1330 | |||
| 1331 | attivato = stringaTruccoAttivato; | ||
| 1332 | |||
| 1333 | frame.carteInMano[0] = frame.arrayCarte[0][semeBriscola]; | ||
| 1334 | frame.carteInMano[1] = frame.arrayCarte[0][semeBriscola]; | ||
| 1335 | frame.carteInMano[2] = frame.arrayCarte[0][semeBriscola]; | ||
| 1336 | |||
| 1337 | } | ||
| 1338 | |||
| 1339 | /* Fa finire la partita al prossimo piglio. */ | ||
| 1340 | if ( trucco.equalsIgnoreCase( "Omega" ) ) { | ||
| 1341 | |||
| 1342 | attivato = stringaTruccoAttivato; | ||
| 1343 | |||
| 1344 | mano = 19; | ||
| 1345 | |||
| 1346 | } | ||
| 1347 | |||
| 1348 | JOptionPane.showMessageDialog( frame, attivato, "JBriscola - " + version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 1349 | frame.pannello.repaint(); | ||
| 1350 | frame.repaint(); | ||
| 1351 | |||
| 1352 | } | ||
| 1353 | |||
| 1354 | /* Imposta le opzioni dell'utente cercando di leggerle dal file di configurazione. */ | ||
| 1355 | public static void settaOpzioni() { | ||
| 1356 | |||
| 1357 | /* Impostazioni predefinite. */ | ||
| 1358 | lang = "it"; | ||
| 1359 | soundString = "suono=si"; | ||
| 1360 | keysString = "tasti=si"; | ||
| 1361 | int r = 0; | ||
| 1362 | int g = 150; | ||
| 1363 | int b = 0; | ||
| 1364 | |||
| 1365 | /* Cerca di leggere il file per impostare le opzioni. */ | ||
| 1366 | Scanner scanner = null; | ||
| 1367 | File file = new File( "JBriscolaConfig.txt" ); | ||
| 1368 | if ( file.exists() ) { | ||
| 1369 | try { | ||
| 1370 | scanner = new Scanner( file ); | ||
| 1371 | } catch ( FileNotFoundException e ) { } | ||
| 1372 | try { | ||
| 1373 | lang = scanner.next(); | ||
| 1374 | soundString = scanner.next(); | ||
| 1375 | keysString = scanner.next(); | ||
| 1376 | r = scanner.nextInt(); | ||
| 1377 | g = scanner.nextInt(); | ||
| 1378 | b = scanner.nextInt(); | ||
| 1379 | } catch ( NoSuchElementException e ) { } | ||
| 1380 | } | ||
| 1381 | |||
| 1382 | /* Modifica le opzioni. */ | ||
| 1383 | if ( lang.equals( "it" ) ) { | ||
| 1384 | semi[0] = "Bastoni"; | ||
| 1385 | semi[1] = "Coppe"; | ||
| 1386 | semi[2] = "Denari"; | ||
| 1387 | semi[3] = "Spade"; | ||
| 1388 | stringaBriscola = "Briscola"; | ||
| 1389 | stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 1390 | stringaPrimaGioca = "Prima Gioca!"; | ||
| 1391 | stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 1392 | stringaVinto = "Hai Vinto!"; | ||
| 1393 | stringaPerso = "Hai Perso"; | ||
| 1394 | stringaPareggio = "Pareggio"; | ||
| 1395 | stringaGiocatore = "Giocatore: "; | ||
| 1396 | stringaComputer = "\nComputer: "; | ||
| 1397 | stringaNuovaPartita = "Nuova Partita"; | ||
| 1398 | stringaNuovaPartitaAiTrenta = "Nuova Partita Ai 30"; | ||
| 1399 | stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 1400 | stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 1401 | stringaSi = "Si"; | ||
| 1402 | stringaNo = "No"; | ||
| 1403 | stringaOpzioni = "Opzioni..."; | ||
| 1404 | stringaEsci = "Esci"; | ||
| 1405 | stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 1406 | stringaLingua = "Lingua"; | ||
| 1407 | stringaAnnulla = "Annulla"; | ||
| 1408 | stringaIt = "Italiano"; | ||
| 1409 | stringaLa = "Latino"; | ||
| 1410 | stringaBL = "Dialetto Bellunese"; | ||
| 1411 | stringaBV = "Dialetto Basso Veneto"; | ||
| 1412 | stringaEN = "Inglese"; | ||
| 1413 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1414 | stringaInformazioni = "Informazioni"; | ||
| 1415 | 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"; | ||
| 1416 | stringaSuono = "Effetti sonori"; | ||
| 1417 | stringaPunteggio = "Punteggio"; | ||
| 1418 | stringaSfondo = "Sfondo"; | ||
| 1419 | stringaTasti = "Tasti rapidi"; | ||
| 1420 | stringaAggiornamenti = "Cerca aggiornamenti"; | ||
| 1421 | stringaTrucchi = "Trucchi"; | ||
| 1422 | stringaInserisciCodice = "Inserisci il codice:"; | ||
| 1423 | stringaTruccoAttivato = "Trucco attivato!"; | ||
| 1424 | stringaTruccoSbagliato = "Trucco non valido"; | ||
| 1425 | stringaCheCartaVuoi = "E allora che carta vuoi?"; | ||
| 1426 | stringaAggiornamentiSi = "Aggiornamento disponibile: "; | ||
| 1427 | stringaAggiornamentiNo = "Nessun aggiornamento disponibile"; | ||
| 1428 | stringaScarica = "E' possibile scaricare la versione più recente\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 1429 | stringaNoInternet = "Errore: nessuna connessione internet"; | ||
| 1430 | 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 + "\nF7 " + stringaNuovaPartitaAiTrenta + "\nF8 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 1431 | } | ||
| 1432 | else if ( lang.equals( "la" ) ) { | ||
| 1433 | semi[0] = "BACULI"; | ||
| 1434 | semi[1] = "CALICES"; | ||
| 1435 | semi[2] = "DENARII"; | ||
| 1436 | semi[3] = "GLADII"; | ||
| 1437 | stringaBriscola = "BRISCOLA"; | ||
| 1438 | stringaBottonePrendi = "CAPIS/RELINQVIS CHARTAS"; | ||
| 1439 | stringaPrimaGioca = "ANTE CHARTAM PONE!"; | ||
| 1440 | stringaUltime4 = "CHARTA POSTREMA - INTVERE BRISCOLAM!"; | ||
| 1441 | stringaVinto = "VICISTI!"; | ||
| 1442 | stringaPerso = "PERDIDISTI"; | ||
| 1443 | stringaPareggio = "AEQVATIO!"; | ||
| 1444 | stringaGiocatore = "LVSOR: "; | ||
| 1445 | stringaComputer = "\nCOMPVTER: "; | ||
| 1446 | stringaNuovaPartita = "NOVA LVSO"; | ||
| 1447 | stringaNuovaPartitaAiTrenta = "NOVA LVSO XXX"; | ||
| 1448 | stringaVuoiDavveroIniziare = "NOVAM LVSIONEM INCIPERE?"; | ||
| 1449 | stringaVuoiDavveroUscire = "EXIRE?"; | ||
| 1450 | stringaSi = "ID VOLO"; | ||
| 1451 | stringaNo = "NOLO"; | ||
| 1452 | stringaOpzioni = "OPTIONES..."; | ||
| 1453 | stringaEsci = "EXIRE"; | ||
| 1454 | stringaImpossibileConfigurare = "CONFIGVRATIONIS FILE SCRIBERE NON POTVI.\nERROREM ME CERTIOREM FACITE: sebastiano@luganega.org\n\nEXCEPTIO:\n"; | ||
| 1455 | stringaLingua = "LINGVA"; | ||
| 1456 | stringaAnnulla = "ABROGA"; | ||
| 1457 | stringaIt = "ITALICA"; | ||
| 1458 | stringaLa = "LATINA"; | ||
| 1459 | stringaBL = "BELLUNI"; | ||
| 1460 | stringaBV = "VENETIAE"; | ||
| 1461 | stringaEN = "ANGLICVS"; | ||
| 1462 | stringaModificaOpzioni = "OPTIONES NOVARE"; | ||
| 1463 | stringaInformazioni = "INFORMATIONES"; | ||
| 1464 | 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"; | ||
| 1465 | stringaSuono = "SONVS"; | ||
| 1466 | stringaPunteggio = "NVMERI"; | ||
| 1467 | stringaSfondo = "COLOR"; | ||
| 1468 | stringaTasti = "TASTI RAPIDI"; | ||
| 1469 | stringaAggiornamenti = "VERSIONEM RECENTIOREM QVAERERE"; | ||
| 1470 | stringaTrucchi = "CODICES"; | ||
| 1471 | stringaInserisciCodice = "CODICEM INSCRIBE:"; | ||
| 1472 | stringaTruccoAttivato = "CODEX INCIPIVIT!"; | ||
| 1473 | stringaTruccoSbagliato = "ERROR CODICIS"; | ||
| 1474 | stringaCheCartaVuoi = "QUAM CHARTAM VOLIS?"; | ||
| 1475 | stringaNoInternet = "ERROR: INTERNETIS CONIVCTIO NON EST"; | ||
| 1476 | stringaAggiornamentiSi = "VERSIO RECENTIOR EST: "; | ||
| 1477 | stringaAggiornamentiNo = "VERSIO RECENTIOR NON EST"; | ||
| 1478 | stringaScarica = "VERSIONEM RECENTIOREM CEPTA ESSE POTEST:\nhttp://porkynator.altervista.org/programmi.html"; | ||
| 1479 | 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 + "\nF7 " + stringaNuovaPartitaAiTrenta + "\nF8 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 1480 | } | ||
| 1481 | if ( lang.equals( "bl" ) ) { | ||
| 1482 | semi[0] = "Bastoi"; | ||
| 1483 | semi[1] = "Coppe"; | ||
| 1484 | semi[2] = "Danari"; | ||
| 1485 | semi[3] = "Spade"; | ||
| 1486 | stringaBriscola = "Briscola"; | ||
| 1487 | stringaBottonePrendi = "Cio' su/lasa le carte"; | ||
| 1488 | stringaPrimaGioca = "Prima Duga!"; | ||
| 1489 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1490 | stringaVinto = "Te ha vint!"; | ||
| 1491 | stringaPerso = "Te ha pers"; | ||
| 1492 | stringaPareggio = "Pari"; | ||
| 1493 | stringaGiocatore = "Dugador: "; | ||
| 1494 | stringaComputer = "\nComputer: "; | ||
| 1495 | stringaNuovaPartita = "Taca n'altra partida"; | ||
| 1496 | stringaNuovaPartitaAiTrenta = "Taca na partida ai 30"; | ||
| 1497 | stringaVuoiDavveroIniziare = "Utu sul serio scuminziar n'altra partida?"; | ||
| 1498 | stringaVuoiDavveroUscire = "Utu sul serio stusar su?"; | ||
| 1499 | stringaSi = "Si"; | ||
| 1500 | stringaNo = "No"; | ||
| 1501 | stringaOpzioni = "Opzioni..."; | ||
| 1502 | stringaEsci = "Stusa su"; | ||
| 1503 | stringaImpossibileConfigurare = "No ghe ho riva' a scrivere al file de configurazion.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1504 | stringaLingua = "Lengua"; | ||
| 1505 | stringaAnnulla = "Annulla"; | ||
| 1506 | stringaIt = "Italian"; | ||
| 1507 | stringaLa = "Latin"; | ||
| 1508 | stringaBL = "Dialeto de Belun"; | ||
| 1509 | stringaBV = "Dialeto de la basa"; | ||
| 1510 | stringaEN = "Inglese"; | ||
| 1511 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1512 | stringaInformazioni = "Informazioni"; | ||
| 1513 | 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"; | ||
| 1514 | stringaSuono = "Efeti sonori"; | ||
| 1515 | stringaPunteggio = "Varda i punti"; | ||
| 1516 | stringaSfondo = "Sfondo"; | ||
| 1517 | stringaTasti = "Tasti rapidi"; | ||
| 1518 | stringaAggiornamenti = "Varda se ghe ne' na version pi nova"; | ||
| 1519 | stringaTrucchi = "Truchi"; | ||
| 1520 | stringaInserisciCodice = "Scrivi al codice:"; | ||
| 1521 | stringaTruccoAttivato = "Truco ativa'!"; | ||
| 1522 | stringaTruccoSbagliato = "Truco sbaia'"; | ||
| 1523 | stringaCheCartaVuoi = "Che carta utu alora?"; | ||
| 1524 | stringaAggiornamentiSi = "Ghe ne' na version pi nova: "; | ||
| 1525 | stringaAggiornamentiNo = "No ghe ne na version pi nova"; | ||
| 1526 | stringaScarica = "Te pol scaricar le version pi nova\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 1527 | stringaNoInternet = "Erore: no te se su internet"; | ||
| 1528 | 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 + "\nF7 " + stringaNuovaPartitaAiTrenta + "\nF8 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 1529 | } | ||
| 1530 | if ( lang.equals( "bv" ) ) { | ||
| 1531 | semi[0] = "Bastoni"; | ||
| 1532 | semi[1] = "Coppe"; | ||
| 1533 | semi[2] = "Danari"; | ||
| 1534 | semi[3] = "Spade"; | ||
| 1535 | stringaBriscola = "Briscola"; | ||
| 1536 | stringaBottonePrendi = "Ciapa su/lasa e carte"; | ||
| 1537 | stringaPrimaGioca = "Prima Zuga!"; | ||
| 1538 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1539 | stringaVinto = "Ti ga vinto!"; | ||
| 1540 | stringaPerso = "Ti ga perso"; | ||
| 1541 | stringaPareggio = "Pari"; | ||
| 1542 | stringaGiocatore = "Zugador: "; | ||
| 1543 | stringaComputer = "\nComputer: "; | ||
| 1544 | stringaNuovaPartita = "N'altra Partida"; | ||
| 1545 | stringaNuovaPartitaAiTrenta = "Na Partida ai 30"; | ||
| 1546 | stringaVuoiDavveroIniziare = "Ti vol sul serio scuminziar n'altra partida?"; | ||
| 1547 | stringaVuoiDavveroUscire = "Ti vol sul serio stusar su?"; | ||
| 1548 | stringaSi = "Si"; | ||
| 1549 | stringaNo = "No"; | ||
| 1550 | stringaOpzioni = "Opzioni..."; | ||
| 1551 | stringaEsci = "Stusa su"; | ||
| 1552 | stringaImpossibileConfigurare = "No ghe son riusito a scrivere al file de configurazione.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1553 | stringaLingua = "Lengua"; | ||
| 1554 | stringaAnnulla = "Annulla"; | ||
| 1555 | stringaIt = "Italian"; | ||
| 1556 | stringaLa = "Latin"; | ||
| 1557 | stringaBL = "Dialeto Belumat"; | ||
| 1558 | stringaBV = "Dialeto Veneto"; | ||
| 1559 | stringaEN = "Inglese"; | ||
| 1560 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1561 | stringaInformazioni = "Informasioni"; | ||
| 1562 | 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"; | ||
| 1563 | stringaSuono = "Efeti sonori"; | ||
| 1564 | stringaPunteggio = "Varda i punti"; | ||
| 1565 | stringaSfondo = "Sfondo"; | ||
| 1566 | stringaTasti = "Tasti rapidi"; | ||
| 1567 | stringaAggiornamenti = "Varda se ghe xe na versione pi nova"; | ||
| 1568 | stringaTrucchi = "Truchi"; | ||
| 1569 | stringaInserisciCodice = "Scrivi al codice:"; | ||
| 1570 | stringaTruccoAttivato = "Truco ativa'!"; | ||
| 1571 | stringaTruccoSbagliato = "Truco sbaia'"; | ||
| 1572 | stringaCheCartaVuoi = "Che carta utu alora?"; | ||
| 1573 | stringaAggiornamentiSi = "Ghe xe na versione pi nova: "; | ||
| 1574 | stringaAggiornamentiNo = "No ghe xe na versione pi nova"; | ||
| 1575 | stringaScarica = "Te pol scaricar le versione pi nova\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 1576 | stringaNoInternet = "Erore: no ti xe su internet"; | ||
| 1577 | 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 + "\nF7 " + stringaNuovaPartitaAiTrenta + "\nF8 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 1578 | } | ||
| 1579 | if ( lang.equals( "en" ) ) { | ||
| 1580 | semi[0] = "Sticks"; | ||
| 1581 | semi[1] = "Cups"; | ||
| 1582 | semi[2] = "Golds"; | ||
| 1583 | semi[3] = "Swords"; | ||
| 1584 | stringaBriscola = "Briscola"; | ||
| 1585 | stringaBottonePrendi = "Take/leave cards"; | ||
| 1586 | stringaPrimaGioca = "Play your card before!"; | ||
| 1587 | stringaUltime4 = "Last card - keep your eye on the briscola!"; | ||
| 1588 | stringaVinto = "You won!"; | ||
| 1589 | stringaPerso = "You lost"; | ||
| 1590 | stringaPareggio = "Sixty - sixty!"; | ||
| 1591 | stringaGiocatore = "Palyer: "; | ||
| 1592 | stringaComputer = "\nComputer: "; | ||
| 1593 | stringaNuovaPartita = "New Game"; | ||
| 1594 | stringaNuovaPartitaAiTrenta = "New Game - 30 Points"; | ||
| 1595 | stringaVuoiDavveroIniziare = "Do you really want to start a new game?"; | ||
| 1596 | stringaVuoiDavveroUscire = "Do you really want to exit?"; | ||
| 1597 | stringaSi = "Yes"; | ||
| 1598 | stringaNo = "No"; | ||
| 1599 | stringaOpzioni = "Options..."; | ||
| 1600 | stringaEsci = "Exit"; | ||
| 1601 | stringaImpossibileConfigurare = "Couldn't write to the configuration file.\nPlease report the bug to: sebastiano@luganega.org\n\nException:\n"; | ||
| 1602 | stringaLingua = "Lang"; | ||
| 1603 | stringaAnnulla = "Cancel"; | ||
| 1604 | stringaIt = "Italian"; | ||
| 1605 | stringaLa = "Latin"; | ||
| 1606 | stringaBL = "Belluno dialect"; | ||
| 1607 | stringaBV = "Venice dialect"; | ||
| 1608 | stringaEN = "English"; | ||
| 1609 | stringaModificaOpzioni = "Change options"; | ||
| 1610 | stringaInformazioni = "Information"; | ||
| 1611 | stringaInformazioni2 = "JBriscola is a briscola pc game written in java, meant\nand made by Sebastiano Tronto. The game is protected by the GNU/General public licence version 2 or later.\n\nJBriscola version" + version + "\nCopyright 2009 Sebastiano Tronto, license GNU/Gpl 2.0 or later\nE-mail: sebastiano@luganega.org"; | ||
| 1612 | stringaSuono = "Sound"; | ||
| 1613 | stringaPunteggio = "Score"; | ||
| 1614 | stringaSfondo = "Background"; | ||
| 1615 | stringaTasti = "Hot keys"; | ||
| 1616 | stringaAggiornamenti = "Check updates"; | ||
| 1617 | stringaTrucchi = "Cheats"; | ||
| 1618 | stringaInserisciCodice = "Insert cheat:"; | ||
| 1619 | stringaTruccoAttivato = "Cheat actived!"; | ||
| 1620 | stringaTruccoSbagliato = "Wrong cheat"; | ||
| 1621 | stringaCheCartaVuoi = "So what card do you want?"; | ||
| 1622 | stringaAggiornamentiSi = "Update available: "; | ||
| 1623 | stringaAggiornamentiNo = "No updates available"; | ||
| 1624 | stringaScarica = "You can get the latest version from the site\nhttp://porkynator.altervista.org/programmi.html"; | ||
| 1625 | stringaNoInternet = "Error: no internet connection"; | ||
| 1626 | stringaTasti2 = "1 Play the first card\n2 Play the second card\n3 Play the third card\nF1 Get this message\nF2 " + stringaNuovaPartita + "\nF3 " + stringaOpzioni + "\nF4 " + stringaPunteggio + "\nF5 " + stringaInformazioni + "\nF6 " + stringaAggiornamenti + "\nF7 " + stringaNuovaPartitaAiTrenta + "\nF8 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 1627 | } | ||
| 1628 | sound = ( soundString.equals( "suono=si" ) ); | ||
| 1629 | keys = ( keysString.equals( "tasti=si" ) ); | ||
| 1630 | color = new Color( r, g, b ); | ||
| 1631 | if ( frame != null ) { | ||
| 1632 | frame.pannello.repaint(); | ||
| 1633 | frame.pannello2.repaint(); | ||
| 1634 | frame.repaint(); | ||
| 1635 | } | ||
| 1636 | } | ||
| 1637 | } | ||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/OptionFrame.java b/JBriscola/all_versions/0.3/0.3.1/src/OptionFrame.java new file mode 100755 index 0000000..d89745b --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/OptionFrame.java | |||
| @@ -0,0 +1,169 @@ | |||
| 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.util.Formatter; | ||
| 23 | import javax.swing.*; | ||
| 24 | import java.awt.*; | ||
| 25 | import java.awt.event.*; | ||
| 26 | |||
| 27 | public class OptionFrame extends JFrame { | ||
| 28 | |||
| 29 | public static Main main = new Main(); | ||
| 30 | public static Formatter formatter; | ||
| 31 | public static JButton ok, annulla, scegliColore; | ||
| 32 | public static JLabel lingua, sfondo; | ||
| 33 | public static JComboBox selezionaLingua; | ||
| 34 | public static JCheckBox suono, tastiRapidi; | ||
| 35 | public static JPanel[] pannello = new JPanel[6]; | ||
| 36 | |||
| 37 | public OptionFrame() { | ||
| 38 | |||
| 39 | super( "JBriscola - " + main.stringaModificaOpzioni ); | ||
| 40 | |||
| 41 | ok = new JButton( "OK" ); | ||
| 42 | ok.addActionListener( new ActionListener() { | ||
| 43 | |||
| 44 | /* Quando le modifiche vengono confermate premendo ok, viene scritto | ||
| 45 | * il file di configurazione (o aggiornato) se possibile, e modificate | ||
| 46 | * le impostazioni attuali. */ | ||
| 47 | public void actionPerformed( ActionEvent e ) { | ||
| 48 | |||
| 49 | try { | ||
| 50 | formatter = new Formatter( "JBriscolaConfig.txt" ); | ||
| 51 | } catch ( Exception ex ) { | ||
| 52 | JOptionPane.showMessageDialog( OptionFrame.this, main.stringaImpossibileConfigurare + ex, "JBriscola - " + main.version, JOptionPane.ERROR_MESSAGE ); | ||
| 53 | } | ||
| 54 | |||
| 55 | String lang; | ||
| 56 | |||
| 57 | switch ( selezionaLingua.getSelectedIndex() ) { | ||
| 58 | case 0: | ||
| 59 | lang = "it"; | ||
| 60 | break; | ||
| 61 | case 1: | ||
| 62 | lang = "la"; | ||
| 63 | break; | ||
| 64 | case 2: | ||
| 65 | lang = "bl"; | ||
| 66 | break; | ||
| 67 | case 3: | ||
| 68 | lang = "bv"; | ||
| 69 | break; | ||
| 70 | case 4: | ||
| 71 | lang = "en"; | ||
| 72 | break; | ||
| 73 | default: | ||
| 74 | lang = "it"; | ||
| 75 | break; | ||
| 76 | } | ||
| 77 | |||
| 78 | String suonosiono, tastisiono; | ||
| 79 | |||
| 80 | if ( suono.isSelected() ) | ||
| 81 | suonosiono = "suono=si"; | ||
| 82 | else | ||
| 83 | suonosiono = "suono=no"; | ||
| 84 | if ( tastiRapidi.isSelected() ) | ||
| 85 | tastisiono = "tasti=si"; | ||
| 86 | else | ||
| 87 | tastisiono = "tasti=no"; | ||
| 88 | |||
| 89 | formatter.format( lang ); | ||
| 90 | formatter.format( "\n" ); | ||
| 91 | formatter.format( suonosiono ); | ||
| 92 | formatter.format( "\n" ); | ||
| 93 | formatter.format( tastisiono ); | ||
| 94 | formatter.format( "\n" ); | ||
| 95 | formatter.format( main.color.getRed() + " " + main.color.getGreen() + " " + main.color.getBlue() ); | ||
| 96 | formatter.close(); | ||
| 97 | |||
| 98 | main.settaOpzioni(); | ||
| 99 | |||
| 100 | OptionFrame.this.dispose(); | ||
| 101 | } | ||
| 102 | }); | ||
| 103 | |||
| 104 | annulla = new JButton( main.stringaAnnulla ); | ||
| 105 | annulla.addActionListener( new ActionListener() { | ||
| 106 | /* Se l'utente annulla viene chiusa la finestra senza fare nulla. */ | ||
| 107 | public void actionPerformed( ActionEvent e ) { | ||
| 108 | OptionFrame.this.dispose(); | ||
| 109 | } | ||
| 110 | }); | ||
| 111 | |||
| 112 | scegliColore = new JButton( " " ); | ||
| 113 | scegliColore.setBackground( main.color ); | ||
| 114 | scegliColore.addActionListener( new ActionListener() { | ||
| 115 | /* Permette di scegliere il colore dello sfondo. */ | ||
| 116 | public void actionPerformed( ActionEvent e ) { | ||
| 117 | Color colore = JColorChooser.showDialog( OptionFrame.this, "JBriscola " + main.version, main.color ); | ||
| 118 | if ( colore != null ) | ||
| 119 | main.color = colore; | ||
| 120 | OptionFrame.scegliColore.setBackground( main.color ); | ||
| 121 | } | ||
| 122 | } ); | ||
| 123 | |||
| 124 | /* Vengono impostati e disegnati i vari componenti. */ | ||
| 125 | lingua = new JLabel( main.stringaLingua ); | ||
| 126 | sfondo = new JLabel( main.stringaSfondo ); | ||
| 127 | String[] lingueDaSelezionare = { main.stringaIt, main.stringaLa, main.stringaBL, main.stringaBV, main.stringaEN }; | ||
| 128 | selezionaLingua = new JComboBox( lingueDaSelezionare ); | ||
| 129 | int linguaPreselezionata = 0; | ||
| 130 | |||
| 131 | if ( main.lang.equals( "it" ) ) | ||
| 132 | linguaPreselezionata = 0; | ||
| 133 | else if ( main.lang.equals( "la" ) ) | ||
| 134 | linguaPreselezionata = 1; | ||
| 135 | else if ( main.lang.equals( "bl" ) ) | ||
| 136 | linguaPreselezionata = 2; | ||
| 137 | else if ( main.lang.equals( "bv" ) ) | ||
| 138 | linguaPreselezionata = 3; | ||
| 139 | else if ( main.lang.equals( "en" ) ) | ||
| 140 | linguaPreselezionata = 4; | ||
| 141 | |||
| 142 | selezionaLingua.setSelectedIndex( linguaPreselezionata ); | ||
| 143 | suono = new JCheckBox( main.stringaSuono ); | ||
| 144 | suono.setSelected( main.sound ); | ||
| 145 | tastiRapidi = new JCheckBox( main.stringaTasti ); | ||
| 146 | tastiRapidi.setSelected( main.keys ); | ||
| 147 | |||
| 148 | pannello[0] = new JPanel( new GridLayout( 4, 1 ) ); | ||
| 149 | pannello[1] = new JPanel( new FlowLayout() ); | ||
| 150 | pannello[2] = new JPanel( new FlowLayout() ); | ||
| 151 | pannello[3] = new JPanel( new FlowLayout() ); | ||
| 152 | pannello[4] = new JPanel( new FlowLayout() ); | ||
| 153 | pannello[5] = new JPanel( new FlowLayout() ); | ||
| 154 | pannello[5].add( ok ); | ||
| 155 | pannello[5].add( annulla ); | ||
| 156 | pannello[4].add( sfondo ); | ||
| 157 | pannello[4].add( scegliColore ); | ||
| 158 | pannello[3].add( tastiRapidi ); | ||
| 159 | pannello[2].add( suono ); | ||
| 160 | pannello[1].add( lingua ); | ||
| 161 | pannello[1].add( selezionaLingua ); | ||
| 162 | pannello[0].add( pannello[1] ); | ||
| 163 | pannello[0].add( pannello[2] ); | ||
| 164 | pannello[0].add( pannello[3] ); | ||
| 165 | pannello[0].add( pannello[4] ); | ||
| 166 | add( pannello[0], BorderLayout.CENTER ); | ||
| 167 | add( pannello[5], BorderLayout.SOUTH ); | ||
| 168 | } | ||
| 169 | } | ||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/Pannello.java b/JBriscola/all_versions/0.3/0.3.1/src/Pannello.java new file mode 100755 index 0000000..ca9e9c6 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/Pannello.java | |||
| @@ -0,0 +1,88 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | |||
| 25 | /* Questa classe dispone semplicemente le carte | ||
| 26 | * sulla finestra e imposta la sfondo. */ | ||
| 27 | public class Pannello extends JPanel { | ||
| 28 | |||
| 29 | public static Main main; | ||
| 30 | |||
| 31 | public static Color color; | ||
| 32 | |||
| 33 | public Pannello() { } | ||
| 34 | |||
| 35 | public void paint( Graphics g ) { | ||
| 36 | |||
| 37 | super.paint( g ); | ||
| 38 | |||
| 39 | setBackground( main.color ); | ||
| 40 | |||
| 41 | if ( main.frame.ultimaCarta != null ) | ||
| 42 | main.frame.ultimaCarta.paintIcon( this, g, 50, 180 ); | ||
| 43 | |||
| 44 | if ( main.frame.mazzo ) | ||
| 45 | main.frame.retro2.paintIcon( this, g, 17, 256 ); | ||
| 46 | |||
| 47 | if ( main.carteScoperte ) { | ||
| 48 | |||
| 49 | if ( main.frame.carteCPU[0] != null ) | ||
| 50 | main.frame.carteCPU[0].paintIcon( this, g, 230, 5 ); | ||
| 51 | |||
| 52 | if ( main.frame.carteCPU[1] != null ) | ||
| 53 | main.frame.carteCPU[1].paintIcon( this, g, 300, 5 ); | ||
| 54 | |||
| 55 | if ( main.frame.carteCPU[2] != null ) | ||
| 56 | main.frame.carteCPU[2].paintIcon( this, g, 370, 5 ); | ||
| 57 | |||
| 58 | } else { | ||
| 59 | |||
| 60 | if ( main.frame.carteCPU[0] != null ) | ||
| 61 | main.frame.retro1.paintIcon( this, g, 230, 5 ); | ||
| 62 | |||
| 63 | if ( main.frame.carteCPU[1] != null ) | ||
| 64 | main.frame.retro1.paintIcon( this, g, 300, 5 ); | ||
| 65 | |||
| 66 | if ( main.frame.carteCPU[2] != null ) | ||
| 67 | main.frame.retro1.paintIcon( this, g, 370, 5 ); | ||
| 68 | |||
| 69 | } | ||
| 70 | |||
| 71 | if ( main.frame.carteInMano[0] != null ) | ||
| 72 | main.frame.carteInMano[0].paintIcon( this, g, 230, 340 ); | ||
| 73 | |||
| 74 | if ( main.frame.carteInMano[1] != null ) | ||
| 75 | main.frame.carteInMano[1].paintIcon( this, g, 300, 340 ); | ||
| 76 | |||
| 77 | if ( main.frame.carteInMano[2] != null ) | ||
| 78 | main.frame.carteInMano[2].paintIcon( this, g, 370, 340 ); | ||
| 79 | |||
| 80 | if ( main.frame.giocata[0] != null ) | ||
| 81 | main.frame.giocata[0].paintIcon( this, g, 250, 200 ); | ||
| 82 | |||
| 83 | if ( main.frame.giocata[1] != null ) | ||
| 84 | main.frame.giocata[1].paintIcon( this, g, 325, 150 ); | ||
| 85 | |||
| 86 | } | ||
| 87 | } | ||
| 88 | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/1-1.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/1-1.jpg new file mode 100755 index 0000000..ae43510 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/1-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/1-2.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/1-2.jpg new file mode 100755 index 0000000..3f7c75a --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/1-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/1-3.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/1-3.jpg new file mode 100755 index 0000000..9e1ead7 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/1-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/1-4.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/1-4.jpg new file mode 100755 index 0000000..710f879 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/1-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/10-1.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/10-1.jpg new file mode 100755 index 0000000..9aba45a --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/10-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/10-2.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/10-2.jpg new file mode 100755 index 0000000..037eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/10-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/10-3.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/10-3.jpg new file mode 100755 index 0000000..8780b72 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/10-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/10-4.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/10-4.jpg new file mode 100755 index 0000000..587dc0f --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/10-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/2-1.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/2-1.jpg new file mode 100755 index 0000000..5dcb7db --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/2-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/2-2.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/2-2.jpg new file mode 100755 index 0000000..ea9eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/2-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/2-3.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/2-3.jpg new file mode 100755 index 0000000..8cb22dd --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/2-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/2-4.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/2-4.jpg new file mode 100755 index 0000000..b3e7898 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/2-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/3-1.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/3-1.jpg new file mode 100755 index 0000000..dcb435c --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/3-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/3-2.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/3-2.jpg new file mode 100755 index 0000000..1e5b6ec --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/3-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/3-3.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/3-3.jpg new file mode 100755 index 0000000..9202cfe --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/3-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/3-4.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/3-4.jpg new file mode 100755 index 0000000..5436a8d --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/3-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/4-1.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/4-1.jpg new file mode 100755 index 0000000..3bab6d5 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/4-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/4-2.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/4-2.jpg new file mode 100755 index 0000000..b4901a6 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/4-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/4-3.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/4-3.jpg new file mode 100755 index 0000000..d754ad8 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/4-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/4-4.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/4-4.jpg new file mode 100755 index 0000000..3a54b96 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/4-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/5-1.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/5-1.jpg new file mode 100755 index 0000000..3f7ba1f --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/5-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/5-2.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/5-2.jpg new file mode 100755 index 0000000..fcacb75 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/5-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/5-3.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/5-3.jpg new file mode 100755 index 0000000..ce32f9f --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/5-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/5-4.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/5-4.jpg new file mode 100755 index 0000000..b86b09a --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/5-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/6-1.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/6-1.jpg new file mode 100755 index 0000000..f90cd81 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/6-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/6-2.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/6-2.jpg new file mode 100755 index 0000000..cf2a67a --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/6-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/6-3.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/6-3.jpg new file mode 100755 index 0000000..2cd2fe2 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/6-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/6-4.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/6-4.jpg new file mode 100755 index 0000000..73f410f --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/6-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/7-1.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/7-1.jpg new file mode 100755 index 0000000..08cd397 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/7-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/7-2.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/7-2.jpg new file mode 100755 index 0000000..a168ff8 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/7-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/7-3.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/7-3.jpg new file mode 100755 index 0000000..5cda411 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/7-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/7-4.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/7-4.jpg new file mode 100755 index 0000000..5d63229 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/7-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/8-1.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/8-1.jpg new file mode 100755 index 0000000..a6faa7b --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/8-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/8-2.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/8-2.jpg new file mode 100755 index 0000000..0d9edbb --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/8-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/8-3.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/8-3.jpg new file mode 100755 index 0000000..91f8354 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/8-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/8-4.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/8-4.jpg new file mode 100755 index 0000000..cc0089c --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/8-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/9-1.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/9-1.jpg new file mode 100755 index 0000000..be9c6bf --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/9-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/9-2.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/9-2.jpg new file mode 100755 index 0000000..e25da4c --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/9-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/9-3.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/9-3.jpg new file mode 100755 index 0000000..cd384f8 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/9-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/9-4.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/9-4.jpg new file mode 100755 index 0000000..441210e --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/9-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/Thumbs.db b/JBriscola/all_versions/0.3/0.3.1/src/img/Thumbs.db new file mode 100755 index 0000000..d9b6bc5 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/Thumbs.db | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/carte.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/carte.jpg new file mode 100755 index 0000000..838ffac --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/carte.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/retro1.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/retro1.jpg new file mode 100755 index 0000000..9651b06 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/retro1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/img/retro2.jpg b/JBriscola/all_versions/0.3/0.3.1/src/img/retro2.jpg new file mode 100755 index 0000000..c5d3925 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/img/retro2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/sounds/0.wav b/JBriscola/all_versions/0.3/0.3.1/src/sounds/0.wav new file mode 100755 index 0000000..67d9abd --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/sounds/0.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/sounds/1.wav b/JBriscola/all_versions/0.3/0.3.1/src/sounds/1.wav new file mode 100755 index 0000000..9357c97 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/sounds/1.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/sounds/2.wav b/JBriscola/all_versions/0.3/0.3.1/src/sounds/2.wav new file mode 100755 index 0000000..92b1541 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/sounds/2.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/sounds/3.wav b/JBriscola/all_versions/0.3/0.3.1/src/sounds/3.wav new file mode 100755 index 0000000..45a6e42 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/sounds/3.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/sounds/4.wav b/JBriscola/all_versions/0.3/0.3.1/src/sounds/4.wav new file mode 100755 index 0000000..1f7ec90 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/sounds/4.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/sounds/5.wav b/JBriscola/all_versions/0.3/0.3.1/src/sounds/5.wav new file mode 100755 index 0000000..3627f96 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/sounds/5.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/sounds/pareggio.wav b/JBriscola/all_versions/0.3/0.3.1/src/sounds/pareggio.wav new file mode 100755 index 0000000..ff978e6 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/sounds/pareggio.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/sounds/perso.wav b/JBriscola/all_versions/0.3/0.3.1/src/sounds/perso.wav new file mode 100755 index 0000000..a454ba4 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/sounds/perso.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.1/src/sounds/vinto.wav b/JBriscola/all_versions/0.3/0.3.1/src/sounds/vinto.wav new file mode 100755 index 0000000..a6f3ac5 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.1/src/sounds/vinto.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/CartePassateFrame.java b/JBriscola/all_versions/0.3/0.3.2/src/CartePassateFrame.java new file mode 100755 index 0000000..c1d90ef --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/CartePassateFrame.java | |||
| @@ -0,0 +1,39 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2009-2010 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 javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | |||
| 25 | public class CartePassateFrame extends JFrame { | ||
| 26 | |||
| 27 | public static Main main = new Main(); | ||
| 28 | public static PannelloCartePassate pannelloCP = new PannelloCartePassate(); | ||
| 29 | |||
| 30 | CartePassateFrame() { | ||
| 31 | super( "JBriscola - " + main.stringaCartePassate ); | ||
| 32 | pannelloCP.repaint(); | ||
| 33 | add( pannelloCP ); | ||
| 34 | } | ||
| 35 | |||
| 36 | } | ||
| 37 | |||
| 38 | |||
| 39 | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/Frame.java b/JBriscola/all_versions/0.3/0.3.2/src/Frame.java new file mode 100755 index 0000000..c211cab --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/Frame.java | |||
| @@ -0,0 +1,552 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2009-2010 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 javax.swing.*; | ||
| 23 | import javax.sound.sampled.*; | ||
| 24 | import java.io.*; | ||
| 25 | import java.net.*; | ||
| 26 | import java.awt.*; | ||
| 27 | import java.awt.event.*; | ||
| 28 | |||
| 29 | public class Frame extends JFrame { | ||
| 30 | |||
| 31 | /* Booleana per determinare se disegnare il mazzo di carte o no (se | ||
| 32 | * è l'ultima mano). */ | ||
| 33 | public static boolean mazzo; | ||
| 34 | |||
| 35 | public static Main main; | ||
| 36 | |||
| 37 | /* Menu, bottoni, pannelli e componenti vari. */ | ||
| 38 | public static Pannello pannello; | ||
| 39 | public static JPanel pannello2; | ||
| 40 | public static JButton button; | ||
| 41 | public static JMenuBar barraMenu; | ||
| 42 | public static JMenu file, puntoInterrogativo; | ||
| 43 | public static JMenuItem nuovaPartita, nuovaPartitaAiTrenta, opzioni, esci, informazioni, punti, cartePassate, aggiornamenti, trucchi, tastiRapidi, briscola; | ||
| 44 | |||
| 45 | /* Immagini delle carte. */ | ||
| 46 | public static ImageIcon retro1, retro2, ultimaCarta; | ||
| 47 | public static ImageIcon[] giocata = new ImageIcon[2]; | ||
| 48 | public static ImageIcon[] carteInMano = new ImageIcon[3]; | ||
| 49 | public static ImageIcon[] carteCPU = new ImageIcon[3]; | ||
| 50 | public static ImageIcon[] arrayCarteMescolate = new ImageIcon[40]; | ||
| 51 | public static ImageIcon[] arrayCartePassate = new ImageIcon[40]; | ||
| 52 | public static ImageIcon[][] arrayCarte = new ImageIcon[10][4]; | ||
| 53 | |||
| 54 | public Frame() { | ||
| 55 | |||
| 56 | super( "Tronto's JBriscola " + main.version ); | ||
| 57 | |||
| 58 | mazzo = true; | ||
| 59 | main = new Main(); | ||
| 60 | pannello = new Pannello(); | ||
| 61 | pannello2 = new JPanel( new FlowLayout() ); | ||
| 62 | |||
| 63 | button = new JButton( main.stringaBottonePrendi ); | ||
| 64 | button.addActionListener( new ActionListener() { | ||
| 65 | |||
| 66 | /* Quando viene premuto il bottone per prendere/lasciare le carte, | ||
| 67 | * valuta innanzitutto se il giocatore ha giocato, poi a chi | ||
| 68 | * darle ed eventualmente, se è finita la partita, a caricare | ||
| 69 | * il suono adatto. */ | ||
| 70 | public void actionPerformed( ActionEvent e ) { | ||
| 71 | |||
| 72 | arrayCartePassate[main.mano*2] = giocata[0]; | ||
| 73 | arrayCartePassate[main.mano*2+1] = giocata[1]; | ||
| 74 | |||
| 75 | if ( giocata[0] != null && giocata[1] != null ) | ||
| 76 | main.mano++; | ||
| 77 | |||
| 78 | try { | ||
| 79 | main.chiPrende(); | ||
| 80 | } catch ( Exception ex ) { | ||
| 81 | /* Avvisa di giocare una carta. */ | ||
| 82 | JOptionPane.showMessageDialog( Frame.this, main.stringaPrimaGioca, "JBriscola " + main.version, JOptionPane.WARNING_MESSAGE ); | ||
| 83 | } | ||
| 84 | |||
| 85 | /* Avvisa che si è arrivati alla quartultima mano. */ | ||
| 86 | if ( main.mano == 16 ) | ||
| 87 | JOptionPane.showMessageDialog( Frame.this, main.stringaUltime4, "JBriscola " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 88 | |||
| 89 | /* Non disegna più la briscola e il mazzo se sono già state | ||
| 90 | * pescate tutte le carte. */ | ||
| 91 | if ( main.mano == 17 ) { | ||
| 92 | mazzo = false; | ||
| 93 | ultimaCarta = null; | ||
| 94 | pannello.repaint(); | ||
| 95 | Frame.this.repaint(); | ||
| 96 | } | ||
| 97 | |||
| 98 | /* Mostra il punteggio e carica i suoni se è finita la partita. */ | ||
| 99 | if ( main.mano == 20 || | ||
| 100 | ( main.aiTrenta && | ||
| 101 | ( ( main.punteggio >= 30 || main.punteggioCPU >= 30 ) ) ) ) { | ||
| 102 | |||
| 103 | String titolo = ""; | ||
| 104 | String suonoFinale = ""; | ||
| 105 | |||
| 106 | if ( main.punteggio > main.punteggioCPU ) { | ||
| 107 | titolo = main.stringaVinto; | ||
| 108 | suonoFinale = "sounds/perso.wav"; | ||
| 109 | } | ||
| 110 | if ( main.punteggio < main.punteggioCPU ) { | ||
| 111 | titolo = main.stringaPerso; | ||
| 112 | suonoFinale = "sounds/vinto.wav"; | ||
| 113 | } | ||
| 114 | if ( main.punteggio == main.punteggioCPU ) { | ||
| 115 | titolo = main.stringaPareggio; | ||
| 116 | suonoFinale = "sounds/pareggio.wav"; | ||
| 117 | } | ||
| 118 | |||
| 119 | if ( main.sound ) { | ||
| 120 | try { | ||
| 121 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( ClassLoader.getSystemResource( suonoFinale ) ); | ||
| 122 | AudioInputStream ais = AudioSystem.getAudioInputStream( ClassLoader.getSystemResource( suonoFinale ) ); | ||
| 123 | AudioFormat af = aff.getFormat(); | ||
| 124 | DataLine.Info info = new DataLine.Info( Clip.class, ais.getFormat(), ( (int) ais.getFrameLength() * af.getFrameSize() ) ); | ||
| 125 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 126 | ol.open(ais); | ||
| 127 | ol.loop( 0 ); | ||
| 128 | } catch ( Exception ex ) { | ||
| 129 | System.err.println( e ); | ||
| 130 | } | ||
| 131 | } | ||
| 132 | |||
| 133 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, titolo, JOptionPane.INFORMATION_MESSAGE ); | ||
| 134 | |||
| 135 | main.pulisciTavolo(); | ||
| 136 | |||
| 137 | } | ||
| 138 | if ( main.toccaAllaCPU ) | ||
| 139 | if ( main.aiTrenta ) | ||
| 140 | main.giocaCPUAiTrenta(); | ||
| 141 | else | ||
| 142 | main.giocaCPU(); | ||
| 143 | } | ||
| 144 | } ); | ||
| 145 | button.addKeyListener( new KeyAdapter() { | ||
| 146 | /* Aggiunge il keyListener per le scorciatoie da tastiera. Dato | ||
| 147 | * che il bottone prendi/lascia è l'unico componente effettivo | ||
| 148 | * della finestra, avrà obbligatoriamente il focus ed è necessario | ||
| 149 | * che sia lui a gestire gli eventi della tastiera. */ | ||
| 150 | public void keyReleased( KeyEvent key ) { | ||
| 151 | |||
| 152 | if ( main.keys ) { | ||
| 153 | switch ( key.getKeyCode() ) { | ||
| 154 | case KeyEvent.VK_1: | ||
| 155 | if ( mettiCarta( 231, 500 ) ) { | ||
| 156 | if ( !main.CPUHaGiocato ) | ||
| 157 | if ( main.aiTrenta ) | ||
| 158 | main.giocaCPUAiTrenta(); | ||
| 159 | else | ||
| 160 | main.giocaCPU(); | ||
| 161 | } | ||
| 162 | break; | ||
| 163 | |||
| 164 | case KeyEvent.VK_2: | ||
| 165 | if ( mettiCarta( 301, 500 ) ) { | ||
| 166 | if ( !main.CPUHaGiocato ) | ||
| 167 | if ( main.aiTrenta ) | ||
| 168 | main.giocaCPUAiTrenta(); | ||
| 169 | else | ||
| 170 | main.giocaCPU(); | ||
| 171 | } | ||
| 172 | break; | ||
| 173 | |||
| 174 | case KeyEvent.VK_3: | ||
| 175 | if ( mettiCarta( 371, 500 ) ) { | ||
| 176 | if ( !main.CPUHaGiocato ) | ||
| 177 | if ( main.aiTrenta ) | ||
| 178 | main.giocaCPUAiTrenta(); | ||
| 179 | else | ||
| 180 | main.giocaCPU(); | ||
| 181 | } | ||
| 182 | break; | ||
| 183 | |||
| 184 | case KeyEvent.VK_F1: | ||
| 185 | JOptionPane.showMessageDialog( Frame.this, main.stringaTasti2, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 186 | break; | ||
| 187 | |||
| 188 | case KeyEvent.VK_F2: | ||
| 189 | if ( main.mano == 20 ) { | ||
| 190 | main.aiTrenta = false; | ||
| 191 | main.mischia(); | ||
| 192 | pannello.repaint(); | ||
| 193 | repaint(); | ||
| 194 | } | ||
| 195 | else { | ||
| 196 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 197 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 198 | main.aiTrenta = false; | ||
| 199 | main.mischia(); | ||
| 200 | pannello.repaint(); | ||
| 201 | repaint(); | ||
| 202 | } | ||
| 203 | } | ||
| 204 | break; | ||
| 205 | |||
| 206 | case KeyEvent.VK_F3: | ||
| 207 | OptionFrame optionFrame = new OptionFrame(); | ||
| 208 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 209 | optionFrame.setResizable( false ); | ||
| 210 | optionFrame.setAlwaysOnTop( true ); | ||
| 211 | optionFrame.setSize( 300, 200 ); | ||
| 212 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 213 | optionFrame.setVisible( true ); | ||
| 214 | break; | ||
| 215 | |||
| 216 | case KeyEvent.VK_F4: | ||
| 217 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, main.stringaPunteggio, JOptionPane.INFORMATION_MESSAGE ); | ||
| 218 | break; | ||
| 219 | |||
| 220 | case KeyEvent.VK_F5: | ||
| 221 | CartePassateFrame cartePassateFrame = new CartePassateFrame(); | ||
| 222 | cartePassateFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 223 | cartePassateFrame.setResizable( false ); | ||
| 224 | cartePassateFrame.setAlwaysOnTop( true ); | ||
| 225 | cartePassateFrame.setSize( 700, 560 ); | ||
| 226 | cartePassateFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 700) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - 560) / 2); | ||
| 227 | cartePassateFrame.setVisible( true ); | ||
| 228 | break; | ||
| 229 | |||
| 230 | case KeyEvent.VK_F6: | ||
| 231 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 232 | break; | ||
| 233 | |||
| 234 | case KeyEvent.VK_F7: | ||
| 235 | String latest = main.version; | ||
| 236 | try { | ||
| 237 | URL latestIs = new URL( "http://porkynator.altervista.org/jbriscola-latest.is" ); | ||
| 238 | BufferedReader latestIsReader = new BufferedReader( new InputStreamReader( latestIs.openStream() ) ); | ||
| 239 | latest = latestIsReader.readLine(); | ||
| 240 | } catch ( Exception ex ) { | ||
| 241 | JOptionPane.showMessageDialog( Frame.this, main.stringaNoInternet, "JBriscola - " + main.version, JOptionPane.ERROR_MESSAGE ); | ||
| 242 | } | ||
| 243 | if ( latest.equals( main.version ) ) | ||
| 244 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiNo, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 245 | else | ||
| 246 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiSi + "\n" + main.version + " ==> " + latest + "\n\n" + main.stringaScarica, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 247 | break; | ||
| 248 | |||
| 249 | case KeyEvent.VK_F8: | ||
| 250 | if ( main.mano == 20 ) { | ||
| 251 | main.aiTrenta = true; | ||
| 252 | main.mischia(); | ||
| 253 | pannello.repaint(); | ||
| 254 | repaint(); | ||
| 255 | } | ||
| 256 | else { | ||
| 257 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 258 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 259 | main.aiTrenta = true; | ||
| 260 | main.mischia(); | ||
| 261 | pannello.repaint(); | ||
| 262 | repaint(); | ||
| 263 | } | ||
| 264 | } | ||
| 265 | break; | ||
| 266 | |||
| 267 | case KeyEvent.VK_F9: | ||
| 268 | main.trucco( JOptionPane.showInputDialog( Frame.this, main.stringaInserisciCodice, "JBriscola - " + main.version, JOptionPane.PLAIN_MESSAGE ) ); | ||
| 269 | break; | ||
| 270 | |||
| 271 | case KeyEvent.VK_Q: | ||
| 272 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 273 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 274 | Frame.this.dispose(); | ||
| 275 | break; | ||
| 276 | } | ||
| 277 | } | ||
| 278 | } | ||
| 279 | } ); | ||
| 280 | |||
| 281 | barraMenu = new JMenuBar(); | ||
| 282 | |||
| 283 | file = new JMenu( "File" ); | ||
| 284 | |||
| 285 | nuovaPartita = new JMenuItem( main.stringaNuovaPartita ); | ||
| 286 | nuovaPartita.addActionListener( new ActionListener() { | ||
| 287 | /* Avvia una nuova partita, chiedendo prima conferma se ce n'è | ||
| 288 | * già una in corso. */ | ||
| 289 | public void actionPerformed( ActionEvent e ) { | ||
| 290 | if ( main.mano == 20 ) { | ||
| 291 | main.aiTrenta = false; | ||
| 292 | main.mischia(); | ||
| 293 | pannello.repaint(); | ||
| 294 | repaint(); | ||
| 295 | } | ||
| 296 | |||
| 297 | else { | ||
| 298 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 299 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 300 | main.aiTrenta = false; | ||
| 301 | main.mischia(); | ||
| 302 | pannello.repaint(); | ||
| 303 | repaint(); | ||
| 304 | } | ||
| 305 | } | ||
| 306 | } | ||
| 307 | }); | ||
| 308 | |||
| 309 | nuovaPartitaAiTrenta = new JMenuItem( main.stringaNuovaPartitaAiTrenta ); | ||
| 310 | nuovaPartitaAiTrenta.addActionListener( new ActionListener() { | ||
| 311 | /* Avvia una nuova partita ai 30, chiedendo prima conferma se | ||
| 312 | * ce n'è già una in corso. */ | ||
| 313 | public void actionPerformed( ActionEvent e ) { | ||
| 314 | if ( main.mano == 20 ) { | ||
| 315 | main.aiTrenta = true; | ||
| 316 | main.mischia(); | ||
| 317 | pannello.repaint(); | ||
| 318 | repaint(); | ||
| 319 | } | ||
| 320 | |||
| 321 | else { | ||
| 322 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 323 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 324 | main.aiTrenta = true; | ||
| 325 | main.mischia(); | ||
| 326 | pannello.repaint(); | ||
| 327 | repaint(); | ||
| 328 | } | ||
| 329 | } | ||
| 330 | } | ||
| 331 | }); | ||
| 332 | |||
| 333 | trucchi = new JMenuItem( main.stringaTrucchi ); | ||
| 334 | trucchi.addActionListener( new ActionListener() { | ||
| 335 | public void actionPerformed( ActionEvent e ) { | ||
| 336 | /* Esegue il trucco */ | ||
| 337 | main.trucco( JOptionPane.showInputDialog( Frame.this, main.stringaInserisciCodice, "JBriscola - " + main.version, JOptionPane.PLAIN_MESSAGE ) ); | ||
| 338 | } | ||
| 339 | } ); | ||
| 340 | |||
| 341 | opzioni = new JMenuItem( main.stringaOpzioni ); | ||
| 342 | opzioni.addActionListener( new ActionListener() { | ||
| 343 | /* Apre una OptionFrame per modificare le opzioni. */ | ||
| 344 | public void actionPerformed( ActionEvent e ) { | ||
| 345 | |||
| 346 | OptionFrame optionFrame = new OptionFrame(); | ||
| 347 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 348 | optionFrame.setResizable( false ); | ||
| 349 | optionFrame.setAlwaysOnTop( true ); | ||
| 350 | optionFrame.setSize( 300, 200 ); | ||
| 351 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 352 | optionFrame.setVisible( true ); | ||
| 353 | } | ||
| 354 | }); | ||
| 355 | |||
| 356 | esci = new JMenuItem( main.stringaEsci ); | ||
| 357 | esci.addActionListener( new ActionListener() { | ||
| 358 | /* Ciede conferma prima di uscire. */ | ||
| 359 | public void actionPerformed( ActionEvent e ) { | ||
| 360 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 361 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 362 | Frame.this.dispose(); | ||
| 363 | } | ||
| 364 | }); | ||
| 365 | |||
| 366 | file.add( nuovaPartita ); | ||
| 367 | file.add( nuovaPartitaAiTrenta ); | ||
| 368 | file.add( trucchi ); | ||
| 369 | file.add( opzioni ); | ||
| 370 | file.addSeparator(); | ||
| 371 | file.add( esci ); | ||
| 372 | |||
| 373 | puntoInterrogativo = new JMenu( "?" ); | ||
| 374 | |||
| 375 | informazioni = new JMenuItem( main.stringaInformazioni ); | ||
| 376 | informazioni.addActionListener( new ActionListener() { | ||
| 377 | /* Visualizza le informazioni. */ | ||
| 378 | public void actionPerformed( ActionEvent e ) { | ||
| 379 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 380 | } | ||
| 381 | } ); | ||
| 382 | |||
| 383 | tastiRapidi = new JMenuItem( main.stringaTasti ); | ||
| 384 | tastiRapidi.addActionListener( new ActionListener() { | ||
| 385 | /* Visualizza i tasti rapidi. */ | ||
| 386 | public void actionPerformed( ActionEvent e ) { | ||
| 387 | JOptionPane.showMessageDialog( Frame.this, main.stringaTasti2, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 388 | } | ||
| 389 | } ); | ||
| 390 | |||
| 391 | briscola = new JMenuItem( main.stringaBriscola ); | ||
| 392 | briscola.addActionListener( new ActionListener() { | ||
| 393 | /* Visualizza il seme di briscola corrente. */ | ||
| 394 | public void actionPerformed( ActionEvent e ) { | ||
| 395 | JOptionPane.showMessageDialog( Frame.this, main.stringaBriscola + ": " + main.semi[main.semeBriscola], "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 396 | } | ||
| 397 | }); | ||
| 398 | |||
| 399 | punti = new JMenuItem( main.stringaPunteggio ); | ||
| 400 | punti.addActionListener( new ActionListener() { | ||
| 401 | /* Visualizza il punteggio. */ | ||
| 402 | public void actionPerformed( ActionEvent e ) { | ||
| 403 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, main.stringaPunteggio, JOptionPane.INFORMATION_MESSAGE ); | ||
| 404 | } | ||
| 405 | } ); | ||
| 406 | |||
| 407 | cartePassate = new JMenuItem( main.stringaCartePassate ); | ||
| 408 | cartePassate.addActionListener( new ActionListener() { | ||
| 409 | /*Visualizza le carte passate*/ | ||
| 410 | public void actionPerformed( ActionEvent e ) { | ||
| 411 | CartePassateFrame cartePassateFrame = new CartePassateFrame(); | ||
| 412 | cartePassateFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 413 | cartePassateFrame.setResizable( false ); | ||
| 414 | cartePassateFrame.setAlwaysOnTop( true ); | ||
| 415 | cartePassateFrame.setSize( 700, 560 ); | ||
| 416 | cartePassateFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 700) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - 560) / 2); | ||
| 417 | cartePassateFrame.setVisible( true ); | ||
| 418 | } | ||
| 419 | } ); | ||
| 420 | |||
| 421 | aggiornamenti = new JMenuItem( main.stringaAggiornamenti ); | ||
| 422 | aggiornamenti.addActionListener( new ActionListener() { | ||
| 423 | /* Cerca aggiornamenti sul sito http://porkynator.altervista.org, | ||
| 424 | * confrontando la versione del programma con quella scritta nel | ||
| 425 | * file jbriscola-latest.is (online). */ | ||
| 426 | public void actionPerformed( ActionEvent e ) { | ||
| 427 | String latest = main.version; | ||
| 428 | try { | ||
| 429 | URL latestIs = new URL( "http://porkynator.altervista.org/jbriscola-latest.is" ); | ||
| 430 | BufferedReader latestIsReader = new BufferedReader( new InputStreamReader( latestIs.openStream() ) ); | ||
| 431 | latest = latestIsReader.readLine(); | ||
| 432 | } catch ( Exception ex ) { | ||
| 433 | JOptionPane.showMessageDialog( Frame.this, main.stringaNoInternet, "JBriscola - " + main.version, JOptionPane.ERROR_MESSAGE ); | ||
| 434 | } | ||
| 435 | if ( latest.equals( main.version ) ) | ||
| 436 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiNo, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 437 | else | ||
| 438 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiSi + "\n" + main.version + " ==> " + latest + "\n\n" + main.stringaScarica, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 439 | } | ||
| 440 | } ); | ||
| 441 | |||
| 442 | puntoInterrogativo.add( punti ); | ||
| 443 | puntoInterrogativo.add( cartePassate ); | ||
| 444 | puntoInterrogativo.add( briscola ); | ||
| 445 | puntoInterrogativo.add( tastiRapidi ); | ||
| 446 | puntoInterrogativo.add( informazioni ); | ||
| 447 | puntoInterrogativo.add( aggiornamenti ); | ||
| 448 | |||
| 449 | barraMenu.add( file ); | ||
| 450 | barraMenu.add( puntoInterrogativo ); | ||
| 451 | |||
| 452 | setJMenuBar( barraMenu ); | ||
| 453 | |||
| 454 | /* Inizializza le immagini del retro delle carte. */ | ||
| 455 | retro1 = new ImageIcon( ClassLoader.getSystemResource( "img/retro1.jpg" ) ); | ||
| 456 | retro2 = new ImageIcon( ClassLoader.getSystemResource( "img/retro2.jpg" ) ); | ||
| 457 | |||
| 458 | /* Inizializza tutte le immagini delle carte scorrendo l'array bidimensionale. */ | ||
| 459 | for (int i = 0; i < 10; i++) | ||
| 460 | for (int j = 0; j < 4; j++) | ||
| 461 | arrayCarte[i][j] = new ImageIcon( ClassLoader.getSystemResource( "img/" + (i+1) + "-" + (j+1) + ".jpg" ) ); | ||
| 462 | |||
| 463 | /* Mischia le carte. */ | ||
| 464 | main.mischia(); | ||
| 465 | |||
| 466 | /* Aggiunge i vari componenti. */ | ||
| 467 | pannello2.add( button ); | ||
| 468 | setLayout( new BorderLayout() ); | ||
| 469 | add( pannello, BorderLayout.CENTER ); | ||
| 470 | add( pannello2, BorderLayout.SOUTH ); | ||
| 471 | |||
| 472 | /* Chiama il metodo mettiCarta se l'utente clicca. */ | ||
| 473 | addMouseListener( | ||
| 474 | new MouseAdapter() { | ||
| 475 | public void mouseClicked ( MouseEvent e ) { | ||
| 476 | if ( mettiCarta( e.getX(), e.getY() ) ) { | ||
| 477 | if ( !main.CPUHaGiocato ) | ||
| 478 | if ( main.aiTrenta ) | ||
| 479 | main.giocaCPUAiTrenta(); | ||
| 480 | else | ||
| 481 | main.giocaCPU(); | ||
| 482 | } | ||
| 483 | } | ||
| 484 | } | ||
| 485 | ); | ||
| 486 | |||
| 487 | /* Chiede conferma prima di uscire quando viene chiusa la finestra. */ | ||
| 488 | addWindowListener( | ||
| 489 | new WindowAdapter() { | ||
| 490 | public void windowClosing( WindowEvent e ) { | ||
| 491 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 492 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 493 | System.exit( 0 ); | ||
| 494 | } | ||
| 495 | } | ||
| 496 | ); | ||
| 497 | } | ||
| 498 | |||
| 499 | /* Se il giocatore ha cliccato su una carta la gioca e riproduce un suono casuale. */ | ||
| 500 | public boolean mettiCarta( int x, int y ) { | ||
| 501 | |||
| 502 | if ( !main.toccaAllaCPU && giocata[0] == null ) { | ||
| 503 | if ( main.sound && | ||
| 504 | ( ( x > 230 && x < 290 && y > 340 && y < 566 && carteInMano[0] != null ) || | ||
| 505 | ( x > 300 && x < 360 && y > 340 && y < 566 && carteInMano[1] != null ) || | ||
| 506 | ( x > 370 && x < 430 && y > 340 && y < 566 && carteInMano[2] != null ) ) ) { | ||
| 507 | try { | ||
| 508 | |||
| 509 | double a = Math.random() * 6; | ||
| 510 | int i = (int) a; | ||
| 511 | |||
| 512 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( ClassLoader.getSystemResource("sounds/" + i + ".wav") ); | ||
| 513 | AudioInputStream ais = AudioSystem.getAudioInputStream( ClassLoader.getSystemResource("sounds/" + i + ".wav") ); | ||
| 514 | AudioFormat af = aff.getFormat(); | ||
| 515 | DataLine.Info info = new DataLine.Info( Clip.class, ais.getFormat(), ( (int) ais.getFrameLength() * af.getFrameSize() ) ); | ||
| 516 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 517 | |||
| 518 | ol.open(ais); | ||
| 519 | ol.loop( 0 ); | ||
| 520 | |||
| 521 | } catch ( Exception e ) { | ||
| 522 | System.err.println( e ); | ||
| 523 | } | ||
| 524 | } | ||
| 525 | |||
| 526 | if ( x > 230 && x < 290 && y > 340 && y < 566 && carteInMano[0] != null ) { | ||
| 527 | giocata[0] = carteInMano[0]; | ||
| 528 | carteInMano[0] = null; | ||
| 529 | pannello.repaint(); | ||
| 530 | return true; | ||
| 531 | } | ||
| 532 | |||
| 533 | if ( x > 300 && x < 360 && y > 340 && y < 566 && carteInMano[1] != null ) { | ||
| 534 | giocata[0] = carteInMano[1]; | ||
| 535 | carteInMano[1] = null; | ||
| 536 | pannello.repaint(); | ||
| 537 | return true; | ||
| 538 | } | ||
| 539 | |||
| 540 | if ( x > 370 && x < 430 && y > 340 && y < 566 && carteInMano[2] != null ) { | ||
| 541 | giocata[0] = carteInMano[2]; | ||
| 542 | carteInMano[2] = null; | ||
| 543 | pannello.repaint(); | ||
| 544 | return true; | ||
| 545 | } | ||
| 546 | } | ||
| 547 | |||
| 548 | return false; | ||
| 549 | } | ||
| 550 | } | ||
| 551 | |||
| 552 | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/Main.java b/JBriscola/all_versions/0.3/0.3.2/src/Main.java new file mode 100755 index 0000000..3760a0d --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/Main.java | |||
| @@ -0,0 +1,2086 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2009-2010 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 | |||
| 29 | /*Costanti per i semi e i valori delle carte*/ | ||
| 30 | public static final int COPPE = 0; | ||
| 31 | public static final int BASTONI = 1; | ||
| 32 | public static final int DENARI = 2; | ||
| 33 | public static final int SPADE = 3; | ||
| 34 | public static final int RE = 0; | ||
| 35 | public static final int ASSO = 1; | ||
| 36 | public static final int DUE = 2; | ||
| 37 | public static final int TRE = 3; | ||
| 38 | public static final int QUATTRO = 4; | ||
| 39 | public static final int CINQUE = 5; | ||
| 40 | public static final int SEI = 6; | ||
| 41 | public static final int SETTE = 7; | ||
| 42 | public static final int FANTE = 8; | ||
| 43 | public static final int CAVALLO = 9; | ||
| 44 | |||
| 45 | /* semeBriscola serve a determinare quale il seme di briscola (0 coppe, | ||
| 46 | * 1 bastoni, 2 denari, 3 spade). | ||
| 47 | * punteggio è il punteggio del giocatore, punteggioCPU quello della CPU | ||
| 48 | * mano tiene il conto della mano a cui si è arrivati. | ||
| 49 | * cartaDaPescare è la carta che la CPU deve raccogliere dal mazzo | ||
| 50 | * cartaDaGiocare (può assumere valore compraso tra 0 e 2) è la carta | ||
| 51 | * che la cpu deve giocare. */ | ||
| 52 | public static int semeBriscola, punteggio, punteggioCPU, mano, cartaDaPescare, cartaDaGiocare; | ||
| 53 | |||
| 54 | /* toccaAllaCPU determina se è il turno del computer o del giocatore, | ||
| 55 | * CPUHaGiocato se il computer ha già giocato in questo turno e | ||
| 56 | * haGiocatoPrima se la prima mossa del turno è stata del giocatore | ||
| 57 | * (true) o della CPU (false). | ||
| 58 | * aiTrenta serve per determinare se la partida che si sta giocando è | ||
| 59 | * normale o ai 30. | ||
| 60 | * carteScoperte serve se viene attivato il trucco per mostrare le | ||
| 61 | * carte della CPU. | ||
| 62 | * sound e keys riguardano le opzioni (souno si o no, tasti rapidi si | ||
| 63 | * o no) salvate nel file di configurazione. */ | ||
| 64 | public static boolean toccaAllaCPU = false; | ||
| 65 | public static boolean CPUHaGiocato = false; | ||
| 66 | public static boolean haGiocatoPrima = true; | ||
| 67 | public static boolean aiTrenta = false; | ||
| 68 | public static boolean carteScoperte = false; | ||
| 69 | public static boolean sound = true; | ||
| 70 | public static boolean keys = true; | ||
| 71 | |||
| 72 | /* frame è la finestra principale del gioco, color il colore dello sfondo. | ||
| 73 | * lang, soundString e keysString servono a leggere le opzioni dal file | ||
| 74 | * di configurazione. */ | ||
| 75 | public static Frame frame; | ||
| 76 | public static Color color = new Color( 0, 150, 0 ); | ||
| 77 | public static String lang, soundString, keysString; | ||
| 78 | |||
| 79 | /* Tutte le stringhe che vengono utilizzate durante il gioco sono | ||
| 80 | * inizializzate qui, per poter essere tradotte in altre lingue. */ | ||
| 81 | public static String version = "0.3.2"; | ||
| 82 | public static String semi[] = { "Bastoni", "Coppe", "Denari", "Spade" }; | ||
| 83 | public static String stringaBriscola = "Briscola"; | ||
| 84 | public static String stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 85 | public static String stringaPrimaGioca = "Prima Gioca!"; | ||
| 86 | public static String stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 87 | public static String stringaVinto = "Hai Vinto!"; | ||
| 88 | public static String stringaPerso = "Hai Perso"; | ||
| 89 | public static String stringaPareggio = "Pareggio"; | ||
| 90 | public static String stringaGiocatore = "Giocatore: "; | ||
| 91 | public static String stringaComputer = "\nComputer: "; | ||
| 92 | public static String stringaNuovaPartita = "Nuova Partita"; | ||
| 93 | public static String stringaNuovaPartitaAiTrenta = "Nuova Partita Ai 30"; | ||
| 94 | public static String stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 95 | public static String stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 96 | public static String stringaSi = "Si"; | ||
| 97 | public static String stringaNo = "No"; | ||
| 98 | public static String stringaOpzioni = "Opzioni..."; | ||
| 99 | public static String stringaEsci = "Esci"; | ||
| 100 | public static String stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 101 | public static String stringaLingua = "Lingua"; | ||
| 102 | public static String stringaAnnulla = "Annulla"; | ||
| 103 | public static String stringaIt = "Italiano"; | ||
| 104 | public static String stringaLa = "Latino"; | ||
| 105 | public static String stringaBL = "Dialetto Bellunese"; | ||
| 106 | public static String stringaBV = "Dialetto Basso Veneto"; | ||
| 107 | public static String stringaEN = "Inglese"; | ||
| 108 | public static String stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 109 | public static String stringaInformazioni = "Informazioni"; | ||
| 110 | 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"; | ||
| 111 | public static String stringaSuono = "Effetti Sonori"; | ||
| 112 | public static String stringaPunteggio = "Punteggio"; | ||
| 113 | public static String stringaCartePassate = "Carte Passate"; | ||
| 114 | public static String stringaSfondo = "Sfondo"; | ||
| 115 | public static String stringaTasti = "Tasti rapidi"; | ||
| 116 | public static String stringaAggiornamenti = "Cerca aggiornamenti"; | ||
| 117 | public static String stringaTrucchi = "Trucchi"; | ||
| 118 | public static String stringaInserisciCodice = "Inserisci il codice:"; | ||
| 119 | public static String stringaTruccoAttivato = "Trucco attivato!"; | ||
| 120 | public static String stringaTruccoSbagliato = "Trucco non valido"; | ||
| 121 | public static String stringaCheCartaVuoi = "E allora che carta vuoi?"; | ||
| 122 | public static String stringaAggiornamentiSi = "Aggiornamento disponibile: "; | ||
| 123 | public static String stringaAggiornamentiNo = "Nessun aggiornamento disponibile"; | ||
| 124 | public static String stringaScarica = "E' possibile scaricare la versione più recente\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 125 | public static String stringaNoInternet = "Errore: nessuna connessione internet"; | ||
| 126 | 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 " + stringaCartePassate + "\nF6 " + stringaInformazioni + "\nF7 " + stringaAggiornamenti + "\nF8 " + stringaNuovaPartitaAiTrenta + "\nF9 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 127 | |||
| 128 | public static void main( String args[] ) { | ||
| 129 | |||
| 130 | /* Chiama il metodo settaOpzioni per leggere le impostazioni | ||
| 131 | * dell'utente da un eventuale file di configurazione */ | ||
| 132 | settaOpzioni(); | ||
| 133 | |||
| 134 | /* Crea la finestra principale del gioco e la posiziona al centro | ||
| 135 | * dello schermo. */ | ||
| 136 | frame = new Frame(); | ||
| 137 | frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); | ||
| 138 | frame.setResizable( false ); | ||
| 139 | frame.setSize( 600, 600 ); | ||
| 140 | frame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 600) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - 600) / 2); | ||
| 141 | frame.setVisible( true ); | ||
| 142 | } | ||
| 143 | |||
| 144 | /* Algoritmo per mischiare il mazzo: prende due carte a caso e le | ||
| 145 | * inverte di posto, utilizzando una variabile aux. Ripete il procedimento | ||
| 146 | * per 391 volte. */ | ||
| 147 | public void mischia() { | ||
| 148 | |||
| 149 | ImageIcon aux; | ||
| 150 | |||
| 151 | mano = 0; | ||
| 152 | punteggio = 0; | ||
| 153 | punteggioCPU = 0; | ||
| 154 | cartaDaPescare = 6; | ||
| 155 | frame.mazzo = true; | ||
| 156 | toccaAllaCPU = false; | ||
| 157 | CPUHaGiocato = false; | ||
| 158 | haGiocatoPrima = true; | ||
| 159 | frame.mazzo = true; | ||
| 160 | |||
| 161 | /* Inizializza l'array di carte mescolate ordinato */ | ||
| 162 | for ( int i = 0, k = 0; i < 10; i++ ) | ||
| 163 | for ( int j = 0; j < 4; j++, k++ ) | ||
| 164 | frame.arrayCarteMescolate[k] = frame.arrayCarte[i][j]; | ||
| 165 | |||
| 166 | /* Mescola le carte utilizzando il metodo sopra citato */ | ||
| 167 | for ( int i = 0; i < 391; i++ ) { | ||
| 168 | double a = Math.random() * 40; | ||
| 169 | int x = (int) a; | ||
| 170 | double b = Math.random() * 40; | ||
| 171 | int y = (int) b; | ||
| 172 | aux = frame.arrayCarteMescolate[x]; | ||
| 173 | frame.arrayCarteMescolate[x] = frame.arrayCarteMescolate[y]; | ||
| 174 | frame.arrayCarteMescolate[y] = aux; | ||
| 175 | } | ||
| 176 | |||
| 177 | /* Imposta il seme della briscola */ | ||
| 178 | semeBriscola = seme( frame.arrayCarteMescolate[39] ); | ||
| 179 | |||
| 180 | /* Distribuisce le carte */ | ||
| 181 | frame.carteInMano[0] = frame.arrayCarteMescolate[0]; | ||
| 182 | frame.carteInMano[1] = frame.arrayCarteMescolate[1]; | ||
| 183 | frame.carteInMano[2] = frame.arrayCarteMescolate[2]; | ||
| 184 | frame.carteCPU[0] = frame.arrayCarteMescolate[3]; | ||
| 185 | frame.carteCPU[1] = frame.arrayCarteMescolate[4]; | ||
| 186 | frame.carteCPU[2] = frame.arrayCarteMescolate[5]; | ||
| 187 | frame.ultimaCarta = frame.arrayCarteMescolate[39]; | ||
| 188 | frame.giocata[0] = null; | ||
| 189 | frame.giocata[1] = null; | ||
| 190 | } | ||
| 191 | |||
| 192 | /* Viene chiamato a fine partita. */ | ||
| 193 | public void pulisciTavolo() { | ||
| 194 | |||
| 195 | punteggio = 0; | ||
| 196 | punteggioCPU = 0; | ||
| 197 | cartaDaPescare = 6; | ||
| 198 | toccaAllaCPU = false; | ||
| 199 | CPUHaGiocato = false; | ||
| 200 | haGiocatoPrima = true; | ||
| 201 | |||
| 202 | frame.mazzo = false; | ||
| 203 | frame.ultimaCarta = null; | ||
| 204 | for ( int i = 0; i < 3; i++ ) { | ||
| 205 | frame.carteCPU[i] = null; | ||
| 206 | frame.carteInMano[i] = null; | ||
| 207 | } | ||
| 208 | |||
| 209 | for ( int i = 0; i < 40; i++ ) | ||
| 210 | frame.arrayCartePassate[i] = null; | ||
| 211 | |||
| 212 | frame.pannello.repaint(); | ||
| 213 | frame.repaint(); | ||
| 214 | |||
| 215 | } | ||
| 216 | |||
| 217 | /* Fa giocare la CPU. Questo metodo contiene l'intelligenza artificiale | ||
| 218 | * del gioco. Ho preferito non commentare molto il corpo del metodo per | ||
| 219 | * due motivi; il primo è che abbastanza intuitivo: basta sapere che i | ||
| 220 | * vari metodi vaiLiscio(), vaiTaglio() ecc... tentano di fare ciò che | ||
| 221 | * ovviamente dice il loro nome, se ci riescono restituiscono true, | ||
| 222 | * in caso contrario false.*/ | ||
| 223 | public void giocaCPU() { | ||
| 224 | |||
| 225 | /* Nelle prime 16 mani ragiona in maniera diversa*/ | ||
| 226 | if ( mano < 16 ) { | ||
| 227 | |||
| 228 | /* Valuta cosa fare se il giocatore non ha ancora giocato. */ | ||
| 229 | if ( !haGiocato() ) { | ||
| 230 | if ( vaiPuntiConCarichiPassati() ); | ||
| 231 | else if ( vaiLiscioConCarichiPassati() ); | ||
| 232 | else if ( vaiLiscio() ); | ||
| 233 | else if ( vaiPunti() ); | ||
| 234 | else if ( vaiTaglio() ); | ||
| 235 | else if ( vaiBriscolaAlta() ); | ||
| 236 | else if ( vaiCarico() ); | ||
| 237 | else if ( vaiTre() ); | ||
| 238 | else if ( vaiAsso() ); | ||
| 239 | else; | ||
| 240 | } | ||
| 241 | |||
| 242 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 243 | else { | ||
| 244 | if ( haLisciato() ) { | ||
| 245 | if ( vaiSopra() ); | ||
| 246 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 247 | else if ( vaiLiscio() ); | ||
| 248 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 249 | else if ( vaiPunti() ); | ||
| 250 | else if ( vaiTaglio() ); | ||
| 251 | else if ( vaiTre() ); | ||
| 252 | else if ( vaiBriscolaAlta() ); | ||
| 253 | else if ( vaiCarico() ); | ||
| 254 | else if ( vaiAsso() ); | ||
| 255 | } else if ( haMessoPunti() ) { | ||
| 256 | if ( vaiSopra() ); | ||
| 257 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 258 | else if ( vaiLiscio() ); | ||
| 259 | else if ( vaiTaglio() ); | ||
| 260 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 261 | else if ( vaiPunti() ); | ||
| 262 | else if ( vaiTre() ); | ||
| 263 | else if ( vaiBriscolaAlta() ); | ||
| 264 | else if ( vaiCarico() ); | ||
| 265 | else if ( vaiAsso() ); | ||
| 266 | } else if ( haTagliato() ) { | ||
| 267 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 268 | else if ( vaiLiscio() ); | ||
| 269 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 270 | else if ( vaiPunti() ); | ||
| 271 | else if ( vaiTaglio() ); | ||
| 272 | else if ( vaiTre() ); | ||
| 273 | else if ( vaiBriscolaAlta() ); | ||
| 274 | else if ( vaiCarico() ); | ||
| 275 | else if ( vaiAsso() ); | ||
| 276 | } else if ( haMessoBriscolaAlta() ) { | ||
| 277 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 278 | else if ( vaiLiscio() ); | ||
| 279 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 280 | else if ( vaiPunti() ); | ||
| 281 | else if ( vaiTre() ); | ||
| 282 | else if ( vaiTaglio() ); | ||
| 283 | else if ( vaiBriscolaAlta() ); | ||
| 284 | else if ( vaiCarico() ); | ||
| 285 | else if ( vaiAsso() ); | ||
| 286 | } else if ( haMessoTre() ) { | ||
| 287 | if ( vaiAsso() ); | ||
| 288 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 289 | else if ( vaiLiscio() ); | ||
| 290 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 291 | else if ( vaiPunti() ); | ||
| 292 | else if ( vaiTaglio() ); | ||
| 293 | else if ( vaiBriscolaAlta() ); | ||
| 294 | else if ( vaiCarico() ); | ||
| 295 | } else if ( haMessoAsso() ) { | ||
| 296 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 297 | else if ( vaiLiscio() ); | ||
| 298 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 299 | else if ( vaiPunti() ); | ||
| 300 | else if ( vaiTaglio() ); | ||
| 301 | else if ( vaiBriscolaAlta() ); | ||
| 302 | else if ( vaiCarico() ); | ||
| 303 | else if ( vaiTre() ); | ||
| 304 | } else if ( haCaricato() ) { | ||
| 305 | if ( vaiSopra() ); | ||
| 306 | else if ( vaiTre() ); | ||
| 307 | else if ( vaiBriscolaAlta() ); | ||
| 308 | else if ( vaiTaglio() ); | ||
| 309 | else if ( vaiAsso() ); | ||
| 310 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 311 | else if ( vaiLiscio() ); | ||
| 312 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 313 | else if ( vaiPunti() ); | ||
| 314 | else if ( vaiCarico() ); | ||
| 315 | } | ||
| 316 | } | ||
| 317 | } | ||
| 318 | |||
| 319 | /* Nella penultima mano (prima di pescare l'ultima carta) */ | ||
| 320 | else if ( mano == 16 ) { | ||
| 321 | |||
| 322 | /* Valuta cosa fare se il giocatore non ha ancora giocato. */ | ||
| 323 | if ( !haGiocato() ) { | ||
| 324 | if ( valore( frame.ultimaCarta ) == TRE || valore( frame.ultimaCarta ) == ASSO ) { | ||
| 325 | |||
| 326 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 327 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 328 | else if ( vaiCarico() ); | ||
| 329 | else if ( vaiPunti() ); | ||
| 330 | else if ( vaiLiscio() ); | ||
| 331 | else if ( vaiTaglio() ); | ||
| 332 | else if ( vaiBriscolaAlta() ); | ||
| 333 | else if ( vaiTre() ); | ||
| 334 | else if ( vaiAsso() ); | ||
| 335 | else; | ||
| 336 | } else { | ||
| 337 | if ( vaiPuntiConCarichiPassati() ); | ||
| 338 | else if ( vaiLiscioConCarichiPassati() ); | ||
| 339 | else if ( vaiLiscio() ); | ||
| 340 | else if ( vaiPunti() ); | ||
| 341 | else if ( vaiTaglio() ); | ||
| 342 | else if ( vaiBriscolaAlta() ); | ||
| 343 | else if ( vaiCarico() ); | ||
| 344 | else if ( vaiTre() ); | ||
| 345 | else if ( vaiAsso() ); | ||
| 346 | else; | ||
| 347 | } | ||
| 348 | } | ||
| 349 | |||
| 350 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 351 | else { | ||
| 352 | if ( valore( frame.ultimaCarta ) == TRE || valore( frame.ultimaCarta ) == ASSO ) { | ||
| 353 | if ( haCaricato() ) { | ||
| 354 | if ( vaiSopra() ); | ||
| 355 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 356 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 357 | else if ( vaiLiscio() ); | ||
| 358 | else if ( vaiPunti() ); | ||
| 359 | else if ( vaiTre() ); | ||
| 360 | else if ( vaiTaglio() ); | ||
| 361 | else if ( vaiBriscolaAlta() ); | ||
| 362 | else if ( vaiAsso() ); | ||
| 363 | else if ( vaiCarico() ); | ||
| 364 | } | ||
| 365 | } else { | ||
| 366 | if ( haLisciato() ) { | ||
| 367 | if ( vaiSopra() ); | ||
| 368 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 369 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 370 | else if ( vaiLiscio() ); | ||
| 371 | else if ( vaiPunti() ); | ||
| 372 | else if ( vaiTaglio() ); | ||
| 373 | else if ( vaiTre() ); | ||
| 374 | else if ( vaiBriscolaAlta() ); | ||
| 375 | else if ( vaiCarico() ); | ||
| 376 | else if ( vaiAsso() ); | ||
| 377 | } else if ( haMessoPunti() ) { | ||
| 378 | if ( vaiSopra() ); | ||
| 379 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 380 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 381 | else if ( vaiLiscio() ); | ||
| 382 | else if ( vaiTaglio() ); | ||
| 383 | else if ( vaiPunti() ); | ||
| 384 | else if ( vaiTre() ); | ||
| 385 | else if ( vaiBriscolaAlta() ); | ||
| 386 | else if ( vaiCarico() ); | ||
| 387 | else if ( vaiAsso() ); | ||
| 388 | } else if ( haTagliato() ) { | ||
| 389 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 390 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 391 | else if ( vaiLiscio() ); | ||
| 392 | else if ( vaiPunti() ); | ||
| 393 | else if ( vaiTaglio() ); | ||
| 394 | else if ( vaiTre() ); | ||
| 395 | else if ( vaiBriscolaAlta() ); | ||
| 396 | else if ( vaiCarico() ); | ||
| 397 | else if ( vaiAsso() ); | ||
| 398 | } else if ( haMessoBriscolaAlta() ) { | ||
| 399 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 400 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 401 | else if ( vaiLiscio() ); | ||
| 402 | else if ( vaiPunti() ); | ||
| 403 | else if ( vaiTre() ); | ||
| 404 | else if ( vaiTaglio() ); | ||
| 405 | else if ( vaiBriscolaAlta() ); | ||
| 406 | else if ( vaiCarico() ); | ||
| 407 | else if ( vaiAsso() ); | ||
| 408 | } else if ( haMessoTre() ) { | ||
| 409 | if ( vaiAsso() ); | ||
| 410 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 411 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 412 | else if ( vaiLiscio() ); | ||
| 413 | else if ( vaiPunti() ); | ||
| 414 | else if ( vaiTaglio() ); | ||
| 415 | else if ( vaiBriscolaAlta() ); | ||
| 416 | else if ( vaiCarico() ); | ||
| 417 | } else if ( haMessoAsso() ) { | ||
| 418 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 419 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 420 | else if ( vaiLiscio() ); | ||
| 421 | else if ( vaiPunti() ); | ||
| 422 | else if ( vaiTaglio() ); | ||
| 423 | else if ( vaiBriscolaAlta() ); | ||
| 424 | else if ( vaiCarico() ); | ||
| 425 | else if ( vaiTre() ); | ||
| 426 | } else if ( haCaricato() ) { | ||
| 427 | if ( vaiSopra() ); | ||
| 428 | else if ( vaiTre() ); | ||
| 429 | else if ( vaiBriscolaAlta() ); | ||
| 430 | else if ( vaiAsso() ); | ||
| 431 | else if ( vaiTaglio() ); | ||
| 432 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 433 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 434 | else if ( vaiLiscio() ); | ||
| 435 | else if ( vaiPunti() ); | ||
| 436 | else if ( vaiCarico() ); | ||
| 437 | } | ||
| 438 | } | ||
| 439 | } | ||
| 440 | |||
| 441 | } else if ( mano == 17 ) { | ||
| 442 | /* AVVISO: nelle ultime 3 mani, la CPU "guarda" le carte al giocatore; | ||
| 443 | * Questa non è una scorrettezza, ma semplicemente un metodo per sem- | ||
| 444 | * plificare i passaggi: il computer potrebbe comunque dedurre le carte | ||
| 445 | * che ha in mano il giocatore controllando le proprie carte e quelle | ||
| 446 | * che sono già passate. */ | ||
| 447 | |||
| 448 | /* Valuta cosa fare se il giocatore non ha ancora giocato. */ | ||
| 449 | if ( !haGiocato() ) { | ||
| 450 | if ( hoLaBriscolaPiuAltaInGioco() && hoLaSecondaBriscolaPiuAltaInGioco() ) | ||
| 451 | vaiSecondaBriscolaPiuAltaInGioco(); | ||
| 452 | else { | ||
| 453 | if ( vaiLiscioConCarichiPassati() ); | ||
| 454 | else if ( vaiPuntiConCarichiPassati() ); | ||
| 455 | else if ( vaiLiscio() ); | ||
| 456 | else if ( vaiPunti() ); | ||
| 457 | else if ( vaiTaglio() ); | ||
| 458 | else if ( vaiBriscolaAlta() ); | ||
| 459 | else if ( vaiCarico() ); | ||
| 460 | else if ( vaiTre() ); | ||
| 461 | } | ||
| 462 | } | ||
| 463 | |||
| 464 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 465 | else { | ||
| 466 | if ( haLisciato() ) { | ||
| 467 | if ( vaiSopra() ); | ||
| 468 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 469 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 470 | else if ( vaiLiscio() ); | ||
| 471 | else if ( vaiPunti() ); | ||
| 472 | else if ( vaiTaglio() ); | ||
| 473 | else if ( vaiTre() ); | ||
| 474 | else if ( vaiBriscolaAlta() ); | ||
| 475 | else if ( vaiCarico() ); | ||
| 476 | else if ( vaiAsso() ); | ||
| 477 | } else if ( haMessoPunti() ) { | ||
| 478 | if ( vaiSopra() ); | ||
| 479 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 480 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 481 | else if ( vaiLiscio() ); | ||
| 482 | else if ( vaiTaglio() ); | ||
| 483 | else if ( vaiPunti() ); | ||
| 484 | else if ( vaiTre() ); | ||
| 485 | else if ( vaiBriscolaAlta() ); | ||
| 486 | else if ( vaiCarico() ); | ||
| 487 | else if ( vaiAsso() ); | ||
| 488 | } else if ( haTagliato() ) { | ||
| 489 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 490 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 491 | else if ( vaiLiscio() ); | ||
| 492 | else if ( vaiPunti() ); | ||
| 493 | else if ( vaiTaglio() ); | ||
| 494 | else if ( vaiTre() ); | ||
| 495 | else if ( vaiBriscolaAlta() ); | ||
| 496 | else if ( vaiCarico() ); | ||
| 497 | else if ( vaiAsso() ); | ||
| 498 | } else if ( haMessoBriscolaAlta() ) { | ||
| 499 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 500 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 501 | else if ( vaiLiscio() ); | ||
| 502 | else if ( vaiPunti() ); | ||
| 503 | else if ( vaiTre() ); | ||
| 504 | else if ( vaiTaglio() ); | ||
| 505 | else if ( vaiBriscolaAlta() ); | ||
| 506 | else if ( vaiCarico() ); | ||
| 507 | else if ( vaiAsso() ); | ||
| 508 | } else if ( haMessoTre() ) { | ||
| 509 | if ( vaiAsso() ); | ||
| 510 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 511 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 512 | else if ( vaiLiscio() ); | ||
| 513 | else if ( vaiPunti() ); | ||
| 514 | else if ( vaiTaglio() ); | ||
| 515 | else if ( vaiBriscolaAlta() ); | ||
| 516 | else if ( vaiCarico() ); | ||
| 517 | } else if ( haMessoAsso() ) { | ||
| 518 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 519 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 520 | else if ( vaiLiscio() ); | ||
| 521 | else if ( vaiPunti() ); | ||
| 522 | else if ( vaiTaglio() ); | ||
| 523 | else if ( vaiBriscolaAlta() ); | ||
| 524 | else if ( vaiCarico() ); | ||
| 525 | else if ( vaiTre() ); | ||
| 526 | } else if ( haCaricato() ) { | ||
| 527 | if ( vaiSopra() ); | ||
| 528 | else if ( piuAltaInGioco() == ASSO && luiHaLaBriscolaPiuAltaInGioco() && hoTre() ) | ||
| 529 | vaiTre(); | ||
| 530 | else if ( vaiTaglio() ); | ||
| 531 | else if ( vaiBriscolaAlta() ); | ||
| 532 | else if ( piuAltaInGioco() == ASSO && !luiHaLaSecondaBriscolaPiuAltaInGioco() && hoAsso() ) | ||
| 533 | vaiAsso(); | ||
| 534 | else if ( vaiTre() ); | ||
| 535 | else if ( vaiAsso() ); | ||
| 536 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 537 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 538 | else if ( vaiLiscio() ); | ||
| 539 | else if ( vaiPunti() ); | ||
| 540 | else if ( vaiCarico() ); | ||
| 541 | } | ||
| 542 | } | ||
| 543 | |||
| 544 | } else if ( mano == 18 ) { | ||
| 545 | |||
| 546 | /* Valuta cosa fare se il giocatore non ha ancora giocato. */ | ||
| 547 | if ( !haGiocato() ) { | ||
| 548 | if ( hoLaBriscolaPiuAltaInGioco() ) | ||
| 549 | vaiBriscolaPiuAltaInGioco(); | ||
| 550 | else | ||
| 551 | if ( hoLaSecondaBriscolaPiuAltaInGioco() ) | ||
| 552 | vaiNon( secondaPiuAltaInGioco(), semeBriscola ); | ||
| 553 | else | ||
| 554 | if ( luiHaTutteBriscole() ) | ||
| 555 | vaiPrima(); | ||
| 556 | else if ( vaiTaglio() ); | ||
| 557 | else if ( vaiBriscolaAlta() ); | ||
| 558 | else if ( vaiLiscioConCarichiPassati() ); | ||
| 559 | else if ( vaiPuntiConCarichiPassati() ); | ||
| 560 | else if ( vaiLiscio() ); | ||
| 561 | else if ( vaiPunti() ); | ||
| 562 | else if ( vaiCarico() ); | ||
| 563 | else if ( vaiTre() ); | ||
| 564 | } | ||
| 565 | |||
| 566 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 567 | else { | ||
| 568 | if ( haLisciato() ) { | ||
| 569 | if ( luiHaLaBriscolaPiuAltaInGioco() && hoLaSecondaBriscolaPiuAltaInGioco() ) | ||
| 570 | vaiSecondaBriscolaPiuAltaInGioco(); | ||
| 571 | else if ( vaiSopra() ); | ||
| 572 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 573 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 574 | else if ( vaiLiscio() ); | ||
| 575 | else if ( vaiPunti() ); | ||
| 576 | else if ( vaiTaglio() ); | ||
| 577 | else if ( vaiTre() ); | ||
| 578 | else if ( vaiBriscolaAlta() ); | ||
| 579 | else if ( vaiCarico() ); | ||
| 580 | else if ( vaiAsso() ); | ||
| 581 | } else if ( haMessoPunti() ) { | ||
| 582 | if ( luiHaLaBriscolaPiuAltaInGioco() && hoLaSecondaBriscolaPiuAltaInGioco() ) | ||
| 583 | vaiSecondaBriscolaPiuAltaInGioco(); | ||
| 584 | else if ( vaiSopra() ); | ||
| 585 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 586 | else if ( vaiLiscio() ); | ||
| 587 | else if ( vaiTaglio() ); | ||
| 588 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 589 | else if ( vaiPunti() ); | ||
| 590 | else if ( vaiTre() ); | ||
| 591 | else if ( vaiBriscolaAlta() ); | ||
| 592 | else if ( vaiCarico() ); | ||
| 593 | else if ( vaiAsso() ); | ||
| 594 | } else if ( haTagliato() ) { | ||
| 595 | if ( luiHaLaBriscolaPiuAltaInGioco() && hoLaSecondaBriscolaPiuAltaInGioco() ) | ||
| 596 | vaiSecondaBriscolaPiuAltaInGioco(); | ||
| 597 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 598 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 599 | else if ( vaiLiscio() ); | ||
| 600 | else if ( vaiPunti() ); | ||
| 601 | else if ( vaiTaglio() ); | ||
| 602 | else if ( vaiTre() ); | ||
| 603 | else if ( vaiBriscolaAlta() ); | ||
| 604 | else if ( vaiCarico() ); | ||
| 605 | else if ( vaiAsso() ); | ||
| 606 | } else if ( haMessoBriscolaAlta() ) { | ||
| 607 | if ( luiHaLaBriscolaPiuAltaInGioco() && hoLaSecondaBriscolaPiuAltaInGioco() ) | ||
| 608 | vaiSecondaBriscolaPiuAltaInGioco(); | ||
| 609 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 610 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 611 | else if ( vaiLiscio() ); | ||
| 612 | else if ( vaiPunti() ); | ||
| 613 | else if ( vaiTre() ); | ||
| 614 | else if ( vaiTaglio() ); | ||
| 615 | else if ( vaiSopra() ); | ||
| 616 | else if ( vaiBriscolaAlta() ); | ||
| 617 | else if ( vaiAsso() ); | ||
| 618 | else if ( vaiCarico() ); | ||
| 619 | } else if ( haMessoTre() ) { | ||
| 620 | if ( vaiAsso() ); | ||
| 621 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 622 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 623 | else if ( vaiLiscio() ); | ||
| 624 | else if ( vaiPunti() ); | ||
| 625 | else if ( vaiTaglio() ); | ||
| 626 | else if ( vaiBriscolaAlta() ); | ||
| 627 | else if ( vaiCarico() ); | ||
| 628 | } else if ( haMessoAsso() ) { | ||
| 629 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 630 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 631 | else if ( vaiLiscio() ); | ||
| 632 | else if ( vaiPunti() ); | ||
| 633 | else if ( vaiTaglio() ); | ||
| 634 | else if ( vaiBriscolaAlta() ); | ||
| 635 | else if ( vaiCarico() ); | ||
| 636 | else if ( vaiTre() ); | ||
| 637 | } else if ( haCaricato() ) { | ||
| 638 | if ( vaiSopra() ); | ||
| 639 | else if ( luiHaLaBriscolaPiuAltaInGioco() && hoLaSecondaBriscolaPiuAltaInGioco() ) | ||
| 640 | vaiSecondaBriscolaPiuAltaInGioco(); | ||
| 641 | else if ( vaiTre() ); | ||
| 642 | else if ( vaiBriscolaAlta() ); | ||
| 643 | else if ( vaiAsso() ); | ||
| 644 | else if ( vaiTaglio() ); | ||
| 645 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 646 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 647 | else if ( vaiLiscio() ); | ||
| 648 | else if ( vaiPunti() ); | ||
| 649 | else if ( vaiCarico() ); | ||
| 650 | } | ||
| 651 | } | ||
| 652 | |||
| 653 | /* All'ultima mano è inutile ragionare, dato che ha una sola carta */ | ||
| 654 | } else vaiPrima(); | ||
| 655 | |||
| 656 | /* Gioca la carta e aggiorna la finestra con il metodo repaint() */ | ||
| 657 | frame.giocata[1] = frame.carteCPU[cartaDaGiocare]; | ||
| 658 | frame.carteCPU[cartaDaGiocare] = null; | ||
| 659 | frame.pannello.repaint(); | ||
| 660 | |||
| 661 | CPUHaGiocato = true; | ||
| 662 | |||
| 663 | if ( !haGiocato() ) | ||
| 664 | toccaAllaCPU = false; | ||
| 665 | } | ||
| 666 | |||
| 667 | /* Fa giocare una partita ai 30. È analogo al metodo precedente, cambia | ||
| 668 | * solo la tecnica di gioco, quindi non è commentato. */ | ||
| 669 | public void giocaCPUAiTrenta() { | ||
| 670 | |||
| 671 | if ( punteggio <= 20 ) { | ||
| 672 | |||
| 673 | if ( !haGiocato() ) { | ||
| 674 | if ( vaiPuntiConCarichiPassati() ); | ||
| 675 | else if ( vaiPunti() ); | ||
| 676 | else if ( vaiLiscioConCarichiPassati() ); | ||
| 677 | else if ( vaiLiscio() ); | ||
| 678 | else if ( vaiTaglio() ); | ||
| 679 | else if ( vaiBriscolaAlta() ); | ||
| 680 | else if ( vaiCarico() ); | ||
| 681 | else if ( vaiTre() ); | ||
| 682 | else if ( vaiAsso() ); | ||
| 683 | else; | ||
| 684 | } | ||
| 685 | |||
| 686 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 687 | else { | ||
| 688 | if ( haLisciato() ) { | ||
| 689 | if ( vaiSopra() ); | ||
| 690 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 691 | else if ( vaiLiscio() ); | ||
| 692 | else if ( vaiTre() ); | ||
| 693 | else if ( vaiBriscolaAlta() ); | ||
| 694 | else if ( vaiTaglio() ); | ||
| 695 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 696 | else if ( vaiPunti() ); | ||
| 697 | else if ( vaiAsso() ); | ||
| 698 | else if ( vaiCarico() ); | ||
| 699 | } else if ( haMessoPunti() ) { | ||
| 700 | if ( vaiSopra() ); | ||
| 701 | else if ( vaiTre() ); | ||
| 702 | else if ( vaiBriscolaAlta() ); | ||
| 703 | else if ( vaiTaglio() ); | ||
| 704 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 705 | else if ( vaiLiscio() ); | ||
| 706 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 707 | else if ( vaiPunti() ); | ||
| 708 | else if ( vaiAsso() ); | ||
| 709 | else if ( vaiCarico() ); | ||
| 710 | } else if ( haTagliato() ) { | ||
| 711 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 712 | else if ( vaiLiscio() ); | ||
| 713 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 714 | else if ( vaiPunti() ); | ||
| 715 | else if ( vaiTaglio() ); | ||
| 716 | else if ( vaiTre() ); | ||
| 717 | else if ( vaiBriscolaAlta() ); | ||
| 718 | else if ( vaiAsso() ); | ||
| 719 | else if ( vaiCarico() ); | ||
| 720 | } else if ( haMessoBriscolaAlta() ) { | ||
| 721 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 722 | else if ( vaiLiscio() ); | ||
| 723 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 724 | else if ( vaiPunti() ); | ||
| 725 | else if ( vaiTre() ); | ||
| 726 | else if ( vaiTaglio() ); | ||
| 727 | else if ( vaiBriscolaAlta() ); | ||
| 728 | else if ( vaiAsso() ); | ||
| 729 | else if ( vaiCarico() ); | ||
| 730 | } else if ( haMessoTre() ) { | ||
| 731 | if ( vaiAsso() ); | ||
| 732 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 733 | else if ( vaiLiscio() ); | ||
| 734 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 735 | else if ( vaiPunti() ); | ||
| 736 | else if ( vaiTaglio() ); | ||
| 737 | else if ( vaiBriscolaAlta() ); | ||
| 738 | else if ( vaiCarico() ); | ||
| 739 | } else if ( haMessoAsso() ) { | ||
| 740 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 741 | else if ( vaiLiscio() ); | ||
| 742 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 743 | else if ( vaiPunti() ); | ||
| 744 | else if ( vaiTaglio() ); | ||
| 745 | else if ( vaiBriscolaAlta() ); | ||
| 746 | else if ( vaiCarico() ); | ||
| 747 | else if ( vaiTre() ); | ||
| 748 | } else if ( haCaricato() ) { | ||
| 749 | if ( vaiSopra() ); | ||
| 750 | else if ( vaiTre() ); | ||
| 751 | else if ( vaiBriscolaAlta() ); | ||
| 752 | else if ( vaiTaglio() ); | ||
| 753 | else if ( vaiAsso() ); | ||
| 754 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 755 | else if ( vaiLiscio() ); | ||
| 756 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 757 | else if ( vaiPunti() ); | ||
| 758 | else if ( vaiCarico() ); | ||
| 759 | } | ||
| 760 | } | ||
| 761 | } | ||
| 762 | |||
| 763 | else { | ||
| 764 | |||
| 765 | if ( !haGiocato() ) { | ||
| 766 | if ( vaiLiscioConCarichiPassati() ); | ||
| 767 | else if ( vaiLiscio() ); | ||
| 768 | else if ( vaiPuntiConCarichiPassati() ); | ||
| 769 | else if ( vaiPunti() ); | ||
| 770 | else if ( vaiTaglio() ); | ||
| 771 | else if ( vaiBriscolaAlta() ); | ||
| 772 | else if ( vaiCarico() ); | ||
| 773 | else if ( vaiTre() ); | ||
| 774 | else if ( vaiAsso() ); | ||
| 775 | else; | ||
| 776 | } | ||
| 777 | |||
| 778 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 779 | else { | ||
| 780 | if ( haLisciato() ) { | ||
| 781 | if ( vaiSopra() ); | ||
| 782 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 783 | else if ( vaiLiscio() ); | ||
| 784 | else if ( vaiTre() ); | ||
| 785 | else if ( vaiBriscolaAlta() ); | ||
| 786 | else if ( vaiTaglio() ); | ||
| 787 | else if ( vaiAsso() ); | ||
| 788 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 789 | else if ( vaiPunti() ); | ||
| 790 | else if ( vaiCarico() ); | ||
| 791 | } else if ( haMessoPunti() ) { | ||
| 792 | if ( vaiSopra() ); | ||
| 793 | else if ( vaiTre() ); | ||
| 794 | else if ( vaiBriscolaAlta() ); | ||
| 795 | else if ( vaiTaglio() ); | ||
| 796 | else if ( vaiAsso() ); | ||
| 797 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 798 | else if ( vaiLiscio() ); | ||
| 799 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 800 | else if ( vaiPunti() ); | ||
| 801 | else if ( vaiCarico() ); | ||
| 802 | } else if ( haTagliato() ) { | ||
| 803 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 804 | else if ( vaiLiscio() ); | ||
| 805 | else if ( vaiTaglio() ); | ||
| 806 | else if ( vaiTre() ); | ||
| 807 | else if ( vaiBriscolaAlta() ); | ||
| 808 | else if ( vaiAsso() ); | ||
| 809 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 810 | else if ( vaiPunti() ); | ||
| 811 | else if ( vaiCarico() ); | ||
| 812 | } else if ( haMessoBriscolaAlta() ) { | ||
| 813 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 814 | else if ( vaiLiscio() ); | ||
| 815 | else if ( vaiTre() ); | ||
| 816 | else if ( vaiTaglio() ); | ||
| 817 | else if ( vaiAsso() ); | ||
| 818 | else if ( vaiBriscolaAlta() ); | ||
| 819 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 820 | else if ( vaiPunti() ); | ||
| 821 | else if ( vaiCarico() ); | ||
| 822 | } else if ( haMessoTre() ) { | ||
| 823 | if ( vaiAsso() ); | ||
| 824 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 825 | else if ( vaiLiscio() ); | ||
| 826 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 827 | else if ( vaiPunti() ); | ||
| 828 | else if ( vaiTaglio() ); | ||
| 829 | else if ( vaiBriscolaAlta() ); | ||
| 830 | else if ( vaiCarico() ); | ||
| 831 | } else if ( haMessoAsso() ) { | ||
| 832 | if ( vaiLiscioConCarichiInGioco() ); | ||
| 833 | else if ( vaiLiscio() ); | ||
| 834 | else if ( vaiTaglio() ); | ||
| 835 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 836 | else if ( vaiPunti() ); | ||
| 837 | else if ( vaiBriscolaAlta() ); | ||
| 838 | else if ( vaiCarico() ); | ||
| 839 | else if ( vaiTre() ); | ||
| 840 | } else if ( haCaricato() ) { | ||
| 841 | if ( vaiSopra() ); | ||
| 842 | else if ( vaiTre() ); | ||
| 843 | else if ( vaiBriscolaAlta() ); | ||
| 844 | else if ( vaiTaglio() ); | ||
| 845 | else if ( vaiAsso() ); | ||
| 846 | else if ( vaiLiscioConCarichiInGioco() ); | ||
| 847 | else if ( vaiLiscio() ); | ||
| 848 | else if ( vaiPuntiConCarichiInGioco() ); | ||
| 849 | else if ( vaiPunti() ); | ||
| 850 | else if ( vaiCarico() ); | ||
| 851 | } | ||
| 852 | } | ||
| 853 | } | ||
| 854 | |||
| 855 | /* Gioca la carta e aggiorna la finestra con il metodo repaint() */ | ||
| 856 | frame.giocata[1] = frame.carteCPU[cartaDaGiocare]; | ||
| 857 | frame.carteCPU[cartaDaGiocare] = null; | ||
| 858 | frame.pannello.repaint(); | ||
| 859 | |||
| 860 | CPUHaGiocato = true; | ||
| 861 | |||
| 862 | if ( !haGiocato() ) | ||
| 863 | toccaAllaCPU = false; | ||
| 864 | } | ||
| 865 | |||
| 866 | /* Determina se ha preso la CPU o il giocatore*/ | ||
| 867 | public void chiPrende() { | ||
| 868 | |||
| 869 | /* Chiama il metodo giocatorePrende( boolean giocatore ) con parametro | ||
| 870 | * true se ha preso il giocatore, false se ha preso la CPU */ | ||
| 871 | giocatorePrende( ( (seme( frame.giocata[0] ) == semeBriscola) && (seme( frame.giocata[1] ) != semeBriscola) ) | ||
| 872 | || ( (seme( frame.giocata[0] ) == seme( frame.giocata[1] )) && laPrimaEPiuAlta( valore( frame.giocata[0] ), valore( frame.giocata[1] )) ) | ||
| 873 | || ( (seme( frame.giocata[1] ) != semeBriscola) && (seme( frame.giocata[0] ) != seme( frame.giocata[1] )) && haGiocatoPrima ) ); | ||
| 874 | } | ||
| 875 | |||
| 876 | /* Confronta due carte per decidere quale ha più valore di presa. | ||
| 877 | * Restituisce true se è la prima, false se è la seconda */ | ||
| 878 | public boolean laPrimaEPiuAlta( int prima, int seconda ) { | ||
| 879 | int a, b; | ||
| 880 | switch ( prima ) { | ||
| 881 | case 0: | ||
| 882 | a = 10; | ||
| 883 | break; | ||
| 884 | case 1: | ||
| 885 | a = 12; | ||
| 886 | break; | ||
| 887 | case 3: | ||
| 888 | a = 11; | ||
| 889 | break; | ||
| 890 | default: | ||
| 891 | a = prima; | ||
| 892 | break; | ||
| 893 | } | ||
| 894 | switch ( seconda ) { | ||
| 895 | case 0: | ||
| 896 | b = 10; | ||
| 897 | break; | ||
| 898 | case 1: | ||
| 899 | b = 12; | ||
| 900 | break; | ||
| 901 | case 3: | ||
| 902 | b = 11; | ||
| 903 | break; | ||
| 904 | default: | ||
| 905 | b = seconda; | ||
| 906 | break; | ||
| 907 | } | ||
| 908 | return a > b; | ||
| 909 | } | ||
| 910 | |||
| 911 | /* Viene chiamato con parametro true se ha preso il giocatore, false se | ||
| 912 | * ha preso la CPU */ | ||
| 913 | public void giocatorePrende( boolean giocatore ) { | ||
| 914 | if ( giocatore ) { | ||
| 915 | toccaAllaCPU = CPUHaGiocato = false; | ||
| 916 | haGiocatoPrima = true; | ||
| 917 | } | ||
| 918 | else { | ||
| 919 | toccaAllaCPU = true; | ||
| 920 | CPUHaGiocato = haGiocatoPrima = false; | ||
| 921 | } | ||
| 922 | daiPunti( giocatore ); | ||
| 923 | } | ||
| 924 | |||
| 925 | /* Da i punti (true al giocatore, false alla CPU) e fa pescare le carte*/ | ||
| 926 | public void daiPunti( boolean giocatore ) { | ||
| 927 | |||
| 928 | int punti = 0; | ||
| 929 | |||
| 930 | switch( valore( frame.giocata[0] ) ) { | ||
| 931 | case 0: | ||
| 932 | punti += 4; | ||
| 933 | break; | ||
| 934 | case 1: | ||
| 935 | punti += 11; | ||
| 936 | break; | ||
| 937 | case 3: | ||
| 938 | punti += 10; | ||
| 939 | break; | ||
| 940 | case 8: | ||
| 941 | punti += 2; | ||
| 942 | break; | ||
| 943 | case 9: | ||
| 944 | punti += 3; | ||
| 945 | break; | ||
| 946 | default: | ||
| 947 | break; | ||
| 948 | } | ||
| 949 | switch( valore( frame.giocata[1] ) ) { | ||
| 950 | case 0: | ||
| 951 | punti += 4; | ||
| 952 | break; | ||
| 953 | case 1: | ||
| 954 | punti += 11; | ||
| 955 | break; | ||
| 956 | case 3: | ||
| 957 | punti += 10; | ||
| 958 | break; | ||
| 959 | case 8: | ||
| 960 | punti += 2; | ||
| 961 | break; | ||
| 962 | case 9: | ||
| 963 | punti += 3; | ||
| 964 | break; | ||
| 965 | default: | ||
| 966 | break; | ||
| 967 | } | ||
| 968 | |||
| 969 | frame.giocata[0] = frame.giocata[1] = null; | ||
| 970 | |||
| 971 | if ( giocatore ) { | ||
| 972 | punteggio += punti; | ||
| 973 | if ( mano < 18 ) { | ||
| 974 | if ( frame.carteInMano[0] == null ) | ||
| 975 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 976 | if ( frame.carteInMano[1] == null ) | ||
| 977 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 978 | if ( frame.carteInMano[2] == null ) | ||
| 979 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 980 | cartaDaPescare++; | ||
| 981 | if ( frame.carteCPU[0] == null ) | ||
| 982 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 983 | if ( frame.carteCPU[1] == null ) | ||
| 984 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 985 | if ( frame.carteCPU[2] == null ) | ||
| 986 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 987 | cartaDaPescare++; | ||
| 988 | } | ||
| 989 | } | ||
| 990 | |||
| 991 | else { | ||
| 992 | punteggioCPU += punti; | ||
| 993 | if ( mano < 18 ) { | ||
| 994 | if ( frame.carteCPU[0] == null ) | ||
| 995 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 996 | if ( frame.carteCPU[1] == null ) | ||
| 997 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 998 | if ( frame.carteCPU[2] == null ) | ||
| 999 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 1000 | cartaDaPescare++; | ||
| 1001 | if ( frame.carteInMano[0] == null ) | ||
| 1002 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 1003 | if ( frame.carteInMano[1] == null ) | ||
| 1004 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 1005 | if ( frame.carteInMano[2] == null ) | ||
| 1006 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 1007 | cartaDaPescare++; | ||
| 1008 | } | ||
| 1009 | } | ||
| 1010 | |||
| 1011 | /* Aggiorna la finestra */ | ||
| 1012 | frame.pannello.repaint(); | ||
| 1013 | frame.repaint(); | ||
| 1014 | } | ||
| 1015 | |||
| 1016 | /* Ritorna true se il giocatore ha giocato */ | ||
| 1017 | public boolean haGiocato() { | ||
| 1018 | return frame.giocata[0] != null; | ||
| 1019 | } | ||
| 1020 | |||
| 1021 | /* Vari metodi che determinano che tipo di carta ha giocato il giocatore.*/ | ||
| 1022 | public boolean haLisciato() { | ||
| 1023 | return ( (haGiocato()) && (seme( frame.giocata[0] ) != semeBriscola) && | ||
| 1024 | (valore( frame.giocata[0] ) != RE ) && (valore( frame.giocata[0] ) != ASSO ) && | ||
| 1025 | (valore( frame.giocata[0] ) != TRE ) && (valore( frame.giocata[0] ) < FANTE ) ); | ||
| 1026 | } | ||
| 1027 | |||
| 1028 | public boolean haMessoPunti() { | ||
| 1029 | return ( (haGiocato()) && (seme( frame.giocata[0] ) != semeBriscola) && | ||
| 1030 | ( (valore( frame.giocata[0] ) == RE ) || (valore( frame.giocata[0] ) == FANTE ) || | ||
| 1031 | (valore( frame.giocata[0] ) == CAVALLO ) ) ); | ||
| 1032 | } | ||
| 1033 | |||
| 1034 | public boolean haTagliato() { | ||
| 1035 | return ( (haGiocato()) && (seme( frame.giocata[0] ) == semeBriscola) && | ||
| 1036 | (valore( frame.giocata[0] ) == RE) && (valore( frame.giocata[0] ) != ASSO) && | ||
| 1037 | (valore( frame.giocata[0] ) == TRE) && (valore( frame.giocata[0] ) <= SETTE) ); | ||
| 1038 | } | ||
| 1039 | |||
| 1040 | public boolean haMessoBriscolaAlta() { | ||
| 1041 | return ( (haGiocato()) && (seme( frame.giocata[0] ) == semeBriscola) && | ||
| 1042 | ( (valore( frame.giocata[0] ) == RE ) || (valore( frame.giocata[0] ) == FANTE ) || | ||
| 1043 | (valore( frame.giocata[0] ) == CAVALLO ) ) ); | ||
| 1044 | } | ||
| 1045 | |||
| 1046 | public boolean haMessoTre() { | ||
| 1047 | return ( (haGiocato()) && (seme( frame.giocata[0] ) == semeBriscola) && | ||
| 1048 | (valore( frame.giocata[0] ) == TRE) ); | ||
| 1049 | } | ||
| 1050 | |||
| 1051 | public boolean haMessoAsso() { | ||
| 1052 | return ( (haGiocato()) && (seme( frame.giocata[0] ) == semeBriscola) && | ||
| 1053 | (valore( frame.giocata[0] ) == ASSO) ); | ||
| 1054 | } | ||
| 1055 | |||
| 1056 | public boolean haCaricato() { | ||
| 1057 | return ( (haGiocato()) && (seme( frame.giocata[0] ) != semeBriscola) && | ||
| 1058 | ( (valore( frame.giocata[0] ) == ASSO) || (valore( frame.giocata[0] ) == TRE) ) ); | ||
| 1059 | } | ||
| 1060 | |||
| 1061 | /* I metodi seguenti cercano di andare liscio - dare punti - mettere | ||
| 1062 | * un taglio - ecc... e restituiscono true se hanno avuto successo, | ||
| 1063 | * false altrimenti. Le varianti -ConCarichiPassati e -ConCarichiInGioco | ||
| 1064 | * cercano, rispettivamente, di giocare un seme i cui carichi siano già | ||
| 1065 | * passati o ancora in gioco.*/ | ||
| 1066 | public boolean vaiLiscio() { | ||
| 1067 | for ( int i = 0; i < 3; i++ ) { | ||
| 1068 | if ( frame.carteCPU[i] != null ) { | ||
| 1069 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && | ||
| 1070 | (valore( frame.carteCPU[i] ) != RE) && (valore( frame.carteCPU[i] ) != ASSO) && | ||
| 1071 | (valore( frame.carteCPU[i] ) != TRE) && (valore( frame.carteCPU[i] ) < FANTE) ) { | ||
| 1072 | cartaDaGiocare = i; | ||
| 1073 | return true; | ||
| 1074 | } | ||
| 1075 | } | ||
| 1076 | } | ||
| 1077 | |||
| 1078 | return false; | ||
| 1079 | } | ||
| 1080 | |||
| 1081 | public boolean vaiLiscioConCarichiPassati() { | ||
| 1082 | for ( int i = 0; i < 3; i++ ) { | ||
| 1083 | if ( frame.carteCPU[i] != null ) { | ||
| 1084 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && | ||
| 1085 | (valore( frame.carteCPU[i] ) != RE) && (valore( frame.carteCPU[i] ) != ASSO) && | ||
| 1086 | (valore( frame.carteCPU[i] ) != TRE) && (valore( frame.carteCPU[i] ) < FANTE) | ||
| 1087 | && sonoPassatiICarichi( seme( frame.carteCPU[i] ) ) ) { | ||
| 1088 | cartaDaGiocare = i; | ||
| 1089 | return true; | ||
| 1090 | } else if ( (seme( frame.carteCPU[i] ) != semeBriscola) && | ||
| 1091 | (valore( frame.carteCPU[i] ) != RE) && (valore( frame.carteCPU[i] ) != ASSO) && | ||
| 1092 | (valore( frame.carteCPU[i] ) != TRE) && (valore( frame.carteCPU[i] ) < FANTE) | ||
| 1093 | && ePassato( ASSO, seme( frame.carteCPU[i] ) ) ) { | ||
| 1094 | cartaDaGiocare = i; | ||
| 1095 | return true; | ||
| 1096 | } else if ( (seme( frame.carteCPU[i] ) != semeBriscola) && | ||
| 1097 | (valore( frame.carteCPU[i] ) != RE) && (valore( frame.carteCPU[i] ) != ASSO) && | ||
| 1098 | (valore( frame.carteCPU[i] ) != TRE) && (valore( frame.carteCPU[i] ) < FANTE) | ||
| 1099 | && ePassato( TRE, seme( frame.carteCPU[i] ) ) ) { | ||
| 1100 | cartaDaGiocare = i; | ||
| 1101 | return true; | ||
| 1102 | } | ||
| 1103 | } | ||
| 1104 | } | ||
| 1105 | |||
| 1106 | return false; | ||
| 1107 | } | ||
| 1108 | |||
| 1109 | public boolean vaiLiscioConCarichiInGioco() { | ||
| 1110 | for ( int i = 0; i < 3; i++ ) { | ||
| 1111 | if ( frame.carteCPU[i] != null ) { | ||
| 1112 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && | ||
| 1113 | (valore( frame.carteCPU[i] ) != RE) && (valore( frame.carteCPU[i] ) != ASSO) && | ||
| 1114 | (valore( frame.carteCPU[i] ) != TRE) && (valore( frame.carteCPU[i] ) < FANTE) | ||
| 1115 | && !sonoPassatiICarichi( seme( frame.carteCPU[i] ) ) ) { | ||
| 1116 | cartaDaGiocare = i; | ||
| 1117 | return true; | ||
| 1118 | } else if ( (seme( frame.carteCPU[i] ) != semeBriscola) && | ||
| 1119 | (valore( frame.carteCPU[i] ) != RE) && (valore( frame.carteCPU[i] ) != ASSO) && | ||
| 1120 | (valore( frame.carteCPU[i] ) != TRE) && (valore( frame.carteCPU[i] ) < FANTE) | ||
| 1121 | && !ePassato( ASSO, seme( frame.carteCPU[i] ) ) ) { | ||
| 1122 | cartaDaGiocare = i; | ||
| 1123 | return true; | ||
| 1124 | } else if ( (seme( frame.carteCPU[i] ) != semeBriscola) && | ||
| 1125 | (valore( frame.carteCPU[i] ) != RE) && (valore( frame.carteCPU[i] ) != ASSO) && | ||
| 1126 | (valore( frame.carteCPU[i] ) != TRE) && (valore( frame.carteCPU[i] ) < FANTE) | ||
| 1127 | && !ePassato( TRE, seme( frame.carteCPU[i] ) ) ) { | ||
| 1128 | cartaDaGiocare = i; | ||
| 1129 | return true; | ||
| 1130 | } | ||
| 1131 | } | ||
| 1132 | } | ||
| 1133 | |||
| 1134 | return false; | ||
| 1135 | } | ||
| 1136 | |||
| 1137 | public boolean vaiPunti() { | ||
| 1138 | /* Cerca di dare punti, cercando di darne il meno possibile (meglio | ||
| 1139 | * un fante di re). */ | ||
| 1140 | for ( int i = 0; i < 3; i++ ) { | ||
| 1141 | if ( frame.carteCPU[i] != null ) { | ||
| 1142 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == FANTE ) ) { | ||
| 1143 | cartaDaGiocare = i; | ||
| 1144 | return true; | ||
| 1145 | } | ||
| 1146 | } | ||
| 1147 | } | ||
| 1148 | |||
| 1149 | for ( int i = 0; i < 3; i++ ) { | ||
| 1150 | if ( frame.carteCPU[i] != null ) { | ||
| 1151 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == CAVALLO ) ) { | ||
| 1152 | cartaDaGiocare = i; | ||
| 1153 | return true; | ||
| 1154 | } | ||
| 1155 | } | ||
| 1156 | } | ||
| 1157 | |||
| 1158 | for ( int i = 0; i < 3; i++ ) { | ||
| 1159 | if ( frame.carteCPU[i] != null ) { | ||
| 1160 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == RE ) ) { | ||
| 1161 | cartaDaGiocare = i; | ||
| 1162 | return true; | ||
| 1163 | } | ||
| 1164 | } | ||
| 1165 | } | ||
| 1166 | |||
| 1167 | return false; | ||
| 1168 | } | ||
| 1169 | |||
| 1170 | public boolean vaiPuntiConCarichiPassati() { | ||
| 1171 | for ( int i = 0; i < 3; i++ ) { | ||
| 1172 | if ( frame.carteCPU[i] != null ) { | ||
| 1173 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == FANTE ) | ||
| 1174 | && sonoPassatiICarichi( seme( frame.carteCPU[i] ) ) ) { | ||
| 1175 | cartaDaGiocare = i; | ||
| 1176 | return true; | ||
| 1177 | } else if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == FANTE ) | ||
| 1178 | && ePassato( ASSO, seme( frame.carteCPU[i] ) ) ) { | ||
| 1179 | cartaDaGiocare = i; | ||
| 1180 | return true; | ||
| 1181 | } else if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == FANTE ) | ||
| 1182 | && ePassato( TRE, seme( frame.carteCPU[i] ) ) ) { | ||
| 1183 | cartaDaGiocare = i; | ||
| 1184 | return true; | ||
| 1185 | } | ||
| 1186 | } | ||
| 1187 | } | ||
| 1188 | for ( int i = 0; i < 3; i++ ) { | ||
| 1189 | if ( frame.carteCPU[i] != null ) { | ||
| 1190 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == CAVALLO ) | ||
| 1191 | && sonoPassatiICarichi( seme( frame.carteCPU[i] ) ) ) { | ||
| 1192 | cartaDaGiocare = i; | ||
| 1193 | return true; | ||
| 1194 | } else if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == CAVALLO ) | ||
| 1195 | && ePassato( ASSO, seme( frame.carteCPU[i] ) ) ) { | ||
| 1196 | cartaDaGiocare = i; | ||
| 1197 | return true; | ||
| 1198 | } else if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == CAVALLO ) | ||
| 1199 | && ePassato( TRE, seme( frame.carteCPU[i] ) ) ) { | ||
| 1200 | cartaDaGiocare = i; | ||
| 1201 | return true; | ||
| 1202 | } | ||
| 1203 | } | ||
| 1204 | } | ||
| 1205 | for ( int i = 0; i < 3; i++ ) { | ||
| 1206 | if ( frame.carteCPU[i] != null ) { | ||
| 1207 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == RE ) | ||
| 1208 | && sonoPassatiICarichi( seme( frame.carteCPU[i] ) ) ) { | ||
| 1209 | cartaDaGiocare = i; | ||
| 1210 | return true; | ||
| 1211 | } else if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == RE ) | ||
| 1212 | && ePassato( ASSO, seme( frame.carteCPU[i] ) ) ) { | ||
| 1213 | cartaDaGiocare = i; | ||
| 1214 | return true; | ||
| 1215 | } else if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == RE ) | ||
| 1216 | && ePassato( TRE, seme( frame.carteCPU[i] ) ) ) { | ||
| 1217 | cartaDaGiocare = i; | ||
| 1218 | return true; | ||
| 1219 | } | ||
| 1220 | } | ||
| 1221 | } | ||
| 1222 | |||
| 1223 | return false; | ||
| 1224 | } | ||
| 1225 | |||
| 1226 | public boolean vaiPuntiConCarichiInGioco() { | ||
| 1227 | for ( int i = 0; i < 3; i++ ) { | ||
| 1228 | if ( frame.carteCPU[i] != null ) { | ||
| 1229 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == FANTE ) | ||
| 1230 | && !sonoPassatiICarichi( seme( frame.carteCPU[i] ) ) ) { | ||
| 1231 | cartaDaGiocare = i; | ||
| 1232 | return true; | ||
| 1233 | } else if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == FANTE ) | ||
| 1234 | && !ePassato( ASSO, seme( frame.carteCPU[i] ) ) ) { | ||
| 1235 | cartaDaGiocare = i; | ||
| 1236 | return true; | ||
| 1237 | } else if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == FANTE ) | ||
| 1238 | && !ePassato( TRE, seme( frame.carteCPU[i] ) ) ) { | ||
| 1239 | cartaDaGiocare = i; | ||
| 1240 | return true; | ||
| 1241 | } | ||
| 1242 | } | ||
| 1243 | } | ||
| 1244 | for ( int i = 0; i < 3; i++ ) { | ||
| 1245 | if ( frame.carteCPU[i] != null ) { | ||
| 1246 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == CAVALLO ) | ||
| 1247 | && !sonoPassatiICarichi( seme( frame.carteCPU[i] ) ) ) { | ||
| 1248 | cartaDaGiocare = i; | ||
| 1249 | return true; | ||
| 1250 | } else if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == CAVALLO ) | ||
| 1251 | && !ePassato( ASSO, seme( frame.carteCPU[i] ) ) ) { | ||
| 1252 | cartaDaGiocare = i; | ||
| 1253 | return true; | ||
| 1254 | } else if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == CAVALLO ) | ||
| 1255 | && !ePassato( TRE, seme( frame.carteCPU[i] ) ) ) { | ||
| 1256 | cartaDaGiocare = i; | ||
| 1257 | return true; | ||
| 1258 | } | ||
| 1259 | } | ||
| 1260 | } | ||
| 1261 | for ( int i = 0; i < 3; i++ ) { | ||
| 1262 | if ( frame.carteCPU[i] != null ) { | ||
| 1263 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == RE ) | ||
| 1264 | && !sonoPassatiICarichi( seme( frame.carteCPU[i] ) ) ) { | ||
| 1265 | cartaDaGiocare = i; | ||
| 1266 | return true; | ||
| 1267 | } else if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == RE ) | ||
| 1268 | && !ePassato( ASSO, seme( frame.carteCPU[i] ) ) ) { | ||
| 1269 | cartaDaGiocare = i; | ||
| 1270 | return true; | ||
| 1271 | } else if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == RE ) | ||
| 1272 | && !ePassato( TRE, seme( frame.carteCPU[i] ) ) ) { | ||
| 1273 | cartaDaGiocare = i; | ||
| 1274 | return true; | ||
| 1275 | } | ||
| 1276 | } | ||
| 1277 | } | ||
| 1278 | |||
| 1279 | return false; | ||
| 1280 | } | ||
| 1281 | |||
| 1282 | public boolean vaiTaglio() { | ||
| 1283 | for ( int i = 0; i < 3; i++ ) { | ||
| 1284 | if ( frame.carteCPU[i] != null ) { | ||
| 1285 | if ( seme( frame.carteCPU[i] ) == semeBriscola && | ||
| 1286 | (valore( frame.carteCPU[i] ) != RE) && (valore( frame.carteCPU[i] ) != ASSO) && | ||
| 1287 | (valore( frame.carteCPU[i] ) != TRE) && (valore( frame.carteCPU[i] ) < FANTE) ) { | ||
| 1288 | cartaDaGiocare = i; | ||
| 1289 | return true; | ||
| 1290 | } | ||
| 1291 | } | ||
| 1292 | } | ||
| 1293 | |||
| 1294 | return false; | ||
| 1295 | } | ||
| 1296 | public boolean vaiBriscolaAlta() { | ||
| 1297 | for ( int i = 0; i < 3; i++ ) { | ||
| 1298 | if ( frame.carteCPU[i] != null ) { | ||
| 1299 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && (valore( frame.carteCPU[i] ) == FANTE) ) { | ||
| 1300 | cartaDaGiocare = i; | ||
| 1301 | return true; | ||
| 1302 | } | ||
| 1303 | } | ||
| 1304 | } | ||
| 1305 | |||
| 1306 | for ( int i = 0; i < 3; i++ ) { | ||
| 1307 | if ( frame.carteCPU[i] != null ) { | ||
| 1308 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && (valore( frame.carteCPU[i] ) == CAVALLO) ) { | ||
| 1309 | cartaDaGiocare = i; | ||
| 1310 | return true; | ||
| 1311 | } | ||
| 1312 | } | ||
| 1313 | } | ||
| 1314 | |||
| 1315 | for ( int i = 0; i < 3; i++ ) { | ||
| 1316 | if ( frame.carteCPU[i] != null ) { | ||
| 1317 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && (valore( frame.carteCPU[i] ) == RE) ) { | ||
| 1318 | cartaDaGiocare = i; | ||
| 1319 | return true; | ||
| 1320 | } | ||
| 1321 | } | ||
| 1322 | } | ||
| 1323 | |||
| 1324 | return false; | ||
| 1325 | } | ||
| 1326 | public boolean vaiTre() { | ||
| 1327 | for ( int i = 0; i < 3; i++ ) { | ||
| 1328 | if ( frame.carteCPU[i] != null ) { | ||
| 1329 | if ( seme( frame.carteCPU[i] ) == semeBriscola && (valore( frame.carteCPU[i] ) == TRE) ) { | ||
| 1330 | cartaDaGiocare = i; | ||
| 1331 | return true; | ||
| 1332 | } | ||
| 1333 | } | ||
| 1334 | } | ||
| 1335 | |||
| 1336 | return false; | ||
| 1337 | } | ||
| 1338 | public boolean vaiAsso() { | ||
| 1339 | for ( int i = 0; i < 3; i++ ) { | ||
| 1340 | if ( frame.carteCPU[i] != null ) { | ||
| 1341 | if ( seme( frame.carteCPU[i] ) == semeBriscola && (valore( frame.carteCPU[i] ) == ASSO) ) { | ||
| 1342 | cartaDaGiocare = i; | ||
| 1343 | return true; | ||
| 1344 | } | ||
| 1345 | } | ||
| 1346 | } | ||
| 1347 | |||
| 1348 | return false; | ||
| 1349 | } | ||
| 1350 | public boolean vaiCarico() { | ||
| 1351 | |||
| 1352 | for ( int i = 0; i < 3; i++ ) { | ||
| 1353 | if ( frame.carteCPU[i] != null ) { | ||
| 1354 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == ASSO) ) { | ||
| 1355 | cartaDaGiocare = i; | ||
| 1356 | return true; | ||
| 1357 | } | ||
| 1358 | } | ||
| 1359 | } | ||
| 1360 | |||
| 1361 | for ( int i = 0; i < 3; i++ ) { | ||
| 1362 | if ( frame.carteCPU[i] != null ) { | ||
| 1363 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && (valore( frame.carteCPU[i] ) == TRE) ) { | ||
| 1364 | cartaDaGiocare = i; | ||
| 1365 | return true; | ||
| 1366 | } | ||
| 1367 | } | ||
| 1368 | } | ||
| 1369 | |||
| 1370 | return false; | ||
| 1371 | } | ||
| 1372 | |||
| 1373 | /* Gioca una carta diversa da quella passata come parametro */ | ||
| 1374 | public boolean vaiNon( int valore, int seme ) { | ||
| 1375 | for ( int i = 0; i < 3; i++ ) { | ||
| 1376 | if ( frame.carteCPU[i] != null ) { | ||
| 1377 | if ( seme( frame.carteCPU[i] ) != seme && valore( frame.carteCPU[i] ) != valore ) { | ||
| 1378 | cartaDaGiocare = i; | ||
| 1379 | return true; | ||
| 1380 | } | ||
| 1381 | } | ||
| 1382 | } | ||
| 1383 | |||
| 1384 | return false; | ||
| 1385 | } | ||
| 1386 | |||
| 1387 | /* Gioca la prima carta che trova */ | ||
| 1388 | public boolean vaiPrima() { | ||
| 1389 | for ( int i = 0; i < 3; i++ ) { | ||
| 1390 | if ( frame.carteCPU[i] != null ) { | ||
| 1391 | cartaDaGiocare = i; | ||
| 1392 | return true; | ||
| 1393 | } | ||
| 1394 | } | ||
| 1395 | |||
| 1396 | return false; | ||
| 1397 | } | ||
| 1398 | |||
| 1399 | /* Metodi per l'ultima mano */ | ||
| 1400 | public boolean vaiBriscolaPiuAltaInGioco() { | ||
| 1401 | for ( int i = 0; i < 3; i++ ) { | ||
| 1402 | if ( frame.carteCPU[i] != null ) { | ||
| 1403 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && (valore( frame.carteCPU[i] ) == piuAltaInGioco()) ) { | ||
| 1404 | cartaDaGiocare = i; | ||
| 1405 | return true; | ||
| 1406 | } | ||
| 1407 | } | ||
| 1408 | } | ||
| 1409 | |||
| 1410 | return false; | ||
| 1411 | } | ||
| 1412 | |||
| 1413 | public boolean vaiSecondaBriscolaPiuAltaInGioco() { | ||
| 1414 | for ( int i = 0; i < 3; i++ ) { | ||
| 1415 | if ( frame.carteCPU[i] != null ) { | ||
| 1416 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && (valore( frame.carteCPU[i] ) == secondaPiuAltaInGioco()) ) { | ||
| 1417 | cartaDaGiocare = i; | ||
| 1418 | return true; | ||
| 1419 | } | ||
| 1420 | } | ||
| 1421 | } | ||
| 1422 | |||
| 1423 | return false; | ||
| 1424 | } | ||
| 1425 | |||
| 1426 | public boolean vaiSopra() { | ||
| 1427 | /* Innanzitutto controlla se il giocatore ha giocato (non dovrebbe | ||
| 1428 | * essere possibile, in quanto quando questo metodo viene chiamato | ||
| 1429 | * tale condizione è già stata verificata, ma è sempre meglio un | ||
| 1430 | * controllo in più che uno in meno) e restituisce false in caso | ||
| 1431 | * contrario */ | ||
| 1432 | if ( !haGiocato() ) | ||
| 1433 | return false; | ||
| 1434 | |||
| 1435 | /* Tre variabili intere che serviranno a valutare quali delle tre | ||
| 1436 | * carte è meglio giocare, se più di una può andare sopra. */ | ||
| 1437 | int a = -1; | ||
| 1438 | int b = -1; | ||
| 1439 | int c = -1; | ||
| 1440 | |||
| 1441 | /* Tre booleane che verificano quali delle tre carte possono | ||
| 1442 | * andare sopra. */ | ||
| 1443 | boolean laPrimaPuoAndareSopra = false; | ||
| 1444 | boolean laSecondaPuoAndareSopra = false; | ||
| 1445 | boolean laTerzaPuoAndareSopra = false; | ||
| 1446 | |||
| 1447 | /* Se il giocatore ha giocato un asso, restituisce direttamente false. */ | ||
| 1448 | if ( valore( frame.giocata[0] ) == ASSO ) | ||
| 1449 | return false; | ||
| 1450 | |||
| 1451 | /* Valuta quali delle tre carte possono andare sopra, dopo essersi | ||
| 1452 | * accertato di averle: nelle ultime mani non si hanno tutte le carte | ||
| 1453 | * in mano, e noi non vogliamo una NullPointerException sul più bello | ||
| 1454 | * di una partita, vero?! */ | ||
| 1455 | if ( frame.carteCPU[0] != null ) { | ||
| 1456 | a = valore( frame.carteCPU[0] ); | ||
| 1457 | if ( (seme( frame.carteCPU[0] ) == seme( frame.giocata[0] )) && laPrimaEPiuAlta( a, valore( frame.giocata[0] ) ) ) | ||
| 1458 | laPrimaPuoAndareSopra = true; | ||
| 1459 | } | ||
| 1460 | |||
| 1461 | if ( frame.carteCPU[1] != null ) { | ||
| 1462 | b = valore( frame.carteCPU[1] ); | ||
| 1463 | if ( (seme( frame.carteCPU[1] ) == seme( frame.giocata[0] )) && laPrimaEPiuAlta( b, valore( frame.giocata[0] ) ) ) | ||
| 1464 | laSecondaPuoAndareSopra = true; | ||
| 1465 | } | ||
| 1466 | |||
| 1467 | if ( frame.carteCPU[2] != null ) { | ||
| 1468 | c = valore( frame.carteCPU[2] ); | ||
| 1469 | if ( (seme( frame.carteCPU[2] ) == seme( frame.giocata[0] )) && laPrimaEPiuAlta( c, valore( frame.giocata[0] ) ) ) | ||
| 1470 | laTerzaPuoAndareSopra = true; | ||
| 1471 | } | ||
| 1472 | |||
| 1473 | /* Se nessuna carta può andare sopra, restituisce false. Se una | ||
| 1474 | * sola delle tre può andare sopra la imposta come carta da giocare. */ | ||
| 1475 | if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 1476 | return false; | ||
| 1477 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 1478 | cartaDaGiocare = 0; | ||
| 1479 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 1480 | cartaDaGiocare = 1; | ||
| 1481 | else if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 1482 | cartaDaGiocare = 2; | ||
| 1483 | |||
| 1484 | /* Se più di una carta può andare sopra, valuta quale è più alta. */ | ||
| 1485 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 1486 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 1487 | cartaDaGiocare = 0; | ||
| 1488 | else | ||
| 1489 | cartaDaGiocare = 1; | ||
| 1490 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 1491 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 1492 | cartaDaGiocare = 1; | ||
| 1493 | else | ||
| 1494 | cartaDaGiocare = 2; | ||
| 1495 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 1496 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 1497 | cartaDaGiocare = 0; | ||
| 1498 | else | ||
| 1499 | cartaDaGiocare = 2; | ||
| 1500 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 1501 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 1502 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 1503 | cartaDaGiocare = 0; | ||
| 1504 | else | ||
| 1505 | cartaDaGiocare = 2; | ||
| 1506 | else | ||
| 1507 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 1508 | cartaDaGiocare = 1; | ||
| 1509 | else | ||
| 1510 | cartaDaGiocare = 2; | ||
| 1511 | |||
| 1512 | /* Controlla che la carta con cui sta cercando di andare sopra | ||
| 1513 | * sia una figura o un carico. Non vogliamo mica prendere delle | ||
| 1514 | * scartelle con delle scartelle, giusto?! */ | ||
| 1515 | if ( ( valore( frame.carteCPU[cartaDaGiocare] ) != RE ) && ( valore( frame.carteCPU[cartaDaGiocare] ) != ASSO ) && | ||
| 1516 | ( valore( frame.carteCPU[cartaDaGiocare] ) != TRE ) && ( valore( frame.carteCPU[cartaDaGiocare] ) <= SETTE ) ) | ||
| 1517 | return false; | ||
| 1518 | |||
| 1519 | return true; | ||
| 1520 | } | ||
| 1521 | |||
| 1522 | /* I metodi seguenti valutano le carte che la CPU ha in mano. */ | ||
| 1523 | public boolean hoCarico() { | ||
| 1524 | for ( int i = 0; i < 3; i++ ) { | ||
| 1525 | if ( frame.carteCPU[i] != null ) { | ||
| 1526 | if ( (seme( frame.carteCPU[i] ) != semeBriscola) && | ||
| 1527 | ( ( valore( frame.carteCPU[i] ) == ASSO ) || ( valore( frame.carteCPU[i] ) == TRE ) ) ) { | ||
| 1528 | return true; | ||
| 1529 | } | ||
| 1530 | } | ||
| 1531 | } | ||
| 1532 | |||
| 1533 | return false; | ||
| 1534 | } | ||
| 1535 | public boolean hoAsso() { | ||
| 1536 | for ( int i = 0; i < 3; i++ ) { | ||
| 1537 | if ( frame.carteCPU[i] != null ) { | ||
| 1538 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && (valore( frame.carteCPU[i] ) == ASSO ) ) { | ||
| 1539 | return true; | ||
| 1540 | } | ||
| 1541 | } | ||
| 1542 | } | ||
| 1543 | |||
| 1544 | return false; | ||
| 1545 | } | ||
| 1546 | public boolean hoTre() { | ||
| 1547 | for ( int i = 0; i < 3; i++ ) { | ||
| 1548 | if ( frame.carteCPU[i] != null ) { | ||
| 1549 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && (valore( frame.carteCPU[i] ) == TRE ) ) { | ||
| 1550 | return true; | ||
| 1551 | } | ||
| 1552 | } | ||
| 1553 | } | ||
| 1554 | |||
| 1555 | return false; | ||
| 1556 | } | ||
| 1557 | public boolean hoBriscolaAlta() { | ||
| 1558 | for ( int i = 0; i < 3; i++ ) { | ||
| 1559 | if ( frame.carteCPU[i] != null ) { | ||
| 1560 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && | ||
| 1561 | ( (valore( frame.carteCPU[i] ) == RE) || (valore( frame.carteCPU[i] ) == FANTE) || (valore( frame.carteCPU[i] ) == CAVALLO) ) ) { | ||
| 1562 | return true; | ||
| 1563 | } | ||
| 1564 | } | ||
| 1565 | } | ||
| 1566 | |||
| 1567 | return false; | ||
| 1568 | } | ||
| 1569 | public boolean hoTaglio() { | ||
| 1570 | for ( int i = 0; i < 3; i++ ) { | ||
| 1571 | if ( frame.carteCPU[i] != null ) { | ||
| 1572 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && | ||
| 1573 | (valore( frame.carteCPU[i] ) < FANTE ) && (valore( frame.carteCPU[i] ) != TRE ) | ||
| 1574 | && (valore( frame.carteCPU[i] ) != ASSO ) && (valore( frame.carteCPU[i] ) != RE ) ) { | ||
| 1575 | return true; | ||
| 1576 | } | ||
| 1577 | } | ||
| 1578 | } | ||
| 1579 | |||
| 1580 | return false; | ||
| 1581 | } | ||
| 1582 | |||
| 1583 | /* Metodi per l'ultima mano */ | ||
| 1584 | public boolean hoLaBriscolaPiuAltaInGioco() { | ||
| 1585 | for ( int i = 0; i < 3; i++ ) { | ||
| 1586 | if ( frame.carteCPU[i] != null ) { | ||
| 1587 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && (valore( frame.carteCPU[i] ) == piuAltaInGioco()) ) | ||
| 1588 | return true; | ||
| 1589 | } | ||
| 1590 | } | ||
| 1591 | |||
| 1592 | return false; | ||
| 1593 | } | ||
| 1594 | public boolean hoLaSecondaBriscolaPiuAltaInGioco() { | ||
| 1595 | for ( int i = 0; i < 3; i++ ) { | ||
| 1596 | if ( frame.carteCPU[i] != null ) { | ||
| 1597 | if ( (seme( frame.carteCPU[i] ) == semeBriscola) && (valore( frame.carteCPU[i] ) == secondaPiuAltaInGioco()) ) | ||
| 1598 | return true; | ||
| 1599 | } | ||
| 1600 | } | ||
| 1601 | |||
| 1602 | return false; | ||
| 1603 | } | ||
| 1604 | public boolean luiHaLaBriscolaPiuAltaInGioco() { | ||
| 1605 | for ( int i = 0; i < 3; i++ ) { | ||
| 1606 | if ( frame.carteInMano[i] != null ) { | ||
| 1607 | if ( (seme( frame.carteInMano[i] ) == semeBriscola) && (valore( frame.carteInMano[i] ) == piuAltaInGioco()) ) | ||
| 1608 | return true; | ||
| 1609 | } | ||
| 1610 | } | ||
| 1611 | |||
| 1612 | return false; | ||
| 1613 | } | ||
| 1614 | public boolean luiHaLaSecondaBriscolaPiuAltaInGioco() { | ||
| 1615 | for ( int i = 0; i < 3; i++ ) { | ||
| 1616 | if ( frame.carteInMano[i] != null ) { | ||
| 1617 | if ( (seme( frame.carteInMano[i] ) == semeBriscola) && (valore( frame.carteInMano[i] ) == secondaPiuAltaInGioco()) ) | ||
| 1618 | return true; | ||
| 1619 | } | ||
| 1620 | } | ||
| 1621 | |||
| 1622 | return false; | ||
| 1623 | } | ||
| 1624 | public boolean luiHaTutteBriscole() { | ||
| 1625 | if ( frame.carteInMano[0] != null && seme( frame.carteInMano[0] ) != semeBriscola ) return false; | ||
| 1626 | else if ( frame.carteInMano[1] != null && seme( frame.carteInMano[1] ) != semeBriscola ) return false; | ||
| 1627 | else if ( frame.carteInMano[2] != null && seme( frame.carteInMano[2] ) != semeBriscola ) return false; | ||
| 1628 | else return true; | ||
| 1629 | } | ||
| 1630 | |||
| 1631 | /* Restituisce il seme della carta passata come parametro */ | ||
| 1632 | public static int seme( ImageIcon carta ) { | ||
| 1633 | char aux[] = carta.toString().toCharArray(); | ||
| 1634 | return aux[aux.length-5] - 49; | ||
| 1635 | } | ||
| 1636 | |||
| 1637 | /* Restituisce il valore della carta */ | ||
| 1638 | public static int valore( ImageIcon carta ) { | ||
| 1639 | char aux[] = carta.toString().toCharArray(); | ||
| 1640 | return aux[aux.length-7] - 48; | ||
| 1641 | } | ||
| 1642 | |||
| 1643 | /* Controlla se una carta è già passata */ | ||
| 1644 | public static boolean ePassato( int valore, int seme ) { | ||
| 1645 | for ( int i = 0; ; i++ ) { | ||
| 1646 | if ( frame.arrayCartePassate[i] == null ) { | ||
| 1647 | for ( int j = 0; j < 3; j++ ) | ||
| 1648 | if ( frame.carteCPU[j] != null && valore( frame.carteCPU[j] ) == valore && seme( frame.carteCPU[j] ) == seme ) return true; | ||
| 1649 | return false; | ||
| 1650 | } | ||
| 1651 | else if ( valore( frame.arrayCartePassate[i] ) == valore && seme( frame.arrayCartePassate[i] ) == seme ) return true; | ||
| 1652 | } | ||
| 1653 | } | ||
| 1654 | |||
| 1655 | /* Controlla se sono passati i carichi di un determinato seme */ | ||
| 1656 | public static boolean sonoPassatiICarichi( int seme ) { | ||
| 1657 | return ePassato( TRE, seme ) && ePassato( ASSO, seme ); | ||
| 1658 | } | ||
| 1659 | |||
| 1660 | /* Restituisce il valore della briscola più alta in gioco*/ | ||
| 1661 | public static int piuAltaInGioco() { | ||
| 1662 | if ( !ePassato( ASSO, semeBriscola ) ) return ASSO; | ||
| 1663 | else if ( !ePassato( TRE, semeBriscola ) ) return TRE; | ||
| 1664 | else if ( !ePassato( RE, semeBriscola ) ) return RE; | ||
| 1665 | else if ( !ePassato( CAVALLO, semeBriscola ) ) return CAVALLO; | ||
| 1666 | else if ( !ePassato( FANTE, semeBriscola ) ) return FANTE; | ||
| 1667 | else if ( !ePassato( SETTE, semeBriscola ) ) return SETTE; | ||
| 1668 | else if ( !ePassato( SEI, semeBriscola ) ) return SEI; | ||
| 1669 | else if ( !ePassato( CINQUE, semeBriscola ) ) return CINQUE; | ||
| 1670 | else if ( !ePassato( QUATTRO, semeBriscola ) ) return QUATTRO; | ||
| 1671 | else if ( !ePassato( DUE, semeBriscola ) ) return DUE; | ||
| 1672 | else return -1; | ||
| 1673 | } | ||
| 1674 | |||
| 1675 | /* Restituisce il valore della seconda briscola più alta in gioco*/ | ||
| 1676 | public static int secondaPiuAltaInGioco() { | ||
| 1677 | if ( !ePassato( ASSO, semeBriscola ) && piuAltaInGioco() != ASSO ) return ASSO; | ||
| 1678 | else if ( !ePassato( TRE, semeBriscola ) && piuAltaInGioco() != TRE ) return TRE; | ||
| 1679 | else if ( !ePassato( RE, semeBriscola ) && piuAltaInGioco() != RE ) return RE; | ||
| 1680 | else if ( !ePassato( CAVALLO, semeBriscola ) && piuAltaInGioco() != CAVALLO ) return CAVALLO; | ||
| 1681 | else if ( !ePassato( FANTE, semeBriscola ) && piuAltaInGioco() != FANTE ) return FANTE; | ||
| 1682 | else if ( !ePassato( SETTE, semeBriscola ) && piuAltaInGioco() != SETTE ) return SETTE; | ||
| 1683 | else if ( !ePassato( SEI, semeBriscola ) && piuAltaInGioco() != SEI ) return SEI; | ||
| 1684 | else if ( !ePassato( CINQUE, semeBriscola ) && piuAltaInGioco() != CINQUE ) return CINQUE; | ||
| 1685 | else if ( !ePassato( QUATTRO, semeBriscola ) && piuAltaInGioco() != QUATTRO ) return QUATTRO; | ||
| 1686 | else if ( !ePassato( DUE, semeBriscola ) && piuAltaInGioco() != DUE ) return DUE; | ||
| 1687 | else return -1; | ||
| 1688 | } | ||
| 1689 | |||
| 1690 | /* I vari trucchi del gioco. */ | ||
| 1691 | public static void trucco( String trucco ) { | ||
| 1692 | |||
| 1693 | byte[] truccoByte = trucco.getBytes(); | ||
| 1694 | char[] truccoChar = new char[ truccoByte.length ]; | ||
| 1695 | for ( int i = 0; i < truccoChar.length; i++ ) | ||
| 1696 | truccoChar[i] = (char)truccoByte[i]; | ||
| 1697 | |||
| 1698 | String attivato = stringaTruccoSbagliato; | ||
| 1699 | |||
| 1700 | /* Carta che vuoi dove vuoi. Esempio: x251 sostituisce | ||
| 1701 | * la terza carta (2) con il 6 (5) di coppe (1). */ | ||
| 1702 | if ( truccoChar[0] == 'x' && truccoChar.length == 4 ) { | ||
| 1703 | |||
| 1704 | attivato = stringaTruccoAttivato; | ||
| 1705 | |||
| 1706 | String aS = "" + truccoChar[1]; | ||
| 1707 | String xS = "" + truccoChar[2]; | ||
| 1708 | String yS = "" + truccoChar[3]; | ||
| 1709 | |||
| 1710 | int a, x, y; | ||
| 1711 | |||
| 1712 | try { | ||
| 1713 | |||
| 1714 | a = Integer.parseInt( aS ); | ||
| 1715 | x = Integer.parseInt( xS ); | ||
| 1716 | y = Integer.parseInt( yS ); | ||
| 1717 | |||
| 1718 | frame.carteInMano[a] = frame.arrayCarte[x][y]; | ||
| 1719 | |||
| 1720 | } catch ( Exception e ) { | ||
| 1721 | attivato = stringaTruccoSbagliato; | ||
| 1722 | } | ||
| 1723 | } | ||
| 1724 | |||
| 1725 | /* Mostra le carte del computer. */ | ||
| 1726 | if ( trucco.equalsIgnoreCase( "Kill Devil Hill" ) ) { | ||
| 1727 | |||
| 1728 | attivato = stringaTruccoAttivato; | ||
| 1729 | |||
| 1730 | carteScoperte = true; | ||
| 1731 | |||
| 1732 | } | ||
| 1733 | |||
| 1734 | /* Scambia le carte con il computer. */ | ||
| 1735 | if ( trucco.equalsIgnoreCase( "Darkside of Aquarius" ) ) { | ||
| 1736 | |||
| 1737 | attivato = stringaTruccoAttivato; | ||
| 1738 | |||
| 1739 | ImageIcon aux = null; | ||
| 1740 | |||
| 1741 | for ( int i = 0; i < 3; i++ ) { | ||
| 1742 | |||
| 1743 | aux = frame.carteInMano[i]; | ||
| 1744 | frame.carteInMano[i] = frame.carteCPU[i]; | ||
| 1745 | frame.carteCPU[i] = aux; | ||
| 1746 | |||
| 1747 | } | ||
| 1748 | } | ||
| 1749 | |||
| 1750 | /* Cambia il seme di briscola con uno a caso, senza dire quale. | ||
| 1751 | * L'ultima carta non cambia. È possibile comunque capire | ||
| 1752 | * qual'è la briscola dal menu ?->Briscola*/ | ||
| 1753 | if ( trucco.equalsIgnoreCase( "Change of Heart" ) ) { | ||
| 1754 | |||
| 1755 | attivato = stringaTruccoAttivato; | ||
| 1756 | |||
| 1757 | semeBriscola = (int) ( Math.random() * 4 ); | ||
| 1758 | |||
| 1759 | } | ||
| 1760 | |||
| 1761 | /* Asso Tre e Re di Briscola tutti in mano (anche in caso di doppioni). */ | ||
| 1762 | if ( trucco.equalsIgnoreCase( "Tears of The Dragon" ) ) { | ||
| 1763 | |||
| 1764 | attivato = stringaTruccoAttivato; | ||
| 1765 | |||
| 1766 | frame.carteInMano[0] = frame.arrayCarte[9][semeBriscola]; | ||
| 1767 | frame.carteInMano[1] = frame.arrayCarte[2][semeBriscola]; | ||
| 1768 | frame.carteInMano[2] = frame.arrayCarte[0][semeBriscola]; | ||
| 1769 | |||
| 1770 | } | ||
| 1771 | |||
| 1772 | /* Tre assi di briscola. */ | ||
| 1773 | if ( trucco.equalsIgnoreCase( "Navigate The Seas of The Sun" ) ) { | ||
| 1774 | |||
| 1775 | attivato = stringaTruccoAttivato; | ||
| 1776 | |||
| 1777 | frame.carteInMano[0] = frame.arrayCarte[0][semeBriscola]; | ||
| 1778 | frame.carteInMano[1] = frame.arrayCarte[0][semeBriscola]; | ||
| 1779 | frame.carteInMano[2] = frame.arrayCarte[0][semeBriscola]; | ||
| 1780 | |||
| 1781 | } | ||
| 1782 | |||
| 1783 | /* Fa finire la partita al prossimo piglio. */ | ||
| 1784 | if ( trucco.equalsIgnoreCase( "Omega" ) ) { | ||
| 1785 | |||
| 1786 | attivato = stringaTruccoAttivato; | ||
| 1787 | |||
| 1788 | mano = 19; | ||
| 1789 | |||
| 1790 | } | ||
| 1791 | |||
| 1792 | JOptionPane.showMessageDialog( frame, attivato, "JBriscola - " + version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 1793 | frame.pannello.repaint(); | ||
| 1794 | frame.repaint(); | ||
| 1795 | |||
| 1796 | } | ||
| 1797 | |||
| 1798 | /* Imposta le opzioni dell'utente cercando di leggerle dal file di configurazione. */ | ||
| 1799 | public static void settaOpzioni() { | ||
| 1800 | |||
| 1801 | /* Impostazioni predefinite. */ | ||
| 1802 | lang = "it"; | ||
| 1803 | soundString = "suono=si"; | ||
| 1804 | keysString = "tasti=si"; | ||
| 1805 | int r = 0; | ||
| 1806 | int g = 150; | ||
| 1807 | int b = 0; | ||
| 1808 | |||
| 1809 | /* Cerca di leggere il file per impostare le opzioni. */ | ||
| 1810 | Scanner scanner = null; | ||
| 1811 | File file = new File( "JBriscolaConfig.txt" ); | ||
| 1812 | if ( file.exists() ) { | ||
| 1813 | try { | ||
| 1814 | scanner = new Scanner( file ); | ||
| 1815 | } catch ( FileNotFoundException e ) { } | ||
| 1816 | try { | ||
| 1817 | lang = scanner.next(); | ||
| 1818 | soundString = scanner.next(); | ||
| 1819 | keysString = scanner.next(); | ||
| 1820 | r = scanner.nextInt(); | ||
| 1821 | g = scanner.nextInt(); | ||
| 1822 | b = scanner.nextInt(); | ||
| 1823 | } catch ( NoSuchElementException e ) { } | ||
| 1824 | } | ||
| 1825 | |||
| 1826 | /* Modifica le opzioni. */ | ||
| 1827 | if ( lang.equals( "it" ) ) { | ||
| 1828 | semi[0] = "Bastoni"; | ||
| 1829 | semi[1] = "Coppe"; | ||
| 1830 | semi[2] = "Denari"; | ||
| 1831 | semi[3] = "Spade"; | ||
| 1832 | stringaBriscola = "Briscola"; | ||
| 1833 | stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 1834 | stringaPrimaGioca = "Prima Gioca!"; | ||
| 1835 | stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 1836 | stringaVinto = "Hai Vinto!"; | ||
| 1837 | stringaPerso = "Hai Perso"; | ||
| 1838 | stringaPareggio = "Pareggio"; | ||
| 1839 | stringaGiocatore = "Giocatore: "; | ||
| 1840 | stringaComputer = "\nComputer: "; | ||
| 1841 | stringaNuovaPartita = "Nuova Partita"; | ||
| 1842 | stringaNuovaPartitaAiTrenta = "Nuova Partita Ai 30"; | ||
| 1843 | stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 1844 | stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 1845 | stringaSi = "Si"; | ||
| 1846 | stringaNo = "No"; | ||
| 1847 | stringaOpzioni = "Opzioni..."; | ||
| 1848 | stringaEsci = "Esci"; | ||
| 1849 | stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 1850 | stringaLingua = "Lingua"; | ||
| 1851 | stringaAnnulla = "Annulla"; | ||
| 1852 | stringaIt = "Italiano"; | ||
| 1853 | stringaLa = "Latino"; | ||
| 1854 | stringaBL = "Dialetto Bellunese"; | ||
| 1855 | stringaBV = "Dialetto Basso Veneto"; | ||
| 1856 | stringaEN = "Inglese"; | ||
| 1857 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1858 | stringaInformazioni = "Informazioni"; | ||
| 1859 | 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"; | ||
| 1860 | stringaSuono = "Effetti sonori"; | ||
| 1861 | stringaPunteggio = "Punteggio"; | ||
| 1862 | stringaCartePassate = "Carte Passate"; | ||
| 1863 | stringaSfondo = "Sfondo"; | ||
| 1864 | stringaTasti = "Tasti rapidi"; | ||
| 1865 | stringaAggiornamenti = "Cerca aggiornamenti"; | ||
| 1866 | stringaTrucchi = "Trucchi"; | ||
| 1867 | stringaInserisciCodice = "Inserisci il codice:"; | ||
| 1868 | stringaTruccoAttivato = "Trucco attivato!"; | ||
| 1869 | stringaTruccoSbagliato = "Trucco non valido"; | ||
| 1870 | stringaCheCartaVuoi = "E allora che carta vuoi?"; | ||
| 1871 | stringaAggiornamentiSi = "Aggiornamento disponibile: "; | ||
| 1872 | stringaAggiornamentiNo = "Nessun aggiornamento disponibile"; | ||
| 1873 | stringaScarica = "E' possibile scaricare la versione più recente\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 1874 | stringaNoInternet = "Errore: nessuna connessione internet"; | ||
| 1875 | 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 " + stringaCartePassate + "\nF6 " + stringaInformazioni + "\nF7 " + stringaAggiornamenti + "\nF8 " + stringaNuovaPartitaAiTrenta + "\nF9 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 1876 | } | ||
| 1877 | else if ( lang.equals( "la" ) ) { | ||
| 1878 | semi[0] = "BACULI"; | ||
| 1879 | semi[1] = "CALICES"; | ||
| 1880 | semi[2] = "DENARII"; | ||
| 1881 | semi[3] = "GLADII"; | ||
| 1882 | stringaBriscola = "BRISCOLA"; | ||
| 1883 | stringaBottonePrendi = "CAPIS/RELINQVIS CHARTAS"; | ||
| 1884 | stringaPrimaGioca = "ANTE CHARTAM PONE!"; | ||
| 1885 | stringaUltime4 = "CHARTA POSTREMA - INTVERE BRISCOLAM!"; | ||
| 1886 | stringaVinto = "VICISTI!"; | ||
| 1887 | stringaPerso = "PERDIDISTI"; | ||
| 1888 | stringaPareggio = "AEQVATIO!"; | ||
| 1889 | stringaGiocatore = "LVSOR: "; | ||
| 1890 | stringaComputer = "\nCOMPVTER: "; | ||
| 1891 | stringaNuovaPartita = "NOVA LVSO"; | ||
| 1892 | stringaNuovaPartitaAiTrenta = "NOVA LVSO XXX"; | ||
| 1893 | stringaVuoiDavveroIniziare = "NOVAM LVSIONEM INCIPERE?"; | ||
| 1894 | stringaVuoiDavveroUscire = "EXIRE?"; | ||
| 1895 | stringaSi = "ID VOLO"; | ||
| 1896 | stringaNo = "NOLO"; | ||
| 1897 | stringaOpzioni = "OPTIONES..."; | ||
| 1898 | stringaEsci = "EXIRE"; | ||
| 1899 | stringaImpossibileConfigurare = "CONFIGVRATIONIS FILE SCRIBERE NON POTVI.\nERROREM ME CERTIOREM FACITE: sebastiano@luganega.org\n\nEXCEPTIO:\n"; | ||
| 1900 | stringaLingua = "LINGVA"; | ||
| 1901 | stringaAnnulla = "ABROGA"; | ||
| 1902 | stringaIt = "ITALICA"; | ||
| 1903 | stringaLa = "LATINA"; | ||
| 1904 | stringaBL = "BELLUNI"; | ||
| 1905 | stringaBV = "VENETIAE"; | ||
| 1906 | stringaEN = "ANGLICVS"; | ||
| 1907 | stringaModificaOpzioni = "OPTIONES NOVARE"; | ||
| 1908 | stringaInformazioni = "INFORMATIONES"; | ||
| 1909 | 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"; | ||
| 1910 | stringaSuono = "SONVS"; | ||
| 1911 | stringaPunteggio = "NVMERI"; | ||
| 1912 | stringaCartePassate = "CHARTAS ITAS"; | ||
| 1913 | stringaSfondo = "COLOR"; | ||
| 1914 | stringaTasti = "TASTI RAPIDI"; | ||
| 1915 | stringaAggiornamenti = "VERSIONEM RECENTIOREM QVAERERE"; | ||
| 1916 | stringaTrucchi = "CODICES"; | ||
| 1917 | stringaInserisciCodice = "CODICEM INSCRIBE:"; | ||
| 1918 | stringaTruccoAttivato = "CODEX INCIPIVIT!"; | ||
| 1919 | stringaTruccoSbagliato = "ERROR CODICIS"; | ||
| 1920 | stringaCheCartaVuoi = "QUAM CHARTAM VOLIS?"; | ||
| 1921 | stringaNoInternet = "ERROR: INTERNETIS CONIVCTIO NON EST"; | ||
| 1922 | stringaAggiornamentiSi = "VERSIO RECENTIOR EST: "; | ||
| 1923 | stringaAggiornamentiNo = "VERSIO RECENTIOR NON EST"; | ||
| 1924 | stringaScarica = "VERSIONEM RECENTIOREM CEPTA ESSE POTEST:\nhttp://porkynator.altervista.org/programmi.html"; | ||
| 1925 | stringaTasti2 = "1 PONE CHARTAM PRIMAM\n2 PONE CHARTAM SECUNDAM\n3 PONE CHARTAM TERTIAM\nF1 HEAC INFORMATIONES\nF2 " + stringaNuovaPartita + "\nF3 " + stringaOpzioni + "\nF4 " + stringaPunteggio + "\nF5 " + stringaCartePassate + "\nF6 " + stringaInformazioni + "\nF7 " + stringaAggiornamenti + "\nF8 " + stringaNuovaPartitaAiTrenta + "\nF9 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 1926 | } | ||
| 1927 | if ( lang.equals( "bl" ) ) { | ||
| 1928 | semi[0] = "Bastoi"; | ||
| 1929 | semi[1] = "Coppe"; | ||
| 1930 | semi[2] = "Danari"; | ||
| 1931 | semi[3] = "Spade"; | ||
| 1932 | stringaBriscola = "Briscola"; | ||
| 1933 | stringaBottonePrendi = "Cio' su/lasa le carte"; | ||
| 1934 | stringaPrimaGioca = "Prima Duga!"; | ||
| 1935 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1936 | stringaVinto = "Te ha vint!"; | ||
| 1937 | stringaPerso = "Te ha pers"; | ||
| 1938 | stringaPareggio = "Pari"; | ||
| 1939 | stringaGiocatore = "Dugador: "; | ||
| 1940 | stringaComputer = "\nComputer: "; | ||
| 1941 | stringaNuovaPartita = "Taca n'altra partida"; | ||
| 1942 | stringaNuovaPartitaAiTrenta = "Taca na partida ai 30"; | ||
| 1943 | stringaVuoiDavveroIniziare = "Utu sul serio scuminziar n'altra partida?"; | ||
| 1944 | stringaVuoiDavveroUscire = "Utu sul serio stusar su?"; | ||
| 1945 | stringaSi = "Si"; | ||
| 1946 | stringaNo = "No"; | ||
| 1947 | stringaOpzioni = "Opzioni..."; | ||
| 1948 | stringaEsci = "Stusa su"; | ||
| 1949 | stringaImpossibileConfigurare = "No ghe ho riva' a scrivere al file de configurazion.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1950 | stringaLingua = "Lengua"; | ||
| 1951 | stringaAnnulla = "Annulla"; | ||
| 1952 | stringaIt = "Italian"; | ||
| 1953 | stringaLa = "Latin"; | ||
| 1954 | stringaBL = "Dialeto de Belun"; | ||
| 1955 | stringaBV = "Dialeto de la basa"; | ||
| 1956 | stringaEN = "Inglese"; | ||
| 1957 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1958 | stringaInformazioni = "Informazioni"; | ||
| 1959 | 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"; | ||
| 1960 | stringaSuono = "Efeti sonori"; | ||
| 1961 | stringaPunteggio = "Varda i punti"; | ||
| 1962 | stringaCartePassate = "Carte pasade"; | ||
| 1963 | stringaSfondo = "Sfondo"; | ||
| 1964 | stringaTasti = "Tasti rapidi"; | ||
| 1965 | stringaAggiornamenti = "Varda se ghe ne' na version pi nova"; | ||
| 1966 | stringaTrucchi = "Truchi"; | ||
| 1967 | stringaInserisciCodice = "Scrivi al codice:"; | ||
| 1968 | stringaTruccoAttivato = "Truco ativa'!"; | ||
| 1969 | stringaTruccoSbagliato = "Truco sbaia'"; | ||
| 1970 | stringaCheCartaVuoi = "Che carta utu alora?"; | ||
| 1971 | stringaAggiornamentiSi = "Ghe ne' na version pi nova: "; | ||
| 1972 | stringaAggiornamentiNo = "No ghe ne na version pi nova"; | ||
| 1973 | stringaScarica = "Te pol scaricar le version pi nova\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 1974 | stringaNoInternet = "Erore: no te se su internet"; | ||
| 1975 | 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 " + stringaCartePassate + "\nF6 " + stringaInformazioni + "\nF7 " + stringaAggiornamenti + "\nF8 " + stringaNuovaPartitaAiTrenta + "\nF9 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 1976 | } | ||
| 1977 | if ( lang.equals( "bv" ) ) { | ||
| 1978 | semi[0] = "Bastoni"; | ||
| 1979 | semi[1] = "Coppe"; | ||
| 1980 | semi[2] = "Danari"; | ||
| 1981 | semi[3] = "Spade"; | ||
| 1982 | stringaBriscola = "Briscola"; | ||
| 1983 | stringaBottonePrendi = "Ciapa su/lasa e carte"; | ||
| 1984 | stringaPrimaGioca = "Prima Zuga!"; | ||
| 1985 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1986 | stringaVinto = "Ti ga vinto!"; | ||
| 1987 | stringaPerso = "Ti ga perso"; | ||
| 1988 | stringaPareggio = "Pari"; | ||
| 1989 | stringaGiocatore = "Zugador: "; | ||
| 1990 | stringaComputer = "\nComputer: "; | ||
| 1991 | stringaNuovaPartita = "N'altra Partida"; | ||
| 1992 | stringaNuovaPartitaAiTrenta = "Na Partida ai 30"; | ||
| 1993 | stringaVuoiDavveroIniziare = "Ti vol sul serio scuminziar n'altra partida?"; | ||
| 1994 | stringaVuoiDavveroUscire = "Ti vol sul serio stusar su?"; | ||
| 1995 | stringaSi = "Si"; | ||
| 1996 | stringaNo = "No"; | ||
| 1997 | stringaOpzioni = "Opzioni..."; | ||
| 1998 | stringaEsci = "Stusa su"; | ||
| 1999 | stringaImpossibileConfigurare = "No ghe son riusito a scrivere al file de configurazione.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 2000 | stringaLingua = "Lengua"; | ||
| 2001 | stringaAnnulla = "Annulla"; | ||
| 2002 | stringaIt = "Italian"; | ||
| 2003 | stringaLa = "Latin"; | ||
| 2004 | stringaBL = "Dialeto Belumat"; | ||
| 2005 | stringaBV = "Dialeto Veneto"; | ||
| 2006 | stringaEN = "Inglese"; | ||
| 2007 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 2008 | stringaInformazioni = "Informasioni"; | ||
| 2009 | 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"; | ||
| 2010 | stringaSuono = "Efeti sonori"; | ||
| 2011 | stringaPunteggio = "Varda i punti"; | ||
| 2012 | stringaCartePassate = "Carte pasade"; | ||
| 2013 | stringaSfondo = "Sfondo"; | ||
| 2014 | stringaTasti = "Tasti rapidi"; | ||
| 2015 | stringaAggiornamenti = "Varda se ghe xe na versione pi nova"; | ||
| 2016 | stringaTrucchi = "Truchi"; | ||
| 2017 | stringaInserisciCodice = "Scrivi al codice:"; | ||
| 2018 | stringaTruccoAttivato = "Truco ativa'!"; | ||
| 2019 | stringaTruccoSbagliato = "Truco sbaia'"; | ||
| 2020 | stringaCheCartaVuoi = "Che carta utu alora?"; | ||
| 2021 | stringaAggiornamentiSi = "Ghe xe na versione pi nova: "; | ||
| 2022 | stringaAggiornamentiNo = "No ghe xe na versione pi nova"; | ||
| 2023 | stringaScarica = "Te pol scaricar le versione pi nova\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 2024 | stringaNoInternet = "Erore: no ti xe su internet"; | ||
| 2025 | 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 " + stringaCartePassate + "\nF6 " + stringaInformazioni + "\nF7 " + stringaAggiornamenti + "\nF8 " + stringaNuovaPartitaAiTrenta + "\nF9 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 2026 | } | ||
| 2027 | if ( lang.equals( "en" ) ) { | ||
| 2028 | semi[0] = "Sticks"; | ||
| 2029 | semi[1] = "Cups"; | ||
| 2030 | semi[2] = "Golds"; | ||
| 2031 | semi[3] = "Swords"; | ||
| 2032 | stringaBriscola = "Briscola"; | ||
| 2033 | stringaBottonePrendi = "Take/leave cards"; | ||
| 2034 | stringaPrimaGioca = "Play your card before!"; | ||
| 2035 | stringaUltime4 = "Last card - keep your eye on the briscola!"; | ||
| 2036 | stringaVinto = "You won!"; | ||
| 2037 | stringaPerso = "You lost"; | ||
| 2038 | stringaPareggio = "Sixty - sixty!"; | ||
| 2039 | stringaGiocatore = "Palyer: "; | ||
| 2040 | stringaComputer = "\nComputer: "; | ||
| 2041 | stringaNuovaPartita = "New Game"; | ||
| 2042 | stringaNuovaPartitaAiTrenta = "New Game - 30 Points"; | ||
| 2043 | stringaVuoiDavveroIniziare = "Do you really want to start a new game?"; | ||
| 2044 | stringaVuoiDavveroUscire = "Do you really want to exit?"; | ||
| 2045 | stringaSi = "Yes"; | ||
| 2046 | stringaNo = "No"; | ||
| 2047 | stringaOpzioni = "Options..."; | ||
| 2048 | stringaEsci = "Exit"; | ||
| 2049 | stringaImpossibileConfigurare = "Couldn't write to the configuration file.\nPlease report the bug to: sebastiano@luganega.org\n\nException:\n"; | ||
| 2050 | stringaLingua = "Lang"; | ||
| 2051 | stringaAnnulla = "Cancel"; | ||
| 2052 | stringaIt = "Italian"; | ||
| 2053 | stringaLa = "Latin"; | ||
| 2054 | stringaBL = "Belluno dialect"; | ||
| 2055 | stringaBV = "Venice dialect"; | ||
| 2056 | stringaEN = "English"; | ||
| 2057 | stringaModificaOpzioni = "Change options"; | ||
| 2058 | stringaInformazioni = "Information"; | ||
| 2059 | stringaInformazioni2 = "JBriscola is a briscola pc game written in java, meant\nand made by Sebastiano Tronto. The game is protected by the GNU/General public licence version 2 or later.\n\nJBriscola version" + version + "\nCopyright 2009 Sebastiano Tronto, license GNU/Gpl 2.0 or later\nE-mail: sebastiano@luganega.org"; | ||
| 2060 | stringaSuono = "Sound"; | ||
| 2061 | stringaPunteggio = "Score"; | ||
| 2062 | stringaCartePassate = "Played cards"; | ||
| 2063 | stringaSfondo = "Background"; | ||
| 2064 | stringaTasti = "Hot keys"; | ||
| 2065 | stringaAggiornamenti = "Check updates"; | ||
| 2066 | stringaTrucchi = "Cheats"; | ||
| 2067 | stringaInserisciCodice = "Insert cheat:"; | ||
| 2068 | stringaTruccoAttivato = "Cheat actived!"; | ||
| 2069 | stringaTruccoSbagliato = "Wrong cheat"; | ||
| 2070 | stringaCheCartaVuoi = "So what card do you want?"; | ||
| 2071 | stringaAggiornamentiSi = "Update available: "; | ||
| 2072 | stringaAggiornamentiNo = "No updates available"; | ||
| 2073 | stringaScarica = "You can get the latest version from the site\nhttp://porkynator.altervista.org/programmi.html"; | ||
| 2074 | stringaNoInternet = "Error: no internet connection"; | ||
| 2075 | stringaTasti2 = "1 Play the first card\n2 Play the second card\n3 Play the third card\nF1 Get this message\nF2 " + stringaNuovaPartita + "\nF3 " + stringaOpzioni + "\nF4 " + stringaPunteggio + "\nF5 " + stringaCartePassate + "\nF6 " + stringaInformazioni + "\nF7 " + stringaAggiornamenti + "\nF8 " + stringaNuovaPartitaAiTrenta + "\nF9 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 2076 | } | ||
| 2077 | sound = ( soundString.equals( "suono=si" ) ); | ||
| 2078 | keys = ( keysString.equals( "tasti=si" ) ); | ||
| 2079 | color = new Color( r, g, b ); | ||
| 2080 | if ( frame != null ) { | ||
| 2081 | frame.pannello.repaint(); | ||
| 2082 | frame.pannello2.repaint(); | ||
| 2083 | frame.repaint(); | ||
| 2084 | } | ||
| 2085 | } | ||
| 2086 | } | ||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/OptionFrame.java b/JBriscola/all_versions/0.3/0.3.2/src/OptionFrame.java new file mode 100755 index 0000000..30359f0 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/OptionFrame.java | |||
| @@ -0,0 +1,169 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2009-2010 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.util.Formatter; | ||
| 23 | import javax.swing.*; | ||
| 24 | import java.awt.*; | ||
| 25 | import java.awt.event.*; | ||
| 26 | |||
| 27 | public class OptionFrame extends JFrame { | ||
| 28 | |||
| 29 | public static Main main = new Main(); | ||
| 30 | public static Formatter formatter; | ||
| 31 | public static JButton ok, annulla, scegliColore; | ||
| 32 | public static JLabel lingua, sfondo; | ||
| 33 | public static JComboBox selezionaLingua; | ||
| 34 | public static JCheckBox suono, tastiRapidi; | ||
| 35 | public static JPanel[] pannello = new JPanel[6]; | ||
| 36 | |||
| 37 | public OptionFrame() { | ||
| 38 | |||
| 39 | super( "JBriscola - " + main.stringaModificaOpzioni ); | ||
| 40 | |||
| 41 | ok = new JButton( "OK" ); | ||
| 42 | ok.addActionListener( new ActionListener() { | ||
| 43 | |||
| 44 | /* Quando le modifiche vengono confermate premendo ok, viene scritto | ||
| 45 | * il file di configurazione (o aggiornato) se possibile, e modificate | ||
| 46 | * le impostazioni attuali. */ | ||
| 47 | public void actionPerformed( ActionEvent e ) { | ||
| 48 | |||
| 49 | try { | ||
| 50 | formatter = new Formatter( "JBriscolaConfig.txt" ); | ||
| 51 | } catch ( Exception ex ) { | ||
| 52 | JOptionPane.showMessageDialog( OptionFrame.this, main.stringaImpossibileConfigurare + ex, "JBriscola - " + main.version, JOptionPane.ERROR_MESSAGE ); | ||
| 53 | } | ||
| 54 | |||
| 55 | String lang; | ||
| 56 | |||
| 57 | switch ( selezionaLingua.getSelectedIndex() ) { | ||
| 58 | case 0: | ||
| 59 | lang = "it"; | ||
| 60 | break; | ||
| 61 | case 1: | ||
| 62 | lang = "la"; | ||
| 63 | break; | ||
| 64 | case 2: | ||
| 65 | lang = "bl"; | ||
| 66 | break; | ||
| 67 | case 3: | ||
| 68 | lang = "bv"; | ||
| 69 | break; | ||
| 70 | case 4: | ||
| 71 | lang = "en"; | ||
| 72 | break; | ||
| 73 | default: | ||
| 74 | lang = "it"; | ||
| 75 | break; | ||
| 76 | } | ||
| 77 | |||
| 78 | String suonosiono, tastisiono; | ||
| 79 | |||
| 80 | if ( suono.isSelected() ) | ||
| 81 | suonosiono = "suono=si"; | ||
| 82 | else | ||
| 83 | suonosiono = "suono=no"; | ||
| 84 | if ( tastiRapidi.isSelected() ) | ||
| 85 | tastisiono = "tasti=si"; | ||
| 86 | else | ||
| 87 | tastisiono = "tasti=no"; | ||
| 88 | |||
| 89 | formatter.format( lang ); | ||
| 90 | formatter.format( "\n" ); | ||
| 91 | formatter.format( suonosiono ); | ||
| 92 | formatter.format( "\n" ); | ||
| 93 | formatter.format( tastisiono ); | ||
| 94 | formatter.format( "\n" ); | ||
| 95 | formatter.format( main.color.getRed() + " " + main.color.getGreen() + " " + main.color.getBlue() ); | ||
| 96 | formatter.close(); | ||
| 97 | |||
| 98 | main.settaOpzioni(); | ||
| 99 | |||
| 100 | OptionFrame.this.dispose(); | ||
| 101 | } | ||
| 102 | }); | ||
| 103 | |||
| 104 | annulla = new JButton( main.stringaAnnulla ); | ||
| 105 | annulla.addActionListener( new ActionListener() { | ||
| 106 | /* Se l'utente annulla viene chiusa la finestra senza fare nulla. */ | ||
| 107 | public void actionPerformed( ActionEvent e ) { | ||
| 108 | OptionFrame.this.dispose(); | ||
| 109 | } | ||
| 110 | }); | ||
| 111 | |||
| 112 | scegliColore = new JButton( " " ); | ||
| 113 | scegliColore.setBackground( main.color ); | ||
| 114 | scegliColore.addActionListener( new ActionListener() { | ||
| 115 | /* Permette di scegliere il colore dello sfondo. */ | ||
| 116 | public void actionPerformed( ActionEvent e ) { | ||
| 117 | Color colore = JColorChooser.showDialog( OptionFrame.this, "JBriscola " + main.version, main.color ); | ||
| 118 | if ( colore != null ) | ||
| 119 | main.color = colore; | ||
| 120 | OptionFrame.scegliColore.setBackground( main.color ); | ||
| 121 | } | ||
| 122 | } ); | ||
| 123 | |||
| 124 | /* Vengono impostati e disegnati i vari componenti. */ | ||
| 125 | lingua = new JLabel( main.stringaLingua ); | ||
| 126 | sfondo = new JLabel( main.stringaSfondo ); | ||
| 127 | String[] lingueDaSelezionare = { main.stringaIt, main.stringaLa, main.stringaBL, main.stringaBV, main.stringaEN }; | ||
| 128 | selezionaLingua = new JComboBox( lingueDaSelezionare ); | ||
| 129 | int linguaPreselezionata = 0; | ||
| 130 | |||
| 131 | if ( main.lang.equals( "it" ) ) | ||
| 132 | linguaPreselezionata = 0; | ||
| 133 | else if ( main.lang.equals( "la" ) ) | ||
| 134 | linguaPreselezionata = 1; | ||
| 135 | else if ( main.lang.equals( "bl" ) ) | ||
| 136 | linguaPreselezionata = 2; | ||
| 137 | else if ( main.lang.equals( "bv" ) ) | ||
| 138 | linguaPreselezionata = 3; | ||
| 139 | else if ( main.lang.equals( "en" ) ) | ||
| 140 | linguaPreselezionata = 4; | ||
| 141 | |||
| 142 | selezionaLingua.setSelectedIndex( linguaPreselezionata ); | ||
| 143 | suono = new JCheckBox( main.stringaSuono ); | ||
| 144 | suono.setSelected( main.sound ); | ||
| 145 | tastiRapidi = new JCheckBox( main.stringaTasti ); | ||
| 146 | tastiRapidi.setSelected( main.keys ); | ||
| 147 | |||
| 148 | pannello[0] = new JPanel( new GridLayout( 4, 1 ) ); | ||
| 149 | pannello[1] = new JPanel( new FlowLayout() ); | ||
| 150 | pannello[2] = new JPanel( new FlowLayout() ); | ||
| 151 | pannello[3] = new JPanel( new FlowLayout() ); | ||
| 152 | pannello[4] = new JPanel( new FlowLayout() ); | ||
| 153 | pannello[5] = new JPanel( new FlowLayout() ); | ||
| 154 | pannello[5].add( ok ); | ||
| 155 | pannello[5].add( annulla ); | ||
| 156 | pannello[4].add( sfondo ); | ||
| 157 | pannello[4].add( scegliColore ); | ||
| 158 | pannello[3].add( tastiRapidi ); | ||
| 159 | pannello[2].add( suono ); | ||
| 160 | pannello[1].add( lingua ); | ||
| 161 | pannello[1].add( selezionaLingua ); | ||
| 162 | pannello[0].add( pannello[1] ); | ||
| 163 | pannello[0].add( pannello[2] ); | ||
| 164 | pannello[0].add( pannello[3] ); | ||
| 165 | pannello[0].add( pannello[4] ); | ||
| 166 | add( pannello[0], BorderLayout.CENTER ); | ||
| 167 | add( pannello[5], BorderLayout.SOUTH ); | ||
| 168 | } | ||
| 169 | } | ||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/Pannello.java b/JBriscola/all_versions/0.3/0.3.2/src/Pannello.java new file mode 100755 index 0000000..1dde670 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/Pannello.java | |||
| @@ -0,0 +1,88 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2009-2010 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 javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | |||
| 25 | /* Questa classe dispone semplicemente le carte | ||
| 26 | * sulla finestra e imposta la sfondo. */ | ||
| 27 | public class Pannello extends JPanel { | ||
| 28 | |||
| 29 | public static Main main; | ||
| 30 | |||
| 31 | public static Color color; | ||
| 32 | |||
| 33 | public Pannello() { } | ||
| 34 | |||
| 35 | public void paint( Graphics g ) { | ||
| 36 | |||
| 37 | super.paint( g ); | ||
| 38 | |||
| 39 | setBackground( main.color ); | ||
| 40 | |||
| 41 | if ( main.frame.ultimaCarta != null ) | ||
| 42 | main.frame.ultimaCarta.paintIcon( this, g, 50, 180 ); | ||
| 43 | |||
| 44 | if ( main.frame.mazzo ) | ||
| 45 | main.frame.retro2.paintIcon( this, g, 17, 256 ); | ||
| 46 | |||
| 47 | if ( main.carteScoperte ) { | ||
| 48 | |||
| 49 | if ( main.frame.carteCPU[0] != null ) | ||
| 50 | main.frame.carteCPU[0].paintIcon( this, g, 230, 5 ); | ||
| 51 | |||
| 52 | if ( main.frame.carteCPU[1] != null ) | ||
| 53 | main.frame.carteCPU[1].paintIcon( this, g, 300, 5 ); | ||
| 54 | |||
| 55 | if ( main.frame.carteCPU[2] != null ) | ||
| 56 | main.frame.carteCPU[2].paintIcon( this, g, 370, 5 ); | ||
| 57 | |||
| 58 | } else { | ||
| 59 | |||
| 60 | if ( main.frame.carteCPU[0] != null ) | ||
| 61 | main.frame.retro1.paintIcon( this, g, 230, 5 ); | ||
| 62 | |||
| 63 | if ( main.frame.carteCPU[1] != null ) | ||
| 64 | main.frame.retro1.paintIcon( this, g, 300, 5 ); | ||
| 65 | |||
| 66 | if ( main.frame.carteCPU[2] != null ) | ||
| 67 | main.frame.retro1.paintIcon( this, g, 370, 5 ); | ||
| 68 | |||
| 69 | } | ||
| 70 | |||
| 71 | if ( main.frame.carteInMano[0] != null ) | ||
| 72 | main.frame.carteInMano[0].paintIcon( this, g, 230, 340 ); | ||
| 73 | |||
| 74 | if ( main.frame.carteInMano[1] != null ) | ||
| 75 | main.frame.carteInMano[1].paintIcon( this, g, 300, 340 ); | ||
| 76 | |||
| 77 | if ( main.frame.carteInMano[2] != null ) | ||
| 78 | main.frame.carteInMano[2].paintIcon( this, g, 370, 340 ); | ||
| 79 | |||
| 80 | if ( main.frame.giocata[0] != null ) | ||
| 81 | main.frame.giocata[0].paintIcon( this, g, 250, 200 ); | ||
| 82 | |||
| 83 | if ( main.frame.giocata[1] != null ) | ||
| 84 | main.frame.giocata[1].paintIcon( this, g, 325, 150 ); | ||
| 85 | |||
| 86 | } | ||
| 87 | } | ||
| 88 | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/PannelloCartePassate.java b/JBriscola/all_versions/0.3/0.3.2/src/PannelloCartePassate.java new file mode 100755 index 0000000..fef9666 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/PannelloCartePassate.java | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | /* | ||
| 2 | Copyright 2009-2010 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 javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | |||
| 25 | public class PannelloCartePassate extends JPanel { | ||
| 26 | |||
| 27 | public static int posto[][] = new int[40][2]; | ||
| 28 | |||
| 29 | public static Main main; | ||
| 30 | |||
| 31 | public PannelloCartePassate() { } | ||
| 32 | |||
| 33 | public void paint( Graphics g ) { | ||
| 34 | |||
| 35 | super.paint( g ); | ||
| 36 | |||
| 37 | for( int i = 0; i < 40; i++ ) { | ||
| 38 | posto[i][0] = ( i % 10 ) * 70; | ||
| 39 | posto[i][1] = ( i / 10 ) * 136; | ||
| 40 | } | ||
| 41 | |||
| 42 | for ( int i = 0; i < main.mano*2; i++ ) | ||
| 43 | if ( main.frame.arrayCartePassate[i] != null ) | ||
| 44 | main.frame.arrayCartePassate[i].paintIcon( this, g, posto[i][0], posto[i][1] ); | ||
| 45 | |||
| 46 | |||
| 47 | } | ||
| 48 | |||
| 49 | } | ||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/1-1.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/1-1.jpg new file mode 100755 index 0000000..ae43510 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/1-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/1-2.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/1-2.jpg new file mode 100755 index 0000000..3f7c75a --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/1-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/1-3.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/1-3.jpg new file mode 100755 index 0000000..9e1ead7 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/1-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/1-4.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/1-4.jpg new file mode 100755 index 0000000..710f879 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/1-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/10-1.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/10-1.jpg new file mode 100755 index 0000000..9aba45a --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/10-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/10-2.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/10-2.jpg new file mode 100755 index 0000000..037eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/10-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/10-3.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/10-3.jpg new file mode 100755 index 0000000..8780b72 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/10-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/10-4.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/10-4.jpg new file mode 100755 index 0000000..587dc0f --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/10-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/2-1.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/2-1.jpg new file mode 100755 index 0000000..5dcb7db --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/2-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/2-2.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/2-2.jpg new file mode 100755 index 0000000..ea9eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/2-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/2-3.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/2-3.jpg new file mode 100755 index 0000000..8cb22dd --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/2-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/2-4.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/2-4.jpg new file mode 100755 index 0000000..b3e7898 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/2-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/3-1.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/3-1.jpg new file mode 100755 index 0000000..dcb435c --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/3-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/3-2.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/3-2.jpg new file mode 100755 index 0000000..1e5b6ec --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/3-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/3-3.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/3-3.jpg new file mode 100755 index 0000000..9202cfe --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/3-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/3-4.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/3-4.jpg new file mode 100755 index 0000000..5436a8d --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/3-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/4-1.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/4-1.jpg new file mode 100755 index 0000000..3bab6d5 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/4-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/4-2.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/4-2.jpg new file mode 100755 index 0000000..b4901a6 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/4-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/4-3.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/4-3.jpg new file mode 100755 index 0000000..d754ad8 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/4-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/4-4.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/4-4.jpg new file mode 100755 index 0000000..3a54b96 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/4-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/5-1.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/5-1.jpg new file mode 100755 index 0000000..3f7ba1f --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/5-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/5-2.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/5-2.jpg new file mode 100755 index 0000000..fcacb75 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/5-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/5-3.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/5-3.jpg new file mode 100755 index 0000000..ce32f9f --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/5-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/5-4.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/5-4.jpg new file mode 100755 index 0000000..b86b09a --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/5-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/6-1.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/6-1.jpg new file mode 100755 index 0000000..f90cd81 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/6-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/6-2.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/6-2.jpg new file mode 100755 index 0000000..cf2a67a --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/6-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/6-3.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/6-3.jpg new file mode 100755 index 0000000..2cd2fe2 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/6-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/6-4.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/6-4.jpg new file mode 100755 index 0000000..73f410f --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/6-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/7-1.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/7-1.jpg new file mode 100755 index 0000000..08cd397 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/7-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/7-2.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/7-2.jpg new file mode 100755 index 0000000..a168ff8 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/7-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/7-3.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/7-3.jpg new file mode 100755 index 0000000..5cda411 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/7-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/7-4.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/7-4.jpg new file mode 100755 index 0000000..5d63229 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/7-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/8-1.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/8-1.jpg new file mode 100755 index 0000000..a6faa7b --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/8-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/8-2.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/8-2.jpg new file mode 100755 index 0000000..0d9edbb --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/8-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/8-3.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/8-3.jpg new file mode 100755 index 0000000..91f8354 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/8-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/8-4.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/8-4.jpg new file mode 100755 index 0000000..cc0089c --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/8-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/9-1.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/9-1.jpg new file mode 100755 index 0000000..be9c6bf --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/9-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/9-2.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/9-2.jpg new file mode 100755 index 0000000..e25da4c --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/9-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/9-3.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/9-3.jpg new file mode 100755 index 0000000..cd384f8 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/9-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/9-4.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/9-4.jpg new file mode 100755 index 0000000..441210e --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/9-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/Thumbs.db b/JBriscola/all_versions/0.3/0.3.2/src/img/Thumbs.db new file mode 100755 index 0000000..d9b6bc5 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/Thumbs.db | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/carte.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/carte.jpg new file mode 100755 index 0000000..838ffac --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/carte.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/retro1.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/retro1.jpg new file mode 100755 index 0000000..9651b06 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/retro1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3.2/src/img/retro2.jpg b/JBriscola/all_versions/0.3/0.3.2/src/img/retro2.jpg new file mode 100755 index 0000000..c5d3925 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3.2/src/img/retro2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/Frame.java b/JBriscola/all_versions/0.3/0.3/src/Frame.java new file mode 100755 index 0000000..21c4858 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/Frame.java | |||
| @@ -0,0 +1,523 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import javax.sound.sampled.*; | ||
| 24 | import java.io.*; | ||
| 25 | import java.net.*; | ||
| 26 | import java.awt.*; | ||
| 27 | import java.awt.event.*; | ||
| 28 | |||
| 29 | public class Frame extends JFrame { | ||
| 30 | |||
| 31 | /* Booleana per determinare se disegnare il mazzo di carte o no (se | ||
| 32 | * è l'ultima mano). */ | ||
| 33 | public static boolean mazzo; | ||
| 34 | |||
| 35 | public static Main main; | ||
| 36 | |||
| 37 | /* Menu, bottoni, pannelli e componenti vari. */ | ||
| 38 | public static Pannello pannello; | ||
| 39 | public static JPanel pannello2; | ||
| 40 | public static JButton button; | ||
| 41 | public static JMenuBar barraMenu; | ||
| 42 | public static JMenu file, puntoInterrogativo; | ||
| 43 | public static JMenuItem nuovaPartita, nuovaPartitaAiTrenta, opzioni, esci, informazioni, punti, aggiornamenti, trucchi, tastiRapidi, briscola; | ||
| 44 | |||
| 45 | /* Immagini delle carte. */ | ||
| 46 | public static ImageIcon retro1, retro2, ultimaCarta; | ||
| 47 | public static ImageIcon[] giocata = new ImageIcon[2]; | ||
| 48 | public static ImageIcon[] carteInMano = new ImageIcon[3]; | ||
| 49 | public static ImageIcon[] carteCPU = new ImageIcon[3]; | ||
| 50 | public static ImageIcon[] arrayCarteMescolate = new ImageIcon[40]; | ||
| 51 | public static ImageIcon[][] arrayCarte = new ImageIcon[10][4]; | ||
| 52 | |||
| 53 | public Frame() { | ||
| 54 | |||
| 55 | super( "Tronto's JBriscola " + main.version ); | ||
| 56 | |||
| 57 | mazzo = true; | ||
| 58 | main = new Main(); | ||
| 59 | pannello = new Pannello(); | ||
| 60 | pannello2 = new JPanel( new FlowLayout() ); | ||
| 61 | |||
| 62 | button = new JButton( main.stringaBottonePrendi ); | ||
| 63 | button.addActionListener( new ActionListener() { | ||
| 64 | |||
| 65 | /* Quando viene premuto il bottone per prendere/lasciare le carte, | ||
| 66 | * valuta innanzitutto se il giocatore ha giocato, poi a chi | ||
| 67 | * darle ed eventualmente, se è finita la partita, a caricare | ||
| 68 | * il suono adatto. */ | ||
| 69 | public void actionPerformed( ActionEvent e ) { | ||
| 70 | |||
| 71 | if ( giocata[0] != null && giocata[1] != null ) | ||
| 72 | main.mano++; | ||
| 73 | |||
| 74 | try { | ||
| 75 | main.chiPrende(); | ||
| 76 | } catch ( Exception ex ) { | ||
| 77 | /* Avvisa di giocare una carta. */ | ||
| 78 | JOptionPane.showMessageDialog( Frame.this, main.stringaPrimaGioca, "JBriscola " + main.version, JOptionPane.WARNING_MESSAGE ); | ||
| 79 | } | ||
| 80 | |||
| 81 | /* Avvisa che si è arrivati alla quartultima mano. */ | ||
| 82 | if ( main.mano == 16 ) | ||
| 83 | JOptionPane.showMessageDialog( Frame.this, main.stringaUltime4, "JBriscola " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 84 | |||
| 85 | /* Non disegna più la briscola e il mazzo se sono già state | ||
| 86 | * pescate tutte le carte. */ | ||
| 87 | if ( main.mano == 17 ) { | ||
| 88 | mazzo = false; | ||
| 89 | ultimaCarta = null; | ||
| 90 | pannello.repaint(); | ||
| 91 | Frame.this.repaint(); | ||
| 92 | } | ||
| 93 | |||
| 94 | /* Mostra il punteggio e carica i suoni se è finita la partita. */ | ||
| 95 | if ( main.mano == 20 || | ||
| 96 | ( main.aiTrenta && | ||
| 97 | ( ( main.punteggio >= 30 || main.punteggioCPU >= 30 ) ) ) ) { | ||
| 98 | |||
| 99 | String titolo = ""; | ||
| 100 | String suonoFinale = ""; | ||
| 101 | |||
| 102 | if ( main.punteggio > main.punteggioCPU ) { | ||
| 103 | titolo = main.stringaVinto; | ||
| 104 | suonoFinale = "sounds/perso.wav"; | ||
| 105 | } | ||
| 106 | if ( main.punteggio < main.punteggioCPU ) { | ||
| 107 | titolo = main.stringaPerso; | ||
| 108 | suonoFinale = "sounds/vinto.wav"; | ||
| 109 | } | ||
| 110 | if ( main.punteggio == main.punteggioCPU ) { | ||
| 111 | titolo = main.stringaPareggio; | ||
| 112 | suonoFinale = "sounds/pareggio.wav"; | ||
| 113 | } | ||
| 114 | |||
| 115 | if ( main.sound ) { | ||
| 116 | try { | ||
| 117 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( ClassLoader.getSystemResource( suonoFinale ) ); | ||
| 118 | AudioInputStream ais = AudioSystem.getAudioInputStream( ClassLoader.getSystemResource( suonoFinale ) ); | ||
| 119 | AudioFormat af = aff.getFormat(); | ||
| 120 | DataLine.Info info = new DataLine.Info( Clip.class, ais.getFormat(), ( (int) ais.getFrameLength() * af.getFrameSize() ) ); | ||
| 121 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 122 | ol.open(ais); | ||
| 123 | ol.loop( 0 ); | ||
| 124 | } catch ( Exception ex ) { | ||
| 125 | System.err.println( e ); | ||
| 126 | } | ||
| 127 | } | ||
| 128 | |||
| 129 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, titolo, JOptionPane.INFORMATION_MESSAGE ); | ||
| 130 | |||
| 131 | main.pulisciTavolo(); | ||
| 132 | |||
| 133 | } | ||
| 134 | if ( main.toccaAllaCPU ) | ||
| 135 | if ( main.aiTrenta ) | ||
| 136 | main.giocaCPUAiTrenta(); | ||
| 137 | else | ||
| 138 | main.giocaCPU(); | ||
| 139 | } | ||
| 140 | } ); | ||
| 141 | button.addKeyListener( new KeyAdapter() { | ||
| 142 | /* Aggiunge il keyListener per le scorciatoie da tastiera. Dato | ||
| 143 | * che il bottone prendi/lascia è l'unico componente effettivo | ||
| 144 | * della finestra, avrà obbligatoriamente il focus ed è necessario | ||
| 145 | * che sia lui a gestire gli eventi della tastiera. */ | ||
| 146 | public void keyReleased( KeyEvent key ) { | ||
| 147 | |||
| 148 | if ( main.keys ) { | ||
| 149 | switch ( key.getKeyCode() ) { | ||
| 150 | case KeyEvent.VK_1: | ||
| 151 | if ( mettiCarta( 231, 500 ) ) { | ||
| 152 | if ( !main.CPUHaGiocato ) | ||
| 153 | if ( main.aiTrenta ) | ||
| 154 | main.giocaCPUAiTrenta(); | ||
| 155 | else | ||
| 156 | main.giocaCPU(); | ||
| 157 | } | ||
| 158 | break; | ||
| 159 | |||
| 160 | case KeyEvent.VK_2: | ||
| 161 | if ( mettiCarta( 301, 500 ) ) { | ||
| 162 | if ( !main.CPUHaGiocato ) | ||
| 163 | if ( main.aiTrenta ) | ||
| 164 | main.giocaCPUAiTrenta(); | ||
| 165 | else | ||
| 166 | main.giocaCPU(); | ||
| 167 | } | ||
| 168 | break; | ||
| 169 | |||
| 170 | case KeyEvent.VK_3: | ||
| 171 | if ( mettiCarta( 371, 500 ) ) { | ||
| 172 | if ( !main.CPUHaGiocato ) | ||
| 173 | if ( main.aiTrenta ) | ||
| 174 | main.giocaCPUAiTrenta(); | ||
| 175 | else | ||
| 176 | main.giocaCPU(); | ||
| 177 | } | ||
| 178 | break; | ||
| 179 | |||
| 180 | case KeyEvent.VK_F1: | ||
| 181 | JOptionPane.showMessageDialog( Frame.this, main.stringaTasti2, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 182 | break; | ||
| 183 | |||
| 184 | case KeyEvent.VK_F2: | ||
| 185 | if ( main.mano == 20 ) { | ||
| 186 | main.aiTrenta = false; | ||
| 187 | main.mischia(); | ||
| 188 | pannello.repaint(); | ||
| 189 | repaint(); | ||
| 190 | } | ||
| 191 | else { | ||
| 192 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 193 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 194 | main.aiTrenta = false; | ||
| 195 | main.mischia(); | ||
| 196 | pannello.repaint(); | ||
| 197 | repaint(); | ||
| 198 | } | ||
| 199 | } | ||
| 200 | break; | ||
| 201 | |||
| 202 | case KeyEvent.VK_F3: | ||
| 203 | OptionFrame optionFrame = new OptionFrame(); | ||
| 204 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 205 | optionFrame.setResizable( false ); | ||
| 206 | optionFrame.setAlwaysOnTop( true ); | ||
| 207 | optionFrame.setSize( 300, 200 ); | ||
| 208 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 209 | optionFrame.setVisible( true ); | ||
| 210 | break; | ||
| 211 | |||
| 212 | case KeyEvent.VK_F4: | ||
| 213 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, main.stringaPunteggio, JOptionPane.INFORMATION_MESSAGE ); | ||
| 214 | break; | ||
| 215 | |||
| 216 | case KeyEvent.VK_F5: | ||
| 217 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 218 | break; | ||
| 219 | |||
| 220 | case KeyEvent.VK_F6: | ||
| 221 | String latest = main.version; | ||
| 222 | try { | ||
| 223 | URL latestIs = new URL( "http://porkynator.altervista.org/jbriscola-latest.is" ); | ||
| 224 | BufferedReader latestIsReader = new BufferedReader( new InputStreamReader( latestIs.openStream() ) ); | ||
| 225 | latest = latestIsReader.readLine(); | ||
| 226 | } catch ( Exception ex ) { | ||
| 227 | JOptionPane.showMessageDialog( Frame.this, main.stringaNoInternet, "JBriscola - " + main.version, JOptionPane.ERROR_MESSAGE ); | ||
| 228 | } | ||
| 229 | if ( latest.equals( main.version ) ) | ||
| 230 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiNo, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 231 | else | ||
| 232 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiSi + "\n" + main.version + " ==> " + latest + "\n\n" + main.stringaScarica, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 233 | break; | ||
| 234 | |||
| 235 | case KeyEvent.VK_F7: | ||
| 236 | if ( main.mano == 20 ) { | ||
| 237 | main.aiTrenta = true; | ||
| 238 | main.mischia(); | ||
| 239 | pannello.repaint(); | ||
| 240 | repaint(); | ||
| 241 | } | ||
| 242 | else { | ||
| 243 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 244 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 245 | main.aiTrenta = true; | ||
| 246 | main.mischia(); | ||
| 247 | pannello.repaint(); | ||
| 248 | repaint(); | ||
| 249 | } | ||
| 250 | } | ||
| 251 | break; | ||
| 252 | |||
| 253 | case KeyEvent.VK_F8: | ||
| 254 | main.trucco( JOptionPane.showInputDialog( Frame.this, main.stringaInserisciCodice, "JBriscola - " + main.version, JOptionPane.PLAIN_MESSAGE ) ); | ||
| 255 | break; | ||
| 256 | |||
| 257 | case KeyEvent.VK_Q: | ||
| 258 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 259 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 260 | Frame.this.dispose(); | ||
| 261 | break; | ||
| 262 | } | ||
| 263 | } | ||
| 264 | } | ||
| 265 | } ); | ||
| 266 | |||
| 267 | barraMenu = new JMenuBar(); | ||
| 268 | |||
| 269 | file = new JMenu( "File" ); | ||
| 270 | |||
| 271 | nuovaPartita = new JMenuItem( main.stringaNuovaPartita ); | ||
| 272 | nuovaPartita.addActionListener( new ActionListener() { | ||
| 273 | /* Avvia una nuova partita, chiedendo prima conferma se ce n'è | ||
| 274 | * già una in corso. */ | ||
| 275 | public void actionPerformed( ActionEvent e ) { | ||
| 276 | if ( main.mano == 20 ) { | ||
| 277 | main.aiTrenta = false; | ||
| 278 | main.mischia(); | ||
| 279 | pannello.repaint(); | ||
| 280 | repaint(); | ||
| 281 | } | ||
| 282 | |||
| 283 | else { | ||
| 284 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 285 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 286 | main.aiTrenta = false; | ||
| 287 | main.mischia(); | ||
| 288 | pannello.repaint(); | ||
| 289 | repaint(); | ||
| 290 | } | ||
| 291 | } | ||
| 292 | } | ||
| 293 | }); | ||
| 294 | |||
| 295 | nuovaPartitaAiTrenta = new JMenuItem( main.stringaNuovaPartitaAiTrenta ); | ||
| 296 | nuovaPartitaAiTrenta.addActionListener( new ActionListener() { | ||
| 297 | /* Avvia una nuova partita ai 30, chiedendo prima conferma se | ||
| 298 | * ce n'è già una in corso. */ | ||
| 299 | public void actionPerformed( ActionEvent e ) { | ||
| 300 | if ( main.mano == 20 ) { | ||
| 301 | main.aiTrenta = true; | ||
| 302 | main.mischia(); | ||
| 303 | pannello.repaint(); | ||
| 304 | repaint(); | ||
| 305 | } | ||
| 306 | |||
| 307 | else { | ||
| 308 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroIniziare, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 309 | if ( selezione == JOptionPane.YES_OPTION ) { | ||
| 310 | main.aiTrenta = true; | ||
| 311 | main.mischia(); | ||
| 312 | pannello.repaint(); | ||
| 313 | repaint(); | ||
| 314 | } | ||
| 315 | } | ||
| 316 | } | ||
| 317 | }); | ||
| 318 | |||
| 319 | trucchi = new JMenuItem( main.stringaTrucchi ); | ||
| 320 | trucchi.addActionListener( new ActionListener() { | ||
| 321 | public void actionPerformed( ActionEvent e ) { | ||
| 322 | /* Esegue il trucco */ | ||
| 323 | main.trucco( JOptionPane.showInputDialog( Frame.this, main.stringaInserisciCodice, "JBriscola - " + main.version, JOptionPane.PLAIN_MESSAGE ) ); | ||
| 324 | } | ||
| 325 | } ); | ||
| 326 | |||
| 327 | opzioni = new JMenuItem( main.stringaOpzioni ); | ||
| 328 | opzioni.addActionListener( new ActionListener() { | ||
| 329 | /* Apre una OptionFrame per modificare le opzioni. */ | ||
| 330 | public void actionPerformed( ActionEvent e ) { | ||
| 331 | |||
| 332 | OptionFrame optionFrame = new OptionFrame(); | ||
| 333 | optionFrame.setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE ); | ||
| 334 | optionFrame.setResizable( false ); | ||
| 335 | optionFrame.setAlwaysOnTop( true ); | ||
| 336 | optionFrame.setSize( 300, 200 ); | ||
| 337 | optionFrame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 300) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - 150) / 2); | ||
| 338 | optionFrame.setVisible( true ); | ||
| 339 | } | ||
| 340 | }); | ||
| 341 | |||
| 342 | esci = new JMenuItem( main.stringaEsci ); | ||
| 343 | esci.addActionListener( new ActionListener() { | ||
| 344 | /* Ciede conferma prima di uscire. */ | ||
| 345 | public void actionPerformed( ActionEvent e ) { | ||
| 346 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 347 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 348 | Frame.this.dispose(); | ||
| 349 | } | ||
| 350 | }); | ||
| 351 | |||
| 352 | file.add( nuovaPartita ); | ||
| 353 | file.add( nuovaPartitaAiTrenta ); | ||
| 354 | file.add( trucchi ); | ||
| 355 | file.add( opzioni ); | ||
| 356 | file.addSeparator(); | ||
| 357 | file.add( esci ); | ||
| 358 | |||
| 359 | puntoInterrogativo = new JMenu( "?" ); | ||
| 360 | |||
| 361 | informazioni = new JMenuItem( main.stringaInformazioni ); | ||
| 362 | informazioni.addActionListener( new ActionListener() { | ||
| 363 | /* Visualizza le informazioni. */ | ||
| 364 | public void actionPerformed( ActionEvent e ) { | ||
| 365 | JOptionPane.showMessageDialog( Frame.this, main.stringaInformazioni2, main.stringaInformazioni, JOptionPane.PLAIN_MESSAGE ); | ||
| 366 | } | ||
| 367 | } ); | ||
| 368 | |||
| 369 | tastiRapidi = new JMenuItem( main.stringaTasti ); | ||
| 370 | tastiRapidi.addActionListener( new ActionListener() { | ||
| 371 | /* Visualizza i tasti rapidi. */ | ||
| 372 | public void actionPerformed( ActionEvent e ) { | ||
| 373 | JOptionPane.showMessageDialog( Frame.this, main.stringaTasti2, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 374 | } | ||
| 375 | } ); | ||
| 376 | |||
| 377 | briscola = new JMenuItem( main.stringaBriscola ); | ||
| 378 | briscola.addActionListener( new ActionListener() { | ||
| 379 | /* Visualizza il seme di briscola corrente. */ | ||
| 380 | public void actionPerformed( ActionEvent e ) { | ||
| 381 | JOptionPane.showMessageDialog( Frame.this, main.stringaBriscola + ": " + main.semi[main.semeBriscola], "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 382 | } | ||
| 383 | }); | ||
| 384 | |||
| 385 | punti = new JMenuItem( main.stringaPunteggio ); | ||
| 386 | punti.addActionListener( new ActionListener() { | ||
| 387 | /* Visualizza il punteggio. */ | ||
| 388 | public void actionPerformed( ActionEvent e ) { | ||
| 389 | JOptionPane.showMessageDialog( Frame.this, main.stringaGiocatore + main.punteggio + main.stringaComputer + main.punteggioCPU, main.stringaPunteggio, JOptionPane.INFORMATION_MESSAGE ); | ||
| 390 | } | ||
| 391 | } ); | ||
| 392 | |||
| 393 | aggiornamenti = new JMenuItem( main.stringaAggiornamenti ); | ||
| 394 | aggiornamenti.addActionListener( new ActionListener() { | ||
| 395 | /* Cerca aggiornamenti sul sito http://porkynator.altervista.org, | ||
| 396 | * confrontando la versione del programma con quella scritta nel | ||
| 397 | * file jbriscola-latest.is (online). */ | ||
| 398 | public void actionPerformed( ActionEvent e ) { | ||
| 399 | String latest = main.version; | ||
| 400 | try { | ||
| 401 | URL latestIs = new URL( "http://porkynator.altervista.org/jbriscola-latest.is" ); | ||
| 402 | BufferedReader latestIsReader = new BufferedReader( new InputStreamReader( latestIs.openStream() ) ); | ||
| 403 | latest = latestIsReader.readLine(); | ||
| 404 | } catch ( Exception ex ) { | ||
| 405 | JOptionPane.showMessageDialog( Frame.this, main.stringaNoInternet, "JBriscola - " + main.version, JOptionPane.ERROR_MESSAGE ); | ||
| 406 | } | ||
| 407 | if ( latest.equals( main.version ) ) | ||
| 408 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiNo, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 409 | else | ||
| 410 | JOptionPane.showMessageDialog( Frame.this, main.stringaAggiornamentiSi + "\n" + main.version + " ==> " + latest + "\n\n" + main.stringaScarica, "JBriscola - " + main.version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 411 | } | ||
| 412 | } ); | ||
| 413 | |||
| 414 | puntoInterrogativo.add( punti ); | ||
| 415 | puntoInterrogativo.add( briscola ); | ||
| 416 | puntoInterrogativo.add( tastiRapidi ); | ||
| 417 | puntoInterrogativo.add( informazioni ); | ||
| 418 | puntoInterrogativo.add( aggiornamenti ); | ||
| 419 | |||
| 420 | barraMenu.add( file ); | ||
| 421 | barraMenu.add( puntoInterrogativo ); | ||
| 422 | |||
| 423 | setJMenuBar( barraMenu ); | ||
| 424 | |||
| 425 | /* Inizializza le immagini del retro delle carte. */ | ||
| 426 | retro1 = new ImageIcon( ClassLoader.getSystemResource( "img/retro1.jpg" ) ); | ||
| 427 | retro2 = new ImageIcon( ClassLoader.getSystemResource( "img/retro2.jpg" ) ); | ||
| 428 | |||
| 429 | /* Inizializza tutte le immagini delle carte scorrendo l'array bidimensionale. */ | ||
| 430 | for (int i = 0; i < 10; i++) | ||
| 431 | for (int j = 0; j < 4; j++) | ||
| 432 | arrayCarte[i][j] = new ImageIcon( ClassLoader.getSystemResource( "img/" + (i+1) + "-" + (j+1) + ".jpg" ) ); | ||
| 433 | |||
| 434 | /* Mischia le carte. */ | ||
| 435 | main.mischia(); | ||
| 436 | |||
| 437 | /* Aggiunge i vari componenti. */ | ||
| 438 | pannello2.add( button ); | ||
| 439 | setLayout( new BorderLayout() ); | ||
| 440 | add( pannello, BorderLayout.CENTER ); | ||
| 441 | add( pannello2, BorderLayout.SOUTH ); | ||
| 442 | |||
| 443 | /* Chiama il metodo mettiCarta se l'utente clicca. */ | ||
| 444 | addMouseListener( | ||
| 445 | new MouseAdapter() { | ||
| 446 | public void mouseClicked ( MouseEvent e ) { | ||
| 447 | if ( mettiCarta( e.getX(), e.getY() ) ) { | ||
| 448 | if ( !main.CPUHaGiocato ) | ||
| 449 | if ( main.aiTrenta ) | ||
| 450 | main.giocaCPUAiTrenta(); | ||
| 451 | else | ||
| 452 | main.giocaCPU(); | ||
| 453 | } | ||
| 454 | } | ||
| 455 | } | ||
| 456 | ); | ||
| 457 | |||
| 458 | /* Chiede conferma prima di uscire quando viene chiusa la finestra. */ | ||
| 459 | addWindowListener( | ||
| 460 | new WindowAdapter() { | ||
| 461 | public void windowClosing( WindowEvent e ) { | ||
| 462 | int selezione = JOptionPane.showOptionDialog( Frame.this, main.stringaVuoiDavveroUscire, "JBriscola " + main.version, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new String[] { main.stringaSi, main.stringaNo }, main.stringaNo ); | ||
| 463 | if ( selezione == JOptionPane.YES_OPTION ) | ||
| 464 | System.exit( 0 ); | ||
| 465 | } | ||
| 466 | } | ||
| 467 | ); | ||
| 468 | } | ||
| 469 | |||
| 470 | /* Se il giocatore ha cliccato su una carta la gioca e riproduce un suono casuale. */ | ||
| 471 | public boolean mettiCarta( int x, int y ) { | ||
| 472 | |||
| 473 | if ( !main.toccaAllaCPU && giocata[0] == null ) { | ||
| 474 | if ( main.sound && | ||
| 475 | ( ( x > 230 && x < 290 && y > 340 && y < 566 && carteInMano[0] != null ) || | ||
| 476 | ( x > 300 && x < 360 && y > 340 && y < 566 && carteInMano[1] != null ) || | ||
| 477 | ( x > 370 && x < 430 && y > 340 && y < 566 && carteInMano[2] != null ) ) ) { | ||
| 478 | try { | ||
| 479 | |||
| 480 | double a = Math.random() * 6; | ||
| 481 | int i = (int) a; | ||
| 482 | |||
| 483 | AudioFileFormat aff = AudioSystem.getAudioFileFormat( ClassLoader.getSystemResource("sounds/" + i + ".wav") ); | ||
| 484 | AudioInputStream ais = AudioSystem.getAudioInputStream( ClassLoader.getSystemResource("sounds/" + i + ".wav") ); | ||
| 485 | AudioFormat af = aff.getFormat(); | ||
| 486 | DataLine.Info info = new DataLine.Info( Clip.class, ais.getFormat(), ( (int) ais.getFrameLength() * af.getFrameSize() ) ); | ||
| 487 | Clip ol = ( Clip ) AudioSystem.getLine( info ); | ||
| 488 | |||
| 489 | ol.open(ais); | ||
| 490 | ol.loop( 0 ); | ||
| 491 | |||
| 492 | } catch ( Exception e ) { | ||
| 493 | System.err.println( e ); | ||
| 494 | } | ||
| 495 | } | ||
| 496 | |||
| 497 | if ( x > 230 && x < 290 && y > 340 && y < 566 && carteInMano[0] != null ) { | ||
| 498 | giocata[0] = carteInMano[0]; | ||
| 499 | carteInMano[0] = null; | ||
| 500 | pannello.repaint(); | ||
| 501 | return true; | ||
| 502 | } | ||
| 503 | |||
| 504 | if ( x > 300 && x < 360 && y > 340 && y < 566 && carteInMano[1] != null ) { | ||
| 505 | giocata[0] = carteInMano[1]; | ||
| 506 | carteInMano[1] = null; | ||
| 507 | pannello.repaint(); | ||
| 508 | return true; | ||
| 509 | } | ||
| 510 | |||
| 511 | if ( x > 370 && x < 430 && y > 340 && y < 566 && carteInMano[2] != null ) { | ||
| 512 | giocata[0] = carteInMano[2]; | ||
| 513 | carteInMano[2] = null; | ||
| 514 | pannello.repaint(); | ||
| 515 | return true; | ||
| 516 | } | ||
| 517 | } | ||
| 518 | |||
| 519 | return false; | ||
| 520 | } | ||
| 521 | } | ||
| 522 | |||
| 523 | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/Main.java b/JBriscola/all_versions/0.3/0.3/src/Main.java new file mode 100755 index 0000000..4907374 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/Main.java | |||
| @@ -0,0 +1,1702 @@ | |||
| 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 | |||
| 29 | /* semeBriscola serve a determinare quale il seme di briscola (0 coppe, | ||
| 30 | * 1 bastoni, 2 denari, 3 spade). | ||
| 31 | * punteggio è il punteggio del giocatore, punteggioCPU quello della CPU | ||
| 32 | * mano tiene il conto della mano a cui si è arrivati. | ||
| 33 | * cartaDaPescare è la carta che la CPU deve raccogliere dal mazzo | ||
| 34 | * cartaDaGiocare (può assumere valore compraso tra 0 e 2) è la carta | ||
| 35 | * che la cpu deve giocare. */ | ||
| 36 | public static int semeBriscola, punteggio, punteggioCPU, mano, cartaDaPescare, cartaDaGiocare; | ||
| 37 | |||
| 38 | /* toccaAllaCPU determina se è il turno del computer o del giocatore, | ||
| 39 | * CPUHaGiocato se il computer ha già giocato in questo turno e | ||
| 40 | * haGiocatoPrima se la prima mossa del turno è stata del giocatore | ||
| 41 | * (true) o della CPU (false). | ||
| 42 | * aiTrenta serve per determinare se la partida che si sta giocando è | ||
| 43 | * normale o ai 30. | ||
| 44 | * carteScoperte serve se viene attivato il trucco per mostrare le | ||
| 45 | * carte della CPU. | ||
| 46 | * sound e keys riguardano le opzioni (souno si o no, tasti rapidi si | ||
| 47 | * o no) salvate nel file di configurazione. */ | ||
| 48 | public static boolean toccaAllaCPU = false; | ||
| 49 | public static boolean CPUHaGiocato = false; | ||
| 50 | public static boolean haGiocatoPrima = true; | ||
| 51 | public static boolean aiTrenta = false; | ||
| 52 | public static boolean carteScoperte = false; | ||
| 53 | public static boolean sound = true; | ||
| 54 | public static boolean keys = true; | ||
| 55 | |||
| 56 | /* frame è la finestra principale del gioco, color il colore dello sfondo. | ||
| 57 | * lang, soundString e keysString servono a leggere le opzioni dal file | ||
| 58 | * di configurazione. */ | ||
| 59 | public static Frame frame; | ||
| 60 | public static Color color = new Color( 0, 150, 0 ); | ||
| 61 | public static String lang, soundString, keysString; | ||
| 62 | |||
| 63 | /* Tutte le stringhe che vengono utilizzate durante il gioco sono | ||
| 64 | * inizializzate qui, per poter essere tradotte in altre lingue. */ | ||
| 65 | public static String version = "0.3"; | ||
| 66 | public static String semi[] = { "Bastoni", "Coppe", "Denari", "Spade" }; | ||
| 67 | public static String stringaBriscola = "Briscola"; | ||
| 68 | public static String stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 69 | public static String stringaPrimaGioca = "Prima Gioca!"; | ||
| 70 | public static String stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 71 | public static String stringaVinto = "Hai Vinto!"; | ||
| 72 | public static String stringaPerso = "Hai Perso"; | ||
| 73 | public static String stringaPareggio = "Pareggio"; | ||
| 74 | public static String stringaGiocatore = "Giocatore: "; | ||
| 75 | public static String stringaComputer = "\nComputer: "; | ||
| 76 | public static String stringaNuovaPartita = "Nuova Partita"; | ||
| 77 | public static String stringaNuovaPartitaAiTrenta = "Nuova Partita Ai 30"; | ||
| 78 | public static String stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 79 | public static String stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 80 | public static String stringaSi = "Si"; | ||
| 81 | public static String stringaNo = "No"; | ||
| 82 | public static String stringaOpzioni = "Opzioni..."; | ||
| 83 | public static String stringaEsci = "Esci"; | ||
| 84 | public static String stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 85 | public static String stringaLingua = "Lingua"; | ||
| 86 | public static String stringaAnnulla = "Annulla"; | ||
| 87 | public static String stringaIt = "Italiano"; | ||
| 88 | public static String stringaLa = "Latino"; | ||
| 89 | public static String stringaBL = "Dialetto Bellunese"; | ||
| 90 | public static String stringaBV = "Dialetto Basso Veneto"; | ||
| 91 | public static String stringaEN = "Inglese"; | ||
| 92 | public static String stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 93 | public static String stringaInformazioni = "Informazioni"; | ||
| 94 | 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"; | ||
| 95 | public static String stringaSuono = "Effetti Sonori"; | ||
| 96 | public static String stringaPunteggio = "Punteggio"; | ||
| 97 | public static String stringaSfondo = "Sfondo"; | ||
| 98 | public static String stringaTasti = "Tasti rapidi"; | ||
| 99 | public static String stringaAggiornamenti = "Cerca aggiornamenti"; | ||
| 100 | public static String stringaTrucchi = "Trucchi"; | ||
| 101 | public static String stringaInserisciCodice = "Inserisci il codice:"; | ||
| 102 | public static String stringaTruccoAttivato = "Trucco attivato!"; | ||
| 103 | public static String stringaTruccoSbagliato = "Trucco non valido"; | ||
| 104 | public static String stringaCheCartaVuoi = "E allora che carta vuoi?"; | ||
| 105 | public static String stringaAggiornamentiSi = "Aggiornamento disponibile: "; | ||
| 106 | public static String stringaAggiornamentiNo = "Nessun aggiornamento disponibile"; | ||
| 107 | public static String stringaScarica = "E' possibile scaricare la versione più recente\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 108 | public static String stringaNoInternet = "Errore: nessuna connessione internet"; | ||
| 109 | 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 + "\nF7 " + stringaNuovaPartitaAiTrenta + "\nF8 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 110 | |||
| 111 | public static void main( String args[] ) { | ||
| 112 | |||
| 113 | /* Chiama il metodo settaOpzioni per leggere le impostazioni | ||
| 114 | * dell'utente da un eventuale file di configurazione */ | ||
| 115 | settaOpzioni(); | ||
| 116 | |||
| 117 | /* Crea la finestra principale del gioco e la posiziona al centro | ||
| 118 | * dello schermo. */ | ||
| 119 | frame = new Frame(); | ||
| 120 | frame.setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE ); | ||
| 121 | frame.setResizable( false ); | ||
| 122 | frame.setSize( 600, 600 ); | ||
| 123 | frame.setLocation( (Toolkit.getDefaultToolkit().getScreenSize().width - 600) / 2, (Toolkit.getDefaultToolkit().getScreenSize().height - 600) / 2); | ||
| 124 | frame.setVisible( true ); | ||
| 125 | } | ||
| 126 | |||
| 127 | /* Algoritmo per mischiare il mazzo: prende due carte a caso e le | ||
| 128 | * inverte di posto, utilizzando una variabile aux. Ripete il procedimento | ||
| 129 | * per 391 volte. */ | ||
| 130 | public void mischia() { | ||
| 131 | |||
| 132 | ImageIcon aux; | ||
| 133 | |||
| 134 | mano = 0; | ||
| 135 | punteggio = 0; | ||
| 136 | punteggioCPU = 0; | ||
| 137 | cartaDaPescare = 6; | ||
| 138 | frame.mazzo = true; | ||
| 139 | toccaAllaCPU = false; | ||
| 140 | CPUHaGiocato = false; | ||
| 141 | haGiocatoPrima = true; | ||
| 142 | frame.mazzo = true; | ||
| 143 | |||
| 144 | /* Inizializza l'array di carte mescolate ordinato */ | ||
| 145 | for ( int i = 0, k = 0; i < 10; i++ ) | ||
| 146 | for ( int j = 0; j < 4; j++, k++ ) | ||
| 147 | frame.arrayCarteMescolate[k] = frame.arrayCarte[i][j]; | ||
| 148 | |||
| 149 | /* Mescola le carte utilizzando il metodo sopra citato */ | ||
| 150 | for ( int i = 0; i < 391; i++ ) { | ||
| 151 | double a = Math.random() * 40; | ||
| 152 | int x = (int) a; | ||
| 153 | double b = Math.random() * 40; | ||
| 154 | int y = (int) b; | ||
| 155 | aux = frame.arrayCarteMescolate[x]; | ||
| 156 | frame.arrayCarteMescolate[x] = frame.arrayCarteMescolate[y]; | ||
| 157 | frame.arrayCarteMescolate[y] = aux; | ||
| 158 | } | ||
| 159 | |||
| 160 | /* Imposta il seme della briscola leggendo il nome dell'ultima carta | ||
| 161 | * utilizzando un array ausiliare */ | ||
| 162 | char auxChar[] = frame.arrayCarteMescolate[39].toString().toCharArray(); | ||
| 163 | semeBriscola = auxChar[auxChar.length-5] - 49; | ||
| 164 | |||
| 165 | /* Distribuisce le carte */ | ||
| 166 | frame.carteInMano[0] = frame.arrayCarteMescolate[0]; | ||
| 167 | frame.carteInMano[1] = frame.arrayCarteMescolate[1]; | ||
| 168 | frame.carteInMano[2] = frame.arrayCarteMescolate[2]; | ||
| 169 | frame.carteCPU[0] = frame.arrayCarteMescolate[3]; | ||
| 170 | frame.carteCPU[1] = frame.arrayCarteMescolate[4]; | ||
| 171 | frame.carteCPU[2] = frame.arrayCarteMescolate[5]; | ||
| 172 | frame.ultimaCarta = frame.arrayCarteMescolate[39]; | ||
| 173 | frame.giocata[0] = null; | ||
| 174 | frame.giocata[1] = null; | ||
| 175 | } | ||
| 176 | |||
| 177 | /* Viene chiamato a fine partita. */ | ||
| 178 | public void pulisciTavolo() { | ||
| 179 | |||
| 180 | punteggio = 0; | ||
| 181 | punteggioCPU = 0; | ||
| 182 | cartaDaPescare = 6; | ||
| 183 | toccaAllaCPU = false; | ||
| 184 | CPUHaGiocato = false; | ||
| 185 | haGiocatoPrima = true; | ||
| 186 | |||
| 187 | frame.mazzo = false; | ||
| 188 | frame.ultimaCarta = null; | ||
| 189 | for ( int i = 0; i < 3; i++ ) { | ||
| 190 | frame.carteCPU[i] = null; | ||
| 191 | frame.carteInMano[i] = null; | ||
| 192 | } | ||
| 193 | |||
| 194 | frame.pannello.repaint(); | ||
| 195 | frame.repaint(); | ||
| 196 | |||
| 197 | } | ||
| 198 | |||
| 199 | /* Fa giocare la CPU. Questo metodo contiene l'intelligenza artificiale | ||
| 200 | * del gioco. Ho preferito non commentare molto il corpo del metodo per | ||
| 201 | * due motivi; il primo è che abbastanza intuitivo: basta sapere che i | ||
| 202 | * vari metodi vaiLiscio(), vaiTaglio() ecc... tentano di fare ciò che | ||
| 203 | * ovviamente dice il loro nome, se ci riescono restituiscono true, | ||
| 204 | * in caso contrario false.*/ | ||
| 205 | public void giocaCPU() { | ||
| 206 | |||
| 207 | /* Nelle prime 16 mani ragiona in maniera diversa*/ | ||
| 208 | if ( mano < 16 ) { | ||
| 209 | |||
| 210 | /* Valuta cosa fare se il giocatore non ha ancora giocato. */ | ||
| 211 | if ( frame.giocata[0] == null ) { | ||
| 212 | if ( vaiPunti() ); | ||
| 213 | else if ( vaiLiscio() ); | ||
| 214 | else if ( vaiTaglio() ); | ||
| 215 | else if ( vaiBriscolaAlta() ); | ||
| 216 | else if ( vaiCarico() ); | ||
| 217 | else if ( vaiTre() ); | ||
| 218 | else if ( vaiAsso() ); | ||
| 219 | else; | ||
| 220 | } | ||
| 221 | |||
| 222 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 223 | else { | ||
| 224 | if ( haLisciato() ) { | ||
| 225 | if ( vaiSopra() ); | ||
| 226 | else if ( vaiLiscio() ); | ||
| 227 | else if ( vaiPunti() ); | ||
| 228 | else if ( vaiTaglio() ); | ||
| 229 | else if ( vaiTre() ); | ||
| 230 | else if ( vaiBriscolaAlta() ); | ||
| 231 | else if ( vaiCarico() ); | ||
| 232 | else if ( vaiAsso() ); | ||
| 233 | } else if ( haMessoPunti() ) { | ||
| 234 | if ( vaiSopra() ); | ||
| 235 | else if ( vaiLiscio() ); | ||
| 236 | else if ( vaiTaglio() ); | ||
| 237 | else if ( vaiPunti() ); | ||
| 238 | else if ( vaiTre() ); | ||
| 239 | else if ( vaiBriscolaAlta() ); | ||
| 240 | else if ( vaiCarico() ); | ||
| 241 | else if ( vaiAsso() ); | ||
| 242 | } else if ( haTagliato() ) { | ||
| 243 | if ( vaiLiscio() ); | ||
| 244 | else if ( vaiPunti() ); | ||
| 245 | else if ( vaiTaglio() ); | ||
| 246 | else if ( vaiTre() ); | ||
| 247 | else if ( vaiBriscolaAlta() ); | ||
| 248 | else if ( vaiCarico() ); | ||
| 249 | else if ( vaiAsso() ); | ||
| 250 | } else if ( haMessoBriscolaAlta() ) { | ||
| 251 | if ( vaiLiscio() ); | ||
| 252 | else if ( vaiPunti() ); | ||
| 253 | else if ( vaiTre() ); | ||
| 254 | else if ( vaiTaglio() ); | ||
| 255 | else if ( vaiBriscolaAlta() ); | ||
| 256 | else if ( vaiCarico() ); | ||
| 257 | else if ( vaiAsso() ); | ||
| 258 | } else if ( haMessoTre() ) { | ||
| 259 | if ( vaiAsso() ); | ||
| 260 | else if ( vaiLiscio() ); | ||
| 261 | else if ( vaiPunti() ); | ||
| 262 | else if ( vaiTaglio() ); | ||
| 263 | else if ( vaiBriscolaAlta() ); | ||
| 264 | else if ( vaiCarico() ); | ||
| 265 | } else if ( haMessoAsso() ) { | ||
| 266 | if ( vaiLiscio() ); | ||
| 267 | else if ( vaiPunti() ); | ||
| 268 | else if ( vaiTaglio() ); | ||
| 269 | else if ( vaiBriscolaAlta() ); | ||
| 270 | else if ( vaiCarico() ); | ||
| 271 | else if ( vaiTre() ); | ||
| 272 | } else if ( haCaricato() ) { | ||
| 273 | if ( vaiSopra() ); | ||
| 274 | else if ( vaiTre() ); | ||
| 275 | else if ( vaiBriscolaAlta() ); | ||
| 276 | else if ( vaiTaglio() ); | ||
| 277 | else if ( vaiAsso() ); | ||
| 278 | else if ( vaiLiscio() ); | ||
| 279 | else if ( vaiPunti() ); | ||
| 280 | else if ( vaiCarico() ); | ||
| 281 | } | ||
| 282 | } | ||
| 283 | } | ||
| 284 | |||
| 285 | /* Nella penultima mano (prima di pescare l'ultima carta) */ | ||
| 286 | else if ( mano == 16 ) { | ||
| 287 | |||
| 288 | /* Valuta cosa fare se il giocatore non ha ancora giocato. */ | ||
| 289 | if ( frame.giocata[0] == null ) { | ||
| 290 | char aux[]; | ||
| 291 | aux = frame.ultimaCarta.toString().toCharArray(); | ||
| 292 | if ( aux[aux.length-7] - 48 == 3 || aux[aux.length-7] - 48 == 1 ) { | ||
| 293 | if ( vaiCarico() ); | ||
| 294 | else if ( vaiPunti() ); | ||
| 295 | else if ( vaiLiscio() ); | ||
| 296 | else if ( vaiTaglio() ); | ||
| 297 | else if ( vaiBriscolaAlta() ); | ||
| 298 | else if ( vaiTre() ); | ||
| 299 | else if ( vaiAsso() ); | ||
| 300 | else; | ||
| 301 | } else { | ||
| 302 | if ( vaiPunti() ); | ||
| 303 | else if ( vaiLiscio() ); | ||
| 304 | else if ( vaiTaglio() ); | ||
| 305 | else if ( vaiBriscolaAlta() ); | ||
| 306 | else if ( vaiCarico() ); | ||
| 307 | else if ( vaiTre() ); | ||
| 308 | else if ( vaiAsso() ); | ||
| 309 | else; | ||
| 310 | } | ||
| 311 | } | ||
| 312 | |||
| 313 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 314 | else { | ||
| 315 | char aux[]; | ||
| 316 | aux = frame.ultimaCarta.toString().toCharArray(); | ||
| 317 | if ( aux[aux.length-7] - 48 == 3 || aux[aux.length-7] - 48 == 1 ) { | ||
| 318 | if ( haCaricato() ) { | ||
| 319 | if ( vaiSopra() ); | ||
| 320 | else if ( vaiLiscio() ); | ||
| 321 | else if ( vaiPunti() ); | ||
| 322 | else if ( vaiTre() ); | ||
| 323 | else if ( vaiTaglio() ); | ||
| 324 | else if ( vaiBriscolaAlta() ); | ||
| 325 | else if ( vaiAsso() ); | ||
| 326 | else if ( vaiCarico() ); | ||
| 327 | } | ||
| 328 | } else { | ||
| 329 | if ( haLisciato() ) { | ||
| 330 | if ( vaiSopra() ); | ||
| 331 | else 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 ( haMessoPunti() ) { | ||
| 339 | if ( vaiSopra() ); | ||
| 340 | else if ( vaiLiscio() ); | ||
| 341 | else if ( vaiTaglio() ); | ||
| 342 | else if ( vaiPunti() ); | ||
| 343 | else if ( vaiTre() ); | ||
| 344 | else if ( vaiBriscolaAlta() ); | ||
| 345 | else if ( vaiCarico() ); | ||
| 346 | else if ( vaiAsso() ); | ||
| 347 | } else if ( haTagliato() ) { | ||
| 348 | if ( vaiLiscio() ); | ||
| 349 | else if ( vaiPunti() ); | ||
| 350 | else if ( vaiTaglio() ); | ||
| 351 | else if ( vaiTre() ); | ||
| 352 | else if ( vaiBriscolaAlta() ); | ||
| 353 | else if ( vaiCarico() ); | ||
| 354 | else if ( vaiAsso() ); | ||
| 355 | } else if ( haMessoBriscolaAlta() ) { | ||
| 356 | if ( vaiLiscio() ); | ||
| 357 | else if ( vaiPunti() ); | ||
| 358 | else if ( vaiTre() ); | ||
| 359 | else if ( vaiTaglio() ); | ||
| 360 | else if ( vaiBriscolaAlta() ); | ||
| 361 | else if ( vaiCarico() ); | ||
| 362 | else if ( vaiAsso() ); | ||
| 363 | } else if ( haMessoTre() ) { | ||
| 364 | if ( vaiAsso() ); | ||
| 365 | else if ( vaiLiscio() ); | ||
| 366 | else if ( vaiPunti() ); | ||
| 367 | else if ( vaiTaglio() ); | ||
| 368 | else if ( vaiBriscolaAlta() ); | ||
| 369 | else if ( vaiCarico() ); | ||
| 370 | } else if ( haMessoAsso() ) { | ||
| 371 | if ( vaiLiscio() ); | ||
| 372 | else if ( vaiPunti() ); | ||
| 373 | else if ( vaiTaglio() ); | ||
| 374 | else if ( vaiBriscolaAlta() ); | ||
| 375 | else if ( vaiCarico() ); | ||
| 376 | else if ( vaiTre() ); | ||
| 377 | } else if ( haCaricato() ) { | ||
| 378 | if ( vaiSopra() ); | ||
| 379 | else if ( vaiTre() ); | ||
| 380 | else if ( vaiBriscolaAlta() ); | ||
| 381 | else if ( vaiAsso() ); | ||
| 382 | else if ( vaiTaglio() ); | ||
| 383 | else if ( vaiLiscio() ); | ||
| 384 | else if ( vaiPunti() ); | ||
| 385 | else if ( vaiCarico() ); | ||
| 386 | } | ||
| 387 | } | ||
| 388 | } | ||
| 389 | |||
| 390 | } else if ( mano == 17 ) { | ||
| 391 | |||
| 392 | /* Valuta cosa fare se il giocatore non ha ancora giocato. */ | ||
| 393 | if ( frame.giocata[0] == null ) { | ||
| 394 | if ( hoAsso() ) { | ||
| 395 | if ( vaiTre() ); | ||
| 396 | else if ( vaiBriscolaAlta() ); | ||
| 397 | else if ( vaiTaglio() ); | ||
| 398 | else if ( vaiLiscio() ); | ||
| 399 | else if ( vaiPunti() ); | ||
| 400 | else if ( vaiAsso() ); | ||
| 401 | else if ( vaiCarico() ); | ||
| 402 | } else { | ||
| 403 | if ( vaiLiscio() ); | ||
| 404 | else if ( vaiPunti() ); | ||
| 405 | else if ( vaiTaglio() ); | ||
| 406 | else if ( vaiBriscolaAlta() ); | ||
| 407 | else if ( vaiCarico() ); | ||
| 408 | else if ( vaiTre() ); | ||
| 409 | } | ||
| 410 | } | ||
| 411 | |||
| 412 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 413 | else { | ||
| 414 | if ( haLisciato() ) { | ||
| 415 | if ( vaiSopra() ); | ||
| 416 | else if ( vaiLiscio() ); | ||
| 417 | else if ( vaiPunti() ); | ||
| 418 | else if ( vaiTaglio() ); | ||
| 419 | else if ( vaiTre() ); | ||
| 420 | else if ( vaiBriscolaAlta() ); | ||
| 421 | else if ( vaiCarico() ); | ||
| 422 | else if ( vaiAsso() ); | ||
| 423 | } else if ( haMessoPunti() ) { | ||
| 424 | if ( vaiSopra() ); | ||
| 425 | else if ( vaiLiscio() ); | ||
| 426 | else if ( vaiTaglio() ); | ||
| 427 | else if ( vaiPunti() ); | ||
| 428 | else if ( vaiTre() ); | ||
| 429 | else if ( vaiBriscolaAlta() ); | ||
| 430 | else if ( vaiCarico() ); | ||
| 431 | else if ( vaiAsso() ); | ||
| 432 | } else if ( haTagliato() ) { | ||
| 433 | if ( vaiLiscio() ); | ||
| 434 | else if ( vaiPunti() ); | ||
| 435 | else if ( vaiTaglio() ); | ||
| 436 | else if ( vaiTre() ); | ||
| 437 | else if ( vaiBriscolaAlta() ); | ||
| 438 | else if ( vaiCarico() ); | ||
| 439 | else if ( vaiAsso() ); | ||
| 440 | } else if ( haMessoBriscolaAlta() ) { | ||
| 441 | if ( vaiLiscio() ); | ||
| 442 | else if ( vaiPunti() ); | ||
| 443 | else if ( vaiTre() ); | ||
| 444 | else if ( vaiTaglio() ); | ||
| 445 | else if ( vaiBriscolaAlta() ); | ||
| 446 | else if ( vaiCarico() ); | ||
| 447 | else if ( vaiAsso() ); | ||
| 448 | } else if ( haMessoTre() ) { | ||
| 449 | if ( vaiAsso() ); | ||
| 450 | else if ( vaiLiscio() ); | ||
| 451 | else if ( vaiPunti() ); | ||
| 452 | else if ( vaiTaglio() ); | ||
| 453 | else if ( vaiBriscolaAlta() ); | ||
| 454 | else if ( vaiCarico() ); | ||
| 455 | } else if ( haMessoAsso() ) { | ||
| 456 | if ( vaiLiscio() ); | ||
| 457 | else if ( vaiPunti() ); | ||
| 458 | else if ( vaiTaglio() ); | ||
| 459 | else if ( vaiBriscolaAlta() ); | ||
| 460 | else if ( vaiCarico() ); | ||
| 461 | else if ( vaiTre() ); | ||
| 462 | } else if ( haCaricato() ) { | ||
| 463 | if ( vaiSopra() ); | ||
| 464 | else if ( vaiTre() ); | ||
| 465 | else if ( vaiBriscolaAlta() ); | ||
| 466 | else if ( vaiAsso() ); | ||
| 467 | else if ( vaiTaglio() ); | ||
| 468 | else if ( vaiLiscio() ); | ||
| 469 | else if ( vaiPunti() ); | ||
| 470 | else if ( vaiCarico() ); | ||
| 471 | } | ||
| 472 | } | ||
| 473 | |||
| 474 | } else if ( mano == 18 ) { | ||
| 475 | |||
| 476 | /* Valuta cosa fare se il giocatore non ha ancora giocato. */ | ||
| 477 | if ( frame.giocata[0] == null ) { | ||
| 478 | if ( vaiAsso() ); | ||
| 479 | else if ( vaiCarico() ); | ||
| 480 | else if ( vaiBriscolaAlta() ); | ||
| 481 | else if ( vaiTaglio() ); | ||
| 482 | else if ( vaiPunti() ); | ||
| 483 | else if ( vaiLiscio() ); | ||
| 484 | else if ( vaiTre() ); | ||
| 485 | } | ||
| 486 | |||
| 487 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 488 | else { | ||
| 489 | if ( haLisciato() ) { | ||
| 490 | if ( vaiSopra() ); | ||
| 491 | else if ( vaiLiscio() ); | ||
| 492 | else if ( vaiPunti() ); | ||
| 493 | else if ( vaiTaglio() ); | ||
| 494 | else if ( vaiTre() ); | ||
| 495 | else if ( vaiBriscolaAlta() ); | ||
| 496 | else if ( vaiCarico() ); | ||
| 497 | else if ( vaiAsso() ); | ||
| 498 | } else if ( haMessoPunti() ) { | ||
| 499 | if ( vaiSopra() ); | ||
| 500 | else if ( vaiLiscio() ); | ||
| 501 | else if ( vaiTaglio() ); | ||
| 502 | else if ( vaiPunti() ); | ||
| 503 | else if ( vaiTre() ); | ||
| 504 | else if ( vaiBriscolaAlta() ); | ||
| 505 | else if ( vaiCarico() ); | ||
| 506 | else if ( vaiAsso() ); | ||
| 507 | } else if ( haTagliato() ) { | ||
| 508 | if ( vaiLiscio() ); | ||
| 509 | else if ( vaiPunti() ); | ||
| 510 | else if ( vaiTaglio() ); | ||
| 511 | else if ( vaiTre() ); | ||
| 512 | else if ( vaiBriscolaAlta() ); | ||
| 513 | else if ( vaiCarico() ); | ||
| 514 | else if ( vaiAsso() ); | ||
| 515 | } else if ( haMessoBriscolaAlta() ) { | ||
| 516 | if ( vaiLiscio() ); | ||
| 517 | else if ( vaiPunti() ); | ||
| 518 | else if ( vaiTre() ); | ||
| 519 | else if ( vaiTaglio() ); | ||
| 520 | else if ( vaiBriscolaAlta() ); | ||
| 521 | else if ( vaiCarico() ); | ||
| 522 | else if ( vaiAsso() ); | ||
| 523 | } else if ( haMessoTre() ) { | ||
| 524 | if ( vaiAsso() ); | ||
| 525 | else if ( vaiLiscio() ); | ||
| 526 | else if ( vaiPunti() ); | ||
| 527 | else if ( vaiTaglio() ); | ||
| 528 | else if ( vaiBriscolaAlta() ); | ||
| 529 | else if ( vaiCarico() ); | ||
| 530 | } else if ( haMessoAsso() ) { | ||
| 531 | if ( vaiLiscio() ); | ||
| 532 | else if ( vaiPunti() ); | ||
| 533 | else if ( vaiTaglio() ); | ||
| 534 | else if ( vaiBriscolaAlta() ); | ||
| 535 | else if ( vaiCarico() ); | ||
| 536 | else if ( vaiTre() ); | ||
| 537 | } else if ( haCaricato() ) { | ||
| 538 | if ( vaiSopra() ); | ||
| 539 | else if ( vaiTre() ); | ||
| 540 | else if ( vaiBriscolaAlta() ); | ||
| 541 | else if ( vaiAsso() ); | ||
| 542 | else if ( vaiTaglio() ); | ||
| 543 | else if ( vaiLiscio() ); | ||
| 544 | else if ( vaiPunti() ); | ||
| 545 | else if ( vaiCarico() ); | ||
| 546 | } | ||
| 547 | } | ||
| 548 | |||
| 549 | /* All'ultima mano è inutile ragionare, dato che ha una sola carta */ | ||
| 550 | } else { | ||
| 551 | if ( vaiTre() ); | ||
| 552 | else if ( vaiBriscolaAlta() ); | ||
| 553 | else if ( vaiAsso() ); | ||
| 554 | else if ( vaiTaglio() ); | ||
| 555 | else if ( vaiLiscio() ); | ||
| 556 | else if ( vaiPunti() ); | ||
| 557 | else if ( vaiCarico() ); | ||
| 558 | } | ||
| 559 | |||
| 560 | /* Gioca la carta e aggiorna la finestra con il metodo repaint() */ | ||
| 561 | frame.giocata[1] = frame.carteCPU[cartaDaGiocare]; | ||
| 562 | frame.carteCPU[cartaDaGiocare] = null; | ||
| 563 | frame.pannello.repaint(); | ||
| 564 | |||
| 565 | CPUHaGiocato = true; | ||
| 566 | |||
| 567 | if ( frame.giocata[0] == null ) | ||
| 568 | toccaAllaCPU = false; | ||
| 569 | } | ||
| 570 | |||
| 571 | /* Fa giocare una partita ai 30. È analogo al metodo precedente, cambia | ||
| 572 | * solo la tecnica di gioco, quindi non è commentato. */ | ||
| 573 | public void giocaCPUAiTrenta() { | ||
| 574 | |||
| 575 | if ( punteggio <= 20 ) { | ||
| 576 | |||
| 577 | if ( frame.giocata[0] == null ) { | ||
| 578 | if ( vaiPunti() ); | ||
| 579 | else if ( vaiLiscio() ); | ||
| 580 | else if ( vaiTaglio() ); | ||
| 581 | else if ( vaiBriscolaAlta() ); | ||
| 582 | else if ( vaiCarico() ); | ||
| 583 | else if ( vaiTre() ); | ||
| 584 | else if ( vaiAsso() ); | ||
| 585 | else; | ||
| 586 | } | ||
| 587 | |||
| 588 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 589 | else { | ||
| 590 | if ( haLisciato() ) { | ||
| 591 | if ( vaiSopra() ); | ||
| 592 | else if ( vaiLiscio() ); | ||
| 593 | else if ( vaiTre() ); | ||
| 594 | else if ( vaiBriscolaAlta() ); | ||
| 595 | else if ( vaiTaglio() ); | ||
| 596 | else if ( vaiPunti() ); | ||
| 597 | else if ( vaiAsso() ); | ||
| 598 | else if ( vaiCarico() ); | ||
| 599 | } else if ( haMessoPunti() ) { | ||
| 600 | if ( vaiSopra() ); | ||
| 601 | else if ( vaiTre() ); | ||
| 602 | else if ( vaiBriscolaAlta() ); | ||
| 603 | else if ( vaiTaglio() ); | ||
| 604 | else if ( vaiLiscio() ); | ||
| 605 | else if ( vaiPunti() ); | ||
| 606 | else if ( vaiAsso() ); | ||
| 607 | else if ( vaiCarico() ); | ||
| 608 | } else if ( haTagliato() ) { | ||
| 609 | if ( vaiLiscio() ); | ||
| 610 | else if ( vaiPunti() ); | ||
| 611 | else if ( vaiTaglio() ); | ||
| 612 | else if ( vaiTre() ); | ||
| 613 | else if ( vaiBriscolaAlta() ); | ||
| 614 | else if ( vaiAsso() ); | ||
| 615 | else if ( vaiCarico() ); | ||
| 616 | } else if ( haMessoBriscolaAlta() ) { | ||
| 617 | if ( vaiLiscio() ); | ||
| 618 | else if ( vaiPunti() ); | ||
| 619 | else if ( vaiTre() ); | ||
| 620 | else if ( vaiTaglio() ); | ||
| 621 | else if ( vaiBriscolaAlta() ); | ||
| 622 | else if ( vaiAsso() ); | ||
| 623 | else if ( vaiCarico() ); | ||
| 624 | } else if ( haMessoTre() ) { | ||
| 625 | if ( vaiAsso() ); | ||
| 626 | else if ( vaiLiscio() ); | ||
| 627 | else if ( vaiPunti() ); | ||
| 628 | else if ( vaiTaglio() ); | ||
| 629 | else if ( vaiBriscolaAlta() ); | ||
| 630 | else if ( vaiCarico() ); | ||
| 631 | } else if ( haMessoAsso() ) { | ||
| 632 | if ( vaiLiscio() ); | ||
| 633 | else if ( vaiPunti() ); | ||
| 634 | else if ( vaiTaglio() ); | ||
| 635 | else if ( vaiBriscolaAlta() ); | ||
| 636 | else if ( vaiCarico() ); | ||
| 637 | else if ( vaiTre() ); | ||
| 638 | } else if ( haCaricato() ) { | ||
| 639 | if ( vaiSopra() ); | ||
| 640 | else if ( vaiTre() ); | ||
| 641 | else if ( vaiBriscolaAlta() ); | ||
| 642 | else if ( vaiTaglio() ); | ||
| 643 | else if ( vaiAsso() ); | ||
| 644 | else if ( vaiLiscio() ); | ||
| 645 | else if ( vaiPunti() ); | ||
| 646 | else if ( vaiCarico() ); | ||
| 647 | } | ||
| 648 | } | ||
| 649 | } | ||
| 650 | |||
| 651 | else { | ||
| 652 | |||
| 653 | if ( frame.giocata[0] == null ) { | ||
| 654 | if ( vaiLiscio() ); | ||
| 655 | else if ( vaiPunti() ); | ||
| 656 | else if ( vaiTaglio() ); | ||
| 657 | else if ( vaiBriscolaAlta() ); | ||
| 658 | else if ( vaiAsso() ); | ||
| 659 | else if ( vaiTre() ); | ||
| 660 | else if ( vaiCarico() ); | ||
| 661 | else; | ||
| 662 | } | ||
| 663 | |||
| 664 | /* Valuta cosa fare quando invece il giocatore ha giocato */ | ||
| 665 | else { | ||
| 666 | if ( haLisciato() ) { | ||
| 667 | if ( vaiSopra() ); | ||
| 668 | else if ( vaiLiscio() ); | ||
| 669 | else if ( vaiTre() ); | ||
| 670 | else if ( vaiBriscolaAlta() ); | ||
| 671 | else if ( vaiTaglio() ); | ||
| 672 | else if ( vaiAsso() ); | ||
| 673 | else if ( vaiPunti() ); | ||
| 674 | else if ( vaiCarico() ); | ||
| 675 | } else if ( haMessoPunti() ) { | ||
| 676 | if ( vaiSopra() ); | ||
| 677 | else if ( vaiTre() ); | ||
| 678 | else if ( vaiBriscolaAlta() ); | ||
| 679 | else if ( vaiTaglio() ); | ||
| 680 | else if ( vaiAsso() ); | ||
| 681 | else if ( vaiLiscio() ); | ||
| 682 | else if ( vaiPunti() ); | ||
| 683 | else if ( vaiCarico() ); | ||
| 684 | } else if ( haTagliato() ) { | ||
| 685 | if ( vaiLiscio() ); | ||
| 686 | else if ( vaiTaglio() ); | ||
| 687 | else if ( vaiTre() ); | ||
| 688 | else if ( vaiBriscolaAlta() ); | ||
| 689 | else if ( vaiAsso() ); | ||
| 690 | else if ( vaiPunti() ); | ||
| 691 | else if ( vaiCarico() ); | ||
| 692 | } else if ( haMessoBriscolaAlta() ) { | ||
| 693 | if ( vaiLiscio() ); | ||
| 694 | else if ( vaiTre() ); | ||
| 695 | else if ( vaiTaglio() ); | ||
| 696 | else if ( vaiAsso() ); | ||
| 697 | else if ( vaiBriscolaAlta() ); | ||
| 698 | else if ( vaiPunti() ); | ||
| 699 | else if ( vaiCarico() ); | ||
| 700 | } else if ( haMessoTre() ) { | ||
| 701 | if ( vaiAsso() ); | ||
| 702 | else if ( vaiLiscio() ); | ||
| 703 | else if ( vaiPunti() ); | ||
| 704 | else if ( vaiTaglio() ); | ||
| 705 | else if ( vaiBriscolaAlta() ); | ||
| 706 | else if ( vaiCarico() ); | ||
| 707 | } else if ( haMessoAsso() ) { | ||
| 708 | if ( vaiLiscio() ); | ||
| 709 | else if ( vaiTaglio() ); | ||
| 710 | else if ( vaiPunti() ); | ||
| 711 | else if ( vaiBriscolaAlta() ); | ||
| 712 | else if ( vaiCarico() ); | ||
| 713 | else if ( vaiTre() ); | ||
| 714 | } else if ( haCaricato() ) { | ||
| 715 | if ( vaiSopra() ); | ||
| 716 | else if ( vaiTre() ); | ||
| 717 | else if ( vaiBriscolaAlta() ); | ||
| 718 | else if ( vaiTaglio() ); | ||
| 719 | else if ( vaiAsso() ); | ||
| 720 | else if ( vaiLiscio() ); | ||
| 721 | else if ( vaiPunti() ); | ||
| 722 | else if ( vaiCarico() ); | ||
| 723 | } | ||
| 724 | } | ||
| 725 | } | ||
| 726 | |||
| 727 | /* Gioca la carta e aggiorna la finestra con il metodo repaint() */ | ||
| 728 | frame.giocata[1] = frame.carteCPU[cartaDaGiocare]; | ||
| 729 | frame.carteCPU[cartaDaGiocare] = null; | ||
| 730 | frame.pannello.repaint(); | ||
| 731 | |||
| 732 | CPUHaGiocato = true; | ||
| 733 | |||
| 734 | if ( frame.giocata[0] == null ) | ||
| 735 | toccaAllaCPU = false; | ||
| 736 | } | ||
| 737 | |||
| 738 | /* Determina se ha preso la CPU o il giocatore */ | ||
| 739 | public void chiPrende() { | ||
| 740 | char aux[], auxCPU[]; | ||
| 741 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 742 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 743 | |||
| 744 | /* Chiama il metodo giocatorePrende( boolean giocatore ) con parametro | ||
| 745 | * true se ha preso il giocatore, false se ha preso la CPU */ | ||
| 746 | giocatorePrende( ( (aux[aux.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) ) | ||
| 747 | || ( (aux[aux.length-5] == auxCPU[auxCPU.length-5]) && laPrimaEPiuAlta( aux[aux.length-7] - 48, auxCPU[auxCPU.length-7] - 48 ) ) | ||
| 748 | || ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (aux[aux.length-5] != auxCPU[auxCPU.length-5]) && haGiocatoPrima ) ); | ||
| 749 | } | ||
| 750 | |||
| 751 | /* Confronta due carte per decidere quale ha più valore di presa. | ||
| 752 | * Restituisce true se è la prima, false se è la seconda */ | ||
| 753 | public boolean laPrimaEPiuAlta( int prima, int seconda ) { | ||
| 754 | int a, b; | ||
| 755 | switch ( prima ) { | ||
| 756 | case 0: | ||
| 757 | a = 10; | ||
| 758 | break; | ||
| 759 | case 1: | ||
| 760 | a = 12; | ||
| 761 | break; | ||
| 762 | case 3: | ||
| 763 | a = 11; | ||
| 764 | break; | ||
| 765 | default: | ||
| 766 | a = prima; | ||
| 767 | break; | ||
| 768 | } | ||
| 769 | switch ( seconda ) { | ||
| 770 | case 0: | ||
| 771 | b = 10; | ||
| 772 | break; | ||
| 773 | case 1: | ||
| 774 | b = 12; | ||
| 775 | break; | ||
| 776 | case 3: | ||
| 777 | b = 11; | ||
| 778 | break; | ||
| 779 | default: | ||
| 780 | b = seconda; | ||
| 781 | break; | ||
| 782 | } | ||
| 783 | return a > b; | ||
| 784 | } | ||
| 785 | |||
| 786 | /* Viene chiamato con parametro true se ha preso il giocatore, false se | ||
| 787 | * ha preso la CPU */ | ||
| 788 | public void giocatorePrende( boolean giocatore ) { | ||
| 789 | if ( giocatore ) { | ||
| 790 | toccaAllaCPU = CPUHaGiocato = false; | ||
| 791 | haGiocatoPrima = true; | ||
| 792 | } | ||
| 793 | else { | ||
| 794 | toccaAllaCPU = true; | ||
| 795 | CPUHaGiocato = haGiocatoPrima = false; | ||
| 796 | } | ||
| 797 | daiPunti( giocatore ); | ||
| 798 | } | ||
| 799 | |||
| 800 | /* Da i punti (true al giocatore, false alla CPU) e fa pescare le carte*/ | ||
| 801 | public void daiPunti( boolean giocatore ) { | ||
| 802 | |||
| 803 | char aux[], auxCPU[]; | ||
| 804 | aux = frame.giocata[0].toString().toCharArray(); | ||
| 805 | auxCPU = frame.giocata[1].toString().toCharArray(); | ||
| 806 | int punti = 0; | ||
| 807 | |||
| 808 | switch( aux[aux.length-7] - 48 ) { | ||
| 809 | case 0: | ||
| 810 | punti += 4; | ||
| 811 | break; | ||
| 812 | case 1: | ||
| 813 | punti += 11; | ||
| 814 | break; | ||
| 815 | case 3: | ||
| 816 | punti += 10; | ||
| 817 | break; | ||
| 818 | case 8: | ||
| 819 | punti += 2; | ||
| 820 | break; | ||
| 821 | case 9: | ||
| 822 | punti += 3; | ||
| 823 | break; | ||
| 824 | default: | ||
| 825 | break; | ||
| 826 | } | ||
| 827 | switch( auxCPU[auxCPU.length-7] - 48 ) { | ||
| 828 | case 0: | ||
| 829 | punti += 4; | ||
| 830 | break; | ||
| 831 | case 1: | ||
| 832 | punti += 11; | ||
| 833 | break; | ||
| 834 | case 3: | ||
| 835 | punti += 10; | ||
| 836 | break; | ||
| 837 | case 8: | ||
| 838 | punti += 2; | ||
| 839 | break; | ||
| 840 | case 9: | ||
| 841 | punti += 3; | ||
| 842 | break; | ||
| 843 | default: | ||
| 844 | break; | ||
| 845 | } | ||
| 846 | |||
| 847 | frame.giocata[0] = frame.giocata[1] = null; | ||
| 848 | |||
| 849 | if ( giocatore ) { | ||
| 850 | punteggio += punti; | ||
| 851 | if ( mano < 18 ) { | ||
| 852 | if ( frame.carteInMano[0] == null ) | ||
| 853 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 854 | if ( frame.carteInMano[1] == null ) | ||
| 855 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 856 | if ( frame.carteInMano[2] == null ) | ||
| 857 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 858 | cartaDaPescare++; | ||
| 859 | if ( frame.carteCPU[0] == null ) | ||
| 860 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 861 | if ( frame.carteCPU[1] == null ) | ||
| 862 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 863 | if ( frame.carteCPU[2] == null ) | ||
| 864 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 865 | cartaDaPescare++; | ||
| 866 | } | ||
| 867 | } | ||
| 868 | |||
| 869 | else { | ||
| 870 | punteggioCPU += punti; | ||
| 871 | if ( mano < 18 ) { | ||
| 872 | if ( frame.carteCPU[0] == null ) | ||
| 873 | frame.carteCPU[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 874 | if ( frame.carteCPU[1] == null ) | ||
| 875 | frame.carteCPU[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 876 | if ( frame.carteCPU[2] == null ) | ||
| 877 | frame.carteCPU[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 878 | cartaDaPescare++; | ||
| 879 | if ( frame.carteInMano[0] == null ) | ||
| 880 | frame.carteInMano[0] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 881 | if ( frame.carteInMano[1] == null ) | ||
| 882 | frame.carteInMano[1] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 883 | if ( frame.carteInMano[2] == null ) | ||
| 884 | frame.carteInMano[2] = frame.arrayCarteMescolate[cartaDaPescare]; | ||
| 885 | cartaDaPescare++; | ||
| 886 | } | ||
| 887 | } | ||
| 888 | |||
| 889 | /* Aggiorna la finestra */ | ||
| 890 | frame.pannello.repaint(); | ||
| 891 | frame.repaint(); | ||
| 892 | } | ||
| 893 | |||
| 894 | /* Vari metodi che determinano che tipo di carta ha giocato il giocatore. | ||
| 895 | * Per farlo leggono il nome dell'immagine dal file. Dato che ogni carta | ||
| 896 | * a un nome del tipo 1-1.jpg (asso di coppe) o 10-3 (re di denari) e | ||
| 897 | * così via, è facile riconoscerle. */ | ||
| 898 | public boolean haLisciato() { | ||
| 899 | char auxCPU[]; | ||
| 900 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 901 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 902 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 903 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ); | ||
| 904 | } | ||
| 905 | |||
| 906 | public boolean haMessoPunti() { | ||
| 907 | char auxCPU[]; | ||
| 908 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 909 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 910 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || | ||
| 911 | (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ); | ||
| 912 | } | ||
| 913 | |||
| 914 | public boolean haTagliato() { | ||
| 915 | char auxCPU[]; | ||
| 916 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 917 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 918 | (auxCPU[auxCPU.length-7] - 48 != 0) && (auxCPU[auxCPU.length-7] - 48 != 1) && | ||
| 919 | (auxCPU[auxCPU.length-7] - 48 != 3) && (auxCPU[auxCPU.length-7] - 48 <= 7) ); | ||
| 920 | } | ||
| 921 | |||
| 922 | public boolean haMessoBriscolaAlta() { | ||
| 923 | char auxCPU[]; | ||
| 924 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 925 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 926 | ( (auxCPU[auxCPU.length-7] - 48 == 0) || (auxCPU[auxCPU.length-7] - 48 == 8) || | ||
| 927 | (auxCPU[auxCPU.length-7] - 48 == 9) ) ); | ||
| 928 | } | ||
| 929 | |||
| 930 | public boolean haMessoTre() { | ||
| 931 | char auxCPU[]; | ||
| 932 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 933 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 934 | (auxCPU[auxCPU.length-7] - 48 == 3) ); | ||
| 935 | } | ||
| 936 | |||
| 937 | public boolean haMessoAsso() { | ||
| 938 | char auxCPU[]; | ||
| 939 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 940 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 941 | (auxCPU[auxCPU.length-7] - 48 == 1) ); | ||
| 942 | } | ||
| 943 | |||
| 944 | public boolean haCaricato() { | ||
| 945 | char auxCPU[]; | ||
| 946 | auxCPU = frame.giocata[0].toString().toCharArray(); | ||
| 947 | return ( (frame.giocata[0] != null) && (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 948 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ); | ||
| 949 | } | ||
| 950 | |||
| 951 | /* I metodi seguenti cercano di andare liscio - dare punti - mettere | ||
| 952 | * un taglio - ecc... e restituiscono true se hanno avuto successo, | ||
| 953 | * false altrimenti. */ | ||
| 954 | public boolean vaiLiscio() { | ||
| 955 | |||
| 956 | char auxCPU[]; | ||
| 957 | |||
| 958 | for ( int i = 0; i < 3; i++ ) { | ||
| 959 | if ( frame.carteCPU[i] != null ) { | ||
| 960 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 961 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 962 | (auxCPU[auxCPU.length-7] - 48 != 0 ) && (auxCPU[auxCPU.length-7] - 48 != 1 ) && | ||
| 963 | (auxCPU[auxCPU.length-7] - 48 != 3 ) && (auxCPU[auxCPU.length-7] - 48 < 8 ) ) { | ||
| 964 | cartaDaGiocare = i; | ||
| 965 | return true; | ||
| 966 | } | ||
| 967 | } | ||
| 968 | } | ||
| 969 | |||
| 970 | return false; | ||
| 971 | } | ||
| 972 | |||
| 973 | public boolean vaiPunti() { | ||
| 974 | /* Cerca di dare punti, cercando di darne il meno possibile (meglio | ||
| 975 | * un fante di re). */ | ||
| 976 | |||
| 977 | char[] auxCPU; | ||
| 978 | |||
| 979 | for ( int i = 0; i < 3; i++ ) { | ||
| 980 | if ( frame.carteCPU[i] != null ) { | ||
| 981 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 982 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 8 ) ) { | ||
| 983 | cartaDaGiocare = i; | ||
| 984 | return true; | ||
| 985 | } | ||
| 986 | } | ||
| 987 | } | ||
| 988 | |||
| 989 | for ( int i = 0; i < 3; i++ ) { | ||
| 990 | if ( frame.carteCPU[i] != null ) { | ||
| 991 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 992 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 9 ) ) { | ||
| 993 | cartaDaGiocare = i; | ||
| 994 | return true; | ||
| 995 | } | ||
| 996 | } | ||
| 997 | } | ||
| 998 | |||
| 999 | for ( int i = 0; i < 3; i++ ) { | ||
| 1000 | if ( frame.carteCPU[i] != null ) { | ||
| 1001 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1002 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 0 ) ) { | ||
| 1003 | cartaDaGiocare = i; | ||
| 1004 | return true; | ||
| 1005 | } | ||
| 1006 | } | ||
| 1007 | } | ||
| 1008 | |||
| 1009 | return false; | ||
| 1010 | } | ||
| 1011 | public boolean vaiTaglio() { | ||
| 1012 | |||
| 1013 | char auxCPU[]; | ||
| 1014 | |||
| 1015 | for ( int i = 0; i < 3; i++ ) { | ||
| 1016 | if ( frame.carteCPU[i] != null ) { | ||
| 1017 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1018 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && | ||
| 1019 | (auxCPU[auxCPU.length-7] - 48 != 0) && (auxCPU[auxCPU.length-7] - 48 != 1) && | ||
| 1020 | (auxCPU[auxCPU.length-7] - 48 != 3) && (auxCPU[auxCPU.length-7] - 48 <= 7) ) { | ||
| 1021 | cartaDaGiocare = i; | ||
| 1022 | return true; | ||
| 1023 | } | ||
| 1024 | } | ||
| 1025 | } | ||
| 1026 | |||
| 1027 | return false; | ||
| 1028 | } | ||
| 1029 | public boolean vaiBriscolaAlta() { | ||
| 1030 | |||
| 1031 | char[] auxCPU; | ||
| 1032 | |||
| 1033 | for ( int i = 0; i < 3; i++ ) { | ||
| 1034 | if ( frame.carteCPU[i] != null ) { | ||
| 1035 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1036 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 8 ) ) { | ||
| 1037 | cartaDaGiocare = i; | ||
| 1038 | return true; | ||
| 1039 | } | ||
| 1040 | } | ||
| 1041 | } | ||
| 1042 | |||
| 1043 | for ( int i = 0; i < 3; i++ ) { | ||
| 1044 | if ( frame.carteCPU[i] != null ) { | ||
| 1045 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1046 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 9 ) ) { | ||
| 1047 | cartaDaGiocare = i; | ||
| 1048 | return true; | ||
| 1049 | } | ||
| 1050 | } | ||
| 1051 | } | ||
| 1052 | |||
| 1053 | for ( int i = 0; i < 3; i++ ) { | ||
| 1054 | if ( frame.carteCPU[i] != null ) { | ||
| 1055 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1056 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 0 ) ) { | ||
| 1057 | cartaDaGiocare = i; | ||
| 1058 | return true; | ||
| 1059 | } | ||
| 1060 | } | ||
| 1061 | } | ||
| 1062 | |||
| 1063 | return false; | ||
| 1064 | } | ||
| 1065 | public boolean vaiTre() { | ||
| 1066 | |||
| 1067 | char auxCPU[]; | ||
| 1068 | |||
| 1069 | for ( int i = 0; i < 3; i++ ) { | ||
| 1070 | if ( frame.carteCPU[i] != null ) { | ||
| 1071 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1072 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && (auxCPU[auxCPU.length-7] - 48 == 3) ) { | ||
| 1073 | cartaDaGiocare = i; | ||
| 1074 | return true; | ||
| 1075 | } | ||
| 1076 | } | ||
| 1077 | } | ||
| 1078 | |||
| 1079 | return false; | ||
| 1080 | } | ||
| 1081 | public boolean vaiAsso() { | ||
| 1082 | |||
| 1083 | char auxCPU[]; | ||
| 1084 | |||
| 1085 | for ( int i = 0; i < 3; i++ ) { | ||
| 1086 | if ( frame.carteCPU[i] != null ) { | ||
| 1087 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1088 | if ( auxCPU[auxCPU.length-5] - 49 == semeBriscola && (auxCPU[auxCPU.length-7] - 48 == 1) ) { | ||
| 1089 | cartaDaGiocare = i; | ||
| 1090 | return true; | ||
| 1091 | } | ||
| 1092 | } | ||
| 1093 | } | ||
| 1094 | |||
| 1095 | return false; | ||
| 1096 | } | ||
| 1097 | public boolean vaiCarico() { | ||
| 1098 | |||
| 1099 | char[] auxCPU; | ||
| 1100 | |||
| 1101 | for ( int i = 0; i < 3; i++ ) { | ||
| 1102 | if ( frame.carteCPU[i] != null ) { | ||
| 1103 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1104 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 3 ) ) { | ||
| 1105 | cartaDaGiocare = i; | ||
| 1106 | return true; | ||
| 1107 | } | ||
| 1108 | } | ||
| 1109 | } | ||
| 1110 | |||
| 1111 | for ( int i = 0; i < 3; i++ ) { | ||
| 1112 | if ( frame.carteCPU[i] != null ) { | ||
| 1113 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1114 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 1 ) ) { | ||
| 1115 | cartaDaGiocare = i; | ||
| 1116 | return true; | ||
| 1117 | } | ||
| 1118 | } | ||
| 1119 | } | ||
| 1120 | |||
| 1121 | return false; | ||
| 1122 | } | ||
| 1123 | public boolean vaiSopra() { | ||
| 1124 | /* Innanzitutto controlla se il giocatore ha giocato (non dovrebbe | ||
| 1125 | * essere possibile, in quanto quando questo metodo viene chiamato | ||
| 1126 | * tale condizione è già stata verificata, ma è sempre meglio un | ||
| 1127 | * controllo in più che uno in meno) e restituisce false in caso | ||
| 1128 | * contrario */ | ||
| 1129 | if ( frame.giocata[0] == null ) | ||
| 1130 | return false; | ||
| 1131 | |||
| 1132 | /* Tre variabili intere che serviranno a valutare quali delle tre | ||
| 1133 | * carte è meglio giocare, se più di una può andare sopra. */ | ||
| 1134 | int a = -1; | ||
| 1135 | int b = -1; | ||
| 1136 | int c = -1; | ||
| 1137 | |||
| 1138 | /* Tre booleane che verificano quali delle tre carte possono | ||
| 1139 | * andare sopra. */ | ||
| 1140 | boolean laPrimaPuoAndareSopra = false; | ||
| 1141 | boolean laSecondaPuoAndareSopra = false; | ||
| 1142 | boolean laTerzaPuoAndareSopra = false; | ||
| 1143 | |||
| 1144 | /* E tre array di caratteri ausiliari per leggere il nome delle | ||
| 1145 | * carte, più quello per la carta giocata dal giocatore.*/ | ||
| 1146 | char[] auxCPU1 = new char[1024]; | ||
| 1147 | char[] auxCPU2 = new char[1024]; | ||
| 1148 | char[] auxCPU3 = new char[1024]; | ||
| 1149 | char[] aux = frame.giocata[0].toString().toCharArray(); | ||
| 1150 | |||
| 1151 | /* Se il giocatore ha giocato un asso, restituisce direttamente false. */ | ||
| 1152 | if ( aux[aux.length-7] - 48 == 1 ) | ||
| 1153 | return false; | ||
| 1154 | |||
| 1155 | /* Valuta quali delle tre carte possono andare sopra, dopo essersi | ||
| 1156 | * accertato di averle: nelle ultime mani non si hanno tutte le carte | ||
| 1157 | * in mano, e noi non vogliamo una NullPointerException sul più bello | ||
| 1158 | * di una partita, vero?! */ | ||
| 1159 | if ( frame.carteCPU[0] != null ) { | ||
| 1160 | auxCPU1 = frame.carteCPU[0].toString().toCharArray(); | ||
| 1161 | a = auxCPU1[auxCPU1.length-7] - 48; | ||
| 1162 | if ( (auxCPU1[auxCPU1.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( a, aux[aux.length-7] - 48 ) ) | ||
| 1163 | laPrimaPuoAndareSopra = true; | ||
| 1164 | } | ||
| 1165 | |||
| 1166 | if ( frame.carteCPU[1] != null ) { | ||
| 1167 | auxCPU2 = frame.carteCPU[1].toString().toCharArray(); | ||
| 1168 | b = auxCPU2[auxCPU2.length-7] - 48; | ||
| 1169 | if ( (auxCPU2[auxCPU2.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( b, aux[aux.length-7] - 48 ) ) | ||
| 1170 | laSecondaPuoAndareSopra = true; | ||
| 1171 | } | ||
| 1172 | |||
| 1173 | if ( frame.carteCPU[2] != null ) { | ||
| 1174 | auxCPU3 = frame.carteCPU[2].toString().toCharArray(); | ||
| 1175 | c = auxCPU3[auxCPU3.length-7] - 48; | ||
| 1176 | if ( (auxCPU3[auxCPU3.length-5] - 49 == aux[aux.length-5] - 49) && laPrimaEPiuAlta( c, aux[aux.length-7] - 48 ) ) | ||
| 1177 | laTerzaPuoAndareSopra = true; | ||
| 1178 | } | ||
| 1179 | |||
| 1180 | /* Se nessuna carta può andare sopra, restituisce false. Se una | ||
| 1181 | * sola delle tre può andare sopra la imposta come carta da giocare. */ | ||
| 1182 | if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 1183 | return false; | ||
| 1184 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 1185 | cartaDaGiocare = 0; | ||
| 1186 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 1187 | cartaDaGiocare = 1; | ||
| 1188 | else if ( !laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 1189 | cartaDaGiocare = 2; | ||
| 1190 | |||
| 1191 | /* Se più di una carta può andare sopra, valuta quale è più alta. */ | ||
| 1192 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && !laTerzaPuoAndareSopra ) | ||
| 1193 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 1194 | cartaDaGiocare = 0; | ||
| 1195 | else | ||
| 1196 | cartaDaGiocare = 1; | ||
| 1197 | else if ( !laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 1198 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 1199 | cartaDaGiocare = 1; | ||
| 1200 | else | ||
| 1201 | cartaDaGiocare = 2; | ||
| 1202 | else if ( laPrimaPuoAndareSopra && !laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 1203 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 1204 | cartaDaGiocare = 0; | ||
| 1205 | else | ||
| 1206 | cartaDaGiocare = 2; | ||
| 1207 | else if ( laPrimaPuoAndareSopra && laSecondaPuoAndareSopra && laTerzaPuoAndareSopra ) | ||
| 1208 | if ( laPrimaEPiuAlta( a, b ) ) | ||
| 1209 | if ( laPrimaEPiuAlta( a, c ) ) | ||
| 1210 | cartaDaGiocare = 0; | ||
| 1211 | else | ||
| 1212 | cartaDaGiocare = 2; | ||
| 1213 | else | ||
| 1214 | if ( laPrimaEPiuAlta( b, c ) ) | ||
| 1215 | cartaDaGiocare = 1; | ||
| 1216 | else | ||
| 1217 | cartaDaGiocare = 2; | ||
| 1218 | |||
| 1219 | /* Controlla che la carta con cui sta cercando di andare sopra | ||
| 1220 | * sia una figura o un carico. Non vogliamo mica prendere delle | ||
| 1221 | * scartelle con delle scartelle, giusto?! */ | ||
| 1222 | aux = frame.carteCPU[cartaDaGiocare].toString().toCharArray(); | ||
| 1223 | if ( (aux[aux.length-7] - 48 != 0) && (aux[aux.length-7] - 48 != 1) && | ||
| 1224 | (aux[aux.length-7] - 48 != 3) && (aux[aux.length-7] - 48 <= 7) ) | ||
| 1225 | return false; | ||
| 1226 | |||
| 1227 | return true; | ||
| 1228 | } | ||
| 1229 | |||
| 1230 | /* I metodi seguenti valutano le carte che la CPU ha in mano. */ | ||
| 1231 | public boolean hoCarico() { | ||
| 1232 | |||
| 1233 | char auxCPU[]; | ||
| 1234 | |||
| 1235 | for ( int i = 0; i < 3; i++ ) { | ||
| 1236 | if ( frame.carteCPU[i] != null ) { | ||
| 1237 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1238 | if ( (auxCPU[auxCPU.length-5] - 49 != semeBriscola) && | ||
| 1239 | ( (auxCPU[auxCPU.length-7] - 48 == 1 ) || (auxCPU[auxCPU.length-7] - 48 == 3 ) ) ) { | ||
| 1240 | return true; | ||
| 1241 | } | ||
| 1242 | } | ||
| 1243 | } | ||
| 1244 | |||
| 1245 | return false; | ||
| 1246 | } | ||
| 1247 | public boolean hoAsso() { | ||
| 1248 | |||
| 1249 | char auxCPU[]; | ||
| 1250 | |||
| 1251 | for ( int i = 0; i < 3; i++ ) { | ||
| 1252 | if ( frame.carteCPU[i] != null ) { | ||
| 1253 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1254 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 1 ) ) { | ||
| 1255 | return true; | ||
| 1256 | } | ||
| 1257 | } | ||
| 1258 | } | ||
| 1259 | |||
| 1260 | return false; | ||
| 1261 | } | ||
| 1262 | public boolean hoTre() { | ||
| 1263 | |||
| 1264 | char auxCPU[]; | ||
| 1265 | |||
| 1266 | for ( int i = 0; i < 3; i++ ) { | ||
| 1267 | if ( frame.carteCPU[i] != null ) { | ||
| 1268 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1269 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && (auxCPU[auxCPU.length-7] - 48 == 3 ) ) { | ||
| 1270 | return true; | ||
| 1271 | } | ||
| 1272 | } | ||
| 1273 | } | ||
| 1274 | |||
| 1275 | return false; | ||
| 1276 | } | ||
| 1277 | public boolean hoBriscolaAlta() { | ||
| 1278 | |||
| 1279 | char auxCPU[]; | ||
| 1280 | |||
| 1281 | for ( int i = 0; i < 3; i++ ) { | ||
| 1282 | if ( frame.carteCPU[i] != null ) { | ||
| 1283 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1284 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 1285 | ( (auxCPU[auxCPU.length-7] - 48 == 0 ) || (auxCPU[auxCPU.length-7] - 48 == 8 ) || (auxCPU[auxCPU.length-7] - 48 == 9 ) ) ) { | ||
| 1286 | return true; | ||
| 1287 | } | ||
| 1288 | } | ||
| 1289 | } | ||
| 1290 | |||
| 1291 | return false; | ||
| 1292 | } | ||
| 1293 | public boolean hoTaglio() { | ||
| 1294 | |||
| 1295 | char auxCPU[]; | ||
| 1296 | |||
| 1297 | for ( int i = 0; i < 3; i++ ) { | ||
| 1298 | if ( frame.carteCPU[i] != null ) { | ||
| 1299 | auxCPU = frame.carteCPU[i].toString().toCharArray(); | ||
| 1300 | if ( (auxCPU[auxCPU.length-5] - 49 == semeBriscola) && | ||
| 1301 | (auxCPU[auxCPU.length-7] - 48 < 8 ) && (auxCPU[auxCPU.length-7] - 48 != 3 ) | ||
| 1302 | && (auxCPU[auxCPU.length-7] - 48 != 1 ) && (auxCPU[auxCPU.length-7] - 48 != 0 ) ) { | ||
| 1303 | return true; | ||
| 1304 | } | ||
| 1305 | } | ||
| 1306 | } | ||
| 1307 | |||
| 1308 | return false; | ||
| 1309 | } | ||
| 1310 | |||
| 1311 | /* I vari trucchi del gioco. */ | ||
| 1312 | public static void trucco( String trucco ) { | ||
| 1313 | |||
| 1314 | byte[] truccoByte = trucco.getBytes(); | ||
| 1315 | char[] truccoChar = new char[ truccoByte.length ]; | ||
| 1316 | for ( int i = 0; i < truccoChar.length; i++ ) | ||
| 1317 | truccoChar[i] = (char)truccoByte[i]; | ||
| 1318 | |||
| 1319 | String attivato = stringaTruccoSbagliato; | ||
| 1320 | |||
| 1321 | /* Carta che vuoi dove vuoi. Esempio: x251 sostituisce | ||
| 1322 | * la terza carta (2) con il 6 (5) di coppe (1). */ | ||
| 1323 | if ( truccoChar[0] == 'x' && truccoChar.length == 4 ) { | ||
| 1324 | |||
| 1325 | attivato = stringaTruccoAttivato; | ||
| 1326 | |||
| 1327 | String aS = "" + truccoChar[1]; | ||
| 1328 | String xS = "" + truccoChar[2]; | ||
| 1329 | String yS = "" + truccoChar[3]; | ||
| 1330 | |||
| 1331 | int a, x, y; | ||
| 1332 | |||
| 1333 | try { | ||
| 1334 | |||
| 1335 | a = Integer.parseInt( aS ); | ||
| 1336 | x = Integer.parseInt( xS ); | ||
| 1337 | y = Integer.parseInt( yS ); | ||
| 1338 | |||
| 1339 | frame.carteInMano[a] = frame.arrayCarte[x][y]; | ||
| 1340 | |||
| 1341 | } catch ( Exception e ) { | ||
| 1342 | attivato = stringaTruccoSbagliato; | ||
| 1343 | } | ||
| 1344 | } | ||
| 1345 | |||
| 1346 | /* Mostra le carte del computer. */ | ||
| 1347 | if ( trucco.equalsIgnoreCase( "Kill Devil Hill" ) ) { | ||
| 1348 | |||
| 1349 | attivato = stringaTruccoAttivato; | ||
| 1350 | |||
| 1351 | carteScoperte = true; | ||
| 1352 | |||
| 1353 | } | ||
| 1354 | |||
| 1355 | /* Scambia le carte con il computer. */ | ||
| 1356 | if ( trucco.equalsIgnoreCase( "Darkside of Aquarius" ) ) { | ||
| 1357 | |||
| 1358 | attivato = stringaTruccoAttivato; | ||
| 1359 | |||
| 1360 | ImageIcon aux = null; | ||
| 1361 | |||
| 1362 | for ( int i = 0; i < 3; i++ ) { | ||
| 1363 | |||
| 1364 | aux = frame.carteInMano[i]; | ||
| 1365 | frame.carteInMano[i] = frame.carteCPU[i]; | ||
| 1366 | frame.carteCPU[i] = aux; | ||
| 1367 | |||
| 1368 | } | ||
| 1369 | } | ||
| 1370 | |||
| 1371 | /* Cambia il seme di briscola con uno a caso, senza dire quale. | ||
| 1372 | * L'ultima carta non cambia. È possibile comunque capire | ||
| 1373 | * qual'è la briscola dal menu ?->Briscola*/ | ||
| 1374 | if ( trucco.equalsIgnoreCase( "Change of Heart" ) ) { | ||
| 1375 | |||
| 1376 | attivato = stringaTruccoAttivato; | ||
| 1377 | |||
| 1378 | semeBriscola = (int) ( Math.random() * 4 ); | ||
| 1379 | |||
| 1380 | } | ||
| 1381 | |||
| 1382 | /* Asso Tre e Re di Briscola tutti in mano (anche in caso di doppioni). */ | ||
| 1383 | if ( trucco.equalsIgnoreCase( "Tears of The Dragon" ) ) { | ||
| 1384 | |||
| 1385 | attivato = stringaTruccoAttivato; | ||
| 1386 | |||
| 1387 | frame.carteInMano[0] = frame.arrayCarte[9][semeBriscola]; | ||
| 1388 | frame.carteInMano[1] = frame.arrayCarte[2][semeBriscola]; | ||
| 1389 | frame.carteInMano[2] = frame.arrayCarte[0][semeBriscola]; | ||
| 1390 | |||
| 1391 | } | ||
| 1392 | |||
| 1393 | /* Tre assi di briscola. */ | ||
| 1394 | if ( trucco.equalsIgnoreCase( "Navigate The Seas of The Sun" ) ) { | ||
| 1395 | |||
| 1396 | attivato = stringaTruccoAttivato; | ||
| 1397 | |||
| 1398 | frame.carteInMano[0] = frame.arrayCarte[0][semeBriscola]; | ||
| 1399 | frame.carteInMano[1] = frame.arrayCarte[0][semeBriscola]; | ||
| 1400 | frame.carteInMano[2] = frame.arrayCarte[0][semeBriscola]; | ||
| 1401 | |||
| 1402 | } | ||
| 1403 | |||
| 1404 | /* Fa finire la partita al prossimo piglio. */ | ||
| 1405 | if ( trucco.equalsIgnoreCase( "Omega" ) ) { | ||
| 1406 | |||
| 1407 | attivato = stringaTruccoAttivato; | ||
| 1408 | |||
| 1409 | mano = 19; | ||
| 1410 | |||
| 1411 | } | ||
| 1412 | |||
| 1413 | JOptionPane.showMessageDialog( frame, attivato, "JBriscola - " + version, JOptionPane.INFORMATION_MESSAGE ); | ||
| 1414 | frame.pannello.repaint(); | ||
| 1415 | frame.repaint(); | ||
| 1416 | |||
| 1417 | } | ||
| 1418 | |||
| 1419 | /* Imposta le opzioni dell'utente cercando di leggerle dal file di configurazione. */ | ||
| 1420 | public static void settaOpzioni() { | ||
| 1421 | |||
| 1422 | /* Impostazioni predefinite. */ | ||
| 1423 | lang = "it"; | ||
| 1424 | soundString = "suono=si"; | ||
| 1425 | keysString = "tasti=si"; | ||
| 1426 | int r = 0; | ||
| 1427 | int g = 150; | ||
| 1428 | int b = 0; | ||
| 1429 | |||
| 1430 | /* Cerca di leggere il file per impostare le opzioni. */ | ||
| 1431 | Scanner scanner = null; | ||
| 1432 | File file = new File( "JBriscolaConfig.txt" ); | ||
| 1433 | if ( file.exists() ) { | ||
| 1434 | try { | ||
| 1435 | scanner = new Scanner( file ); | ||
| 1436 | } catch ( FileNotFoundException e ) { } | ||
| 1437 | try { | ||
| 1438 | lang = scanner.next(); | ||
| 1439 | soundString = scanner.next(); | ||
| 1440 | keysString = scanner.next(); | ||
| 1441 | r = scanner.nextInt(); | ||
| 1442 | g = scanner.nextInt(); | ||
| 1443 | b = scanner.nextInt(); | ||
| 1444 | } catch ( NoSuchElementException e ) { } | ||
| 1445 | } | ||
| 1446 | |||
| 1447 | /* Modifica le opzioni. */ | ||
| 1448 | if ( lang.equals( "it" ) ) { | ||
| 1449 | semi[0] = "Bastoni"; | ||
| 1450 | semi[1] = "Coppe"; | ||
| 1451 | semi[2] = "Denari"; | ||
| 1452 | semi[3] = "Spade"; | ||
| 1453 | stringaBriscola = "Briscola"; | ||
| 1454 | stringaBottonePrendi = "Prendi/Lascia carte"; | ||
| 1455 | stringaPrimaGioca = "Prima Gioca!"; | ||
| 1456 | stringaUltime4 = "Ultima carta - Occhio alla briscola!"; | ||
| 1457 | stringaVinto = "Hai Vinto!"; | ||
| 1458 | stringaPerso = "Hai Perso"; | ||
| 1459 | stringaPareggio = "Pareggio"; | ||
| 1460 | stringaGiocatore = "Giocatore: "; | ||
| 1461 | stringaComputer = "\nComputer: "; | ||
| 1462 | stringaNuovaPartita = "Nuova Partita"; | ||
| 1463 | stringaNuovaPartitaAiTrenta = "Nuova Partita Ai 30"; | ||
| 1464 | stringaVuoiDavveroIniziare = "Vuoi davvero iniziare una nuova partita?"; | ||
| 1465 | stringaVuoiDavveroUscire = "Vuoi davvero uscire?"; | ||
| 1466 | stringaSi = "Si"; | ||
| 1467 | stringaNo = "No"; | ||
| 1468 | stringaOpzioni = "Opzioni..."; | ||
| 1469 | stringaEsci = "Esci"; | ||
| 1470 | stringaImpossibileConfigurare = "Impossibile modificare il file di configurazione.\nSegnalare il bug a: sebastiano@luganega.org\n\nEccezione:\n"; | ||
| 1471 | stringaLingua = "Lingua"; | ||
| 1472 | stringaAnnulla = "Annulla"; | ||
| 1473 | stringaIt = "Italiano"; | ||
| 1474 | stringaLa = "Latino"; | ||
| 1475 | stringaBL = "Dialetto Bellunese"; | ||
| 1476 | stringaBV = "Dialetto Basso Veneto"; | ||
| 1477 | stringaEN = "Inglese"; | ||
| 1478 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1479 | stringaInformazioni = "Informazioni"; | ||
| 1480 | 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"; | ||
| 1481 | stringaSuono = "Effetti sonori"; | ||
| 1482 | stringaPunteggio = "Punteggio"; | ||
| 1483 | stringaSfondo = "Sfondo"; | ||
| 1484 | stringaTasti = "Tasti rapidi"; | ||
| 1485 | stringaAggiornamenti = "Cerca aggiornamenti"; | ||
| 1486 | stringaTrucchi = "Trucchi"; | ||
| 1487 | stringaInserisciCodice = "Inserisci il codice:"; | ||
| 1488 | stringaTruccoAttivato = "Trucco attivato!"; | ||
| 1489 | stringaTruccoSbagliato = "Trucco non valido"; | ||
| 1490 | stringaCheCartaVuoi = "E allora che carta vuoi?"; | ||
| 1491 | stringaAggiornamentiSi = "Aggiornamento disponibile: "; | ||
| 1492 | stringaAggiornamentiNo = "Nessun aggiornamento disponibile"; | ||
| 1493 | stringaScarica = "E' possibile scaricare la versione più recente\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 1494 | stringaNoInternet = "Errore: nessuna connessione internet"; | ||
| 1495 | 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 + "\nF7 " + stringaNuovaPartitaAiTrenta + "\nF8 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 1496 | } | ||
| 1497 | else if ( lang.equals( "la" ) ) { | ||
| 1498 | semi[0] = "BACULI"; | ||
| 1499 | semi[1] = "CALICES"; | ||
| 1500 | semi[2] = "DENARII"; | ||
| 1501 | semi[3] = "GLADII"; | ||
| 1502 | stringaBriscola = "BRISCOLA"; | ||
| 1503 | stringaBottonePrendi = "CAPIS/RELINQVIS CHARTAS"; | ||
| 1504 | stringaPrimaGioca = "ANTE CHARTAM PONE!"; | ||
| 1505 | stringaUltime4 = "CHARTA POSTREMA - INTVERE BRISCOLAM!"; | ||
| 1506 | stringaVinto = "VICISTI!"; | ||
| 1507 | stringaPerso = "PERDIDISTI"; | ||
| 1508 | stringaPareggio = "AEQVATIO!"; | ||
| 1509 | stringaGiocatore = "LVSOR: "; | ||
| 1510 | stringaComputer = "\nCOMPVTER: "; | ||
| 1511 | stringaNuovaPartita = "NOVA LVSO"; | ||
| 1512 | stringaNuovaPartitaAiTrenta = "NOVA LVSO XXX"; | ||
| 1513 | stringaVuoiDavveroIniziare = "NOVAM LVSIONEM INCIPERE?"; | ||
| 1514 | stringaVuoiDavveroUscire = "EXIRE?"; | ||
| 1515 | stringaSi = "ID VOLO"; | ||
| 1516 | stringaNo = "NOLO"; | ||
| 1517 | stringaOpzioni = "OPTIONES..."; | ||
| 1518 | stringaEsci = "EXIRE"; | ||
| 1519 | stringaImpossibileConfigurare = "CONFIGVRATIONIS FILE SCRIBERE NON POTVI.\nERROREM ME CERTIOREM FACITE: sebastiano@luganega.org\n\nEXCEPTIO:\n"; | ||
| 1520 | stringaLingua = "LINGVA"; | ||
| 1521 | stringaAnnulla = "ABROGA"; | ||
| 1522 | stringaIt = "ITALICA"; | ||
| 1523 | stringaLa = "LATINA"; | ||
| 1524 | stringaBL = "BELLUNI"; | ||
| 1525 | stringaBV = "VENETIAE"; | ||
| 1526 | stringaEN = "ANGLICVS"; | ||
| 1527 | stringaModificaOpzioni = "OPTIONES NOVARE"; | ||
| 1528 | stringaInformazioni = "INFORMATIONES"; | ||
| 1529 | 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"; | ||
| 1530 | stringaSuono = "SONVS"; | ||
| 1531 | stringaPunteggio = "NVMERI"; | ||
| 1532 | stringaSfondo = "COLOR"; | ||
| 1533 | stringaTasti = "TASTI RAPIDI"; | ||
| 1534 | stringaAggiornamenti = "VERSIONEM RECENTIOREM QVAERERE"; | ||
| 1535 | stringaTrucchi = "CODICES"; | ||
| 1536 | stringaInserisciCodice = "CODICEM INSCRIBE:"; | ||
| 1537 | stringaTruccoAttivato = "CODEX INCIPIVIT!"; | ||
| 1538 | stringaTruccoSbagliato = "ERROR CODICIS"; | ||
| 1539 | stringaCheCartaVuoi = "QUAM CHARTAM VOLIS?"; | ||
| 1540 | stringaNoInternet = "ERROR: INTERNETIS CONIVCTIO NON EST"; | ||
| 1541 | stringaAggiornamentiSi = "VERSIO RECENTIOR EST: "; | ||
| 1542 | stringaAggiornamentiNo = "VERSIO RECENTIOR NON EST"; | ||
| 1543 | stringaScarica = "VERSIONEM RECENTIOREM CEPTA ESSE POTEST:\nhttp://porkynator.altervista.org/programmi.html"; | ||
| 1544 | 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 + "\nF7 " + stringaNuovaPartitaAiTrenta + "\nF8 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 1545 | } | ||
| 1546 | if ( lang.equals( "bl" ) ) { | ||
| 1547 | semi[0] = "Bastoi"; | ||
| 1548 | semi[1] = "Coppe"; | ||
| 1549 | semi[2] = "Danari"; | ||
| 1550 | semi[3] = "Spade"; | ||
| 1551 | stringaBriscola = "Briscola"; | ||
| 1552 | stringaBottonePrendi = "Cio' su/lasa le carte"; | ||
| 1553 | stringaPrimaGioca = "Prima Duga!"; | ||
| 1554 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1555 | stringaVinto = "Te ha vint!"; | ||
| 1556 | stringaPerso = "Te ha pers"; | ||
| 1557 | stringaPareggio = "Pari"; | ||
| 1558 | stringaGiocatore = "Dugador: "; | ||
| 1559 | stringaComputer = "\nComputer: "; | ||
| 1560 | stringaNuovaPartita = "Taca n'altra partida"; | ||
| 1561 | stringaNuovaPartitaAiTrenta = "Taca na partida ai 30"; | ||
| 1562 | stringaVuoiDavveroIniziare = "Utu sul serio scuminziar n'altra partida?"; | ||
| 1563 | stringaVuoiDavveroUscire = "Utu sul serio stusar su?"; | ||
| 1564 | stringaSi = "Si"; | ||
| 1565 | stringaNo = "No"; | ||
| 1566 | stringaOpzioni = "Opzioni..."; | ||
| 1567 | stringaEsci = "Stusa su"; | ||
| 1568 | stringaImpossibileConfigurare = "No ghe ho riva' a scrivere al file de configurazion.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1569 | stringaLingua = "Lengua"; | ||
| 1570 | stringaAnnulla = "Annulla"; | ||
| 1571 | stringaIt = "Italian"; | ||
| 1572 | stringaLa = "Latin"; | ||
| 1573 | stringaBL = "Dialeto de Belun"; | ||
| 1574 | stringaBV = "Dialeto de la basa"; | ||
| 1575 | stringaEN = "Inglese"; | ||
| 1576 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1577 | stringaInformazioni = "Informazioni"; | ||
| 1578 | 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"; | ||
| 1579 | stringaSuono = "Efeti sonori"; | ||
| 1580 | stringaPunteggio = "Varda i punti"; | ||
| 1581 | stringaSfondo = "Sfondo"; | ||
| 1582 | stringaTasti = "Tasti rapidi"; | ||
| 1583 | stringaAggiornamenti = "Varda se ghe ne' na version pi nova"; | ||
| 1584 | stringaTrucchi = "Truchi"; | ||
| 1585 | stringaInserisciCodice = "Scrivi al codice:"; | ||
| 1586 | stringaTruccoAttivato = "Truco ativa'!"; | ||
| 1587 | stringaTruccoSbagliato = "Truco sbaia'"; | ||
| 1588 | stringaCheCartaVuoi = "Che carta utu alora?"; | ||
| 1589 | stringaAggiornamentiSi = "Ghe ne' na version pi nova: "; | ||
| 1590 | stringaAggiornamentiNo = "No ghe ne na version pi nova"; | ||
| 1591 | stringaScarica = "Te pol scaricar le version pi nova\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 1592 | stringaNoInternet = "Erore: no te se su internet"; | ||
| 1593 | 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 + "\nF7 " + stringaNuovaPartitaAiTrenta + "\nF8 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 1594 | } | ||
| 1595 | if ( lang.equals( "bv" ) ) { | ||
| 1596 | semi[0] = "Bastoni"; | ||
| 1597 | semi[1] = "Coppe"; | ||
| 1598 | semi[2] = "Danari"; | ||
| 1599 | semi[3] = "Spade"; | ||
| 1600 | stringaBriscola = "Briscola"; | ||
| 1601 | stringaBottonePrendi = "Ciapa su/lasa e carte"; | ||
| 1602 | stringaPrimaGioca = "Prima Zuga!"; | ||
| 1603 | stringaUltime4 = "Ultima carta - Ocio a la briscola!"; | ||
| 1604 | stringaVinto = "Ti ga vinto!"; | ||
| 1605 | stringaPerso = "Ti ga perso"; | ||
| 1606 | stringaPareggio = "Pari"; | ||
| 1607 | stringaGiocatore = "Zugador: "; | ||
| 1608 | stringaComputer = "\nComputer: "; | ||
| 1609 | stringaNuovaPartita = "N'altra Partida"; | ||
| 1610 | stringaNuovaPartitaAiTrenta = "Na Partida ai 30"; | ||
| 1611 | stringaVuoiDavveroIniziare = "Ti vol sul serio scuminziar n'altra partida?"; | ||
| 1612 | stringaVuoiDavveroUscire = "Ti vol sul serio stusar su?"; | ||
| 1613 | stringaSi = "Si"; | ||
| 1614 | stringaNo = "No"; | ||
| 1615 | stringaOpzioni = "Opzioni..."; | ||
| 1616 | stringaEsci = "Stusa su"; | ||
| 1617 | stringaImpossibileConfigurare = "No ghe son riusito a scrivere al file de configurazione.\nMandeme na mail a: sebastiano@luganega.org\n\nEcezion:\n"; | ||
| 1618 | stringaLingua = "Lengua"; | ||
| 1619 | stringaAnnulla = "Annulla"; | ||
| 1620 | stringaIt = "Italian"; | ||
| 1621 | stringaLa = "Latin"; | ||
| 1622 | stringaBL = "Dialeto Belumat"; | ||
| 1623 | stringaBV = "Dialeto Veneto"; | ||
| 1624 | stringaEN = "Inglese"; | ||
| 1625 | stringaModificaOpzioni = "Modifica Opzioni"; | ||
| 1626 | stringaInformazioni = "Informasioni"; | ||
| 1627 | 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"; | ||
| 1628 | stringaSuono = "Efeti sonori"; | ||
| 1629 | stringaPunteggio = "Varda i punti"; | ||
| 1630 | stringaSfondo = "Sfondo"; | ||
| 1631 | stringaTasti = "Tasti rapidi"; | ||
| 1632 | stringaAggiornamenti = "Varda se ghe xe na versione pi nova"; | ||
| 1633 | stringaTrucchi = "Truchi"; | ||
| 1634 | stringaInserisciCodice = "Scrivi al codice:"; | ||
| 1635 | stringaTruccoAttivato = "Truco ativa'!"; | ||
| 1636 | stringaTruccoSbagliato = "Truco sbaia'"; | ||
| 1637 | stringaCheCartaVuoi = "Che carta utu alora?"; | ||
| 1638 | stringaAggiornamentiSi = "Ghe xe na versione pi nova: "; | ||
| 1639 | stringaAggiornamentiNo = "No ghe xe na versione pi nova"; | ||
| 1640 | stringaScarica = "Te pol scaricar le versione pi nova\ndal sito http://porkynator.altervista.org/programmi.html"; | ||
| 1641 | stringaNoInternet = "Erore: no ti xe su internet"; | ||
| 1642 | 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 + "\nF7 " + stringaNuovaPartitaAiTrenta + "\nF8 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 1643 | } | ||
| 1644 | if ( lang.equals( "en" ) ) { | ||
| 1645 | semi[0] = "Sticks"; | ||
| 1646 | semi[1] = "Cups"; | ||
| 1647 | semi[2] = "Golds"; | ||
| 1648 | semi[3] = "Swords"; | ||
| 1649 | stringaBriscola = "Briscola"; | ||
| 1650 | stringaBottonePrendi = "Take/leave cards"; | ||
| 1651 | stringaPrimaGioca = "Play your card before!"; | ||
| 1652 | stringaUltime4 = "Last card - keep your eye on the briscola!"; | ||
| 1653 | stringaVinto = "You won!"; | ||
| 1654 | stringaPerso = "You lost"; | ||
| 1655 | stringaPareggio = "Sixty - sixty!"; | ||
| 1656 | stringaGiocatore = "Palyer: "; | ||
| 1657 | stringaComputer = "\nComputer: "; | ||
| 1658 | stringaNuovaPartita = "New Game"; | ||
| 1659 | stringaNuovaPartitaAiTrenta = "New Game - 30 Points"; | ||
| 1660 | stringaVuoiDavveroIniziare = "Do you really want to start a new game?"; | ||
| 1661 | stringaVuoiDavveroUscire = "Do you really want to exit?"; | ||
| 1662 | stringaSi = "Yes"; | ||
| 1663 | stringaNo = "No"; | ||
| 1664 | stringaOpzioni = "Options..."; | ||
| 1665 | stringaEsci = "Exit"; | ||
| 1666 | stringaImpossibileConfigurare = "Couldn't write to the configuration file.\nPlease report the bug to: sebastiano@luganega.org\n\nException:\n"; | ||
| 1667 | stringaLingua = "Lang"; | ||
| 1668 | stringaAnnulla = "Cancel"; | ||
| 1669 | stringaIt = "Italian"; | ||
| 1670 | stringaLa = "Latin"; | ||
| 1671 | stringaBL = "Belluno dialect"; | ||
| 1672 | stringaBV = "Venice dialect"; | ||
| 1673 | stringaEN = "English"; | ||
| 1674 | stringaModificaOpzioni = "Change options"; | ||
| 1675 | stringaInformazioni = "Information"; | ||
| 1676 | stringaInformazioni2 = "JBriscola is a briscola pc game written in java, meant\nand made by Sebastiano Tronto. The game is protected by the GNU/General public licence version 2 or later.\n\nJBriscola version" + version + "\nCopyright 2009 Sebastiano Tronto, license GNU/Gpl 2.0 or later\nE-mail: sebastiano@luganega.org"; | ||
| 1677 | stringaSuono = "Sound"; | ||
| 1678 | stringaPunteggio = "Score"; | ||
| 1679 | stringaSfondo = "Background"; | ||
| 1680 | stringaTasti = "Hot keys"; | ||
| 1681 | stringaAggiornamenti = "Check updates"; | ||
| 1682 | stringaTrucchi = "Cheats"; | ||
| 1683 | stringaInserisciCodice = "Insert cheat:"; | ||
| 1684 | stringaTruccoAttivato = "Cheat actived!"; | ||
| 1685 | stringaTruccoSbagliato = "Wrong cheat"; | ||
| 1686 | stringaCheCartaVuoi = "So what card do you want?"; | ||
| 1687 | stringaAggiornamentiSi = "Update available: "; | ||
| 1688 | stringaAggiornamentiNo = "No updates available"; | ||
| 1689 | stringaScarica = "You can get the latest version from the site\nhttp://porkynator.altervista.org/programmi.html"; | ||
| 1690 | stringaNoInternet = "Error: no internet connection"; | ||
| 1691 | stringaTasti2 = "1 Play the first card\n2 Play the second card\n3 Play the third card\nF1 Get this message\nF2 " + stringaNuovaPartita + "\nF3 " + stringaOpzioni + "\nF4 " + stringaPunteggio + "\nF5 " + stringaInformazioni + "\nF6 " + stringaAggiornamenti + "\nF7 " + stringaNuovaPartitaAiTrenta + "\nF8 " + stringaTrucchi + "\nq " + stringaEsci; | ||
| 1692 | } | ||
| 1693 | sound = ( soundString.equals( "suono=si" ) ); | ||
| 1694 | keys = ( keysString.equals( "tasti=si" ) ); | ||
| 1695 | color = new Color( r, g, b ); | ||
| 1696 | if ( frame != null ) { | ||
| 1697 | frame.pannello.repaint(); | ||
| 1698 | frame.pannello2.repaint(); | ||
| 1699 | frame.repaint(); | ||
| 1700 | } | ||
| 1701 | } | ||
| 1702 | } | ||
diff --git a/JBriscola/all_versions/0.3/0.3/src/OptionFrame.java b/JBriscola/all_versions/0.3/0.3/src/OptionFrame.java new file mode 100755 index 0000000..d89745b --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/OptionFrame.java | |||
| @@ -0,0 +1,169 @@ | |||
| 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.util.Formatter; | ||
| 23 | import javax.swing.*; | ||
| 24 | import java.awt.*; | ||
| 25 | import java.awt.event.*; | ||
| 26 | |||
| 27 | public class OptionFrame extends JFrame { | ||
| 28 | |||
| 29 | public static Main main = new Main(); | ||
| 30 | public static Formatter formatter; | ||
| 31 | public static JButton ok, annulla, scegliColore; | ||
| 32 | public static JLabel lingua, sfondo; | ||
| 33 | public static JComboBox selezionaLingua; | ||
| 34 | public static JCheckBox suono, tastiRapidi; | ||
| 35 | public static JPanel[] pannello = new JPanel[6]; | ||
| 36 | |||
| 37 | public OptionFrame() { | ||
| 38 | |||
| 39 | super( "JBriscola - " + main.stringaModificaOpzioni ); | ||
| 40 | |||
| 41 | ok = new JButton( "OK" ); | ||
| 42 | ok.addActionListener( new ActionListener() { | ||
| 43 | |||
| 44 | /* Quando le modifiche vengono confermate premendo ok, viene scritto | ||
| 45 | * il file di configurazione (o aggiornato) se possibile, e modificate | ||
| 46 | * le impostazioni attuali. */ | ||
| 47 | public void actionPerformed( ActionEvent e ) { | ||
| 48 | |||
| 49 | try { | ||
| 50 | formatter = new Formatter( "JBriscolaConfig.txt" ); | ||
| 51 | } catch ( Exception ex ) { | ||
| 52 | JOptionPane.showMessageDialog( OptionFrame.this, main.stringaImpossibileConfigurare + ex, "JBriscola - " + main.version, JOptionPane.ERROR_MESSAGE ); | ||
| 53 | } | ||
| 54 | |||
| 55 | String lang; | ||
| 56 | |||
| 57 | switch ( selezionaLingua.getSelectedIndex() ) { | ||
| 58 | case 0: | ||
| 59 | lang = "it"; | ||
| 60 | break; | ||
| 61 | case 1: | ||
| 62 | lang = "la"; | ||
| 63 | break; | ||
| 64 | case 2: | ||
| 65 | lang = "bl"; | ||
| 66 | break; | ||
| 67 | case 3: | ||
| 68 | lang = "bv"; | ||
| 69 | break; | ||
| 70 | case 4: | ||
| 71 | lang = "en"; | ||
| 72 | break; | ||
| 73 | default: | ||
| 74 | lang = "it"; | ||
| 75 | break; | ||
| 76 | } | ||
| 77 | |||
| 78 | String suonosiono, tastisiono; | ||
| 79 | |||
| 80 | if ( suono.isSelected() ) | ||
| 81 | suonosiono = "suono=si"; | ||
| 82 | else | ||
| 83 | suonosiono = "suono=no"; | ||
| 84 | if ( tastiRapidi.isSelected() ) | ||
| 85 | tastisiono = "tasti=si"; | ||
| 86 | else | ||
| 87 | tastisiono = "tasti=no"; | ||
| 88 | |||
| 89 | formatter.format( lang ); | ||
| 90 | formatter.format( "\n" ); | ||
| 91 | formatter.format( suonosiono ); | ||
| 92 | formatter.format( "\n" ); | ||
| 93 | formatter.format( tastisiono ); | ||
| 94 | formatter.format( "\n" ); | ||
| 95 | formatter.format( main.color.getRed() + " " + main.color.getGreen() + " " + main.color.getBlue() ); | ||
| 96 | formatter.close(); | ||
| 97 | |||
| 98 | main.settaOpzioni(); | ||
| 99 | |||
| 100 | OptionFrame.this.dispose(); | ||
| 101 | } | ||
| 102 | }); | ||
| 103 | |||
| 104 | annulla = new JButton( main.stringaAnnulla ); | ||
| 105 | annulla.addActionListener( new ActionListener() { | ||
| 106 | /* Se l'utente annulla viene chiusa la finestra senza fare nulla. */ | ||
| 107 | public void actionPerformed( ActionEvent e ) { | ||
| 108 | OptionFrame.this.dispose(); | ||
| 109 | } | ||
| 110 | }); | ||
| 111 | |||
| 112 | scegliColore = new JButton( " " ); | ||
| 113 | scegliColore.setBackground( main.color ); | ||
| 114 | scegliColore.addActionListener( new ActionListener() { | ||
| 115 | /* Permette di scegliere il colore dello sfondo. */ | ||
| 116 | public void actionPerformed( ActionEvent e ) { | ||
| 117 | Color colore = JColorChooser.showDialog( OptionFrame.this, "JBriscola " + main.version, main.color ); | ||
| 118 | if ( colore != null ) | ||
| 119 | main.color = colore; | ||
| 120 | OptionFrame.scegliColore.setBackground( main.color ); | ||
| 121 | } | ||
| 122 | } ); | ||
| 123 | |||
| 124 | /* Vengono impostati e disegnati i vari componenti. */ | ||
| 125 | lingua = new JLabel( main.stringaLingua ); | ||
| 126 | sfondo = new JLabel( main.stringaSfondo ); | ||
| 127 | String[] lingueDaSelezionare = { main.stringaIt, main.stringaLa, main.stringaBL, main.stringaBV, main.stringaEN }; | ||
| 128 | selezionaLingua = new JComboBox( lingueDaSelezionare ); | ||
| 129 | int linguaPreselezionata = 0; | ||
| 130 | |||
| 131 | if ( main.lang.equals( "it" ) ) | ||
| 132 | linguaPreselezionata = 0; | ||
| 133 | else if ( main.lang.equals( "la" ) ) | ||
| 134 | linguaPreselezionata = 1; | ||
| 135 | else if ( main.lang.equals( "bl" ) ) | ||
| 136 | linguaPreselezionata = 2; | ||
| 137 | else if ( main.lang.equals( "bv" ) ) | ||
| 138 | linguaPreselezionata = 3; | ||
| 139 | else if ( main.lang.equals( "en" ) ) | ||
| 140 | linguaPreselezionata = 4; | ||
| 141 | |||
| 142 | selezionaLingua.setSelectedIndex( linguaPreselezionata ); | ||
| 143 | suono = new JCheckBox( main.stringaSuono ); | ||
| 144 | suono.setSelected( main.sound ); | ||
| 145 | tastiRapidi = new JCheckBox( main.stringaTasti ); | ||
| 146 | tastiRapidi.setSelected( main.keys ); | ||
| 147 | |||
| 148 | pannello[0] = new JPanel( new GridLayout( 4, 1 ) ); | ||
| 149 | pannello[1] = new JPanel( new FlowLayout() ); | ||
| 150 | pannello[2] = new JPanel( new FlowLayout() ); | ||
| 151 | pannello[3] = new JPanel( new FlowLayout() ); | ||
| 152 | pannello[4] = new JPanel( new FlowLayout() ); | ||
| 153 | pannello[5] = new JPanel( new FlowLayout() ); | ||
| 154 | pannello[5].add( ok ); | ||
| 155 | pannello[5].add( annulla ); | ||
| 156 | pannello[4].add( sfondo ); | ||
| 157 | pannello[4].add( scegliColore ); | ||
| 158 | pannello[3].add( tastiRapidi ); | ||
| 159 | pannello[2].add( suono ); | ||
| 160 | pannello[1].add( lingua ); | ||
| 161 | pannello[1].add( selezionaLingua ); | ||
| 162 | pannello[0].add( pannello[1] ); | ||
| 163 | pannello[0].add( pannello[2] ); | ||
| 164 | pannello[0].add( pannello[3] ); | ||
| 165 | pannello[0].add( pannello[4] ); | ||
| 166 | add( pannello[0], BorderLayout.CENTER ); | ||
| 167 | add( pannello[5], BorderLayout.SOUTH ); | ||
| 168 | } | ||
| 169 | } | ||
diff --git a/JBriscola/all_versions/0.3/0.3/src/Pannello.java b/JBriscola/all_versions/0.3/0.3/src/Pannello.java new file mode 100755 index 0000000..ca9e9c6 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/Pannello.java | |||
| @@ -0,0 +1,88 @@ | |||
| 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 javax.swing.*; | ||
| 23 | import java.awt.*; | ||
| 24 | |||
| 25 | /* Questa classe dispone semplicemente le carte | ||
| 26 | * sulla finestra e imposta la sfondo. */ | ||
| 27 | public class Pannello extends JPanel { | ||
| 28 | |||
| 29 | public static Main main; | ||
| 30 | |||
| 31 | public static Color color; | ||
| 32 | |||
| 33 | public Pannello() { } | ||
| 34 | |||
| 35 | public void paint( Graphics g ) { | ||
| 36 | |||
| 37 | super.paint( g ); | ||
| 38 | |||
| 39 | setBackground( main.color ); | ||
| 40 | |||
| 41 | if ( main.frame.ultimaCarta != null ) | ||
| 42 | main.frame.ultimaCarta.paintIcon( this, g, 50, 180 ); | ||
| 43 | |||
| 44 | if ( main.frame.mazzo ) | ||
| 45 | main.frame.retro2.paintIcon( this, g, 17, 256 ); | ||
| 46 | |||
| 47 | if ( main.carteScoperte ) { | ||
| 48 | |||
| 49 | if ( main.frame.carteCPU[0] != null ) | ||
| 50 | main.frame.carteCPU[0].paintIcon( this, g, 230, 5 ); | ||
| 51 | |||
| 52 | if ( main.frame.carteCPU[1] != null ) | ||
| 53 | main.frame.carteCPU[1].paintIcon( this, g, 300, 5 ); | ||
| 54 | |||
| 55 | if ( main.frame.carteCPU[2] != null ) | ||
| 56 | main.frame.carteCPU[2].paintIcon( this, g, 370, 5 ); | ||
| 57 | |||
| 58 | } else { | ||
| 59 | |||
| 60 | if ( main.frame.carteCPU[0] != null ) | ||
| 61 | main.frame.retro1.paintIcon( this, g, 230, 5 ); | ||
| 62 | |||
| 63 | if ( main.frame.carteCPU[1] != null ) | ||
| 64 | main.frame.retro1.paintIcon( this, g, 300, 5 ); | ||
| 65 | |||
| 66 | if ( main.frame.carteCPU[2] != null ) | ||
| 67 | main.frame.retro1.paintIcon( this, g, 370, 5 ); | ||
| 68 | |||
| 69 | } | ||
| 70 | |||
| 71 | if ( main.frame.carteInMano[0] != null ) | ||
| 72 | main.frame.carteInMano[0].paintIcon( this, g, 230, 340 ); | ||
| 73 | |||
| 74 | if ( main.frame.carteInMano[1] != null ) | ||
| 75 | main.frame.carteInMano[1].paintIcon( this, g, 300, 340 ); | ||
| 76 | |||
| 77 | if ( main.frame.carteInMano[2] != null ) | ||
| 78 | main.frame.carteInMano[2].paintIcon( this, g, 370, 340 ); | ||
| 79 | |||
| 80 | if ( main.frame.giocata[0] != null ) | ||
| 81 | main.frame.giocata[0].paintIcon( this, g, 250, 200 ); | ||
| 82 | |||
| 83 | if ( main.frame.giocata[1] != null ) | ||
| 84 | main.frame.giocata[1].paintIcon( this, g, 325, 150 ); | ||
| 85 | |||
| 86 | } | ||
| 87 | } | ||
| 88 | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/1-1.jpg b/JBriscola/all_versions/0.3/0.3/src/img/1-1.jpg new file mode 100755 index 0000000..ae43510 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/1-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/1-2.jpg b/JBriscola/all_versions/0.3/0.3/src/img/1-2.jpg new file mode 100755 index 0000000..3f7c75a --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/1-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/1-3.jpg b/JBriscola/all_versions/0.3/0.3/src/img/1-3.jpg new file mode 100755 index 0000000..9e1ead7 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/1-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/1-4.jpg b/JBriscola/all_versions/0.3/0.3/src/img/1-4.jpg new file mode 100755 index 0000000..710f879 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/1-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/10-1.jpg b/JBriscola/all_versions/0.3/0.3/src/img/10-1.jpg new file mode 100755 index 0000000..9aba45a --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/10-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/10-2.jpg b/JBriscola/all_versions/0.3/0.3/src/img/10-2.jpg new file mode 100755 index 0000000..037eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/10-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/10-3.jpg b/JBriscola/all_versions/0.3/0.3/src/img/10-3.jpg new file mode 100755 index 0000000..8780b72 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/10-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/10-4.jpg b/JBriscola/all_versions/0.3/0.3/src/img/10-4.jpg new file mode 100755 index 0000000..587dc0f --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/10-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/2-1.jpg b/JBriscola/all_versions/0.3/0.3/src/img/2-1.jpg new file mode 100755 index 0000000..5dcb7db --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/2-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/2-2.jpg b/JBriscola/all_versions/0.3/0.3/src/img/2-2.jpg new file mode 100755 index 0000000..ea9eeb7 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/2-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/2-3.jpg b/JBriscola/all_versions/0.3/0.3/src/img/2-3.jpg new file mode 100755 index 0000000..8cb22dd --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/2-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/2-4.jpg b/JBriscola/all_versions/0.3/0.3/src/img/2-4.jpg new file mode 100755 index 0000000..b3e7898 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/2-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/3-1.jpg b/JBriscola/all_versions/0.3/0.3/src/img/3-1.jpg new file mode 100755 index 0000000..dcb435c --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/3-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/3-2.jpg b/JBriscola/all_versions/0.3/0.3/src/img/3-2.jpg new file mode 100755 index 0000000..1e5b6ec --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/3-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/3-3.jpg b/JBriscola/all_versions/0.3/0.3/src/img/3-3.jpg new file mode 100755 index 0000000..9202cfe --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/3-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/3-4.jpg b/JBriscola/all_versions/0.3/0.3/src/img/3-4.jpg new file mode 100755 index 0000000..5436a8d --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/3-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/4-1.jpg b/JBriscola/all_versions/0.3/0.3/src/img/4-1.jpg new file mode 100755 index 0000000..3bab6d5 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/4-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/4-2.jpg b/JBriscola/all_versions/0.3/0.3/src/img/4-2.jpg new file mode 100755 index 0000000..b4901a6 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/4-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/4-3.jpg b/JBriscola/all_versions/0.3/0.3/src/img/4-3.jpg new file mode 100755 index 0000000..d754ad8 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/4-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/4-4.jpg b/JBriscola/all_versions/0.3/0.3/src/img/4-4.jpg new file mode 100755 index 0000000..3a54b96 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/4-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/5-1.jpg b/JBriscola/all_versions/0.3/0.3/src/img/5-1.jpg new file mode 100755 index 0000000..3f7ba1f --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/5-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/5-2.jpg b/JBriscola/all_versions/0.3/0.3/src/img/5-2.jpg new file mode 100755 index 0000000..fcacb75 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/5-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/5-3.jpg b/JBriscola/all_versions/0.3/0.3/src/img/5-3.jpg new file mode 100755 index 0000000..ce32f9f --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/5-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/5-4.jpg b/JBriscola/all_versions/0.3/0.3/src/img/5-4.jpg new file mode 100755 index 0000000..b86b09a --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/5-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/6-1.jpg b/JBriscola/all_versions/0.3/0.3/src/img/6-1.jpg new file mode 100755 index 0000000..f90cd81 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/6-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/6-2.jpg b/JBriscola/all_versions/0.3/0.3/src/img/6-2.jpg new file mode 100755 index 0000000..cf2a67a --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/6-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/6-3.jpg b/JBriscola/all_versions/0.3/0.3/src/img/6-3.jpg new file mode 100755 index 0000000..2cd2fe2 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/6-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/6-4.jpg b/JBriscola/all_versions/0.3/0.3/src/img/6-4.jpg new file mode 100755 index 0000000..73f410f --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/6-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/7-1.jpg b/JBriscola/all_versions/0.3/0.3/src/img/7-1.jpg new file mode 100755 index 0000000..08cd397 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/7-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/7-2.jpg b/JBriscola/all_versions/0.3/0.3/src/img/7-2.jpg new file mode 100755 index 0000000..a168ff8 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/7-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/7-3.jpg b/JBriscola/all_versions/0.3/0.3/src/img/7-3.jpg new file mode 100755 index 0000000..5cda411 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/7-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/7-4.jpg b/JBriscola/all_versions/0.3/0.3/src/img/7-4.jpg new file mode 100755 index 0000000..5d63229 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/7-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/8-1.jpg b/JBriscola/all_versions/0.3/0.3/src/img/8-1.jpg new file mode 100755 index 0000000..a6faa7b --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/8-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/8-2.jpg b/JBriscola/all_versions/0.3/0.3/src/img/8-2.jpg new file mode 100755 index 0000000..0d9edbb --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/8-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/8-3.jpg b/JBriscola/all_versions/0.3/0.3/src/img/8-3.jpg new file mode 100755 index 0000000..91f8354 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/8-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/8-4.jpg b/JBriscola/all_versions/0.3/0.3/src/img/8-4.jpg new file mode 100755 index 0000000..cc0089c --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/8-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/9-1.jpg b/JBriscola/all_versions/0.3/0.3/src/img/9-1.jpg new file mode 100755 index 0000000..be9c6bf --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/9-1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/9-2.jpg b/JBriscola/all_versions/0.3/0.3/src/img/9-2.jpg new file mode 100755 index 0000000..e25da4c --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/9-2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/9-3.jpg b/JBriscola/all_versions/0.3/0.3/src/img/9-3.jpg new file mode 100755 index 0000000..cd384f8 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/9-3.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/9-4.jpg b/JBriscola/all_versions/0.3/0.3/src/img/9-4.jpg new file mode 100755 index 0000000..441210e --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/9-4.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/Thumbs.db b/JBriscola/all_versions/0.3/0.3/src/img/Thumbs.db new file mode 100755 index 0000000..d9b6bc5 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/Thumbs.db | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/carte.jpg b/JBriscola/all_versions/0.3/0.3/src/img/carte.jpg new file mode 100755 index 0000000..838ffac --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/carte.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/retro1.jpg b/JBriscola/all_versions/0.3/0.3/src/img/retro1.jpg new file mode 100755 index 0000000..9651b06 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/retro1.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/img/retro2.jpg b/JBriscola/all_versions/0.3/0.3/src/img/retro2.jpg new file mode 100755 index 0000000..c5d3925 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/img/retro2.jpg | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/sounds/0.wav b/JBriscola/all_versions/0.3/0.3/src/sounds/0.wav new file mode 100755 index 0000000..67d9abd --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/sounds/0.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/sounds/1.wav b/JBriscola/all_versions/0.3/0.3/src/sounds/1.wav new file mode 100755 index 0000000..9357c97 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/sounds/1.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/sounds/2.wav b/JBriscola/all_versions/0.3/0.3/src/sounds/2.wav new file mode 100755 index 0000000..92b1541 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/sounds/2.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/sounds/3.wav b/JBriscola/all_versions/0.3/0.3/src/sounds/3.wav new file mode 100755 index 0000000..45a6e42 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/sounds/3.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/sounds/4.wav b/JBriscola/all_versions/0.3/0.3/src/sounds/4.wav new file mode 100755 index 0000000..1f7ec90 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/sounds/4.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/sounds/5.wav b/JBriscola/all_versions/0.3/0.3/src/sounds/5.wav new file mode 100755 index 0000000..3627f96 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/sounds/5.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/sounds/pareggio.wav b/JBriscola/all_versions/0.3/0.3/src/sounds/pareggio.wav new file mode 100755 index 0000000..ff978e6 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/sounds/pareggio.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/sounds/perso.wav b/JBriscola/all_versions/0.3/0.3/src/sounds/perso.wav new file mode 100755 index 0000000..a454ba4 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/sounds/perso.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/all_versions/0.3/0.3/src/sounds/vinto.wav b/JBriscola/all_versions/0.3/0.3/src/sounds/vinto.wav new file mode 100755 index 0000000..a6f3ac5 --- /dev/null +++ b/JBriscola/all_versions/0.3/0.3/src/sounds/vinto.wav | |||
| Binary files differ | |||
diff --git a/JBriscola/trucchi.txt b/JBriscola/trucchi.txt new file mode 100644 index 0000000..c2974e0 --- /dev/null +++ b/JBriscola/trucchi.txt | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | Tutti i trucchi vanno inseriti (dal menu file->trucchi) senza virgolette e con gli spazi. Il programma non distingue tra lettere maiuscole e minuscole. | ||
| 2 | |||
| 3 | "Kill Devil Hill" - La CPU gioca a carte scoperte | ||
| 4 | |||
| 5 | "Darkside of Aquarius" - Scambia le proprie carte con quelle della CPU | ||
| 6 | |||
| 7 | "Change of Heart" - Cambia il seme di briscola con uno a caso, senza dire quale. L'ultima carta non cambia. È possibile comunque capire qual'è la briscola dal menu ?->Briscola | ||
| 8 | |||
| 9 | "Tears of The Dragon" - Asso Tre e Re di Briscola tutti in mano (anche in caso di doppioni). | ||
| 10 | |||
| 11 | "Navigate The Seas of The Sun" - Tre assi di briscola in mano | ||
| 12 | |||
| 13 | "Omega" - Fa finire la partita al prossimo piglio | ||
| 14 | |||
| 15 | P.S.: Sì, sono tutti titoli di canzoni di Bruce Dickinson. | ||
| 16 | P.P.S.: Se c'è qualche trucco che vi picerebbe avere, chiedete pure, e vedrò di implementarlo nella prossima versione :) | ||
| 17 | |||
| 18 | per contattarmi: <i>sebastiano@luganega.org</i> \ No newline at end of file | ||
