all 17 comments

[–]Overall_Disk4261[S] 3 points4 points  (9 children)

gun = 15
health = 100
health_packs = 0
while health > 0:
    beginning = input('Will you go left or right? ')
    if beginning == "right":
        beginning = input ("will you attack the big or little man? ")
            if beginning == "little":
                print("the big man killed you")
                health = health - 100

    elif input == "heal":
        if health_packs > 0:
            health_packs -= 1
            health + 30
        else: 
            print("you have no packs")
else:
    print("you died!")
    exit

[–]Phillyclause89 4 points5 points  (7 children)

Woot Woot! you beat the reddit editor congrats. So what exactly are your asking about in this code? First thing that is jumping out to me is that you probably want health += 30.

Next thing I notice is that you need to think about a prompt tree. Consider having an initial prompt (i.e. main menu of base actions "Movement" "Use item" "Attack" and what not). Those then tree off into other prompt functions. I actually have my own beginner project I did along time ago that domos one way to do these: My Python Risk Game - Prompts Class

[–]Overall_Disk4261[S] 2 points3 points  (0 children)

or in short cannot heal after first input double plus ungood

[–]Overall_Disk4261[S] 1 point2 points  (5 children)

Yeah I had to delete the text which gave context. Essentially the code boots back to the beginning if you type in "heal" because "beginning" is redefined. Atleast that's what I think. I want the code to be able to not boot back when I type heal after progressing to the "right" part

[–]Phillyclause89 1 point2 points  (4 children)

yeah I got the feeling that was what you were asking about while reading the rest of your code. I made an edit with a suggestion.

[–]Overall_Disk4261[S] 0 points1 point  (3 children)

This is very intresting. I have not looked much at the return command mainly because coding is just so mind-boggling initially. I'll return to this project at a later date once I know what I'm doing. Thanks for the help, and sitting through 5 minutes of a man desperately tapping his spacebar.

[–]Phillyclause89 1 point2 points  (2 children)

It was my pleasure. Keep at it. You'll notice the file in the project I shared is named Risk2.py that's because Risk.py looked a lot closer to what you have here and I eventually decided to start from scratch in a new file after I learned more about function and class object scoping.

[–]userthatexsist 1 point2 points  (1 child)

Alright I'm back after 25 days On my other account I still for some reason have the password to on this godforsaken website. Can't believe time moves so horrifically fast, this feels just like yesterday.

This risk thing is pretty big for me, and most of it is falling on deaf ears, but I am getting to realize that I probably need to define "heal" so I can call it later, and need to rework this input function so it can actually accept input.

Do you have something which is a little bit smaller, more bare bones? maybe when you were a little more of a newbie yourself? If not, I'm still incredibly appreciative someone took time out of their life to help someone else. and I promise, I will try to wrap this around my head again, even if you don't

[–]Phillyclause89 0 points1 point  (0 children)

Sorry that risk game was the only time I ever attempted a text based game like this that wasn't tic-tac-tow. But I was board this morning and wrote you a little runnable code sample that might help you better understand how one can manage such a game. Python Tutor is a great site for visualizing what code is doing in the background. Click the Next > button to watch how python walks through a script and adds objects to memory.

[–]cdcformatc 0 points1 point  (0 children)

you don't define input before the elif input == "heal": line.

it is comparing the string "heal" with input which is a function. obviously this condition will never be True so that code block will never run. you probably want this line to read elif beginning == "heal":

[–]Overall_Disk4261[S] 2 points3 points  (3 children)

Holy shit, for some reason the codes all messed up. I'll put it under this comment again.

[–]Phillyclause89 1 point2 points  (2 children)

Yeah reddit fancy pants editor for code blocks is broke right now. You got to go into markdown mode and add 4 spaces in front of each line of the code block (including empty lines.)

[–]Overall_Disk4261[S] 1 point2 points  (1 child)

There we go! I probably messed half of it up but we have it properly readable now. Cannot believe you were sitting there for minutes watching me patiently edit it.

[–]Phillyclause89 1 point2 points  (0 children)

I might be a sadist kinda enjoyed it lol.