reset card p/t when empty string is sent
This commit is contained in:
parent
480d2730c6
commit
be7779a466
1 changed files with 23 additions and 18 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue