mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
rework pt setting (#3584)
* rework pt setting save pt as a string serverside set the pt of cards that enter the battlefield to empty (was -1/0) implement old behaviour as changePT clientside display old pt to messagelog add new keybind for new set behaviour (default ctrl+shift+p) add flow pt actions and keybinds that increase while decreasing put more braces everywhere various refactors like adding consts and for loops remove a single superfluous semicolon does not change the way pt is displayed client side does not fix 3455 fully * fix drawing of pt remove search for / in carditem's paint() (crash) ptstring is now always orange unless it's a faceup card with a pt that matches the cardinfo pt set changept to remove the pt if the field is empty set changept to keep the old value if one side is empty return in changept for +0/+0 clean up some if statements * return on change to +0/+0 * change log message for empty original pts * typo * remove changept add parsept to unify reading pt strings change setpt behavior to be an "upgraded" version of the old setpt add arbitrary strings as anything that starts with / * clangify * remove debug lines * add tip of the day * add missing images * clangify
This commit is contained in:
parent
18ad3cf4a5
commit
9411396b97
13 changed files with 831 additions and 498 deletions
|
|
@ -24,8 +24,7 @@
|
|||
|
||||
Server_Card::Server_Card(QString _name, int _id, int _coord_x, int _coord_y, Server_CardZone *_zone)
|
||||
: zone(_zone), id(_id), coord_x(_coord_x), coord_y(_coord_y), name(_name), tapped(false), attacking(false),
|
||||
facedown(false), color(QString()), power(-1), toughness(-1), annotation(QString()), destroyOnZoneChange(false),
|
||||
doesntUntap(false), parentCard(0)
|
||||
facedown(false), color(), ptString(), annotation(), destroyOnZoneChange(false), doesntUntap(false), parentCard(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -44,8 +43,7 @@ void Server_Card::resetState()
|
|||
counters.clear();
|
||||
setTapped(false);
|
||||
setAttacking(false);
|
||||
power = -1;
|
||||
toughness = -1;
|
||||
setPT(QString());
|
||||
setAnnotation(QString());
|
||||
setDoesntUntap(false);
|
||||
}
|
||||
|
|
@ -89,40 +87,6 @@ void Server_Card::setCounter(int id, int value)
|
|||
counters.remove(id);
|
||||
}
|
||||
|
||||
void Server_Card::setPT(const QString &_pt)
|
||||
{
|
||||
if (_pt.isEmpty()) {
|
||||
power = 0;
|
||||
toughness = -1;
|
||||
} else {
|
||||
int sep = _pt.indexOf('/');
|
||||
QString p1 = _pt.left(sep);
|
||||
QString p2 = _pt.mid(sep + 1);
|
||||
if (p1.isEmpty() || p2.isEmpty())
|
||||
return;
|
||||
|
||||
if ((p1[0] == '+') || (p2[0] == '+'))
|
||||
if (toughness < 0)
|
||||
toughness = 0;
|
||||
if (p1[0] == '+')
|
||||
power += p1.mid(1).toInt();
|
||||
else
|
||||
power = p1.toInt();
|
||||
|
||||
if (p2[0] == '+')
|
||||
toughness += p2.mid(1).toInt();
|
||||
else
|
||||
toughness = p2.toInt();
|
||||
}
|
||||
}
|
||||
|
||||
QString Server_Card::getPT() const
|
||||
{
|
||||
if (toughness < 0)
|
||||
return QString("");
|
||||
return QString::number(power) + "/" + QString::number(toughness);
|
||||
}
|
||||
|
||||
void Server_Card::setParentCard(Server_Card *_parentCard)
|
||||
{
|
||||
if (parentCard)
|
||||
|
|
@ -140,24 +104,28 @@ void Server_Card::getInfo(ServerInfo_Card *info)
|
|||
info->set_name(displayedName.toStdString());
|
||||
info->set_x(coord_x);
|
||||
info->set_y(coord_y);
|
||||
QString ptStr = getPT();
|
||||
if (facedown) {
|
||||
info->set_face_down(true);
|
||||
ptStr = getPT();
|
||||
}
|
||||
info->set_tapped(tapped);
|
||||
if (attacking)
|
||||
if (attacking) {
|
||||
info->set_attacking(true);
|
||||
if (!color.isEmpty())
|
||||
}
|
||||
if (!color.isEmpty()) {
|
||||
info->set_color(color.toStdString());
|
||||
if (!ptStr.isEmpty())
|
||||
info->set_pt(ptStr.toStdString());
|
||||
if (!annotation.isEmpty())
|
||||
}
|
||||
if (!ptString.isEmpty()) {
|
||||
info->set_pt(ptString.toStdString());
|
||||
}
|
||||
if (!annotation.isEmpty()) {
|
||||
info->set_annotation(annotation.toStdString());
|
||||
if (destroyOnZoneChange)
|
||||
}
|
||||
if (destroyOnZoneChange) {
|
||||
info->set_destroy_on_zone_change(true);
|
||||
if (doesntUntap)
|
||||
}
|
||||
if (doesntUntap) {
|
||||
info->set_doesnt_untap(true);
|
||||
}
|
||||
|
||||
QMapIterator<int, int> cardCounterIterator(counters);
|
||||
while (cardCounterIterator.hasNext()) {
|
||||
|
|
@ -172,4 +140,4 @@ void Server_Card::getInfo(ServerInfo_Card *info)
|
|||
info->set_attach_zone(parentCard->getZone()->getName().toStdString());
|
||||
info->set_attach_card_id(parentCard->getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue