Class wrapping a komi value. More...
#include <GoKomi.h>
Classes | |
class | InvalidKomi |
Exception thrown if komi is constructed with invalid value. More... | |
Public Member Functions | |
GoKomi () | |
Construct komi with unknown value. | |
GoKomi (float komi) | |
Construct komi from float. | |
GoKomi (const std::string &komi) | |
Construct komi from string. | |
GoKomi & | operator= (const GoKomi &komi) |
bool | operator== (const GoKomi &komi) const |
bool | operator!= (const GoKomi &komi) const |
bool | IsUnknown () const |
Check if komi is unknown. | |
float | ToFloat () const |
Convert komi to float. | |
std::string | ToString () const |
Convert komi to string. | |
Private Attributes | |
bool | m_isUnknown |
int | m_value |
Komi value stored as integer. |
Class wrapping a komi value.
Supported komi values are "unknown" or multiples of 0.5.
Definition at line 15 of file GoKomi.h.
GoKomi::GoKomi | ( | ) |
GoKomi::GoKomi | ( | float | komi | ) |
GoKomi::GoKomi | ( | const std::string & | komi | ) |
Construct komi from string.
komi | The string, leading and trailing whitespaces will be ignored, empty for unknown komi, float otherwise. The float will be rounded to a multiple of 0.5. |
InvalidKomi | If string is not empty or contains a float. |
Definition at line 39 of file GoKomi.cpp.
References GoKomi(), m_isUnknown, and m_value.
bool GoKomi::IsUnknown | ( | ) | const |
Check if komi is unknown.
Definition at line 108 of file GoKomi.h.
References m_isUnknown.
Referenced by GoGame::Init(), and GoGame::SetKomiGlobal().
Definition at line 91 of file GoKomi.h.
References m_isUnknown, and m_value.
bool GoKomi::operator== | ( | const GoKomi & | komi | ) | const |
Definition at line 98 of file GoKomi.h.
References m_isUnknown, and m_value.
float GoKomi::ToFloat | ( | ) | const |
Convert komi to float.
Definition at line 113 of file GoKomi.h.
References m_isUnknown, and m_value.
Referenced by GoGtpEngine::CmdFinalScore(), GoSafetyUtil::GetWinner(), GoGame::Init(), GoBoardUtil::ScorePosition(), GoGame::SetKomiGlobal(), and GoBoardUtil::TrompTaylorPassWins().
string GoKomi::ToString | ( | ) | const |
Convert komi to string.
Definition at line 62 of file GoKomi.cpp.
References m_isUnknown, and m_value.
Referenced by operator<<().
bool GoKomi::m_isUnknown [private] |
Definition at line 65 of file GoKomi.h.
Referenced by GoKomi(), IsUnknown(), operator=(), operator==(), ToFloat(), and ToString().
int GoKomi::m_value [private] |
Komi value stored as integer.
Corresponds to the real komi multiplied by two.
Definition at line 69 of file GoKomi.h.
Referenced by GoKomi(), operator=(), operator==(), ToFloat(), and ToString().