From 64730b32e2c595469eb23e9cd40332b4a80e3e27 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Thu, 25 Sep 2008 22:55:25 +0000 Subject: [FIX] Removed *_End defines [FIX] Added weights to items and associated fields [FIX] Option for pausing during ATB battles when choosing moves added git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@267 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- sigmod/MapTrainerTeamMember.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'sigmod/MapTrainerTeamMember.cpp') diff --git a/sigmod/MapTrainerTeamMember.cpp b/sigmod/MapTrainerTeamMember.cpp index beab6d54..595277df 100644 --- a/sigmod/MapTrainerTeamMember.cpp +++ b/sigmod/MapTrainerTeamMember.cpp @@ -144,8 +144,13 @@ void Sigmod::MapTrainerTeamMember::setItem(const int item, const bool state) { if (m_item.size() < qobject_cast(sigmod())->rules()->maxHeldItems()) { - m_item.append(item); - emit(changed()); + if (checkWeight(item)) + { + m_item.append(item); + emit(changed()); + } + else + emit(error("Cannot carry that much weight")); } else emit(error("Cannot hold any more items")); @@ -271,3 +276,18 @@ Sigmod::MapTrainerTeamMember& Sigmod::MapTrainerTeamMember::operator=(const MapT COPY(nature); return *this; } + +bool Sigmod::MapTrainerTeamMember::checkWeight(const int item) +{ + const int speciesIndex = qobject_cast(sigmod())->speciesIndex(m_species); + if (speciesIndex == INT_MAX) + return true; + int totalWeight = qobject_cast(sigmod())->itemById(item)->weight(); + foreach (int item, m_item) + { + const int itemIndex = qobject_cast(sigmod())->itemIndex(item); + if (itemIndex != INT_MAX) + totalWeight += qobject_cast(sigmod())->item(itemIndex)->weight(); + } + return (totalWeight <= qobject_cast(sigmod())->species(speciesIndex)->maxHoldWeight()); +} -- cgit