diff --git a/Doc/TestPlan/TestPlan.pdf b/Doc/TestPlan/TestPlan.pdf index f17799862fa3d13cb64c8afd9d17dbf4c5e91832..bf12dc6e73ed23c3e8c88351fdf7dfe41014ce6e 100644 Binary files a/Doc/TestPlan/TestPlan.pdf and b/Doc/TestPlan/TestPlan.pdf differ diff --git a/Doc/TestPlan/TestPlan.pdf.orig b/Doc/TestPlan/TestPlan.pdf.orig new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/Doc/TestPlan/TestPlan.tex b/Doc/TestPlan/TestPlan.tex index b29640b0548c6bc627ae6c82e6b20f4de1a5a85e..bae79c4914b55c85784d8f9301a6abce0b5ba084 100644 --- a/Doc/TestPlan/TestPlan.tex +++ b/Doc/TestPlan/TestPlan.tex @@ -127,7 +127,8 @@ 10/26/16 & 0.4.1 & Added Test Template \\ 10/30/16 & 0.5 & Added Non-Functional Req. Tests \\ 10/30/16 & 0.5.1 & Added Bibliography \\ - 10/31/16 & 0.6 & Switch PoC to test template \\ + 10/31/16 & 0.6 & Switch PoC to Test Template \\ + 10/31/16 & 0.7 & Add Name to Test Template \\ \bottomrule \end{tabularx} \end{table} @@ -338,55 +339,56 @@ \subsubsection{Look and Feel Requirements} % Appearance - \test{N}{Aesthetic Similarity}{Dynamic}{Manual}{Black}{Generic State}{Users are asked to rate the aesthetic similarity between \textit{Rogue} and Rogue Reborn.}{A numeric quantity between 0 and 10, where 0 indicates that the graphics are entirely disjoint and 10 indicates that the graphics are virtually indistinguishable.}{A random sample of users will be asked to play \textit{Rogue} and the Rogue Reborn variant for \hyperref[symbolicParameters]{PLAYTEST\_SHORT\_TIME} minutes. Afterwards, they will be asked to judge the graphical similarity of the games based on the aforementioned scale.} + \test{N}{Aesthetic Similarity Check}{Dynamic}{Manual}{Black}{Generic State}{Users are asked to rate the aesthetic similarity between \textit{Rogue} and Rogue Reborn.}{A numeric quantity between 0 and 10, where 0 indicates that the graphics are entirely disjoint and 10 indicates that the graphics are virtually indistinguishable.}{A random sample of users will be asked to play \textit{Rogue} and the Rogue Reborn variant for \hyperref[symbolicParameters]{PLAYTEST\_SHORT\_TIME} minutes. Afterwards, they will be asked to judge the graphical similarity of the games based on the aforementioned scale.} \subsubsection{Usability and Humanity Requirements} % Ease of Use - \test{N}{Interest Gauge}{Dynamic}{Manual}{Black}{Generic State}{New users are instructed to play Rogue Reborn.}{The quantity of time the user willingly decides to play the game.}{A random sample of users who are unfamiliar with \textit{Rogue} will be asked to play Rogue Reborn until they feel bored (or \hyperref[symbolicParameters]{MAXIMUM\_ENTERTAINMENT\_TIME} has expired). Once the user indicates that they are no longer interested in the game, their playing time will be recorded.} + \test{N}{Interest Gauge Check}{Dynamic}{Manual}{Black}{Generic State}{New users are instructed to play Rogue Reborn.}{The quantity of time the user willingly decides to play the game.}{A random sample of users who are unfamiliar with \textit{Rogue} will be asked to play Rogue Reborn until they feel bored (or \hyperref[symbolicParameters]{MAXIMUM\_ENTERTAINMENT\_TIME} has expired). Once the user indicates that they are no longer interested in the game, their playing time will be recorded.} % Personalization and Internationalization - \test{N}{English Check}{Static}{Manual}{White}{Developer State}{Rogue Reborn source code.}{An approximation of the English spelling, punctuation, and grammar mistakes that are visible through the GUI.}{All strings in the Rogue Reborn source code will be concatenated with a newline delimiter and outputted to a text file. A modern edition of Microsoft Word from ~\citep{MicrosoftWord} will be used to open this generated text file, and a developer will manually correct all of the indicated errors that are potentially associated with a GUI output.} + \test{N}{English Mechanics Check}{Static}{Manual}{White}{Developer State}{Rogue Reborn source code.}{An approximation of the English spelling, punctuation, and grammar mistakes that are visible through the GUI.}{All strings in the Rogue Reborn source code will be concatenated with a newline delimiter and outputted to a text file. A modern edition of Microsoft Word from ~\citep{MicrosoftWord} will be used to open this generated text file, and a developer will manually correct all of the indicated errors that are potentially associated with a GUI output.} % Learning - \test{N}{Key Comfort}{Dynamic}{Manual}{Black}{Generic State}{Users are asked to rate the intuitiveness of the Rogue Reborn key bindings.}{A numeric quantity between 0 and 10, where 0 indicates that the key bindings are extremely confusing and 10 indicates that the key bindings are perfectly natural.}{A random sample of users who are inexperienced with the roguelike genre will be asked to play Rogue Reborn for \hyperref[symbolicParameters]{SHORT\_TIME} minutes without viewing the in-game help screen. Next, the key bindings will be revealed, and the users will continue to play the game for an additional \hyperref[symbolicParameters]{PLAYTEST\_SHORT\_TIME} minutes. Afterwards, they will be asked to judge the quality of the key bindings based on the aforementioned scale} + \test{N}{Key Comfort Check}{Dynamic}{Manual}{Black}{Generic State}{Users are asked to rate the intuitiveness of the Rogue Reborn key bindings.}{A numeric quantity between 0 and 10, where 0 indicates that the key bindings are extremely confusing and 10 indicates that the key bindings are perfectly natural.}{A random sample of users who are inexperienced with the roguelike genre will be asked to play Rogue Reborn for \hyperref[symbolicParameters]{SHORT\_TIME} minutes without viewing the in-game help screen. Next, the key bindings will be revealed, and the users will continue to play the game for an additional \hyperref[symbolicParameters]{PLAYTEST\_SHORT\_TIME} minutes. Afterwards, they will be asked to judge the quality of the key bindings based on the aforementioned scale} \subsubsection{Performance Requirements} % Speed and Latency - \test{N}{Response Delay}{Dynamic}{Automatic}{White}{Generic State}{Users are instructed to play Rogue Reborn.}{A log of occurrences that indicate events where a computation that was initiated by a user input took an excessive quantity of time to execute.}{A random sample of experienced users will be asked to play a special version of Rogue Reborn for \hyperref[symbolicParameters]{PLAYTEST\_MEDIUM\_RANGE} minutes. This edition will utilize a StopWatch implementation to measure the execution time of a computation, and if the computation exceeds \hyperref[symbolicParameters]{RESPONSE\_SPEED} milliseconds, the user action and the associated timestamp will be recorded in a log file.} + \test{N}{Response Delay Check}{Dynamic}{Automatic}{White}{Generic State}{Users are instructed to play Rogue Reborn.}{A log of occurrences that indicate events where a computation that was initiated by a user input took an excessive quantity of time to execute.}{A random sample of experienced users will be asked to play a special version of Rogue Reborn for \hyperref[symbolicParameters]{PLAYTEST\_MEDIUM\_RANGE} minutes. This edition will utilize a StopWatch implementation to measure the execution time of a computation, and if the computation exceeds \hyperref[symbolicParameters]{RESPONSE\_SPEED} milliseconds, the user action and the associated timestamp will be recorded in a log file.} % Precision or Accuracy - \test{N}{Overflow Avoidance}{Static}{Manual}{White}{Developer State}{Rogue Reborn source code.}{All declarations of integer-typed variables.}{All occurrences of lines that match \hyperref[symbolicParameters]{REGEX\_INTEGER} (i.e., integer declarations) in the Rogue Reborn source code will be outputted to a file. A group of Rogue++ developers will then review these declarations together and alter them if deemed necessary to avoid integer overflow issues.} + \test{N}{Overflow Avoidance Check}{Static}{Manual}{White}{Developer State}{Rogue Reborn source code.}{All declarations of integer-typed variables.}{All occurrences of lines that match \hyperref[symbolicParameters]{REGEX\_INTEGER} (i.e., integer declarations) in the Rogue Reborn source code will be outputted to a file. A group of Rogue++ developers will then review these declarations together and alter them if deemed necessary to avoid integer overflow issues.} % Reliability or Availability - \test{N}{Crash Collection}{Dynamic}{Manual}{Black}{Generic State}{Playtesters are instructed to play Rogue Reborn for at least \hyperref[symbolicParameters]{PLAYTEST\_LONG\_TIME} hours.}{A collection of crash occurrences along with a detailed description of the failure environment.}{All Rogue Reborn playtesters will be required to play the game for at least \hyperref[symbolicParameters]{PLAYTEST\_LONG\_TIME} hours in total (spanned over multiple sessions if desired). Every time the application crashes, the playtester must record the incident along with a description of the visible GUI state and the steps required to reproduce the failure. After this data has been collected, the Rogue++ team will address every crash occurrence by either resolving the issue or confidently declaring that the event is irreproducible.} + \test{N}{Crash Collection Check}{Dynamic}{Manual}{Black}{Generic State}{Playtesters are instructed to play Rogue Reborn for at least \hyperref[symbolicParameters]{PLAYTEST\_LONG\_TIME} hours.}{A collection of crash occurrences along with a detailed description of the failure environment.}{All Rogue Reborn playtesters will be required to play the game for at least \hyperref[symbolicParameters]{PLAYTEST\_LONG\_TIME} hours in total (spanned over multiple sessions if desired). Every time the application crashes, the playtester must record the incident along with a description of the visible GUI state and the steps required to reproduce the failure. After this data has been collected, the Rogue++ team will address every crash occurrence by either resolving the issue or confidently declaring that the event is irreproducible.} % Capacity - \test{N}{Score Overflow}{Dynamic}{Dynamic}{White}{High Score State}{A high score record file containing a large quantity of entries.}{Rogue Reborn GUI displaying the top high scores.}{The Rogue Reborn developers will artificially fabricate a high score record file with at least \hyperref[symbolicParameters]{HIGH\_SCORE\_CAPACITY} + 2 records. The game will then be played until the high score screen is revealed; only the top \hyperref[symbolicParameters]{HIGH\_SCORE\_CAPACITY} scores should be displayed.} + \test{N}{Score Overflow Check}{Dynamic}{Dynamic}{White}{High Score State}{A high score record file containing a large quantity of entries.}{Rogue Reborn GUI displaying the top high scores.}{The Rogue Reborn developers will artificially fabricate a high score record file with at least \hyperref[symbolicParameters]{HIGH\_SCORE\_CAPACITY} + 2 records. The game will then be played until the high score screen is revealed; only the top \hyperref[symbolicParameters]{HIGH\_SCORE\_CAPACITY} scores should be displayed.} \subsubsection{Operational and Environment Requirements} % Expected Physical Environment - \test{N}{Processor Compatibility}{Dynamic}{Manual}{Black}{Fresh State}{Users are instructed to install and run Rogue Reborn on their personal machines.}{An indication of whether or not the game is able to successfully execute.}{A random sample of users with computers that are equipped with Intel x64 processors will be asked to download the latest Rogue Reborn distribution, perform any necessary installation, and then run the executable file. The user will then report if the game was able to successfully run on their machine.} + \test{N}{Processor Compatibility Check}{Dynamic}{Manual}{Black}{Fresh State}{Users are instructed to install and run Rogue Reborn on their personal machines.}{An indication of whether or not the game is able to successfully execute.}{A random sample of users with computers that are equipped with Intel x64 processors will be asked to download the latest Rogue Reborn distribution, perform any necessary installation, and then run the executable file. The user will then report if the game was able to successfully run on their machine.} % Productization - \test{N}{Streamline Packaging}{Static}{Manual}{Black}{Developer State}{Rogue Reborn distribution package.}{An indication of whether or not the distribution contains any files aside from the primary executable and the associated development licenses.}{The public distribution package will be visually inspected for extraneous files.} + \test{N}{Streamline Distribution Check}{Static}{Manual}{Black}{Developer State}{Rogue Reborn distribution package.}{An indication of whether or not the distribution contains any files aside from the primary executable and the associated development licenses.}{The public distribution package will be visually inspected for extraneous files.} \subsubsection{Maintainability Requirements} % Maintenance - \test{N}{Bug Productivity}{Static}{Manual}{Black}{Developer State}{All ITS issues labeled as bugs in the Rogue Reborn GitLab repository.}{An indication of whether or not all bug reports were closed within a month of their conception.}{The Rogue Reborn GitLab repository will be queried for all issues concerning bugs (which are denoted by a ``Bug'' label). Next, a developer will manually verify that every closed bug fix request was resolved within a month of its creation.} + \test{N}{Bug Productivity Check}{Static}{Manual}{Black}{Developer State}{All ITS issues labeled as bugs in the Rogue Reborn GitLab repository.}{An indication of whether or not all bug reports were closed within a month of their conception.}{The Rogue Reborn GitLab repository will be queried for all issues concerning bugs (which are denoted by a ``Bug'' label). Next, a developer will manually verify that every closed bug fix request was resolved within a month of its creation.} % Adaptability - \test{N}{Linux Compatibility}{Dynamic}{Manual}{Black}{Fresh State}{Users are instructed to run Rogue Reborn on their personal machine.}{An indication of whether the game can successfully execute.}{A random sample of users with computers that use a modern 64-bit Linux operating system will be asked to download the latest Rogue Reborn distribution, perform any necessary installation, and then run the executable file. The user will then report if the game was able to successfully run on their machine.} + \test{N}{Linux Compatibility Check}{Dynamic}{Manual}{Black}{Fresh State}{Users are instructed to run Rogue Reborn on their personal machine.}{An indication of whether the game can successfully execute.}{A random sample of users with computers that use a modern 64-bit Linux operating system will be asked to download the latest Rogue Reborn distribution, perform any necessary installation, and then run the executable file. The user will then report if the game was able to successfully run on their machine.} \subsubsection{Security Requirements} % Integrity - \test{N}{Illegal Records}{Dynamic}{Manual}{White}{Seasoned State}{A corrupted high score record file.}{Rogue Reborn GUI displaying the top high scores.}{The Rogue++ team will illegally modify a high score record file by manually altering or adding values such that the expected format or value integrity is violated. These modifications should include negative high score values, missing text, and incorrect delimiter usage. The game will then be played until the high score screen is revealed; all invalid record file contents should be ignored and amended in the next write to the record file.} + \test{N}{Illegal Records Check}{Dynamic}{Manual}{White}{Seasoned State}{A corrupted high score record file.}{Rogue Reborn GUI displaying the top high scores.}{The Rogue++ team will illegally modify a high score record file by manually altering or adding values such that the expected format or value integrity is violated. These modifications should include negative high score values, missing text, and incorrect delimiter usage. The game will then be played until the high score screen is revealed; all invalid record file contents should be ignored and amended in the next write to the record file.} \subsubsection{Legal Requirements} % Compliance - \test{N}{License Presence}{Static}{Manual}{Black}{Developer State}{Rogue Reborn distribution package.}{An indication of whether or not the distribution is missing any mandatory license files.}{The original \textit{Rogue} source code hosted by ~\citep{BSDRogue} will be reviewed for legal requirements, and the public distribution package will be visually inspected to ensure that all mandatory license files are present.} + \test{N}{License Presence Check}{Static}{Manual}{Black}{Developer State}{Rogue Reborn distribution package.}{An indication of whether or not the distribution is missing any mandatory license files.}{The original \textit{Rogue} source code hosted by ~\citep{BSDRogue} will be reviewed for legal requirements, and the public distribution package will be visually inspected to ensure that all mandatory license files are present.} \subsubsection{Health and Safety Requirements} - \test{N}{Seizure Prevention}{Dynamic}{Manual}{Black}{Developer State}{Two screenshots denoting the largest possible luminosity difference present between consecutive frames.}{The difference in luminosity between the two captured frames.}{After identifying the frame pair that is most likely to induce a seizure, the game will be played to reach the states that reflect each frame (this should be a brief process; no clever game model manipulation is required). At the occurrence of each desired frame, the game screen will be captured and saved. At this point, the average monochrome luminance across each frame will be calculated according to the formula \[L = 0.299R + 0.587G + 0.114B\] where $L$ is the luminance, $R$ is the red RGB component, $G$ is the green RGB component, and $B$ is the blue RGB component ~\citep{MonochromeLuminance}. Finally, the absolute value of the luminance difference can then compared to \hyperref[symbolicParameters]{LUMINOSITY\_DELTA}.} + % Seizure Prevention + \test{N}{Seizure Prevention Check}{Dynamic}{Manual}{Black}{Developer State}{Two screenshots denoting the largest possible luminosity difference present between consecutive frames.}{The difference in luminosity between the two captured frames.}{After identifying the frame pair that is most likely to induce a seizure, the game will be played to reach the states that reflect each frame (this should be a brief process; no clever game model manipulation is required). At the occurrence of each desired frame, the game screen will be captured and saved. At this point, the average monochrome luminance across each frame will be calculated according to the formula \[L = 0.299R + 0.587G + 0.114B\] where $L$ is the luminance, $R$ is the red RGB component, $G$ is the green RGB component, and $B$ is the blue RGB component ~\citep{MonochromeLuminance}. Finally, the absolute value of the luminance difference can then compared to \hyperref[symbolicParameters]{LUMINOSITY\_DELTA}.} \newpage \section{Tests for Proof of Concept} @@ -394,28 +396,28 @@ \subsection{Static Testing} - \test{P}{Name}{Static}{Automatic}{White}{None}{Program Source}{Program Executable}{Verify that the program compiles with g++.} + \test{P}{Compile Test}{Static}{Automatic}{White}{None}{Program Source}{Program Executable}{Verify that the program compiles with g++.} - \test{P}{Name}{Dynamic}{Manual}{White}{None}{A brief but complete playthrough of the game.}{Breakdown of program memory usage.}{A tester will briefly play the game, and a developer will use Valgrind's memcheck utility to verify that program does not leak memory or utilize uninitialized memory.} + \test{P}{Memory Check}{Dynamic}{Manual}{White}{None}{A brief but complete playthrough of the game.}{Breakdown of program memory usage.}{A tester will briefly play the game, and a developer will use Valgrind's memcheck utility to verify that program does not leak memory or utilize uninitialized memory.} \subsection{Rendering} - \test{P}{Name}{Dynamic}{Manual}l{Black}{Gameplay State}{30-60 seconds of gameplay.}{ The player character and any dungeon features should be shown at the correct location with the correct glyphs. Correct player statistics will be shown along the bottom. The dialog box will correctly display the log and any prompts.}{A tester will manually play the game and verify the display is correct.} + \test{P}{Render Check}{Dynamic}{Manual}l{Black}{Gameplay State}{30-60 seconds of gameplay.}{ The player character and any dungeon features should be shown at the correct location with the correct glyphs. Correct player statistics will be shown along the bottom. The dialog box will correctly display the log and any prompts.}{A tester will manually play the game and verify the display is correct.} \subsection{Dungeon Generation} - \test{P}{Name}{Dynamic}{Manual}{Black}{None}{Repeated restarts of the game}{Level should contain ROOMS\-PER\_LEVEL rooms, which should form a connected graph.}{A tester will manually start the game, briefly explore the level to verify correct generation, then repeat this process until confidence is achieved.} + \test{P}{Dungeon-Gen Check}{Dynamic}{Manual}{Black}{None}{Repeated restarts of the game}{Level should contain \hyperref[symbolicParameters]{ROOMS\_PER\_LEVEL} rooms, which should form a connected graph.}{A tester will manually start the game, briefly explore the level to verify correct generation, then repeat this process until confidence is achieved.} \subsection{Basic Movement} - \test{P}{Name}{Dynamic}{Manual}{Black}{Gameplay State}{Movement commands}{Player should move about the level, without clipping through walls, failing to walk through empty space, or jump to an unconnected square.}{A tester will manually walk through the level, and visually verify correctness.} + \test{P}{Movement Check}{Dynamic}{Manual}{Black}{Gameplay State}{Movement commands}{Player should move about the level, without clipping through walls, failing to walk through empty space, or jump to an unconnected square.}{A tester will manually walk through the level, and visually verify correctness.} \subsection{Score File} - \test{P}{Name}{Dynamic}{Manual}{Black}{Menu State}{Enter name, then quit, restart game, enter name again, and quit.}{1st name should appear in both the first and second score screens. The 2nd should appear in the second. Both should have correct values for level, cause of death/quit, and gold collected.}{A developer will manually perform the above input, and verify the output. Should be tested both with and without an initial score file.} + \test{P}{Scoring File Check}{Dynamic}{Manual}{Black}{Menu State}{Enter name, then quit, restart game, enter name again, and quit.}{1st name should appear in both the first and second score screens. The 2nd should appear in the second. Both should have correct values for level, cause of death/quit, and gold collected.}{A developer will manually perform the above input, and verify the output. Should be tested both with and without an initial score file.} \subsection{Line of Sight System} - \test{P}{Name}{Dynamic}{Manual}{Black}{Gameplay State}{Movement commands}{Screen should display correct portions of level, with correct coloration schemes. This means that the player should be able to see the entirety of a room they are in or in the doorway of, and VIEW\_DISTANCE squares away if they are in a corridor. Squares that the player has seen in the past but cannot see currently should be shown greyed out. Squares they have not seen should be black and featureless.}{A developer will manually walk through the level, verifying that the above LoS rules are preserved, especially in edge cases like the corners of rooms and doorways.} + \test{P}{LoS Check}{Dynamic}{Manual}{Black}{Gameplay State}{Movement commands}{Screen should display correct portions of level, with correct coloration schemes. This means that the player should be able to see the entirety of a room they are in or in the doorway of, and \hyperref[symbolicParameters]{VIEW\_DISTANCE} squares away if they are in a corridor. Squares that the player has seen in the past but cannot see currently should be shown greyed out. Squares they have not seen should be black and featureless.}{A developer will manually walk through the level, verifying that the above LoS rules are preserved, especially in edge cases like the corners of rooms and doorways.} \newpage \section{Comparison to Existing Implementation} diff --git a/src/feature.cpp b/src/feature.cpp index 36f871f4fc7c221f6f07afc12876407aec31021d..0f0f98f4276b779b2eabf31b573c194566eca241 100644 --- a/src/feature.cpp +++ b/src/feature.cpp @@ -13,4 +13,8 @@ Coord Feature::getLocation() { return this->location; } +void Feature::setLocation(Coord newLoc) { + this->location = newLoc; +} + Feature::~Feature() {} diff --git a/src/include/feature.h b/src/include/feature.h index 6e4b42b2f9cc997cbfc2ee9ee91f6a9329ada147..bcafffd047b2a13f501319bf0e6cb702f57c07aa 100644 --- a/src/include/feature.h +++ b/src/include/feature.h @@ -7,6 +7,7 @@ class Feature { Feature(char, Coord); char getSymbol(); Coord getLocation(); + void setLocation(Coord); virtual ~Feature(); private: Coord location; diff --git a/src/include/item.h b/src/include/item.h index 3b278966e6ce98e55b980875494fb86ee397ca7c..74abd833af938c97d83d998f484859cda33d7235 100644 --- a/src/include/item.h +++ b/src/include/item.h @@ -22,6 +22,7 @@ class Item : public Feature { bool operator<(const Item&) const; Context getContext(); + void setContext(Context); std::string getDisplayName(); std::string getName(); int getType(); diff --git a/src/include/playerchar.h b/src/include/playerchar.h index a7000c488388cd0a016513aee2ebc3ce7721f77d..d29871bb067a6b00be4455160bc35cacdad30b8c 100644 --- a/src/include/playerchar.h +++ b/src/include/playerchar.h @@ -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*); diff --git a/src/item.cpp b/src/item.cpp index 04ef4553dee5fc1eccb77cd8f82f0359274e0c12..82ac10d49c856c4ded2bf7db2de93f1f0b213d06 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -38,6 +38,10 @@ Item::Context Item::getContext() { return this->context; } +void Item::setContext(Item::Context newContext) { + this->context = newContext; +} + std::string Item::getDisplayName() { if (Item::identified[this->className].find(this->type) == Item::identified[this->className].end()) { return this->pseudoName; diff --git a/src/playerchar.cpp b/src/playerchar.cpp index 0c080addd169517273f788f71ae08424f0dec2c1..2346e6b17d6461f3bdfbab20226bd6b29448a985 100644 --- a/src/playerchar.cpp +++ b/src/playerchar.cpp @@ -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; }