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;
}
}
}
}
}