Search in sources :

Example 1 with Window

use of cardgame1.Window in project cardgame1 by joey101937.

the class CampaignManager method goToCardAdder.

public static void goToCardAdder() {
    Board board = Board.getMainBoard();
    board.running = false;
    Window window = board.window;
    JFrame frame = window.frame;
    if (frame == null) {
        System.out.println("frame is null");
        System.exit(1);
    } else {
        frame.dispose();
        board.running = false;
        if (level <= 4)
            new CardAdderFrame(4);
        else
            new CardAdderFrame(2);
    // available = true;
    }
}
Also used : Window(cardgame1.Window) Board(cardgame1.Board) JFrame(javax.swing.JFrame) CardAdderFrame(Campaign.campaignGUI.CardAdderFrame)

Example 2 with Window

use of cardgame1.Window in project cardgame1 by joey101937.

the class CampaignManager method returnToInterface.

/**
 * ends the current game instance and returns to campaign interface
 */
public static void returnToInterface() {
    Board board = Board.getMainBoard();
    board.running = false;
    Window window = board.window;
    JFrame frame = window.frame;
    if (frame == null) {
        System.out.println("frame is null");
        System.exit(1);
    } else {
        frame.dispose();
        board.running = false;
        new CampaignInterface();
    // available = true;
    }
}
Also used : Window(cardgame1.Window) Board(cardgame1.Board) CampaignInterface(Campaign.campaignGUI.CampaignInterface) JFrame(javax.swing.JFrame)

Example 3 with Window

use of cardgame1.Window in project cardgame1 by joey101937.

the class LegacyGUI method mpTestingButtonActionPerformed.

// GEN-LAST:event_jButton1ActionPerformed
private void mpTestingButtonActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_mpTestingButtonActionPerformed
    if (this.yourDeckCombo.getSelectedItem().equals(useCustomText)) {
        if (this.loadedCustomDeckPlayer == null) {
            JOptionPane.showMessageDialog(null, "Custom deck not loaded");
            return;
        }
    }
    int x = 0, y = 0;
    try {
        x = Integer.parseInt(this.resX.getText());
        y = Integer.parseInt(this.resY.getText());
        if (x < 480 || y < 480) {
            Main.display("Warning, window too small");
            return;
        }
        if (x > 2560 || y > 2560) {
            Main.display("Warning, window too big");
            return;
        }
    } catch (NumberFormatException nfe) {
        Main.display("Invalid dimensions. Must be numeric.");
        return;
    } catch (Exception e) {
        e.printStackTrace();
    }
    String[] options = { "Client", "Server" };
    int choice = JOptionPane.showOptionDialog(null, "Use as Client or Server?", "Client/Server Prompt", 0, 0, null, options, "init");
    // -1 = exit, 0 = client, 1= server
    if (choice == -1)
        return;
    boolean isServer = choice == 1;
    this.assignDecks();
    Hero bot = new Hero("user", PlayerDeck, SpriteHandler.ashePortrait);
    // emptyDeck because phantom will populate it
    Hero top = new Hero("top", new ArrayList<Card>(), SpriteHandler.knightHero);
    if (!isServer)
        Phantom.connectionAddress = JOptionPane.showInputDialog("Enter Connection Address");
    if (Phantom.connectionAddress == null)
        return;
    top.isAIControlled = false;
    Board board;
    if (isServer)
        JOptionPane.showMessageDialog(null, "Game will now wait 25 seconds for another player to connect");
    try {
        board = new Board(top, bot, new Dimension(x, y), isServer);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
Also used : Board(cardgame1.Board) Hero(cardgame1.Hero) Dimension(java.awt.Dimension) GeomancerCard(Cards.Elemental.GeomancerCard) SpearmanCard(Cards.Base.SpearmanCard) SorcererCard(Cards.Elemental.SorcererCard) StoneGolemCard(Cards.Elemental.StoneGolemCard) Card(Cards.Card) SandElementalCard(Cards.Elemental.SandElementalCard)

Example 4 with Window

use of cardgame1.Window in project tests by datanucleus.

the class ManagedRelationshipTest method testOneToManyJoinBidirPersistElement.

/**
 * Test for management of relations with a 1-N JoinTable bidir where the objects are persisted
 * and only the FK side is set.
 */
public void testOneToManyJoinBidirPersistElement() {
    try {
        PersistenceManager pm = pmf.getPersistenceManager();
        pm.setProperty(PropertyNames.PROPERTY_MANAGE_RELATIONSHIPS, "true");
        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();
            House house = new House(14, "Smith Street");
            Window window1 = new Window(100, 200, house);
            Window window2 = new Window(600, 200, house);
            assertNotNull("Window1 has null House but should be not-null before persist", window1.getHouse());
            assertNotNull("Window2 has null House but should be not-null before persist", window2.getHouse());
            assertEquals("House has Windows yet should be empty before persist", 0, house.getWindows().size());
            pm.makePersistent(window1);
            pm.makePersistent(window2);
            pm.flush();
            // Check that the relation sides are both set
            assertSame("Window1 has incorrect House after persist/flush", house, window1.getHouse());
            assertSame("Window2 has incorrect House after persist/flush", house, window2.getHouse());
            assertEquals("House has incorrect Windows after persist/flush", 2, house.getWindows().size());
            tx.commit();
        } catch (Exception e) {
            LOG.error("Exception thrown persisting 1-N JoinTable bidir with only FK side set", e);
            fail("Error in test : " + e.getMessage());
        } finally {
            if (tx.isActive()) {
                tx.rollback();
            }
            pm.close();
        }
    } finally {
        clean(House.class);
        clean(Window.class);
    }
}
Also used : Window(org.datanucleus.samples.one_many.bidir_2.Window) Transaction(javax.jdo.Transaction) PersistenceManager(javax.jdo.PersistenceManager) House(org.datanucleus.samples.one_many.bidir_2.House)

Example 5 with Window

use of cardgame1.Window in project tests by datanucleus.

the class ManagedRelationshipTest method testOneToManyJoinBidirPersistCollection.

/**
 * Test for management of relations with a 1-N jointable bidir where the objects are persisted
 * and only the collection side is set.
 */
public void testOneToManyJoinBidirPersistCollection() {
    try {
        PersistenceManager pm = pmf.getPersistenceManager();
        pm.setProperty(PropertyNames.PROPERTY_MANAGE_RELATIONSHIPS, "true");
        Transaction tx = pm.currentTransaction();
        try {
            tx.begin();
            House house = new House(15, "King Street");
            Window window1 = new Window(150, 200, null);
            Window window2 = new Window(350, 400, null);
            house.addWindow(window1);
            house.addWindow(window2);
            assertNull("Window1 has non-null House but should be null before persist", window1.getHouse());
            assertNull("Window2 has non-null House but should be null before persist", window2.getHouse());
            assertNotNull("House has null Windows yet should be non-null before persist", house.getWindows());
            pm.makePersistent(house);
            pm.flush();
            // Check that the relation sides are both set
            assertNotNull("Window1 has null House but should be not-null after persist/flush", window1.getHouse());
            assertNotNull("Window2 has null House but should be not-null after persist/flush", window2.getHouse());
            assertNotNull("House has null Windows yet should be non-null after persist/flush", house.getWindows());
            tx.commit();
        } catch (Exception e) {
            LOG.error("Exception thrown persisting 1-N JoinTable bidir with only collection side set", e);
            fail("Error in test : " + e.getMessage());
        } finally {
            if (tx.isActive()) {
                tx.rollback();
            }
            pm.close();
        }
    } finally {
        clean(House.class);
        clean(Window.class);
    }
}
Also used : Window(org.datanucleus.samples.one_many.bidir_2.Window) Transaction(javax.jdo.Transaction) PersistenceManager(javax.jdo.PersistenceManager) House(org.datanucleus.samples.one_many.bidir_2.House)

Aggregations

PersistenceManager (javax.jdo.PersistenceManager)12 Transaction (javax.jdo.Transaction)12 House (org.datanucleus.samples.one_many.bidir_2.House)12 Window (org.datanucleus.samples.one_many.bidir_2.Window)12 List (java.util.List)6 ArrayList (java.util.ArrayList)5 Board (cardgame1.Board)4 Query (javax.jdo.Query)3 EntityManager (javax.persistence.EntityManager)3 EntityTransaction (javax.persistence.EntityTransaction)3 House (org.datanucleus.samples.annotations.one_many.bidir_2.House)3 Window (org.datanucleus.samples.annotations.one_many.bidir_2.Window)3 Hero (cardgame1.Hero)2 Window (cardgame1.Window)2 Button (com.googlecode.lanterna.gui2.Button)2 GridLayout (com.googlecode.lanterna.gui2.GridLayout)2 Panel (com.googlecode.lanterna.gui2.Panel)2 Window (com.googlecode.lanterna.gui2.Window)2 MessageDialogButton (com.googlecode.lanterna.gui2.dialogs.MessageDialogButton)2 Dimension (java.awt.Dimension)2