Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Triikk committed Feb 17, 2024
2 parents b194f17 + 84ad5d6 commit 5af9710
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ private void logCard(final CardType card) {
}

private void logRobber() {
appView.updateLog(getCurrentPlayerName(), "must place robber");
appView.updateLog(getCurrentPlayerName(), messageFactory.createRobberMessage().getMessage());
}

@Override
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/it/unibo/controller/main/message/MessageFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import it.unibo.common.property.PropertyType;
import it.unibo.common.tile.ResourceType;

/**
* Factory of messages.
*/
public interface MessageFactory {
/**
* Create a message representing the resource and the amount.
Expand Down Expand Up @@ -36,4 +39,11 @@ public interface MessageFactory {
* @return the message
*/
Message createBuildRoadMessage();

/**
* Create a message representing the robber.
*
* @return the message
*/
Message createRobberMessage();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
import it.unibo.common.property.PropertyType;
import it.unibo.common.tile.ResourceType;

public class MessageFactoryImpl implements MessageFactory {
/**
* Implementation of MessageFactory.
*/
public final class MessageFactoryImpl implements MessageFactory {

@Override
public Message createResourceMessage(ResourceType resource, int amount) {
public Message createResourceMessage(final ResourceType resource, final int amount) {
return new Message() {
@Override
public String getMessage() {
Expand All @@ -19,7 +22,7 @@ public String getMessage() {
}

@Override
public Message createCardMessage(CardType card) {
public Message createCardMessage(final CardType card) {
return new Message() {
@Override
public String getMessage() {
Expand All @@ -29,7 +32,7 @@ public String getMessage() {
}

@Override
public Message createBuildPropertyMessage(PropertyType property) {
public Message createBuildPropertyMessage(final PropertyType property) {
return new Message() {
@Override
public String getMessage() {
Expand All @@ -48,4 +51,14 @@ public String getMessage() {
};
}

@Override
public Message createRobberMessage() {
return new Message() {
@Override
public String getMessage() {
return "must place robber";
}
};
}

}
2 changes: 1 addition & 1 deletion src/main/java/it/unibo/view/app/StartMenuView.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* Application.
*/
public class StartMenuView {
private final static int PLAYERS_LIMIT = 4;
private static final int PLAYERS_LIMIT = 4;
private final Stage stage;
private final ObservableList<String> players = FXCollections.observableArrayList();

Expand Down
2 changes: 1 addition & 1 deletion src/test/java/it/unibo/model/PropertyManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void testCity() {
void testGetPlayerProperties() {
propertyManager.addSettlement(pos1, PLAYER1);
propertyManager.addSettlement(pos2, PLAYER1);
for (Property property : propertyManager.getPlayerProperties(PLAYER1)) {
for (final Property property : propertyManager.getPlayerProperties(PLAYER1)) {
assertTrue(
Set.of(new PropertyImpl(pos2, PLAYER1).getPosition(), new PropertyImpl(pos1, PLAYER1).getPosition())
.contains(property.getPosition()));
Expand Down

0 comments on commit 5af9710

Please sign in to comment.