Rev | Line | |
---|
[2293] | 1 | #include "Item.h" |
---|
[2294] | 2 | #include "ShipEquipment.h" |
---|
[2289] | 3 | |
---|
| 4 | |
---|
| 5 | namespace orxonox |
---|
| 6 | { |
---|
[2293] | 7 | bool ShipEquipment::insert(Item* item) |
---|
[2289] | 8 | { |
---|
[2290] | 9 | if(checkSlot(player)==true) |
---|
| 10 | Equipment.insert ( std::pair<std::string, Item*>(item->getName(),item) ); |
---|
| 11 | else |
---|
| 12 | COUT(3) << "swap?" << std::endl; |
---|
| 13 | |
---|
| 14 | }; |
---|
[2293] | 15 | bool ShipEquipment::erase (Item* item) |
---|
[2290] | 16 | { |
---|
| 17 | if(Equipment.find(item->getName())!= Equipment.end()) |
---|
| 18 | { |
---|
| 19 | std::multimap<std::string,Item*>::iterator it; |
---|
| 20 | it=Equipment.find(item->getName()); |
---|
| 21 | Equipment.erase (it); |
---|
| 22 | return true; |
---|
| 23 | } |
---|
| 24 | else |
---|
| 25 | return false; |
---|
| 26 | }; |
---|
[2293] | 27 | bool ShipEquipment::checkSlot(Item* item) const |
---|
[2290] | 28 | { |
---|
| 29 | std::multimap<std::string,Item*>::iterator it; |
---|
| 30 | for ( it=Equipment.begin() ; it != Equipment.end(); it++ ) |
---|
| 31 | { |
---|
| 32 | if((*it).second->playerBaseClass_==item->playerBaseClass_) |
---|
| 33 | return false; |
---|
[2289] | 34 | } |
---|
[2290] | 35 | return true; |
---|
| 36 | }; |
---|
[2289] | 37 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.