mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 01:23:24 -08:00
61 lines
1.5 KiB
C++
61 lines
1.5 KiB
C++
#include "table_zone_logic.h"
|
|
|
|
#include "../../game_graphics/board/card_item.h"
|
|
#include "../board/card_list.h"
|
|
#include "libcockatrice/card/card_info.h"
|
|
|
|
#include <QPoint>
|
|
|
|
class PlayerLogic;
|
|
class QObject;
|
|
|
|
TableZoneLogic::TableZoneLogic(PlayerLogic *_player,
|
|
const QString &_name,
|
|
bool _hasCardAttr,
|
|
bool _isShufflable,
|
|
bool _contentsKnown,
|
|
QObject *parent)
|
|
: CardZoneLogic(_player, _name, _hasCardAttr, _isShufflable, _contentsKnown, parent)
|
|
{
|
|
}
|
|
|
|
void TableZoneLogic::addCardImpl(CardItem *card, int _x, int _y)
|
|
{
|
|
cards.append(card);
|
|
if (!card->getFaceDown() && card->getPT().isEmpty()) {
|
|
card->setPT(card->getCardInfo().getPowTough());
|
|
}
|
|
if (card->getCardInfo().getUiAttributes().cipt && card->getCardInfo().getUiAttributes().landscapeOrientation) {
|
|
card->setDoesntUntap(true);
|
|
}
|
|
card->setGridPoint(QPoint(_x, _y));
|
|
}
|
|
|
|
CardItem *TableZoneLogic::takeCard(int position, int cardId, bool toNewZone)
|
|
{
|
|
CardItem *result = CardZoneLogic::takeCard(position, cardId);
|
|
|
|
if (toNewZone) {
|
|
emit contentSizeChanged();
|
|
}
|
|
return result;
|
|
}
|
|
|
|
int TableZoneLogic::clampValidTableRow(const int row)
|
|
{
|
|
if (row < 0) {
|
|
return 0;
|
|
}
|
|
if (row >= ROW_COUNT) {
|
|
return ROW_COUNT - 1;
|
|
}
|
|
return row;
|
|
}
|
|
|
|
int TableZoneLogic::tableRowToGridY(int tableRow)
|
|
{
|
|
if (tableRow > 2) {
|
|
tableRow = 1;
|
|
}
|
|
return clampValidTableRow(2 - tableRow);
|
|
}
|