1 | #include "Item.h" |
---|
2 | #include "ShipEquipment.h" |
---|
3 | #include "objects/worldentities/pawns/Pawn.h" |
---|
4 | |
---|
5 | |
---|
6 | namespace orxonox |
---|
7 | { |
---|
8 | |
---|
9 | bool ShipEquipment::insert(Item* item) |
---|
10 | { |
---|
11 | if(checkSlot(item)==true) |
---|
12 | { |
---|
13 | Equipment.insert ( std::pair<std::string, Item*>(item->getName(),item) ); |
---|
14 | return true; |
---|
15 | } |
---|
16 | COUT(3) << "swap?" << std::endl; |
---|
17 | return false; |
---|
18 | |
---|
19 | return false; |
---|
20 | }; |
---|
21 | bool ShipEquipment::erase (Item* item) |
---|
22 | { |
---|
23 | std::multimap<std::string,Item*>::iterator it = Equipment.find(item->getName()); |
---|
24 | if(it != Equipment.end()) |
---|
25 | { |
---|
26 | Equipment.erase (it); |
---|
27 | return true; |
---|
28 | } |
---|
29 | return false; |
---|
30 | }; |
---|
31 | /*void print(std::multimap<std::string, Item*> eut) |
---|
32 | { |
---|
33 | std::multimap<std::string,Item*>::iterator it; |
---|
34 | COUT(3) << "Liste:" << endl; |
---|
35 | for ( it=eut.begin() ; it != eut.end(); ++it ) |
---|
36 | COUT(3) << (*it).first << endl; |
---|
37 | |
---|
38 | }*/ |
---|
39 | void ShipEquipment::eraseAll() |
---|
40 | { |
---|
41 | //print(Equipment); |
---|
42 | for (std::multimap<std::string,Item*>::iterator it = Equipment.begin(); it != Equipment.end(); ) |
---|
43 | { |
---|
44 | |
---|
45 | (it++)->second->dropped(this->getPlayer()); |
---|
46 | } |
---|
47 | //print(Equipment); |
---|
48 | } |
---|
49 | |
---|
50 | bool ShipEquipment::checkSlot(Item* item) |
---|
51 | { |
---|
52 | std::multimap<std::string,Item*>::iterator it; |
---|
53 | for ( it= getPlayer()->getPickUp().getEquipment().begin() ; it != getPlayer()->getPickUp().getEquipment().end(); it++ ) |
---|
54 | { |
---|
55 | //if((*it).second->getPlayerBaseClass()==item->getPlayerBaseClass()) |
---|
56 | if(item->isExactlyA((*it).second->getIdentifier())) |
---|
57 | return false; |
---|
58 | } |
---|
59 | return true; |
---|
60 | }; |
---|
61 | } |
---|