mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-17 04:27:45 -07:00
Lots of todos but it compiles.
Took 3 hours 38 minutes Took 11 seconds Took 9 minutes Took 2 minutes Took 22 minutes Took 43 minutes Took 4 minutes Took 31 minutes Took 7 seconds Took 1 minute [Game][Player] Pull out graphics_items out of player_logic Took 3 minutes Took 24 seconds Took 5 minutes Took 19 minutes Took 7 minutes Took 32 seconds Took 3 minutes Took 14 minutes Took 5 seconds Took 28 minutes Took 5 minutes Took 28 minutes Took 7 seconds Took 12 minutes Took 20 minutes Took 2 minutes
This commit is contained in:
parent
0f3e6fbe26
commit
0cfffdf9df
62 changed files with 789 additions and 699 deletions
|
|
@ -1,5 +1,43 @@
|
|||
#include "card_state.h"
|
||||
|
||||
#include "../player/player_logic.h"
|
||||
#include "../zones/card_zone_logic.h"
|
||||
|
||||
CardState::CardState(PlayerLogic *_owner, const CardRef &cardRef, int _id, CardZoneLogic *_zone)
|
||||
: AbstractCardState(_owner, cardRef, _id), zone(_zone)
|
||||
{
|
||||
owner->addCard(this);
|
||||
}
|
||||
|
||||
void CardState::prepareDelete()
|
||||
{
|
||||
while (!attachedCards.isEmpty()) {
|
||||
attachedCards.first()->setZone(nullptr); // so that it won't try to call reorganizeCards()
|
||||
attachedCards.first()->setAttachedTo(nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void CardState::processCardInfo(const ServerInfo_Card &_info)
|
||||
{
|
||||
clearCounters();
|
||||
const int counterListSize = _info.counter_list_size();
|
||||
for (int i = 0; i < counterListSize; ++i) {
|
||||
const ServerInfo_CardCounter &counterInfo = _info.counter_list(i);
|
||||
insertCounter(counterInfo.id(), counterInfo.value());
|
||||
}
|
||||
|
||||
setId(_info.id());
|
||||
setCardRef({QString::fromStdString(_info.name()), QString::fromStdString(_info.provider_id())});
|
||||
setAttacking(_info.attacking());
|
||||
setFaceDown(_info.face_down());
|
||||
setPT(QString::fromStdString(_info.pt()));
|
||||
setAnnotation(QString::fromStdString(_info.annotation()));
|
||||
setColor(QString::fromStdString(_info.color()));
|
||||
setTapped(_info.tapped());
|
||||
setDestroyOnZoneChange(_info.destroy_on_zone_change());
|
||||
setDoesntUntap(_info.doesnt_untap());
|
||||
}
|
||||
|
||||
void CardState::resetState(bool keepAnnotations)
|
||||
{
|
||||
attacking = false;
|
||||
|
|
@ -11,6 +49,11 @@ void CardState::resetState(bool keepAnnotations)
|
|||
attachedTo = nullptr;
|
||||
}
|
||||
|
||||
void CardState::clearAttachedCards()
|
||||
{
|
||||
attachedCards.clear();
|
||||
}
|
||||
|
||||
void CardState::setZone(CardZoneLogic *_zone)
|
||||
{
|
||||
if (zone == _zone) {
|
||||
|
|
@ -100,7 +143,7 @@ void CardState::setDestroyOnZoneChange(bool _destroyOnZoneChange)
|
|||
emit stateChanged();
|
||||
}
|
||||
|
||||
void CardState::setAttachedTo(CardItem *_attachedTo)
|
||||
void CardState::setAttachedTo(CardState *_attachedTo)
|
||||
{
|
||||
if (attachedTo == _attachedTo) {
|
||||
return;
|
||||
|
|
@ -108,4 +151,40 @@ void CardState::setAttachedTo(CardItem *_attachedTo)
|
|||
attachedTo = _attachedTo;
|
||||
emit attachedToChanged(_attachedTo);
|
||||
emit stateChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void CardItem::setAttachedTo(CardItem *_attachedTo)
|
||||
{
|
||||
if (state->getAttachedTo() != nullptr) {
|
||||
state->getAttachedTo()->removeAttachedCard(this);
|
||||
}
|
||||
|
||||
gridPoint.setX(-1);
|
||||
state->setAttachedTo(_attachedTo);
|
||||
if (state->getAttachedTo() != nullptr) {
|
||||
// If the zone is being torn down, it might already be null by the time a card tries to un-attach all its
|
||||
// attached cards
|
||||
if (state->getAttachedTo()->getState()->getZone() == nullptr) {
|
||||
deleteLater();
|
||||
} else {
|
||||
emit state->getAttachedTo()->getState()->getZone()->cardAdded(this);
|
||||
state->getAttachedTo()->addAttachedCard(this);
|
||||
if (state->getZone() != state->getAttachedTo()->getState()->getZone()) {
|
||||
state->getAttachedTo()->getState()->getZone()->reorganizeCards();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// If the zone is being torn down, it might already be null by the time a card tries to un-attach all its
|
||||
// attached cards
|
||||
if (state->getZone() == nullptr) {
|
||||
deleteLater();
|
||||
} else {
|
||||
emit state->getZone()->cardAdded(this);
|
||||
}
|
||||
}
|
||||
|
||||
if (state->getZone() != nullptr) {
|
||||
state->getZone()->reorganizeCards();
|
||||
}
|
||||
}*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue