Richard Henderson wrote:
The main method also instantiates an instance of the Player class. This class contains the player's stats as variables and a number of methods for updating them and making random rolls based on those values. This class also contains instances of the weapons and armour the player uses, both of which are also classes.
Richard Henderson wrote:Yes, the Player has-a Weapon and the Player has-an Armour. Neither of those will actually be listed in the "Inventory", just as members of the Player class.
The inventory will be a List or Array, displayed in a JList component.
Richard Henderson wrote:
Mapping Items to Locations is more sophisticated than I need to be in this game version too. If this works I'll go more detailed in a later version which might include items by location though. That later version will also be more graphical too and might head away from text based altogether. I'm intend to work my way up through the levels of complexity with each version.
Richard Henderson wrote:
Ok, so getting back to Area locations...
It would be great to have a little list of items in each location, to go along with any monsters or traps that might already be there. But how do I record all this stuff before the Area is instantiated? I had thought I could use an Enum, like I have done with my monster types:
//more creature enum types can be added here, easy like[/code]But instead of the creatures skill, stamina, gold/loot etc, the enum will list something like this:
Richard Henderson wrote:
So you can see that Weapon and Armour are just listed as what the player is carrying. At this stage a player wont be carrying around a lot of different armour items like in WoW or other MMOs, just a Weapon with some parameters and Amour with other parameters. Ie:
Richard Henderson wrote:
After looking through what you wrote about my code again, i'm starting to figure out what you mean. So yeah, i'll be adding something like:
List<Equipment> inventory = new ArrayList<>();
But I wont be mapping items to body parts/locations with a two dimensional array because it's redundant. The player has one weapon and one armour (but might also end up able to get a shield, after more work by me) and everything else is in the inventory. The inventory will be an abstraction of the players backpack or something similar.
Richard Henderson wrote:Sorry this took a while to reply.
I'll go back to that little ordered list you posted:
1. I'm only concerned about the items before an area is instantiated because I will have to know what item(s) is(are) in each area when it is instantiated and i'll have to tell the constructor what to put there when it is instantiated. So I need to record what is in every area, which is why I was consider making an Enum of them.
Richard Henderson wrote:Haven't got time for a proper answer yet.
I'll just say that I might have the use of the MVC term incorrect.
I'm using swing and the GUI as the View.
If the Controller part of MVC is what changes and controls what you see on the view then I have a combined controller and view in the GUI class.
The class I've called GameController is the mechanics of the game and if the above is correct then it is actually my Model.
There is no mechanical code in my GUI class.
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
|