package jrummikub; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import javax.swing.UIManager; import jrummikub.control.TurnTimer; import jrummikub.model.Position; import jrummikub.model.Stone; import jrummikub.model.StoneColor; import jrummikub.model.StoneSet; import jrummikub.util.IListener; import jrummikub.util.IListener1; import jrummikub.util.IListener2; import jrummikub.view.IView; public class JRummikub { /** * @param args */ public static void main(String[] args) { String nativeLF = UIManager.getSystemLookAndFeelClassName(); try { UIManager.setLookAndFeel(nativeLF); } catch (Exception e) { } final IView view = new jrummikub.view.impl.View(); view.setCurrentPlayerName("Player 1"); TurnTimer testTimer = new TurnTimer(view); testTimer.startTimer(); view.getTablePanel().setLeftPlayerName("Player 2"); view.getTablePanel().setTopPlayerName("Player 3"); view.getTablePanel().setRightPlayerName("Player 4"); view.getPlayerPanel().getSortByGroupsEvent().add(new IListener() { @Override public void handle() { System.out.println("'Sort by groups' fired"); } }); view.getPlayerPanel().getSortByRunsEvent().add(new IListener() { @Override public void handle() { System.out.println("'Sort by runs' fired"); } }); view.getPlayerPanel().getEndTurnEvent().add(new IListener() { @Override public void handle() { System.out.println("'End turn' fired"); view.enableStartTurnPanel(true); } }); view.getStartTurnEvent().add(new IListener() { @Override public void handle() { System.out.println("'Start turn' fired"); view.enableStartTurnPanel(false); } }); // stones on the board Map stones = new HashMap(); stones.put(new Stone(1, StoneColor.ORANGE), new Position(0, 0)); stones.put(new Stone(10, StoneColor.BLUE), new Position(1, 0)); stones.put(new Stone(9, StoneColor.RED), new Position(0.5f, 1)); stones.put(new Stone(7, StoneColor.BLACK), new Position(1.75f, 1)); Stone stoneJoker = new Stone(StoneColor.RED); stones.put(stoneJoker, new Position(2.5f, 0)); stones.put(new Stone(StoneColor.BLACK), new Position(3.5f, 0)); view.getPlayerPanel().getHandPanel().setStones(stones); view.getPlayerPanel().getHandPanel().getClickEvent() .add(new IListener1() { @Override public void handle(Position p) { System.out.println("Hand clicked at " + p); } }); view.getPlayerPanel().getHandPanel().getStoneClickEvent() .add(new IListener2() { @Override public void handle(Stone s, Boolean collect) { System.out.println("Hand clicked on " + s + (collect ? ", collect" : "")); } }); view.getPlayerPanel().getHandPanel().getRangeClickEvent() .add(new IListener2() { @Override public void handle(Stone s, Boolean collect) { System.out.println("Hand range-clicked on " + s + (collect ? ", collect" : "")); } }); view.getPlayerPanel().getHandPanel().getSetClickEvent() .add(new IListener2() { @Override public void handle(Stone s, Boolean collect) { System.out.println("Hand set-clicked at " + s + (collect ? ", collect" : "")); } }); view.getTablePanel().getClickEvent().add(new IListener1() { @Override public void handle(Position p) { System.out.println("Table clicked at " + p); } }); view.getTablePanel().getStoneClickEvent() .add(new IListener2() { @Override public void handle(Stone s, Boolean collect) { System.out.println("Table clicked on " + s + (collect ? ", collect" : "")); } }); view.getTablePanel().getRangeClickEvent() .add(new IListener2() { @Override public void handle(Stone s, Boolean collect) { System.out.println("Table range-clicked on " + s + (collect ? ", collect" : "")); } }); view.getTablePanel().getSetClickEvent() .add(new IListener2() { @Override public void handle(Stone s, Boolean collect) { System.out.println("Table set-clicked at " + s + (collect ? ", collect" : "")); view.enableWinPanel(true); } }); view.getTablePanel().getLeftConnectorClickEvent() .add(new IListener1() { @Override public void handle(StoneSet s) { System.out.println("Left connector clicked on " + s); } }); view.getTablePanel().getRightConnectorClickEvent() .add(new IListener1() { @Override public void handle(StoneSet s) { System.out.println("Right connector clicked on " + s); } }); view.getTablePanel().getStoneCollectionPanel().getStoneClickEvent() .add(new IListener2() { @Override public void handle(Stone s, Boolean collect) { System.out.println("Collection clicked on " + s + (collect ? ", collect" : "")); } }); view.getTablePanel().getStoneCollectionPanel().getRangeClickEvent() .add(new IListener2() { @Override public void handle(Stone s, Boolean collect) { System.out.println("Collection range-clicked on " + s + (collect ? ", collect" : "")); } }); view.getTablePanel().getStoneCollectionPanel().getSetClickEvent() .add(new IListener2() { @Override public void handle(Stone s, Boolean collect) { System.out.println("Collection set-clicked at " + s + (collect ? ", collect" : "")); } }); // stoneSets on the table Map stoneSets = new HashMap(); stoneSets.put(new StoneSet(new Stone(5, StoneColor.ORANGE)), new Position(0.5f, 1)); List stoneList = new ArrayList(); stoneList.add(new Stone(7, StoneColor.BLACK)); Stone stone8 = new Stone(8, StoneColor.BLACK); stoneList.add(stone8); stoneList.add(new Stone(9, StoneColor.BLACK)); stoneList.add(new Stone(10, StoneColor.BLACK)); stoneSets.put(new StoneSet(stoneList), new Position(3.5f, 4)); view.getTablePanel().setStoneSets(stoneSets); view.setSelectedStones(Arrays.asList(stoneJoker, stone8)); } }