Scale - finished

This commit is contained in:
ericnerdo 2016-04-24 22:36:54 +02:00
parent fd64fd9165
commit 1c8566d96c

View File

@ -4,7 +4,6 @@ import java.util.Stack;
public class Scale extends Field {
private Gate gateConnected;
private Stack<Pickable> itemsOnTile;
private int threshold;
private int weight;
@ -12,28 +11,34 @@ public class Scale extends Field {
public Scale(Gate gate, int threshold){
gateConnected = gate;
this.threshold = threshold;
itemsOnTile = new Stack<Pickable>();
boxStack = new Stack<Box>();
}
public void onEntry() {
@Override
public void onEntry(PlayerBase playerBase) {
gateConnected.setOpen(true);
}
public void onExit() {
@Override
public void onExit(PlayerBase playerBase) {
gateConnected.setOpen(false);
}
@Override
public Pickable removeItemFromTile() {
weight -= itemsOnTile.peek().weight();
public Box getABox() {
if(boxStack.isEmpty())
return null;
weight -= boxStack.peek().weight();
stackChanged();
return itemsOnTile.pop();
return boxStack.pop();
}
@Override
public void setItemOnTile(Pickable item) {
itemsOnTile.push(item);
weight += item.weight();
public void putABox(Box box) {
if(box == null)
return;
boxStack.push(box);
weight += box.weight();
stackChanged();
}