diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-12-24 10:52:15 -0500 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-12-24 10:52:15 -0500 |
| commit | 02f857a6b072bd7b74b8377d186350fbb7fa776a (patch) | |
| tree | 7b63618ba3ea46c6fb30c0276cb5cf65e2c46a0f | |
| parent | fad3ad4d5bc6e888eb769cb746f83e86ed6aff9c (diff) | |
Fixed up some checking in ItemType
| -rw-r--r-- | sigmod/ItemType.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/sigmod/ItemType.cpp b/sigmod/ItemType.cpp index d9d0d754..71bcf97e 100644 --- a/sigmod/ItemType.cpp +++ b/sigmod/ItemType.cpp @@ -59,6 +59,7 @@ void Sigmod::ItemType::validate() TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); + TEST(setComputer, computer); TEST(setPlayer, player); TEST(setMaxWeight, maxWeight); TEST_END(); @@ -92,12 +93,15 @@ void Sigmod::ItemType::setName(const QString& name) void Sigmod::ItemType::setComputer(const int computer) { - CHECK(computer); + if (computer < 0) + emit(error(bounds("computer"))); + else + CHECK(computer); } void Sigmod::ItemType::setPlayer(const int player) { - if (!player) + if (player <= 0) emit(error(bounds("player"))); else CHECK(player); @@ -105,9 +109,7 @@ void Sigmod::ItemType::setPlayer(const int player) void Sigmod::ItemType::setMaxWeight(const int maxWeight) { - if (sigmod()->rules()->maxTotalWeight() < maxWeight) - emit(error(bounds("maxWeight"))); - else if (maxWeight < 0) + if ((maxWeight < 0) || (sigmod()->rules()->maxTotalWeight() < maxWeight)) emit(error(bounds("maxWeight"))); else CHECK(maxWeight); |
