Package server.commands.methods

Source Code of server.commands.methods.HoldDice

package server.commands.methods;

import game.dice.Die;

import java.awt.Point;

import server.protocol.GameRoom;
import client.frame.GameplayFrame;

/**
* The Class HoldDice. Handles the dice holding method.
*/
public class HoldDice {

  /**
   * Holds the dice.
   *
   * @param room the room
   * @param x the x coord
   * @param y the y coord
   */
  public void hold(GameRoom room, int x, int y) {
    Point point = new Point(x, y);
    for (int i = 0; i < room.getDice().getDice().size(); i++) {
      Die tempDie = room.getDice().getDice().get(i);
      if (tempDie.getDieFixture().contains(point)) {
        if (!room.getDice().getSavedDice().contains(tempDie)) {
          room.getDice().addToSavedDice(tempDie);
          tempDie.setDieFixture(new Point(
              GameplayFrame.DIE_SAVE_AREA_WIDTH
                  + (Die.DIE_DIMENSION + 5) * i,
              GameplayFrame.DIE_SAVE_AREA_HEIGHT));
          return;
        } else if (room.getDice().getSavedDice().contains(tempDie)) {
          room.getDice().removeFromSavedDice(tempDie);
          tempDie.calculateNewFixtureLocation();
          return;
        }
      }
    }
  }
}
TOP

Related Classes of server.commands.methods.HoldDice

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.