diff --git a/src/game/Game.java b/src/game/Game.java index 085a91c..a829291 100644 --- a/src/game/Game.java +++ b/src/game/Game.java @@ -1,5 +1,8 @@ package game; import player.AbstractPlayer; +import player.SwingPlayer; +import static game.Card.intColorToText; + import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; @@ -14,7 +17,6 @@ import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; -import javax.swing.SwingConstants; public class Game { @@ -33,7 +35,7 @@ final static int WHITE = 3; final static int BLUE = 4; final static int COLORS = 5; - final static int NR_PLAYERS = 2; + int NR_PLAYERS = 3; static int CARDS_PER_PLAYER; final static int NR_OF_CARDS = 50; static int CARDS_IN_DECK; @@ -41,23 +43,23 @@ final static int MAX_THUNDERS = 3; int hints; int thunders; - static ArrayList cards; - static Card[][] deck; - static int[] deckCounter; - static ArrayList trash; - static AbstractPlayer[] players; - static int currentPlayer; + ArrayList cards; + Card[][] deck; + int[] deckCounter; + ArrayList trash; + AbstractPlayer[] players; + int currentPlayer; - static int selectedPlayer; - static int selectedCards; - static int chosenColor; - static int chosenValue; - static boolean useColor; - static boolean useValue; - static boolean placeCard; - static boolean trashCard; - static boolean won; - static boolean lost; + int selectedPlayer; + int selectedCards; + int chosenColor; + int chosenValue; + boolean useColor; + boolean useValue; + boolean placeCard; + boolean trashCard; + boolean won; + boolean lost; //UI STUFF JFrame mainFrame; @@ -74,12 +76,13 @@ JButton trashCardButton; JLabel[] hintUI; JLabel[] thunderUI; - static JPanel[] playersUI; + JPanel[] playersUI; public static void main(String[] args) { - /*Game game = */new Game(); - System.out.println("Player " + currentPlayer + "'s turn"); + Game game = new Game(); + game.getPlayer(game.currentPlayer).deactiveCards(); + System.out.println("Player " + game.currentPlayer + "'s turn"); } public Game(){ @@ -99,7 +102,7 @@ dealCards(); } - private void resetMoveValues(){ + public void resetMoveValues(){ selectedPlayer = -1; chosenColor = -1; chosenValue = -1; @@ -109,19 +112,19 @@ private void createPlayers(){ players = new AbstractPlayer[NR_PLAYERS]; - playersUI = new JPanel[NR_PLAYERS]; + //playersUI = new JPanel[NR_PLAYERS]; for(int i=0; i(); + cards = new ArrayList<>(); deck = new Card[COLORS][5]; deckCounter = new int[5]; - trash = new ArrayList(); + trash = new ArrayList<>(); int[] dist = new int[]{3, 2, 2, 2, 1}; int[][] tmp_cards = new int[][]{ dist.clone(), @@ -284,23 +287,24 @@ for(int i=0; i 0); } - private String intColorToText(int id){ - String color = ""; - switch(id){ - case 0: - color = "green"; - break; - case 1: - color = "red"; - break; - case 2: - color = "yellow"; - break; - case 3: - color = "white"; - break; - case 4: - color = "blue"; - break; - } - return color; - } - private void setWonOrLost(){ won = true; lost = false; @@ -635,12 +526,72 @@ return (int) (Math.random() * max); } - private void printArray(int[][] arr){ + public void setSelectedPlayer(int selectedPlayer){ + this.selectedPlayer = selectedPlayer; + } + + public int getSelectedPlayer(){ + return selectedPlayer; + } + + public AbstractPlayer getPlayer(int index){ + return players[index]; + } + + public int getCurrentPlayerIndex(){ + return currentPlayer; + } + + public boolean isTrashCard(){ + return trashCard; + } + + public boolean isPlaceCard(){ + return placeCard; + } + + public boolean isUseColor(){ + return useColor; + } + + public boolean isUseValue(){ + return useValue; + } + + public int getChosenColor(){ + return chosenColor; + } + + public void setChosenColor(int chosenColor){ + this.chosenColor = chosenColor; + } + + public int getChosenValue(){ + return chosenValue; + } + + public void setChosenValue(int chosenValue){ + this.chosenValue = chosenValue; + } + + public int getSelectedCards(){ + return selectedCards; + } + + public void addSelectedCards(){ + selectedCards++; + } + + public void removeSelectedCards(){ + selectedCards--; + } + + /*private void printArray(int[][] arr){ for(int j=0; j