java.lang.Object
polimi.ingsw.am21.codex.view.TUI.utils.CliPlayerBoard
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe list of box characters used to draw cardsstatic final int
The number of grid columns to show in a playerboard sectionstatic final int
The number of grid rows to show in a playerboard section -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
addBoxCharacters
(String a, String b) Merges two box characters into onestatic String
colorizeLater
(String string) Re-applies color modifiers to a playerboard string, based on the charactersstatic String
drawPlayerBoard
(List<javafx.util.Pair<Position, javafx.util.Pair<PlayableCard, CardSideType>>> playedCardsByOrder, Set<Position> availableSpots, int verticalOffset, int horizontalOffset) Builds a string representing a playerboardstatic String
multilineOverwrite
(String original, String replacement, int line, int column) Replaces a part of a string with another string, merging box characters when possible
-
Field Details
-
SECTION_COLS
public static final int SECTION_COLSThe number of grid columns to show in a playerboard section- See Also:
-
SECTION_ROWS
public static final int SECTION_ROWSThe number of grid rows to show in a playerboard section- See Also:
-
BOX_CHARACTERS
The list of box characters used to draw cards
-
-
Constructor Details
-
CliPlayerBoard
public CliPlayerBoard()
-
-
Method Details
-
drawPlayerBoard
public static String drawPlayerBoard(List<javafx.util.Pair<Position, javafx.util.Pair<PlayableCard, CardSideType>>> playedCardsByOrder, Set<Position> availableSpots, int verticalOffset, int horizontalOffset) Builds a string representing a playerboard- Parameters:
playedCardsByOrder
- The list of cards that the player has placedavailableSpots
- The set of available spots for the player to place a cardverticalOffset
- The vertical offset of the playerboard (> 0 => down, invalid input: '<' 0 => up)horizontalOffset
- The horizontal offset of the playerboard (> 0 => right, invalid input: '<' 0 => left)- Returns:
- The colorized string representing the playerboard
-
multilineOverwrite
Replaces a part of a string with another string, merging box characters when possible- Parameters:
original
- The original "result" stringreplacement
- The replacement string (can be multiline)line
- The line to position the top-left corner of the replacement string atcolumn
- The column to position the top-left corner of the replacement string at
-
colorizeLater
Re-applies color modifiers to a playerboard string, based on the characters- Parameters:
string
- The playerboard string to colorize
-
addBoxCharacters
Merges two box characters into one- Throws:
IllegalStateException
- If any of the two characters is not a box character
-