mirror of
https://athene2.informatik.unibw-muenchen.de/progproj/gruppen-ht24/Gruppe-02.git
synced 2024-11-25 03:29:44 +01:00
Compare commits
No commits in common. "10e24cf30e6843f3c6660e32eb6ded8d1fb7207d" and "7ada56e21548ae34e799298d85561b0fa6c8753f" have entirely different histories.
10e24cf30e
...
7ada56e215
@ -13,7 +13,6 @@ 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;
|
||||||
@ -121,11 +120,9 @@ 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,10 +8,31 @@ 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
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,6 +56,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,46 +98,21 @@ public class Figure implements Item{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Moves the Figure to the specified coordinates.
|
* Returns the current status of the Figure.
|
||||||
*
|
*
|
||||||
* @param x the new x-coordinate of the Figure's position
|
* @return the status of the Figure
|
||||||
* @param y the new y-coordinate of the Figure's position
|
|
||||||
*/
|
*/
|
||||||
public void moveTo(int fieldId) {
|
public Status getStatus() {
|
||||||
moveTo(fieldIdToPosition(fieldId));
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IntPoint fieldIdToPosition(int fieldId) {
|
/**
|
||||||
if (fieldId < 0 || fieldId > 39) {
|
* Sets the status of the Figure.
|
||||||
throw new IllegalArgumentException("Invalid fieldId: " + fieldId);
|
*
|
||||||
}
|
* @param status the new status to be set for the Figure
|
||||||
|
*/
|
||||||
// Determine which edge and position along the edge
|
public void setStatus(Status status) {
|
||||||
if (fieldId <= 9) {
|
this.status = status;
|
||||||
// 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
|
||||||
*/
|
*/
|
||||||
public static List<Field> createBoard() {
|
private List<Field> createBoard() {
|
||||||
ArrayList<Field> fields = new ArrayList<>();
|
ArrayList<Field> fields = new ArrayList<>();
|
||||||
|
|
||||||
fields.add(new GoField());
|
fields.add(new GoField());
|
||||||
|
@ -15,8 +15,4 @@ public class GulagField extends Field{
|
|||||||
player.visit(this);
|
player.visit(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBailCost() {
|
|
||||||
return bailCost;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,6 @@ public class TestStreckeField extends Field{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int collectMoney() {
|
public int collectMoney() {
|
||||||
int tmp = money;
|
return money = 0;
|
||||||
money = 0;
|
|
||||||
return tmp;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user