Class CliPlayerBoard

java.lang.Object
polimi.ingsw.am21.codex.view.TUI.utils.CliPlayerBoard

public class CliPlayerBoard extends Object
  • Field Details

    • SECTION_COLS

      public static final int SECTION_COLS
      The number of grid columns to show in a playerboard section
      See Also:
    • SECTION_ROWS

      public static final int SECTION_ROWS
      The number of grid rows to show in a playerboard section
      See Also:
    • BOX_CHARACTERS

      public static final List<String> 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 placed
      availableSpots - The set of available spots for the player to place a card
      verticalOffset - 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

      public static String multilineOverwrite(String original, String replacement, int line, int column)
      Replaces a part of a string with another string, merging box characters when possible
      Parameters:
      original - The original "result" string
      replacement - The replacement string (can be multiline)
      line - The line to position the top-left corner of the replacement string at
      column - The column to position the top-left corner of the replacement string at
    • colorizeLater

      public static String colorizeLater(String string)
      Re-applies color modifiers to a playerboard string, based on the characters
      Parameters:
      string - The playerboard string to colorize
    • addBoxCharacters

      public static String addBoxCharacters(String a, String b)
      Merges two box characters into one
      Throws:
      IllegalStateException - If any of the two characters is not a box character