|
CardGame
Rogue-like card videogame
|
Text-based input/output interface for terminal interaction. More...
#include <iotext.h>
Public Member Functions | |
| IOText (std::ostream &out, std::istream &in) | |
| Constructs an IOText interface using the given streams. | |
| void | println (std::string_view msg) |
| Prints a line followed by a newline. | |
| void | print (std::string_view msg) const |
| Prints a line (with newline). | |
| void | getln (std::string &line) |
| Reads a line of input into the given string. | |
| int | promptInt (std::string_view prompt, int validLimit) |
| void | promptln (std::string &line, std::string_view prompt) |
| Prints a prompt and reads a line of input. | |
| void | printCards (const std::vector< std::string > &cardToPrintGrid) |
| Prints a rendered card grid to the output. | |
| void | printHand (const RenderedHand &handToPrint) |
| Prints a rendered hand to the output. | |
Text-based input/output interface for terminal interaction.
IOText provides an abstraction over input and output streams used by the terminal UI. It is responsible only for printing text and rendered grids, and for reading user input.
IOText does not implement any game logic or rendering logic;
|
inline |
Constructs an IOText interface using the given streams.
| out | Output stream used for printing. |
| in | Input stream used for reading user input. |
| void IOText::getln | ( | std::string & | line | ) |
Reads a line of input into the given string.
| void IOText::print | ( | std::string_view | msg | ) | const |
Prints a line (with newline).
| void IOText::printCards | ( | const std::vector< std::string > & | cardToPrintGrid | ) |
Prints a rendered card grid to the output.
| cardToPrintGrid | ASCII grid representing a single card or row of cards. |
| void IOText::printHand | ( | const RenderedHand & | handToPrint | ) |
Prints a rendered hand to the output.
One or two rows are printed depending on the contents of RenderedHand.
| handToPrint | Rendered hand structure to print. |
| void IOText::println | ( | std::string_view | msg | ) |
Prints a line followed by a newline.
| int IOText::promptInt | ( | std::string_view | prompt, |
| int | validLimit | ||
| ) |
| void IOText::promptln | ( | std::string & | line, |
| std::string_view | prompt | ||
| ) |
Prints a prompt and reads a line of input.
| line | Output string receiving the input. |
| prompt | Prompt text printed before reading input. |