Jump to content
Usr6

RST Roulette -python game

Recommended Posts

import random

import sys

import os

print "Welcome to Rst roulette"

print "Exit nr >7"

nrales =0

while nrales <7:

print "Please choose a nr from 1 to 6:"

nrales = int(raw_input())

nrr = random.randrange(1,6)

if nrales >=7:

print "Seeya next time."

sys.exit()

elif nrales == nrr:

try:

os.system('shutdown -r -t 10 -c "You loose"')

except Exception, e:

print "Ai avut noroc de", Exception,

sys.exit()

else :

print "Ai avut noroc, numarul era : %d, tu ai ales %d" %(nrr, nrales)

Trebuie sa alegeti un nr intre 1 si 6, daca ghiciti nr ales aleator primiti ca premiu un restart al calculatorului

daca alegeti un nr mai mare sau egal cu 7 iesiti din joc

Link to comment
Share on other sites

Editie speciala pentru iubitorii de adrenalina, va sterge un fisier random

import random

import sys

import os

print "Welcome to Extreme Rst roulette"

print "random file will be deleted"

print "press 7 to exit"

nrales =0

while nrales <7:

print "Please choose a nr from 1 to 6:"

try:

nrales = int(raw_input())

except:

print "Am zis numar, da?"

nrr = random.randrange(1,6)

if nrales >=7:

print "Seeya next time."

sys.exit()

elif nrales == nrr:

try:

print "You loose, un fisier va fi sters:"

for root, subFolders, files in os.walk("C:\\"):

for file in files:

fullpath = os.path.join(root, file)

noroc = random.randrange(0, 100)

if noroc == 0:

try:

#os.remove(fullpath)

print "Fisierul %s a fost sters." %(fullpath)

sys.exit()

except Exception, e:

print "fisierul %s, nu a putut fi sters" %(fullpath)

print e

else:

continue

except Exception, e:

print "Ai avut noroc de ", e

sys.exit()

else :

print "Ai avut noroc, numarul era : %d, tu ai ales %d" %(nrr, nrales)

Am avut "noroc" :))))


Welcome to Extreme Rst roulette
random file will be deleted
press 7 to exit
Please choose a nr from 1 to 6:
1
You loose, un fisier va fi sters:
Fisierul C:\IO.SYS a fost sters.

Am lasat un mic 'anti noob' protection

Nota: Stergerea unor fisiere de system poate duce la imposibilitatea de a porni pc-ul, aparitia BSOD-urilor, etc

Link to comment
Share on other sites

pe baza feedback-ului primit la versiunile anterioare, un nou release:

5 runde pline de adrenalina, daca le treci iti raman fisierele intacte si primesti felicitarile


Welcome to Extreme Rst roulette v2
If you loose one random file will be deleted
Please choose a nr from 1 to 6 (choose 7 to exit):
6
Ai avut noroc, numarul era: 2, tu ai ales 6
Please choose a nr from 1 to 5 (choose 6 to exit):
5
Ai avut noroc, numarul era: 2, tu ai ales 5
Please choose a nr from 1 to 4(choose 5 to exit):
3
Ai avut noroc, numarul era : 4, tu ai ales 3
Please choose a nr from 1 to 3(choose 4 to exit):
1
Ai avut noroc, numarul era: 3, tu ai ales 1
Please choose between 1 and 2(choose 3 to exit):
1
numarul era: 2, tu ai ales 1
Felicitari!
Game Over.

daca nu... iti vei dori sa nu fi jucat


Welcome to Extreme Rst roulette v2
If you loose one random file will be deleted
Please choose a nr from 1 to 6 (choose 7 to exit):
6
You loose, un fisier va fi sters:
Fisierul C:\boot.ini a fost sters.

Script (python 2.7):

import random

import sys

import os

print "Welcome to Extreme Rst roulette v2"

print "If you loose one random file will be deleted"

def looser():

print "You loose, un fisier va fi sters:"

for root, subFolders, files in os.walk("C:\\"):

for file in files:

fullpath = os.path.join(root, file)

noroc = random.randrange(0, 100)

if noroc == 0:

try:

#os.remove(fullpath)

print "Fisierul %s a fost sters." %(fullpath)

sys.exit()

except Exception, e:

print "fisierul %s, nu a putut fi sters"

print e

else:

continue

nrales =0

while nrales <7:

print "Please choose a nr from 1 to 6 (choose 7 to exit):"

try:

nrales = int(raw_input())

except:

print "Am zis numar, da?"

nrr = random.randrange(1,7)

if nrales >=7:

print "Seeya next time."

sys.exit()

elif nrales == nrr:

looser()

else :

print "Ai avut noroc, numarul era: %d, tu ai ales %d \nPlease choose a nr from 1 to 5 (choose 6 to exit):" %(nrr, nrales)

try:

nrales = int(raw_input())

except:

print "Am zis numar, da?"

nrr = random.randrange(1,6)

if nrales >=6:

print "Seeya next time."

sys.exit()

elif nrales == nrr:

looser()

else :

print "Ai avut noroc, numarul era: %d, tu ai ales %d \nPlease choose a nr from 1 to 4(choose 5 to exit):" %(nrr, nrales)

try:

nrales = int(raw_input())

except:

print "Am zis numar, da?"

nrr = random.randrange(1,5)

if nrales >=5:

print "Seeya next time."

sys.exit()

elif nrales == nrr:

looser()

else :

print "Ai avut noroc, numarul era : %d, tu ai ales %d \nPlease choose a nr from 1 to 3(choose 4 to exit):" %(nrr, nrales)

try:

nrales = int(raw_input())

except:

print "Am zis numar, da?"

nrr = random.randrange(1,4)

if nrales >=4:

print "Seeya next time."

sys.exit()

elif nrales == nrr:

looser()

else :

print "Ai avut noroc, numarul era: %d, tu ai ales %d \nPlease choose between 1 and 2(choose 3 to exit):" %(nrr, nrales)

try:

nrales = int(raw_input())

except:

print "Am zis numar, da?"

nrr = random.randrange(1,3)

if nrales >=3:

print "Seeya next time."

sys.exit()

elif nrales == nrr:

looser()

else :

print "numarul era: %d, tu ai ales %d \nFelicitari!\nGame Over." %(nrr, nrales)

sys.exit()

Am lasat un mic 'anti noob' protection

Nota: Stergerea unor fisiere de system poate duce la imposibilitatea de a porni pc-ul, aparitia BSOD-urilor, etc

Edited by Usr6
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...