Skip to content
This repository has been archived by the owner on Apr 4, 2020. It is now read-only.

Commit

Permalink
fix move setup-command
Browse files Browse the repository at this point in the history
  • Loading branch information
t-ah committed May 16, 2019
1 parent fedccb7 commit 7c6c38d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public Action step() {
if (getName().equals("agentA3")) {
return new Action("submit", new Identifier("test"));
}
if (getName().equals("agentA1")) {
return new Action("request", new Identifier("e"));
}
return new Action("move", new Identifier("n"));
}
}
4 changes: 2 additions & 2 deletions server/src/main/java/massim/simulation/game/GameState.java
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,8 @@ String handleConnectAction(Entity entity, Position blockPos, Entity partnerEntit
}

String handleRequestAction(Entity entity, String direction) {
Position requestPosition = entity.getPosition().moved(direction, 1);
Dispenser dispenser = dispensers.get(requestPosition);
var requestPosition = entity.getPosition().moved(direction, 1);
var dispenser = dispensers.get(requestPosition);
if (dispenser != null && grid.isFree(requestPosition)){
createBlock(requestPosition, dispenser.getBlockType());
return Actions.RESULT_SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ private void move(Set<Attachable> attachables, Map<Attachable, Position> newPosi
public void moveWithoutAttachments(Attachable a, Position pos) {
if(isFree(pos) && a.getAttachments().isEmpty()) {
removeAttachable(a);
insert(a.getID(), a.getPosition());
a.setPosition(pos);
insert(a.getID(), pos);
}
}

Expand Down

0 comments on commit 7c6c38d

Please sign in to comment.