Analysis - Styrkar1/Hopaverk-onn-4 GitHub Wiki
This is an analysis of all the(worth wile) classes in the project.
character class: This class holds onto all of the variables that apply to the player, such as Level, Exp, Health, Defence, Speed etc... It also holds onto the players inventory with a list and a few functions used elsewhere in battles. This class also contains the opening sequence for the game although it is called from elsewhere
Floor classes: There are floors 1 through 5 these classes work in very similar fashions although they have some uniqueness to them, they also create the functions that decide if the player is in battle or not. Furthermore, they also write all the necessary code required to move the player around and tell them about the location they are in, including if an enemy is in the room of not. It is a well construction class that minimizes repeats in code to the best of it's abilities with the use of arrays and for functions.
Intro class: This class creates the flashing intro the character sees when they first open the tower game, it uses a for function to change the color of a string to make it flash a white and red color on the top of the screen along with a Read key and clear to move onto the actual game.
Menu class: This class was never quite finished although it's purpose would have been three fold. It's first purpose would have been to allow the player to see and interact with their inventory, to change weapons or use potions. The second purpose would have been to allow the player to see their stats, the ones that were detailed in the character class. It's third and final purpose would have been allowing the player to gamble their gold for a sizable return, this would create a risk/reward system to allow the player to get a lot of gold or loose all of it.
Monster class: This class held onto the stats a monster would have had, being health defence and etc... It also held onto a function that rolled from it's loot table to give the player once defeated, it uses a for function and a random number generator created elsewhere to go through a set amount of numbers and pick an item based on that number, if the player didn't get an item sometimes a default item would be dropped as a sort of pity loot.
Program class: This is the main class that is executed to run he program, it contains everything needed to make and use all of the classes in the program. It starts off by calling the functions to show the intro sequence and manages the movement from there. Since this class is basically just the execution class there is little else to be said about it that hasn't been detailed elsewhere, it looks for a shop and looks for a boss and reacts based on that information.
Shop class: This class was also never really finished but it's purpose would have been twofold. First it would allow the player to buy objects with the gold they had accumulated in the tower and would sell different items based on the floor level It's second purpose would be allowing the player to sell their items for gold wich the player could then spend at their will.
Use Weapon class: This class was basically the entire fight. First it took the weapon the player was using that then it takes the stats of the current monster, it calculates the damage the player would do based on their weapons pierce damage, it's base damage and the monsters defence. It also took into account if the player landed a critical hit, if so then the payer would to double damage, the class takes measures to prevent negative numbers so that doing damage won't heal iether the monster of player. it also goes through the process of giving the player the appropriate items if they defeated the monster, it ads exp, gold and rolls for an item for the monster to drop, if the player already had such an item then it adds onto it, if not it creates it in the inventory list and adds one. If the monster still lives after an attack then the monster gets to attack, this takes into account the monsters damage, the players defence and health, it also makes sure to prevent negative numbers. If the player should die during this attack then big red letters saying "GAME OVER" appear.
World class: This class creates items and monsters, it defines their characteristics and then creates them. Same goes for the monsters as it defines the loot the monster can drop, adds it to their drop table and creates the monster. It also has a few simple functions so find specific items based on their id but they're just simple for each loops.
And finally, the video showing all of the code. https://www.youtube.com/watch?v=2nBsyOLBXQ4&feature=youtu.be&hd=1