fixed player movement and go money

This commit is contained in:
Johannes Schmelz 2024-12-01 02:14:09 +01:00
parent a6b7ea4ce8
commit b8e1645eb8

View File

@ -161,10 +161,10 @@ public class Player implements FieldVisitor<Void>{
* @return the new position
*/
public int move(int steps) {
fieldID = (fieldID + steps) % 40;
if (fieldID + steps >= 40) {
earnMoney(2000); // Passing GO gives money
}
fieldID = (fieldID + steps) % 40;
figure.moveTo(fieldID);
handler.getLogic().send(this, new PlayerStatusUpdate(handler));
handler.getLogic().getBoardManager().getFieldAtIndex(fieldID).accept(this);
@ -180,6 +180,7 @@ public class Player implements FieldVisitor<Void>{
if(position < 40 && position > 0) {
fieldID = position;
figure.moveTo(fieldID);
handler.getLogic().send(this, new PlayerStatusUpdate(handler));
handler.getLogic().getBoardManager().getFieldAtIndex(fieldID).accept(this);
}
return fieldID;