2005-02-05 12:14:56 +01:00
|
|
|
/*****************************************************************************
|
2008-01-08 14:52:32 +01:00
|
|
|
* Eliot
|
2012-10-07 16:25:41 +02:00
|
|
|
* Copyright (C) 2005-2012 Olivier Teulière & Antoine Fraboulet
|
2008-01-08 14:52:32 +01:00
|
|
|
* Authors: Olivier Teulière <ipkiss @@ gmail.com>
|
|
|
|
* Antoine Fraboulet <antoine.fraboulet @@ free.fr>
|
2005-02-05 12:14:56 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-23 16:53:42 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
2005-02-05 12:14:56 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2006-11-05 14:30:06 +01:00
|
|
|
#include <string>
|
2009-11-29 17:01:31 +01:00
|
|
|
#include <cstdio>
|
2005-02-05 12:14:56 +01:00
|
|
|
#include "cross.h"
|
|
|
|
|
2006-11-05 14:30:06 +01:00
|
|
|
#define CROSS_MASK 0xFFFFFFFF
|
2005-02-05 12:14:56 +01:00
|
|
|
|
2008-01-08 14:52:32 +01:00
|
|
|
|
2012-02-18 22:26:52 +01:00
|
|
|
INIT_LOGGER(game, Cross);
|
|
|
|
|
|
|
|
|
2005-02-05 12:14:56 +01:00
|
|
|
Cross::Cross()
|
|
|
|
{
|
2006-01-22 13:23:52 +01:00
|
|
|
// The default behaviour is to match everything
|
2006-11-05 14:30:06 +01:00
|
|
|
setAny();
|
2005-02-05 12:14:56 +01:00
|
|
|
}
|
|
|
|
|
2008-01-08 14:52:32 +01:00
|
|
|
|
|
|
|
void Cross::setAny()
|
|
|
|
{
|
2006-11-05 14:30:06 +01:00
|
|
|
m_mask = CROSS_MASK;
|
|
|
|
}
|
|
|
|
|
2005-02-05 12:14:56 +01:00
|
|
|
|
2008-01-08 14:52:32 +01:00
|
|
|
bool Cross::isAny() const
|
2005-02-05 12:14:56 +01:00
|
|
|
{
|
2008-01-08 14:52:32 +01:00
|
|
|
return m_mask == CROSS_MASK;
|
2005-02-05 12:14:56 +01:00
|
|
|
}
|
|
|
|
|
2008-01-08 14:52:32 +01:00
|
|
|
|
2006-11-05 14:30:06 +01:00
|
|
|
string Cross::getHexContent() const
|
|
|
|
{
|
|
|
|
char buff[10];
|
|
|
|
sprintf(buff,"%08x",m_mask);
|
|
|
|
string s(buff);
|
|
|
|
return s;
|
|
|
|
}
|
2005-02-05 12:14:56 +01:00
|
|
|
|
2008-01-08 14:52:32 +01:00
|
|
|
|
2005-02-05 12:14:56 +01:00
|
|
|
bool Cross::check(const Tile& iTile) const
|
|
|
|
{
|
2008-10-15 21:43:23 +02:00
|
|
|
return m_mask & (1 << iTile.toCode()) || (iTile.isPureJoker() && m_mask);
|
2005-02-05 12:14:56 +01:00
|
|
|
}
|
2005-04-02 19:59:07 +02:00
|
|
|
|
2008-01-08 14:52:32 +01:00
|
|
|
|
2006-11-05 14:30:06 +01:00
|
|
|
void Cross::insert(const Tile& iTile)
|
2008-01-08 14:52:32 +01:00
|
|
|
{
|
2006-11-05 14:30:06 +01:00
|
|
|
m_mask |= (1 << iTile.toCode());
|
|
|
|
}
|
2005-04-02 19:59:07 +02:00
|
|
|
|
2008-01-08 14:52:32 +01:00
|
|
|
|
2005-04-02 19:59:07 +02:00
|
|
|
bool Cross::operator==(const Cross &iOther) const
|
|
|
|
{
|
2006-01-22 13:23:52 +01:00
|
|
|
return m_mask == iOther.m_mask;
|
2005-04-02 19:59:07 +02:00
|
|
|
}
|
2006-01-01 20:49:35 +01:00
|
|
|
|