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/all_versions/0.1/0.1 Beta 1 | |
| download | ancient-projects-master.tar.gz ancient-projects-master.zip | |
Diffstat (limited to 'JBriscola/all_versions/0.1/0.1 Beta 1')
| -rwxr-xr-x | JBriscola/all_versions/0.1/0.1 Beta 1/src/Frame.java | 159 | ||||
| -rwxr-xr-x | JBriscola/all_versions/0.1/0.1 Beta 1/src/Main.java | 399 | ||||
| -rwxr-xr-x | JBriscola/all_versions/0.1/0.1 Beta 1/src/Pannello.java | 53 |
3 files changed, 611 insertions, 0 deletions
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 | |||
