mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-25 02:19:45 +01:00
Compare commits
2 Commits
7ada56e215
...
10e24cf30e
Author | SHA1 | Date | |
---|---|---|---|
|
10e24cf30e | ||
|
3369057afb |
@ -13,6 +13,7 @@ import java.util.Random;
|
|||||||
import pp.monopoly.message.server.DiceResult;
|
import pp.monopoly.message.server.DiceResult;
|
||||||
import pp.monopoly.model.FieldVisitor;
|
import pp.monopoly.model.FieldVisitor;
|
||||||
import pp.monopoly.model.Figure;
|
import pp.monopoly.model.Figure;
|
||||||
|
import pp.monopoly.model.IntPoint;
|
||||||
import pp.monopoly.model.card.DeckHelper;
|
import pp.monopoly.model.card.DeckHelper;
|
||||||
import pp.monopoly.model.fields.BuildingProperty;
|
import pp.monopoly.model.fields.BuildingProperty;
|
||||||
import pp.monopoly.model.fields.EventField;
|
import pp.monopoly.model.fields.EventField;
|
||||||
@ -120,9 +121,11 @@ public class Player implements FieldVisitor<Void>{
|
|||||||
fieldID = fieldID%40;
|
fieldID = fieldID%40;
|
||||||
earnMoney(2000);
|
earnMoney(2000);
|
||||||
}
|
}
|
||||||
|
figure.moveTo(fieldID);
|
||||||
return fieldID;
|
return fieldID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets all the properties owned by this player
|
* Gets all the properties owned by this player
|
||||||
* @return List of all properties owned by this player
|
* @return List of all properties owned by this player
|
||||||
|
@ -8,31 +8,10 @@ import static java.lang.Math.max;
|
|||||||
import static java.lang.Math.min;
|
import static java.lang.Math.min;
|
||||||
|
|
||||||
public class Figure implements Item{
|
public class Figure implements Item{
|
||||||
/**
|
|
||||||
* Enumeration representing the different statuses a Figure can have during the game.
|
|
||||||
*/
|
|
||||||
public enum Status {
|
|
||||||
/**
|
|
||||||
* The ship is in its normal state, not being previewed for placement.
|
|
||||||
*/
|
|
||||||
NORMAL,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The ship is being previewed in a valid position for placement.
|
|
||||||
*/
|
|
||||||
VALID_PREVIEW,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The ship is being previewed in an invalid position for placement.
|
|
||||||
*/
|
|
||||||
INVALID_PREVIEW
|
|
||||||
}
|
|
||||||
|
|
||||||
private final int length; // The length of the Figure
|
private final int length; // The length of the Figure
|
||||||
private int x; // The x-coordinate of the Figure's position
|
private int x; // The x-coordinate of the Figure's position
|
||||||
private int y; // The y-coordinate of the Figure's position
|
private int y; // The y-coordinate of the Figure's position
|
||||||
private Rotation rot; // The rotation of the Figure
|
private Rotation rot; // The rotation of the Figure
|
||||||
private Status status; // The current status of the Figure
|
|
||||||
private final Set<IntPoint> damaged = new HashSet<>(); // The set of positions that have been hit on this ship
|
private final Set<IntPoint> damaged = new HashSet<>(); // The set of positions that have been hit on this ship
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,7 +35,6 @@ public class Figure implements Item{
|
|||||||
this.y = y;
|
this.y = y;
|
||||||
this.rot = rot;
|
this.rot = rot;
|
||||||
this.length = length;
|
this.length = length;
|
||||||
this.status = Status.NORMAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,21 +76,46 @@ public class Figure implements Item{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current status of the Figure.
|
* Moves the Figure to the specified coordinates.
|
||||||
*
|
*
|
||||||
* @return the status of the Figure
|
* @param x the new x-coordinate of the Figure's position
|
||||||
|
* @param y the new y-coordinate of the Figure's position
|
||||||
*/
|
*/
|
||||||
public Status getStatus() {
|
public void moveTo(int fieldId) {
|
||||||
return status;
|
moveTo(fieldIdToPosition(fieldId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private IntPoint fieldIdToPosition(int fieldId) {
|
||||||
* Sets the status of the Figure.
|
if (fieldId < 0 || fieldId > 39) {
|
||||||
*
|
throw new IllegalArgumentException("Invalid fieldId: " + fieldId);
|
||||||
* @param status the new status to be set for the Figure
|
}
|
||||||
*/
|
|
||||||
public void setStatus(Status status) {
|
// Determine which edge and position along the edge
|
||||||
this.status = status;
|
if (fieldId <= 9) {
|
||||||
|
// Bottom edge: From (-10, -10) to (10, -10)
|
||||||
|
int x = -10 + fieldId * 2;
|
||||||
|
return new IntPoint(x, -10);
|
||||||
|
} else if (fieldId <= 19) {
|
||||||
|
// Right edge: From (10, -10) to (10, 10)
|
||||||
|
int y = -10 + (fieldId - 10) * 2;
|
||||||
|
return new IntPoint(10, y);
|
||||||
|
} else if (fieldId <= 29) {
|
||||||
|
// Top edge: From (10, 10) to (-10, 10)
|
||||||
|
int x = 10 - (fieldId - 20) * 2;
|
||||||
|
return new IntPoint(x, 10);
|
||||||
|
} else {
|
||||||
|
// Left edge: From (-10, 10) to (-10, -10)
|
||||||
|
int y = 10 - (fieldId - 30) * 2;
|
||||||
|
return new IntPoint(-10, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Rotation fieldIdToRotation(int fieldId) {
|
||||||
|
if (fieldId >= 0 && fieldId <= 10) return Rotation.DOWN;
|
||||||
|
else if (fieldId <= 20) return Rotation.LEFT;
|
||||||
|
else if (fieldId <= 30) return Rotation.UP;
|
||||||
|
else if (fieldId <= 39) return Rotation.RIGHT;
|
||||||
|
else throw new IllegalArgumentException();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,7 +22,7 @@ public class BoardManager {
|
|||||||
* Creates a Monopoly GameBoard
|
* Creates a Monopoly GameBoard
|
||||||
* @return the List of Fields in correct Order
|
* @return the List of Fields in correct Order
|
||||||
*/
|
*/
|
||||||
private List<Field> createBoard() {
|
public static List<Field> createBoard() {
|
||||||
ArrayList<Field> fields = new ArrayList<>();
|
ArrayList<Field> fields = new ArrayList<>();
|
||||||
|
|
||||||
fields.add(new GoField());
|
fields.add(new GoField());
|
||||||
|
@ -15,4 +15,8 @@ public class GulagField extends Field{
|
|||||||
player.visit(this);
|
player.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getBailCost() {
|
||||||
|
return bailCost;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,8 @@ public class TestStreckeField extends Field{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int collectMoney() {
|
public int collectMoney() {
|
||||||
return money = 0;
|
int tmp = money;
|
||||||
|
money = 0;
|
||||||
|
return tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user