Skip to content
Snippets Groups Projects
Commit 98996fba authored by Ian Prins's avatar Ian Prins
Browse files

implement item dropping

parent f9349347
No related branches found
No related tags found
No related merge requests found
......@@ -3,20 +3,20 @@
#include <string>
#include <vector>
#include "armor.h"
#include "coord.h"
#include "food.h"
#include "goldpile.h"
#include "item.h"
#include "itemzone.h"
#include "mob.h"
#include "potion.h"
#include "ring.h"
#include "scroll.h"
#include "weapon.h"
#include "wand.h"
class Level;
class Food;
class Item;
class Ring;
class Weapon;
class Armor;
class Wand;
class Scroll;
class Potion;
class PlayerChar : public Mob {
public:
......@@ -26,7 +26,7 @@ class PlayerChar : public Mob {
void attack(Mob*);
int calculateDamage();
void collectGold(GoldPile*);
bool dropItem(Item*);
bool dropItem(Item*, Level*);
void eat(Food*);
void equipArmor(Armor*);
void equipRingLeft(Ring*);
......
......@@ -11,6 +11,11 @@
#include "include/playerchar.h"
#include "include/ring.h"
#include "include/weapon.h"
#include "include/level.h"
#include "include/wand.h"
#include "include/food.h"
#include "include/scroll.h"
#include "include/potion.h"
PlayerChar::PlayerChar(Coord location, std::string name)
: Mob('@', location, name, START_ARMOR, START_EXP, START_LEVEL, START_HP),
......@@ -60,7 +65,7 @@ void PlayerChar::collectGold(GoldPile* goldpile) {
this->gold += goldpile->getQuantity();
}
bool PlayerChar::dropItem(Item* item) {
bool PlayerChar::dropItem(Item* item, Level* level) {
if (this->itemArmor == item ||
this->itemRingLeft == item ||
this->itemRingRight == item ||
......@@ -70,6 +75,9 @@ bool PlayerChar::dropItem(Item* item) {
std::cout << "PlayerChar Dropped Item " << item->getName() << "\n";
this->inventory.remove(item);
item->setContext(Item::FLOOR);
item->setLocation(getLocation());
level->getFeatures().push_back(item);
return true;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment