Trying to simulate an Overwatch loot box opening program in Python

2024/11/15 22:42:37

So basically I am trying to recreate opening a loot box in Overwatch into a runnable program in python. I'm trying to make it take four random items in an array and display them each time the user types 'open' to open a box. After every box is opened, I want it to loop and ask if they want to open another one, or if they don't and then stop the program. Here's my code so far:

import random# welcome
print("Welcome to the Overwatch Loot Box Simulator!")OpenBox = input("Type 'open' to open a loot box!")OverwatchSkins = ['Legendary: Oni Genji','Epic: Frostbite Pharah','Rare: Banana Winston','Rare: Cobalt Reinhardt','Epic: Synaesthesia Lucio','Legendary: Lone Wolf Hanzo','Rare: Rose Widowmaker','Rare: Celestial Mercy','Epic: Carbon Fiber D.VA','Legendary: Dr. Junkenstein Junkrat','Epic: Nihon Genji','Rare: Blood Reaper','Rare: Ebony McCree','Epic: Demon Hanzo','Rare: Peridot Ana','Rare: Lemonlime D.VA','Epic: Taegeukgi D.VA','Legendary: Mei-rry Mei','Legendary: Augmented Sombra','Rare: Technomancer Symmetra','Rare: Mud Roadhog'
]if OpenBox == "open":print(random.choice(OverwatchSkins))

the OverwatchSkins array would just be filled up with more names later on. Any help is greatly appreciated!

Answer

You can wrap everything in a while(True)-Loop and use break to stop the loop, if the user puts in something other than open.

Make sure that only the input and output are in the loop, since you don't want to redefine your list on every pass.

import random
print("Welcome to the Overwatch Loot Box Simulator!")
OverwatchSkins = ['Legendary: Oni Genji', 'Epic: Frostbite Pharah', 'Rare: Banana Winston', 'Rare: Cobalt Reinhardt', 'Epic: Synaesthesia Lucio', 'Legendary: Lone Wolf Hanzo', 'Rare: Rose Widowmaker', 'Rare: Celestial Mercy', 'Epic: Carbon Fiber D.VA', 'Legendary: Dr. Junkenstein Junkrat', 'Epic: Nihon Genji', 'Rare: Blood Reaper', 'Rare: Ebony McCree', 'Epic: Demon Hanzo', 'Rare: Peridot Ana', 'Rare: Lemonlime D.VA', 'Epic: Taegeukgi D.VA', 'Legendary: Mei-rry Mei', 'Legendary: Augmented Sombra', 'Rare: Technomancer Symmetra', 'Rare: Mud Roadhog']while(True):OpenBox = input("Type 'open' to open a loot box! ")if OpenBox == "open":print(random.choice(OverwatchSkins))else:break
https://en.xdnf.cn/q/119263.html

Related Q&A

How to remove extra commas from data in Python

I have a CSV file through which I am trying to load data into my SQL table containing 2 columns. I have 2 columns and the data is separated by commas, which identify the next field. The second column c…

How to linearize the sum of a product of two decision variables in LP?

Being new to Linear Programming and Gurobi, I am dealing with an Integer Linear program where I have two binary decision variables defined as B[u_v, x_y] and A[u_x], I am trying to implement this const…

Basic calculator program in python [closed]

Its difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying thi…

Why am I receiving ERROR 404 - when attempting to use Python Flask

I have been following this tutorial: https://kb.objectrocket.com/postgresql/scrape-a-website-to-postgres-with-python-938 My app.py file looks like this (taken from the above tutorial): from flask impor…

Merge the dataframes dynamically

I am extracting data from APIs to generate a report. But the number of APIs are dynamic for each report. It can be 1,2,3,5 etc. Once we get the data , we need to store the data as dataframe, to generat…

Read an xml element using python

I have an xml file. I want to search for a specific word in the file, and if i find it- i want to copy all of the xml element the word was in it.for example:<Actions><ActionGroup enabled="…

Using .rsplit() not giving desired results

I want to manipulate a string using .rsplit() so that anything after the last comma in a string of data is split using commas. As an example:,000...should be changed to:,0,0,0,In order to this I am usi…

Concatenate numbers in binary [duplicate]

This question already has answers here:Convert int to binary string in Python(36 answers)Closed 7 years ago.When converting a number in binary in Python what you get is the following:b = bin(77) print(…

AttributeError: DataFrame object has no attribute path

Im trying incrementally to build a financial statement database. The first steps center around collecting 10-Ks from the SECs EDGAR database. I have code for pulling the relevant 8-Ks, 10-Ks, and 10-Qs…

two DataFrame plot in a single plot matplotlip

I want to plot two DataFrame in a single plot.Though, I have seen similar post but none seems to work out. First 5 rows of my dataframe looks like this: df1name type start stop stran…