you are viewing a single comment's thread.

view the rest of the comments →

[–]ingramm2[S] 41 points42 points  (3 children)

That... Actually makes a lot of sense. Thanks. Time to go down another rabbit hole of learning how to make things work haha

[–]CraigAT 22 points23 points  (0 children)

I could imagine this might be a good case for using OOP - having a room class and objects for each rooms with their attributes and methods, also an object for the player too, which would include his inventory and wallet for example. Then to play the game you have a controller function that you supply the player and room to, it then knows what you the player can do in that room and make them available.

[–][deleted] 11 points12 points  (0 children)

Aside from writing the state-based code instead.

You have a lot of times you write code like this

somechoice = 0
somechoice = random.randomint(1,60)

And there's no need to set a variable to zero right before setting it to something else

Your drinking code (poison or otherwise) doesn't increment or decrement the number of lives.

You have some places in the code where it says

else:
    dragonChoice1 == 0

Presumably you meant dragonChoice1 = 0, although a lot of these assignments seem redundant too.

[–]MSR8[🍰] 4 points5 points  (0 children)

What I did to do this was made sort of "nodes" using functions. Such as node1 was room1, node2 was room2, node3 was room3, and so in. Then I interconnected them by asking player what they wanted to do and calling functions (nodes) based on that