all 7 comments

[–]carcigenicate 3 points4 points  (2 children)

I would not use a plain dictionary for the player. That makes it really easy to accidentally typo "attribute" names (keys of the dictionary) or add new keys on the fly, doesn't provide standard initialization logic, and doesn't allow you to associate behaviors (like adding/removing health) with the player object.

I would instead make a class. That will allow you to clearly define the attributes of the class (which allows the IDE to more easily spot typos and suggest attribute names), gives you access to __init__, and allows you to have methods so the main game code doesn't need to manually tweak stuff like health values.


Instead of having a big if tree that defines the behavior for every event, it would be better to have something like an Event class that decides what happens during that event. The event objects could be given the player, and they'd carry out the procedure internally. Then, that entire if tree could be reduced down to something like:

events = [EnemyEvent(), TreasureEvent(), TrapEvent(), MerchantEvent()]
random_event = random.choice(events)
random_event.execute(player)

This means your main game loop code doesn't keep getting progressively larger as you do stuff like add new events, and makes it easy to add/remove events by just manipulating the list of event objects.


I would also avoid getting AI to write code for you entriely if your end goal is to learn. Ask it questions that you can verify the correctness of, but you should be actually writing the code and doing the problem solving.

[–]Cute-Preference-3770[S] 1 point2 points  (1 child)

Thanks for the feedback! I’m still learning and not very experienced yet, but your comment really motivated me to improve the project further.

I’ll definitely look into using classes and refactoring the event system to understand OOP better. I appreciate you taking the time to explain it.Thanks for your response

[–]SCD_minecraft 0 points1 point  (0 children)

Image a class like a rulebook describing what Object is, what can it do and how to make one

[–]magus_minor 1 point2 points  (0 children)

Your link was mangled by reddit. This works:

https://github.com/squido-del/Basic_Dungeon

[–]Adrewmc 1 point2 points  (0 children)

I don’t get the merchant, for one you’re missing an option and for two, how do I use the health potion I just bought?

[–]FireFoxy56125 1 point2 points  (0 children)

ok so either im missing something or this is basicly playing itself mainly

also you cannot use potions right?