reset card p/t when empty string is sent

This commit is contained in:
Max-Wilhelm Bruker 2011-03-12 20:43:12 +01:00
parent 480d2730c6
commit be7779a466

View file

@ -80,25 +80,30 @@ void Server_Card::setCounter(int id, int value)
void Server_Card::setPT(const QString &_pt) void Server_Card::setPT(const QString &_pt)
{ {
int sep = _pt.indexOf('/'); if (_pt.isEmpty()) {
QString p1 = _pt.left(sep); power = 0;
QString p2 = _pt.mid(sep + 1); toughness = -1;
if (p1.isEmpty() || p2.isEmpty()) } else {
return; int sep = _pt.indexOf('/');
if ((p1[0] == '+') || (p2[0] == '+')) { QString p1 = _pt.left(sep);
if (power < 0) QString p2 = _pt.mid(sep + 1);
power = 0; if (p1.isEmpty() || p2.isEmpty())
if (toughness < 0) return;
toughness = 0; if ((p1[0] == '+') || (p2[0] == '+')) {
if (power < 0)
power = 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();
} }
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 QString Server_Card::getPT() const