Reputation: 1
I am trying to create a little monster-collection game with the ability to collect multiple monsters of the same type with variable stats between them. The issue I'm having is that I don't know how to make an object that doesn't overwrite the previous one! The previous object made, so if I caught a Slime, five minutes later I could catch a goblin...which overwrites my Slime.
It will be done within Renpy if that changes things
The only thing I can think of is a long drawn out If statement going through each number to see if it the one I want, but that seems so messy especially since I'd need to go through it every time I want to reference . I've tried looking things up online but none of the tutorials seem to touch this aspect.
init python:
class Monster:
def __init__(self, species, hp, slot)
self.type = species
self.health = hp
self.is = slot
label start:
$ Slot1 = Monster("Null", 0, 2)
$ Slot2 = Monster("Null", 0, 2)
$ Slot3 = Monster("Null", 0, 3)
...continue code
label Caught:
#Assume Species and HP are assigned before calling this label)
$ X = 1
$ Counter = 0
while Counter = 0
if Slot[X].slot = 1:
$ X += 1
elseif Slot[X].slot = 3:
"You have too many Monsters"
$ Counter = 1
else:
$ Slot[X] = Monster(Species, HP, 1)
What code do I need to do to make this work? This should increment through them until it finds an open slot assuming my little made-up [X] could actually modify the variable being created/called.
Upvotes: 0
Views: 150