Skip to content
Snippets Groups Projects
Commit fb24ddd1 authored by Mikhail Andrenkov's avatar Mikhail Andrenkov
Browse files

Merged TeX

parents ed18b132 53a51db2
No related branches found
No related tags found
No related merge requests found
No preview for this file type
This diff is collapsed.
...@@ -13,4 +13,8 @@ Coord Feature::getLocation() { ...@@ -13,4 +13,8 @@ Coord Feature::getLocation() {
return this->location; return this->location;
} }
void Feature::setLocation(Coord newLoc) {
this->location = newLoc;
}
Feature::~Feature() {} Feature::~Feature() {}
...@@ -7,6 +7,7 @@ class Feature { ...@@ -7,6 +7,7 @@ class Feature {
Feature(char, Coord); Feature(char, Coord);
char getSymbol(); char getSymbol();
Coord getLocation(); Coord getLocation();
void setLocation(Coord);
virtual ~Feature(); virtual ~Feature();
private: private:
Coord location; Coord location;
......
...@@ -22,6 +22,7 @@ class Item : public Feature { ...@@ -22,6 +22,7 @@ class Item : public Feature {
bool operator<(const Item&) const; bool operator<(const Item&) const;
Context getContext(); Context getContext();
void setContext(Context);
std::string getDisplayName(); std::string getDisplayName();
std::string getName(); std::string getName();
int getType(); int getType();
......
...@@ -3,20 +3,20 @@ ...@@ -3,20 +3,20 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "armor.h"
#include "coord.h" #include "coord.h"
#include "food.h"
#include "goldpile.h" #include "goldpile.h"
#include "item.h"
#include "itemzone.h" #include "itemzone.h"
#include "mob.h" #include "mob.h"
#include "potion.h"
#include "ring.h"
#include "scroll.h"
#include "weapon.h"
#include "wand.h"
class Level; class Level;
class Food;
class Item;
class Ring;
class Weapon;
class Armor;
class Wand;
class Scroll;
class Potion;
class PlayerChar : public Mob { class PlayerChar : public Mob {
public: public:
...@@ -26,7 +26,7 @@ class PlayerChar : public Mob { ...@@ -26,7 +26,7 @@ class PlayerChar : public Mob {
void attack(Mob*); void attack(Mob*);
int calculateDamage(); int calculateDamage();
void collectGold(GoldPile*); void collectGold(GoldPile*);
bool dropItem(Item*); bool dropItem(Item*, Level*);
void eat(Food*); void eat(Food*);
void equipArmor(Armor*); void equipArmor(Armor*);
void equipRingLeft(Ring*); void equipRingLeft(Ring*);
......
...@@ -38,6 +38,10 @@ Item::Context Item::getContext() { ...@@ -38,6 +38,10 @@ Item::Context Item::getContext() {
return this->context; return this->context;
} }
void Item::setContext(Item::Context newContext) {
this->context = newContext;
}
std::string Item::getDisplayName() { std::string Item::getDisplayName() {
if (Item::identified[this->className].find(this->type) == Item::identified[this->className].end()) { if (Item::identified[this->className].find(this->type) == Item::identified[this->className].end()) {
return this->pseudoName; return this->pseudoName;
......
...@@ -11,6 +11,11 @@ ...@@ -11,6 +11,11 @@
#include "include/playerchar.h" #include "include/playerchar.h"
#include "include/ring.h" #include "include/ring.h"
#include "include/weapon.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) PlayerChar::PlayerChar(Coord location, std::string name)
: Mob('@', location, name, START_ARMOR, START_EXP, START_LEVEL, START_HP), : Mob('@', location, name, START_ARMOR, START_EXP, START_LEVEL, START_HP),
...@@ -60,7 +65,7 @@ void PlayerChar::collectGold(GoldPile* goldpile) { ...@@ -60,7 +65,7 @@ void PlayerChar::collectGold(GoldPile* goldpile) {
this->gold += goldpile->getQuantity(); this->gold += goldpile->getQuantity();
} }
bool PlayerChar::dropItem(Item* item) { bool PlayerChar::dropItem(Item* item, Level* level) {
if (this->itemArmor == item || if (this->itemArmor == item ||
this->itemRingLeft == item || this->itemRingLeft == item ||
this->itemRingRight == item || this->itemRingRight == item ||
...@@ -70,6 +75,9 @@ bool PlayerChar::dropItem(Item* item) { ...@@ -70,6 +75,9 @@ bool PlayerChar::dropItem(Item* item) {
std::cout << "PlayerChar Dropped Item " << item->getName() << "\n"; std::cout << "PlayerChar Dropped Item " << item->getName() << "\n";
this->inventory.remove(item); this->inventory.remove(item);
item->setContext(Item::FLOOR);
item->setLocation(getLocation());
level->getFeatures().push_back(item);
return true; 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