示例#1
0
  public GUILogi5Board(Game game) {

    this.game = game;
    dim = game.getDimensions()[0];

    setLayout(new GridLayout(dim, dim));
    spaces = new JButton[dim][dim];

    for (int i = 0; i < spaces.length; i++) {
      for (int j = 0; j < spaces[i].length; j++) {

        Space otherSpace = game.getSpaceAt(i, j);

        GUILogi5Space spacey = new GUILogi5Space(i, j, spaceSize);
        int[] loc = spacey.getDims();
        spacey.setSpace(game.getSpaceAt(loc[0], loc[1]));
        spaces[i][j] = spacey;
        add(spacey);
      }
    }
    setBorder(BorderFactory.createLineBorder(Color.black));
    setPreferredSize(new Dimension(spaceSize * spaces.length, spaceSize * spaces[0].length));
    setMaximumSize(new Dimension(spaceSize * spaces.length, spaceSize * spaces[0].length));

    int num = 255;
    Color[] colors = new Color[6];
    for (int i = 0; i < colors.length; i++) {
      colors[i] = new Color(num, num, num, 220);
      num -= 30;
    }

    possibleColors = colors;
  }
 public void hitResponse(String response) {
   StringTokenizer st = new StringTokenizer(response);
   int k = 0;
   String side = null;
   int x = -1;
   int y = -1;
   while (st.hasMoreTokens()) {
     if (k == 0) st.nextToken();
     if (k == 1) side = st.nextToken();
     if (k == 2) x = Integer.parseInt(st.nextToken());
     if (k == 3) y = Integer.parseInt(st.nextToken());
     k++;
   }
   System.out.println(gameData.getPlayerSide());
   System.out.println(side);
   if (gameData.getPlayerSide().equals(side)) {
     System.out.println("player field hit");
     gameData.shootAtField(side, x, y, 3, false, null, null, -1, -1);
     mw.v.enqueEvent(new CustomEvent(CustomEvent.PLAYER_FIELD_HIT, x, y));
   } else {
     System.out.println("enemy field hit");
     gameData.shootAtField(side, x, y, 3, false, null, null, -1, -1);
     mw.v.enqueEvent(new CustomEvent(CustomEvent.OPPONENT_FIELD_HIT, x, y));
   }
 }
示例#3
0
 public BoardPanel(
     final JFrame frame,
     Game game,
     UnitTypeConfiguration unitTypeConfiguration,
     TileTypeConfiguration tileTypeConfiguration,
     TileStateConfiguration tileStateConfiguration,
     ChessMovementStrategy movementStrategy,
     UnitSelectorMode unitSelectorMode,
     BattleStrategyConfiguration battleStrategyConfiguration) {
   this.frame = frame;
   this.battleStrategyConfiguration = battleStrategyConfiguration;
   thisPanel = this;
   this.game = game;
   game.addGameObserver(this);
   this.board = game.getBoard();
   this.movementStrategy = movementStrategy;
   int rows = board.getDimension().getHeight();
   int columns = board.getDimension().getWidth();
   setLayout(new GridLayout(rows, columns));
   for (Tile tile : board.getTiles()) {
     final TilePanel tilePanel =
         new TilePanel(tileTypeConfiguration, unitTypeConfiguration, tileStateConfiguration, tile);
     if (UnitSelectorMode.MULTIPLE.equals(unitSelectorMode)) {
       tilePanel.addMouseListener(
           new MultipleUnitSelectorMouseListener(tilePanel, frame, thisPanel));
     }
     if (UnitSelectorMode.SINGLE.equals(unitSelectorMode)) {
       tilePanel.addMouseListener(
           new SingleUnitSelectorMouseListener(tilePanel, frame, thisPanel));
     }
     map.put(tile, tilePanel);
     add(tilePanel);
   }
   resetPositions();
 }
示例#4
0
  public void startNGameCycles(Runnable finalAction, int nrOfRuns) {
    Class currWhitePlayer = whitePlayer.getClass();
    Class currBlackPlayer = blackPlayer.getClass();

    new Thread(
            () -> {
              for (int i = 0; i < nrOfRuns; i++) {
                progressOfNGames = OptionalDouble.of((double) i / nrOfRuns);

                GipfBoardState gipfBoardStateCopy =
                    new GipfBoardState(
                        getGipfBoardState(), gipfBoardState.getPieceMap(), gipfBoardState.players);
                Game copyOfGame = new BasicGame();
                try {
                  copyOfGame.whitePlayer = (ComputerPlayer) currWhitePlayer.newInstance();
                  copyOfGame.blackPlayer = (ComputerPlayer) currBlackPlayer.newInstance();
                } catch (InstantiationException | IllegalAccessException e) {
                  e.printStackTrace();
                }
                copyOfGame.loadState(gipfBoardStateCopy);

                GameLoopThread gameLoopThread = new GameLoopThread(copyOfGame, finalAction);
                gameLoopThread.start();
                try {
                  gameLoopThread.join();
                } catch (InterruptedException e) {
                  e.printStackTrace();
                }
              }

              progressOfNGames = OptionalDouble.empty();
            })
        .start();
  }
示例#5
0
 private void paintMenu(Graphics2D g2d) {
   if (showMenu == true) {
     if (c.getPoints() > c.getHighscore().getLowestPointsInTable() && c.getLifes() == 0) {
       menu.setState(4);
     }
     menu.draw(g2d);
   }
 }
示例#6
0
  /* Create and show the graphical user interface. */
  private static void createAndShowGUI() {
    JFrame frame = new JFrame("My Collapsing Puzzle");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Game game = new Game();
    frame.setJMenuBar(game.createMenuBar());
    frame.setContentPane(game.createContentPane());
    frame.setSize(game.getGameSize());

    frame.setVisible(true);
  }
示例#7
0
  public static void main(String[] args) {

    Game game = Game.getInstance();

    JFrame window = new JFrame();
    window.setSize(WIDTH, HEIGHT);
    window.setLocation(100, 50);
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    window.add(game);
    window.setVisible(true);
    window.setResizable(false);

    game.startGame();
  }
示例#8
0
文件: Robots.java 项目: yuan51/CS180
  public void play(int lv) {
    jl.setText("Level " + level);
    Game game = new Game(lv); // An object representing the game
    View view = new View(game); // An object representing the view of the game
    game.newGame();
    view.print();
    gameBoardPanel = view.mainPanel;
    ButtonPanel buttonPanel = new ButtonPanel(game);
    container.add(buttonPanel, BorderLayout.EAST);
    container.add(gameBoardPanel, BorderLayout.WEST);
    mainFrame.pack();

    // Main game loop
    while (true) {

      view.print();
      gameBoardPanel = view.mainPanel;

      // Win/lose conditions
      if (game.isWin()) {
        view.print();
        gameBoardPanel = view.mainPanel;
        int choice;
        choice = JOptionPane.showConfirmDialog(null, "You win!", "", JOptionPane.OK_OPTION);
        if (choice == JOptionPane.OK_OPTION) {
          level++;
          mainFrame.remove(buttonPanel);
          mainFrame.remove(gameBoardPanel);
          play(level);
        }
      }
      if (game.isLose()) {
        view.print();
        gameBoardPanel = view.mainPanel;
        int choice;
        choice =
            JOptionPane.showConfirmDialog(
                null, "You lose!", "Would you like to play again?", JOptionPane.YES_NO_OPTION);
        if (choice == JOptionPane.YES_OPTION) {
          level = 1;
          mainFrame.remove(buttonPanel);
          mainFrame.remove(gameBoardPanel);
          play(level);
        } else {
          System.exit(0);
        }
      }
    }
  }
示例#9
0
 // --------------------------------createAndShowGUI-----------------------------
 public static void createAndShowGUI() {
   Game thisGame = new Game();
   try {
     UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
   } catch (Exception e) {
   }
   JFrame.setDefaultLookAndFeelDecorated(true);
   thisGame.frame = new JFrame("Tactics");
   thisGame.oConn = new SocketManager();
   thisGame.scrBounds = thisGame.frame.getGraphicsConfiguration().getBounds();
   thisGame.frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
   thisGame.frame.setDefaultLookAndFeelDecorated(true);
   thisGame.frame.addWindowListener(thisGame);
   thisGame.frame.setVisible(true);
 }
示例#10
0
    @Override
    public void actionPerformed(ActionEvent e) {
      switch (e.getActionCommand()) {
        case "Cancel":
          screen.show("menu");
          break;

        case "Start game":
          Game startGame = null;
          // 1. if tjekker værdien af hvad der er valgt i comboBoxen og sammenligner med de spil som
          // for-loopet kører igennem
          // 2. if gør så hosten ikke kan joine sit eget spil
          for (Game g : games) {
            if (g.getName().equals(screen.getFindGamePanel().getSelectedGame())) {
              if (g.getHost().getId() != currentUser.getId()) startGame = g;
            }
          }
          if (startGame != null) {

            Gamer opponent = new Gamer();
            opponent.setId(currentUser.getId());
            opponent.setControls(screen.getFindGamePanel().getDirectionsTextfield());
            startGame.setOpponent(opponent);
            String joinGamemessage = api.joinGame(startGame);
            String startGamemessage = api.startGame(startGame);
            System.out.println(startGamemessage);
            String winnerName = "";

            for (User u : users) {

              try {

                if (u.getId() == Integer.parseInt(startGamemessage)) {
                  winnerName = u.getUsername();
                }
              } catch (NumberFormatException e1) {
                e1.printStackTrace();
              }
            }

            JOptionPane.showMessageDialog(
                screen, joinGamemessage + ". The winner was:" + winnerName);
          } else {
            JOptionPane.showMessageDialog(screen, "You can't join a game where you're the host");
          }
          break;
      }
    }
示例#11
0
  public boolean action(Event evt, Object arg) {
    if (evt.target instanceof Button) {
      String selectedButton = arg.toString();
      if (selectedButton == "Play") {
        String x[] = {"A", "B"};
        Game.main(x);
      }
      if (selectedButton == "Map Editor") {
        String x[] = {"A", "B"};
        MapEditor.main(x);
      }
      if (selectedButton == "Exit DuskFire") {
        System.out.println("Exiting Game");
        if (JOptionPane.showConfirmDialog(
                null,
                "Are you sure you want to exit DuskFire",
                "Exiting DuskFire",
                JOptionPane.YES_NO_OPTION)
            == 0) {
          dispose();
        }
      }
    }

    return true;
  }
示例#12
0
  public void setUpGroups() {

    this.groups = game.getGroups();
    Color[] groupToColor = new Color[groups.length];
    for (int i = 0; i < groupToColor.length; i++) {
      groupToColor[i] = possibleColors[i % possibleColors.length];
    }

    for (int i = 0; i < groupToColor.length; i++) {
      Group[] conflictingGroups;
      conflictingGroups = conflicting(i, groupToColor);

      int noOfTimes = 0;

      while (conflictingGroups.length != 0) {
        int offset;
        if (noOfTimes > 5) offset = 3;
        else offset = 2;

        groupToColor[conflictingGroups[0].groupIDX] =
            possibleColors[(conflictingGroups[0].groupIDX + offset) % possibleColors.length];
        conflictingGroups = conflicting(i, groupToColor);
        noOfTimes++;
      }
    }

    for (int i = 0; i < groups.length; i++) {
      Space[] groupSpaces = groups[i].getSpaces();
      for (int j = 0; j < groupSpaces.length; j++) {
        Space current = groupSpaces[j];
        GUILogi5Space currentSpace = (GUILogi5Space) (spaces[current.getX()][current.getY()]);
        currentSpace.setColor(groupToColor[i]);
      }
    }
  }
示例#13
0
  public static void main(String[] args) {
    Game game = new Game();
    game.setPreferredSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
    game.setMaximumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));
    game.setMinimumSize(new Dimension(WIDTH * SCALE, HEIGHT * SCALE));

    JFrame frame = new JFrame("Tiles.Tile RPG");
    frame.setSize(WIDTH * SCALE, HEIGHT * SCALE);

    /** Important line to prevent memory leak! */
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setResizable(false);
    frame.add(game);
    frame.setVisible(true);

    game.start();
  }
示例#14
0
 public void setMap(String Map_str) {
   setLevel(new LevelHandler(Map_str));
   if (alternateCols[0]) {
     Game.setShirtCol(240);
   }
   if (!alternateCols[0]) {
     Game.setShirtCol(111);
   }
   if (alternateCols[1]) {
     Game.setFaceCol(310);
   }
   if (!alternateCols[1]) {
     Game.setFaceCol(543);
   }
   setPlayer(new Player(level, 100, 100, input, getJdata_UserName(), shirtCol, faceCol));
   level.addEntity(player);
 }
示例#15
0
 private void repaintPanels(Iterable<TilePanel> panels) {
   long start = System.currentTimeMillis();
   for (TilePanel panel : panels) {
     game.notifyGameObservers(panel.getTile().getPosition());
   }
   long stop = System.currentTimeMillis();
   Logger.getLogger(BoardPanel.class).debug("Repaint time: " + (stop - start) / 1000.0);
 }
示例#16
0
  /**
   * Create a new board
   *
   * @param c
   */
  public Board(Game c) {
    // add leap motion controller
    leapAdapter = new SensorAdapter(c);
    sensorListener = new SensorListener(leapAdapter);
    shootListener = new ShootListener(leapAdapter);
    leapController = new Controller();
    leapController.addListener(sensorListener);
    leapController.addListener(shootListener);

    addKeyListener(new KeyboardAdapter(c, this));

    this.menu = new Menu(this, c);
    setFocusable(true);
    setDoubleBuffered(true);
    this.c = c;
    c.setPlayer(ItemFactory.createPlayer());
    c.setBackground(ItemFactory.createBackground());
  }
示例#17
0
 private void paintItems(Graphics2D g2d) {
   for (Item item : c.getAllStuff()) {
     if (item != null) {
       if (item.flicker()) {
         g2d.drawImage(
             item.getImage(), item.getPosition().getX(), item.getPosition().getY(), this);
       }
     }
   }
 }
 public void shoot(int x, int y) {
   if (!isServer)
     requestToServer.println(
         "fire "
             + gameData.getPlayerSide()
             + " "
             + new Integer(x).toString()
             + " "
             + new Integer(y).toString());
   if (isServer) elaborateShootRequest(x, y, "host");
 }
 public void shipPlacedResponse(String response) {
   int i = 0;
   StringTokenizer st = new StringTokenizer(response);
   String field = null;
   String alignment = null;
   String shipName = null;
   int xStartCoordinate = -1;
   int yStartCoordinate = -1;
   while (st.hasMoreTokens()) {
     if (i == 0) st.nextToken();
     if (i == 1) field = st.nextToken();
     if (i == 2) alignment = st.nextToken();
     if (i == 3) shipName = st.nextToken();
     if (i == 4) xStartCoordinate = Integer.parseInt(st.nextToken());
     if (i == 5) yStartCoordinate = Integer.parseInt(st.nextToken());
     i++;
   }
   if (field.equals(gameData.getPlayerSide()))
     gameData.placeShipsOnField(alignment, shipName, xStartCoordinate, yStartCoordinate);
 }
 public boolean placeShipsOnField(
     String field, String alignment, String shipName, int xStartCoordinate, int yStartCoordinate) {
   if (!gameData.shipAlreadyPlaced(shipName, alignment, xStartCoordinate, yStartCoordinate)) {
     if (!isServer) {
       requestToServer.println(
           "placeShip "
               + field
               + " "
               + alignment
               + " "
               + shipName
               + " "
               + xStartCoordinate
               + " "
               + yStartCoordinate);
       return true;
     }
     if (isServer) {
       boolean controllerQuery =
           cont.addShip(shipName, alignment, field, xStartCoordinate, yStartCoordinate);
       if (controllerQuery) {
         gameData.placeShipsOnField(alignment, shipName, xStartCoordinate, yStartCoordinate);
         for (ServerService s : services) {
           s.sendMessageToClients(
               "placeShip "
                   + field
                   + " "
                   + alignment
                   + " "
                   + shipName
                   + " "
                   + xStartCoordinate
                   + " "
                   + yStartCoordinate);
         }
         return true;
       }
     }
   }
   return false;
 }
示例#21
0
  public static void main(final String[] args) {

    game = new Game();
    game.frame.add(game);
    game.frame.setResizable(false);
    game.frame.setTitle(Game.title);
    game.frame.pack();
    game.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    game.frame.setLocationRelativeTo(null);
    game.frame.setVisible(true);
    game.start();
  }
示例#22
0
    @Override
    public void actionPerformed(ActionEvent e) {

      switch (e.getActionCommand()) {
        case "Cancel":
          screen.show("menu");
          break;

        case "Create":
          Game startGame = new Game();
          startGame.setName(screen.getStartGamePanel().getGameName());
          startGame.setMapSize(25);
          Gamer opponent = new Gamer();
          // For-loop kører brugerne igennem og viser dem i en comboBox
          // 1. if tjekker værdien af hvad der er valgt i comboBoxen og sammenligner med de brugere
          // som for-loopet kører igennem
          for (User u : users) {
            if (u.getUsername().equals(screen.getStartGamePanel().getSelectedUSer())) {
              opponent.setId(u.getId());
            }
          }
          // If tjekker om hosten vil udfordre sig selv og giver fejlmeddelelse og ellers er spillet
          // oprettet.
          if (opponent.getId() == currentUser.getId()) {
            JOptionPane.showMessageDialog(
                screen, "Error: You need to choose a different opponent than yourself");
          } else {
            Gamer host = new Gamer();
            host.setId(currentUser.getId());
            host.setControls(screen.getStartGamePanel().getControlsToSnake());
            startGame.setHost(host);

            startGame.setOpponent(opponent);
            String message = api.createGame(startGame);
            JOptionPane.showMessageDialog(screen, message);
            screen.show("menu");
          }
          break;
      }
    }
示例#23
0
 @Override
 public void mouseClicked(MouseEvent event) {
   Object obj = event.getSource();
   if (obj instanceof JButton) {
     JButton clickedButton = (JButton) obj;
     if (clickedButton.equals(one)) {
       this.clearPanel();
       Game next = new Game(this.frame, 1, this.bc);
       next.setBounds(0, 0, this.getWidth(), this.getHeight());
       this.frame.setContentPane(next);
       this.revalidate();
       this.repaint();
     }
     if (clickedButton.equals(two)) {
       this.clearPanel();
       Game next = new Game(this.frame, 2, this.bc);
       next.setBounds(0, 0, this.getWidth(), this.getHeight());
       this.frame.setContentPane(next);
       this.revalidate();
       this.repaint();
     }
     if (clickedButton.equals(three)) {
       this.clearPanel();
       Game next = new Game(this.frame, 3, this.bc);
       next.setBounds(0, 0, this.frame.getWidth(), this.frame.getHeight());
       this.frame.setContentPane(next);
       this.revalidate();
       this.repaint();
     }
     if (clickedButton.equals(four)) {
       this.clearPanel();
       Game next = new Game(this.frame, 4, this.bc);
       next.setBounds(0, 0, this.frame.getWidth(), this.frame.getHeight());
       // this.frame.setContentPane(next);
       this.frame.add(next);
       this.revalidate();
       this.repaint();
     }
     if (clickedButton.equals(back)) {
       this.clearPanel();
       HomePanel next = new HomePanel(this.frame, bc);
       next.setBounds(0, 0, this.getWidth(), this.getHeight());
       // this.frame.setContentPane(next);
       this.frame.add(next);
       this.revalidate();
       this.repaint();
     }
   }
 }
 public void allShipsDestroyed(String response) {
   StringTokenizer st = new StringTokenizer(response);
   st.nextToken();
   String result;
   if ((st.nextToken().equals(gameData.getPlayerSide()))) result = "You Lose";
   else result = "You Win!";
   mw.v.enqueEvent(new CustomEvent(CustomEvent.GAME_OVER, result));
   try {
     Thread.sleep(10000);
   } catch (InterruptedException e) {
   }
   System.exit(0);
 }
示例#25
0
 private void paintLifes(Graphics2D g2d) {
   int lifes = c.getLifes();
   for (int i = 0; i < lifes; i++) {
     ImageIcon imageIcon =
         new ImageIcon(
             ItemFactory.class.getResource(Config.getImagePath() + Level.getLevel().getLife()));
     Life life =
         ItemFactory.createLife(
             Config.getBoardDimension().getLength() - (2 + i) * imageIcon.getIconWidth(),
             0,
             imageIcon);
     g2d.drawImage(life.getImage(), life.getPosition().getX(), life.getPosition().getY(), this);
   }
 }
示例#26
0
  public void run() {
    long lastTime = System.nanoTime();
    double nsPerTick = 1000000000D / 60D;

    int ticks = 0;
    int frames = 0;

    long lastTimer = System.currentTimeMillis();
    double delta = 0;

    init();

    while (Game.isRunning()) {
      long now = System.nanoTime();
      delta += (now - lastTime) / nsPerTick;
      lastTime = now;
      boolean shouldRender = false;

      while (delta >= 1) {
        ticks++;
        tick();
        delta -= 1;
        shouldRender = true;
      }

      try {
        Thread.sleep(2);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }

      if (shouldRender) {
        frames++;
        render();
      }

      if (System.currentTimeMillis() - lastTimer >= 1000) {
        lastTimer += 1000;
        getFrame()
            .setTitle(
                "JavaGame - Version "
                    + WordUtils.capitalize(game_Version).substring(1, game_Version.length()));
        fps = frames;
        tps = ticks;
        frames = 0;
        ticks = 0;
      }
    }
  }
示例#27
0
    @Override
    public void actionPerformed(ActionEvent e) {
      switch (e.getActionCommand()) {
        case "Cancel":
          screen.show("menu");
          break;

        case "Delete game":
          Game deleteGame = new Game();
          deleteGame.setName(screen.getDeleteGamePanel().getSelectedGame());
          for (Game g : deleteGames) {
            if (g.getName().equals(screen.getDeleteGamePanel().getSelectedGame())) {
              deleteGame = g;
            }
          }
          // Besked om at spillet er slettet
          String message = api.deleteGame(deleteGame.getGameId());
          JOptionPane.showMessageDialog(screen, message);
          if (message.equals("Game was deleted")) {
            screen.getDeleteGamePanel().removeGame();
          }
          break;
      }
    }
 public void waterResponse(String response) {
   StringTokenizer st = new StringTokenizer(response);
   String side = null;
   int k = 0;
   int x = -1;
   int y = -1;
   while (st.hasMoreTokens()) {
     if (k == 0) st.nextToken();
     if (k == 1) side = st.nextToken();
     if (k == 2) x = Integer.parseInt(st.nextToken());
     if (k == 3) y = Integer.parseInt(st.nextToken());
     k++;
   }
   gameData.shootAtField(side, x, y, 2, false, null, null, -1, -1);
 }
示例#29
0
  public static void main(String[] args) {

    frame = new JFrame("Arkanoid");
    frame.setSize(1000, 700);
    // frame.setLocationRelativeTo(null);
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    game = new Game(frame, 8, 3);
    game.setSize(frame.getSize());
    frame.add(game);

    //		bat = new Bat();
    //		frame.add(bat);
    //		frame.repaint();

    frame.setVisible(true);
  }
示例#30
0
  // Method that allows the user to create a new game in the database
  public void CreateGame(
      ScreenFrame frame, ServerConnection server, User currentUser, Parsers parser) {

    try {

      // Defining variables from typed values in the CreateScreen panel
      String gamename = frame.getCreate().getTfGameName().getText();
      int mapSize = frame.getCreate().getTfMapSize();
      String controls = frame.getCreate().getTfControls().getText();

      // Checks whether the typed in values are legitimate
      // Strings controls and gamename can't be empty and the map size can't be 0
      if (!controls.equals("") && mapSize != 0 && !gamename.equals("")) {

        // Creates objects of/instansialize Game and Gamer classes
        Game game = new Game();
        Gamer gamer = new Gamer();

        // Sets controls equal to the typed controls
        gamer.setControls(controls);

        // Sets id equal to the logged in user (the current user)
        gamer.setId(currentUser.getId());

        // Sets the above defined id as the host of the game
        game.setHost(gamer);

        // Sets the gamename and mapsize equal to the typed values
        game.setName(gamename);
        game.setMapSize(mapSize);

        // All of the above setters are used to @post the variables into the database
        //
        String json = new Gson().toJson(game);
        String message = parser.createParser(server.post(json, "games/"));

        // Checks if the received list of games contains the newly created game
        // If so a confirmation will be shown to the user
        if (message.equals(game.getName())) {

          JOptionPane.showMessageDialog(
              frame,
              "Game was created!\nIt's called " + game.getName(),
              "Success!",
              JOptionPane.INFORMATION_MESSAGE);
        }
      }

      // Prints a stacktrace when catching an unforeseen error
    } catch (Exception e) {
      e.printStackTrace();
    }
  }