Open Megalowhale opened 10 years ago
Hello, I would have replied earlier, I think this is an extremely late reply, but I had to do a lot of school work over the past two weeks. I don't know how to effectively add a mother class, as I have classes for handling fighting, and I have some to just hold and move data around (at the moment). So I'm thinking of having a broad one for each section, such as Entities (mobiles, and players), Items and fighting mechanics at the moment. Hopefully now that I have made my Items and Classes JSON files less class heavy, they will be easier to maintain later. I started off with the:
Class Object: def init(mobile=False, combat=False, block=False)
Format for parsing data, but I personally dislike that form, and made it use a dictionary, I think that it is a big bonus, as all I need to do is read a JSON file and then parse it right into one of my classes and all the work is done, rather then having to split up the dictionary and parse them individually.
I still need to clean the Ork and Troll monsters, as monsters should have random attributes, items and drops (that I haven't implemented yet as my inventory handling is currently very poor.)
Than you very much for the report, as I haven't properly programmed anywhere. At school, I get credited on my ability to make a nice UI, not a good program, and otherwise I'm self taught. (I want to know how to program properly) Also I don't know if this is the right area or not, I'm rather new too, but It was an issue for sure, or was going to be very soon.
I noticed in your readme you complained about having too many classes and say that you're open to advice.
That being said, my best advice would be to create more general objects in your code. For instance, you could create a parent class for all objects in the game. From here you can give your objects the flag which will define how they function and interact within your game. Is it mobile? Does it block the character's path? Is it a combat type or perhaps an object the character will only be able to interact with on a more superficial level?
An example might look like this:
Class Object: def init(mobile=False, combat=False, block=False)
This way you can cut down on code and write more efficiently, as well as add more flexibility by defining what each object will be as you instantiate it. You can then create sub classes such as Mobile, which can then be passed specific attributes such as defining the type of monster (ork, troll, etc), how much hp it has if any, etc. This will allow you one general class rather than one for every monster type.
With the direction you're headed right now, it looks like your code will become very unwieldy and difficult to maintain after a certain point. I hope this was useful to you. Thank you and have a good day.
P.S. Sorry if this wasn't the appropriate place for this, I am still rather new to github and couldn't find a private message feature!