Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/main/java/usecase/readhand/ReadHandInteractor.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public void execute(ReadHandInputData inputData) {
* @return a string describing the player's hand, dora, uradora, and attributes
*/
private String getHandInfo(String playerName, String[] attributeNames) {
// TODO: read more than just Head
List<Tile> hand = dataAccessObj.getPlayer(playerName).getHand();
StringBuilder handInfo = new StringBuilder();

Expand Down Expand Up @@ -109,7 +108,17 @@ private String getHandInfo(String playerName, String[] attributeNames) {
}
handInfo.append("That's all tiles.");

// 4. Create string that describes the player's attributes.
// 4. Create string that describes the player's attributes (comboboxes).
String winType = dataAccessObj.getPlayer(playerName).getWinType();
handInfo.append("You won by ").append(winType).append(". ");
String seatWind = dataAccessObj.getPlayer(playerName).getSeatWind();
handInfo.append("Your seat wind is ").append(seatWind).append(". ");
String roundWind = dataAccessObj.getPlayer(playerName).getRoundWind();
handInfo.append("The round wind is ").append(roundWind).append(". ");
int numAkaDora = dataAccessObj.getPlayer(playerName).getNumAkaDora();
handInfo.append("You have ").append(numAkaDora).append(" red dora. ");

// 4. Create string that describes the player's attributes (checkboxes).
// Get whether all attributes are false.
Boolean[] attributes = dataAccessObj.getPlayer(playerName).getAttributes();
boolean allFalse = false;
Expand Down
34 changes: 25 additions & 9 deletions src/test/java/unit/usecase/readhand/ReadHandInteractorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ void setup() {
void testHandEmptyAllFalse() {
DAO.savePlayer(player);
interactor.execute(new ReadHandInputData(name, attrib));
final String expected = "Your hand is empty."
+ "There are no dora tiles.There are no uradora tiles."
+ "That's all tiles.You have no special attributes.";
final String expected = "Your hand is empty. "
+ "There are no dora tiles.There are no uradora tiles.That's all tiles." +
"You won by Tsumo. " +
"Your seat wind is East. " +
"The round wind is East. " +
"You have 0 red dora. " +
"You have no special attributes.";
Assertions.assertEquals(expected, presenter.getMessage());
}

Expand All @@ -74,9 +78,13 @@ void testHandEmpty() {
player.setAttributes(newAttrib);
DAO.savePlayer(player);
interactor.execute(new ReadHandInputData(name, attrib));
final String expected = "Your hand is empty."
+ "There are no dora tiles.There are no uradora tiles."
+ "That's all tiles.You have the following special attributes: Riichi. Finish. ";
final String expected = "Your hand is empty. "
+ "There are no dora tiles.There are no uradora tiles.That's all tiles." +
"You won by Tsumo. " +
"Your seat wind is East. " +
"The round wind is East. " +
"You have 0 red dora. " +
"You have the following special attributes: Riichi. Finish. ";
Assertions.assertEquals(expected, presenter.getMessage());
}

Expand All @@ -86,9 +94,13 @@ void testHandNonEmptyAllFalse() {
player.setHand(hand);
DAO.savePlayer(player);
interactor.execute(new ReadHandInputData(name, attrib));
final String expected = "Your hand includes 1 Man."
+ "There are no dora tiles.There are no uradora tiles."
+ "That's all tiles.You have no special attributes.";
final String expected = "Your hand includes 1 Man. "
+ "There are no dora tiles.There are no uradora tiles.That's all tiles." +
"You won by Tsumo. " +
"Your seat wind is East. " +
"The round wind is East. " +
"You have 0 red dora. " +
"You have no special attributes.";
Assertions.assertEquals(expected, presenter.getMessage());
}

Expand All @@ -110,6 +122,10 @@ void testHandNonEmpty() {
interactor.execute(new ReadHandInputData(name, attrib));
final String expected = "Your hand includes 2 Man. The dora tiles are 2 Man. " +
"The uradora tiles are 2 Man. That's all tiles." +
"You won by Tsumo. " +
"Your seat wind is East. " +
"The round wind is East. " +
"You have 0 red dora. " +
"You have the following special attributes: Riichi, Double Riichi. Finish. ";
Assertions.assertEquals(expected, presenter.getMessage());
}
Expand Down