#include "tile.h" #include Tile::Tile(Tile::Type t, bool re) : type(t), red(re), rotated(false), invisible(false) { } Tile::Tile(Set s, int num, bool re) : red(re), rotated(false), invisible(false) { switch(s) { case Man: type = Type(Man_1 + num - 1); break; case Pin: type = Type(Pin_1 + num - 1); break; case Sou: type = Type(Sou_1 + num - 1); break; default: // Invalid. break; } } int Tile::get_num() const { if(type >= Man_1 && type <= Sou_9) { return (type - Man_1) % 9 + 1; } else { return 0; } } Tile::Set Tile::get_set() const { if(type >= Man_1 && type <= Man_9) { return Man; } else if(type >= Pin_1 && type <= Pin_9) { return Pin; } else if(type >= Sou_1 && type <= Sou_9) { return Sou; } else { return Honor; } } bool Tile::operator==(const Tile& other) const { return type == other.type; } bool Tile::operator<(const Tile& other) const { return type == other.type ? red : type < other.type; } Tile Tile::operator++(int) { type = Type(type + 1); return *this; }