I need help. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I need help.

Im new to programming and i have to create a dragons realm game. The rules are: 1) include a counter to count player status. 2) it must have 3 caves 3) the actual cave the player entered is random generated. 4) each cave has a good thing or bad thing which is randomly generated. 5) After each move and the corresponding consequences, your program will output a nicely formatted status line on the health of the player. Example: Life: 5. Gold: 120. Weapon: sword, knife 6)The game continues until the player is no longer alive or decided to sxit the game I have been trying to figure this out for 5 days and im lost.

16th Oct 2016, 4:09 PM
Jahnkarlo
11 Answers
+ 1
Do you have more precise instructions? What is the playerstatus counter? Life? How is the number of caves relevant if you choose a cave at random, with a random event happening? Are there some precise events you have to implement or is it up to you? In a nutshell, how much freedom do you have to program the game? (Providing this is a school assignment or something like that, since you said "I have to" instead of "I want to".)
16th Oct 2016, 4:27 PM
Zen
Zen - avatar
+ 1
well how about a code like this you can create your game like this I don't know what you really meant so I don't know if this is what you asked you can change weapon list to add more weapons u can change text too I didnt care about grammer or spelling 😀 I posted the code as CaveGameCodeA in code playground search as cavegamea and youll find it hope I helped
16th Oct 2016, 7:00 PM
Sunera
Sunera - avatar
+ 1
no it works I checked again this is written in python 3 and if you are using Python 2 you have to change it a bit
16th Oct 2016, 7:55 PM
Sunera
Sunera - avatar
+ 1
hey check out the answer now x=int()-1 in line 31 should be x=int(x)-1 I don't know what happens to x but somehow it was deleted now it should work anyway check for python version too (however it works for me I even played it for some time😜)
16th Oct 2016, 8:09 PM
Sunera
Sunera - avatar
0
Basically it's up to me to make the game how i want it. It has to have 3 caves. Player chooses a number between 1 and 3 and the program rabdom pickes the cave. 1 cave will have gold. So the player player goes into that cave the gold gets added to the money i have. Which the player will start with 0 gold. Another cave will have a weapon for the player to collect. And the final cave will will be where the dragon eats the players and he dies. Which the game would end there. The player will continue to chose caves until he's health has depleted. Theres no specific rules to the game as long as I stick with this. Which makes it hard for me because i just started learning prgramming a month ago. Lol
16th Oct 2016, 4:32 PM
Jahnkarlo
0
That's awesome how you did it. I cant wait till i learn this and get to do stuff like this. I wish i understood it more.
16th Oct 2016, 7:08 PM
Jahnkarlo
0
if you have a question ask
16th Oct 2016, 7:09 PM
Sunera
Sunera - avatar
0
I am new to python and programming too so of you found any bugs ,sorry
16th Oct 2016, 7:10 PM
Sunera
Sunera - avatar
0
Not really working, there is a lot of synthax errors. Im trying to mess with it see if i can find where the problem is. Thanks though. I gotta keep trying to figure this out.
16th Oct 2016, 7:44 PM
Jahnkarlo
0
This is the one i had done so far before this. Its beginner stuff and i think you'll be able to see why I got stuck. Don't know what i did wrong. #this is imcomplete and i need help finishing this dragon realm program. Any help would be appriciated it. thanks. import time import random def get_name(): name = input("What is your name, warrior") return name name = get_name() print("hello,"name,) print("Lets play dragon realm.") time.sleep(2) print("you are in a land of dragrons") time.sleep(2) print("ine one cave is gold coins") time.sleep(2) print("in another is a weapon") time.sleep(2) print("and the last cave there is a dragon that will eat you and kill you") time.sleep(2) def choosecave(): while cave !="1" and cave !="2" and cave !="3": cave = input("which cabe will you choose") weaponscave = random.randint(1,3) treasurecave = random.randint(1,3) Deathcave = random.randint(1,3) if cave == str(weaponscave): print("you found the weapons cave") if cave ==str(treasurecave): print("you found the treasures cabe. you got 10 gold coins") if cave ==str(desthcave): print("you entered the cabe of the dragon. he ate you alive, you lose the game")
16th Oct 2016, 8:07 PM
Jahnkarlo
0
1.your code does not keep asking for input you have to put the code from weapon cave=ran......... to ......Lose the game") inside a while True: loop so it will run in an infinite loop use if cave=="exit" :break as exiting code 2.Say that weaponscave=random.randint(1,3) gives weaponscave 3 treasurecave=random.randint(1,3) can give treasurecave 3 too but treasurecave!=weaponcave!=deathcave so you have to make sure that those 3 values are different
16th Oct 2016, 8:21 PM
Sunera
Sunera - avatar