0

having issues with a prize system for a casino type mini game

im working on a text based rpg and part of it is this casino type mini game that has multiple prizes that can be bought with enough in game coins. the problem i am having is allowing the user to purchase more than one type of prize at the end of the game ill put my come in the comments any help would be great thank you

3rd Nov 2020, 9:51 PM
David Aseltine
David Aseltine - avatar
8 odpowiedzi
+ 2
Hi! Post your code to the code playground next time and link it here, this is really hard to read. Anyway I think your while loop condition is the issue. You wrote `while prize != "weapon" ...` so your big loop will only run once: if you choose "weapon" then the first line of your code will be false, since `prize == "weapon"`. So the while loop doesn't continue! Easier may be a simple infinite loop that you manually break out of when you are done. Like so: while true: prize = input("which prize?") ... r = input("buy more, yes or no?") if r == "no": break
4th Nov 2020, 1:04 AM
Schindlabua
Schindlabua - avatar
+ 2
create code on your language and link on your code, better remove this topic and create new topic with code , question and link on your code. In code will write comment “what do you want to do”example: input and output
4th Nov 2020, 6:41 AM
Sergey
Sergey - avatar
0
I was able to work around the issue by making the prize section its own code and assigning the variable "prize" with a place holder variable at the begining of the loop thank you both who answered
5th Nov 2020, 6:50 PM
David Aseltine
David Aseltine - avatar
0
Greetings! That sounds like an interesting idea for an RPG minigame. To allow the user to buy more than one prize, you can implement a system where after choosing one prize, the player is offered to stay in the store and buy more with the available coins. If you are looking for inspiration or examples of successful games with different mechanics, you can look at the MelBet platform https://melbet-bangladesh.bet/ there are also interesting concepts, especially if you are interested in gambling or predictions. Check out their site and maybe you'll find something useful for your game. Good luck with the development!
26th Aug 2024, 3:16 PM
Neil Donaldson
Neil Donaldson - avatar
- 1
while prize != "weapon" and prize != "armor" and prize != "pet" and prize != "hp": prize = input("which prize would you like : ") if prize == "weapon" and coin >=30: coin = coin - 30 attack = attack + 3 print("new attack : ",attack) print("left over coins : ",coin) print("would you like to buy another prize? yes or no") a = "q" while a != "yes" and a != "no": r = input("yes or no? : ") if r == "yes": a = r prize = input("which prize would you like : ") elif r == "no": a = r print("ill cash out the rest of your coins for hp") hp = hp + coin * 3 print ("your hp is : ",hp) print(name," heads to the next area") win1()
3rd Nov 2020, 9:52 PM
David Aseltine
David Aseltine - avatar
- 1
there are 3 other elif statements just like this for the other prizes and i would like to have the user be able to buy as many different prizes and they can but when i try to buy another prize or enter yes into the while loop at the end, it just continues to the next part of the code and will not allow me to choose another prize.
3rd Nov 2020, 9:55 PM
David Aseltine
David Aseltine - avatar