From d757cb9124fd56118afccf332d5ebd5219f4997f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Mon, 18 May 2026 11:19:49 +0200 Subject: [PATCH] Move stuff into .cpp Took 14 minutes --- cockatrice/src/game/board/card_state.cpp | 110 ++++++++++++++++++++++ cockatrice/src/game/board/card_state.h | 113 +++-------------------- 2 files changed, 124 insertions(+), 99 deletions(-) diff --git a/cockatrice/src/game/board/card_state.cpp b/cockatrice/src/game/board/card_state.cpp index da8880e0f..31f5519b4 100644 --- a/cockatrice/src/game/board/card_state.cpp +++ b/cockatrice/src/game/board/card_state.cpp @@ -1 +1,111 @@ #include "card_state.h" + +void CardState::resetState(bool keepAnnotations) +{ + attacking = false; + counters.clear(); + pt.clear(); + if (!keepAnnotations) { + annotation.clear(); + } + attachedTo = nullptr; +} + +void CardState::setZone(CardZoneLogic *_zone) +{ + if (zone == _zone) { + return; + } + + zone = _zone; + emit zoneChanged(zone); + emit stateChanged(); +} + +void CardState::setAttacking(bool v) +{ + if (attacking == v) { + return; + } + attacking = v; + emit attackingChanged(v); + emit stateChanged(); +} + +void CardState::insertCounter(int id, int value) +{ + counters.insert(id, value); + + emit countersChanged(); + emit stateChanged(); +} + +void CardState::setCounter(int id, int value) +{ + if (value) { + counters[id] = value; + } else { + counters.remove(id); + } + + emit countersChanged(); + emit stateChanged(); +} + +void CardState::clearCounters() +{ + counters.clear(); + emit countersChanged(); + emit stateChanged(); +} + +void CardState::setAnnotation(const QString &a) +{ + if (annotation == a) { + return; + } + annotation = a; + emit annotationChanged(); + emit stateChanged(); +} + +void CardState::setPT(const QString &v) +{ + if (pt == v) { + return; + } + pt = v; + emit ptChanged(); + emit stateChanged(); +} + +void CardState::setDoesntUntap(bool v) +{ + if (doesntUntap == v) { + return; + } + doesntUntap = v; + emit doesntUntapChanged(v); + emit stateChanged(); +} + +void CardState::setDestroyOnZoneChange(bool v) +{ + if (destroyOnZoneChange == v) { + return; + } + + destroyOnZoneChange = v; + emit destroyOnZoneChangeChanged(v); + emit stateChanged(); +} + +void CardState::setAttachedTo(CardItem *c) +{ + if (attachedTo == c) { + return; + } + attachedTo = c; + emit attachedToChanged(c); + emit stateChanged(); +} \ No newline at end of file diff --git a/cockatrice/src/game/board/card_state.h b/cockatrice/src/game/board/card_state.h index 379f8fa6b..671c77429 100644 --- a/cockatrice/src/game/board/card_state.h +++ b/cockatrice/src/game/board/card_state.h @@ -38,151 +38,66 @@ public: { } - void resetState(bool keepAnnotations) - { - attacking = false; - counters.clear(); - pt.clear(); - if (!keepAnnotations) { - annotation.clear(); - } - attachedTo = nullptr; - } + void resetState(bool keepAnnotations); CardZoneLogic *getZone() const { return zone; } - void setZone(CardZoneLogic *_zone) - { - if (zone == _zone) { - return; - } - - zone = _zone; - emit zoneChanged(zone); - emit stateChanged(); - } + void setZone(CardZoneLogic *_zone); bool getAttacking() const { return attacking; } - void setAttacking(bool v) - { - if (attacking == v) { - return; - } - attacking = v; - emit attackingChanged(v); - emit stateChanged(); - } + void setAttacking(bool v); const QMap &getCounters() const { return counters; } - void insertCounter(int id, int value) - { - counters.insert(id, value); + void insertCounter(int id, int value); - emit countersChanged(); - emit stateChanged(); - } + void setCounter(int id, int value); - void setCounter(int id, int value) - { - if (value) { - counters[id] = value; - } else { - counters.remove(id); - } - - emit countersChanged(); - emit stateChanged(); - } - - void clearCounters() - { - counters.clear(); - emit countersChanged(); - emit stateChanged(); - } + void clearCounters(); QString getAnnotation() const { return annotation; } - void setAnnotation(const QString &a) - { - if (annotation == a) { - return; - } - annotation = a; - emit annotationChanged(); - emit stateChanged(); - } + + void setAnnotation(const QString &a); QString getPT() const { return pt; } - void setPT(const QString &v) - { - if (pt == v) { - return; - } - pt = v; - emit ptChanged(); - emit stateChanged(); - } + + void setPT(const QString &v); bool getDoesntUntap() const { return doesntUntap; } - void setDoesntUntap(bool v) - { - if (doesntUntap == v) { - return; - } - doesntUntap = v; - emit doesntUntapChanged(v); - emit stateChanged(); - } + + void setDoesntUntap(bool v); bool getDestroyOnZoneChange() const { return destroyOnZoneChange; } - void setDestroyOnZoneChange(bool v) - { - if (destroyOnZoneChange == v) { - return; - } - - destroyOnZoneChange = v; - emit destroyOnZoneChangeChanged(v); - emit stateChanged(); - } + void setDestroyOnZoneChange(bool v); CardItem *getAttachedTo() const { return attachedTo; } - void setAttachedTo(CardItem *c) - { - if (attachedTo == c) { - return; - } - attachedTo = c; - emit attachedToChanged(c); - emit stateChanged(); - } + void setAttachedTo(CardItem *c); }; #endif // COCKATRICE_CARD_STATE_H