Subscribe to Akasen's Blog        RSS Feed

I learn Python and Programming by Working on a Text-Based RPG: Entry 3

Icon Leave Comment
So with this entry it is now time to talk on my current work on this RPG, an inventory system and items.

I have actually looked over many text-based RPG's in Python and one of my personal gripes is that the ones I have looked at do not code an inventory system or an equipment system. The other gripe I had was that the code for these games were all in one Python module.

So in other Python related news, I downloaded Aptana Studio 3 and PyDev so I now have a more proper IDE, I guess.

So without further ado, let us talk on the topic of adding an inventory to this RPG.

Let us ask first off, why does a player need an inventory and equipment? What benefit could it add to a game? In a more indepth RPG, a battle can be made artificially harder via the player needing such gear. In older games, generally you would be the item shop that would sell players the best possible armor and weapons in the area, thus giving players with money the ability to then be able to more easily take down enemies and find items that will help them in the boss battle. Other games simply rely on the players having enough health to just not die all too fast.

If we want to look at another example where equipment itself is the center of attention then look no further than Diablo and it's few and between spawns. All of those games attempt to entertain the player through loot drops that entertain the player by constantly making the player be better at defeating each enemy he comes across. In those games as well though, they tend to have a system also reliant on skills and the weapons themselves have effect from or to skills. Thus in those games of the Action Roleplaying genre that have can be known as "loot games", an even greater thing must be added to the game. The aspect of loot having randomly generated stats to which the player is constantly on the prowl for item drops that hold sufficient stats that the player sees as an upgrade.

So enough on other games, what about our game? What do we want for our game? Probably the simpler thing in design for how a player acquires armor from enemies, chests, and shops. There should be an item list that has the stats and effect of each item possible. Potions, weapons, armor, that's the stuff I want to look into doing for now.

So now let us take a look at the code I have right now and seek to understand what I understand about my own lines of code.

As is said before, some of my code is influenced by QuadRaxi's RPG tutorials and this is true for the bit I have here. As I also said before, I want to get away from copying his work and do my own thing for the most part.

#Items template

#Defines the basics of an item
class Item(object):
    def __init__(self, name, value, quantity = 1): = name
        self.value = value
        self.quantity = quantity

#The Container is something akin to inventory where in which
#items are kept in.
class Container(object):
    def __init__(self, name): = name = []

    def add_item(self, name, quantity = 1): = name
        self.add = self.append(name)
        self.quantity = quantity

#So the Class known as Item is of course item. It is defined by a name, value, and quantity.

#Then we have Container which can (I hope) be used for inventory, containers like chests and packs, and enemy inventory. It has a name for the container and a list used to hold the name for all defined items. I must tell the truth in that my practice with lists, tuples, and dictionaries is much out of practice and I am in need of a firm understanding of it in order to get this to work.

The method 'add_item' is meant to add items to inventory. Currently, I am running into issues in regards to actually getting items added to the inventory and am unsure I even have it set up right. And so thus leads me to investigate to possible solutions to my goal and me leaving this blog post on the topic of an inventory system.

0 Comments On This Entry


Trackbacks for this entry [ Trackback URL ]

There are no Trackbacks for this entry

May 2022

222324 25 262728

Recent Entries

Recent Comments

Search My Blog

5 user(s) viewing

5 Guests
0 member(s)
0 anonymous member(s)