Hmm... after thinking a bit, I believe the following will do:
code:
class d6 {
public:
static bool left_to_right;
static int next_id;
int id;
int value;
bool is_random;
d6() { id = next_id++; value = 0; is_random = true; }
d6(const d6& y) { *this = y; }
int realize() const
{
if (is_random)
return value + original_d6();
return value;
}
bool operator<(const d6& y) const
{
int x1, y1;
if ((id < y.id) == left_to_right)
{
x1 = realize();
y1 = y.realize();
}
else
{
y1 = y.realize();
x1 = realize();
}
return (x1 < y1);
}
};
int d6::next_id = 0;
bool d6::left_to_right = true;
d6 operator+(int x, const d6& y)
{
d6 result(y);
result.value += x;
return result;
}
d6 operator+(const d6& y, int x)
{
return x + y;
}
Not that I'm recommending it though 