#Russian roulette
import sys
from PyQt5.QtWidgets import *
from PyQt5 import QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtCore import *
import random
m=6
s=0
def shoot(la1,la2):
global s
r=random.randint(1,6)
if r!=1:
s=s+1
la1.setText('rounds survived:'+str(s))
la1.repaint()
npcshoot(la2)
else:
la2.setText('YOU DIED! Please leave the game.')
la2.repaint()
#print(la2.t0ext())
def npcshoot(la2):
r=random.randint(1,6)
if r!=1:
la2.setText('The NPC is safe. Your turn!')
la2.repaint()
else:
la2.setText('The NPC has died! You won!')
la2.repaint()
# print(la2.t0ext())
class MyApp(QWidget):
global m
def __init__(self):
super().__init__()
def initUI(self):
label1 = QLabel('rounds survived:'+str(s), self)
label2 = QLabel('Game status', self)
btno=QPushButton('&spin and shoot',self)
btno.clicked.connect(lambda:shoot(label1,label2))
btno.setStyleSheet("color: turquoise;"
"background-color: #DC143C")
label1.setStyleSheet("color: purple;"
"border-style: solid;"
"border-width: 2px;"
"border-color: #ED1B76;"
"border-radius: 1px")
label2.setStyleSheet("color: green;"
"border-style: solid;"
"border-width: 2px;"
"border-color: #037A76;"
"border-radius: 1px")
vbox = QVBoxLayout()
vbox.addWidget(btno)
vbox.addWidget(label1)
vbox.addWidget(label2)
self.setLayout(vbox)
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('Russian roulette')
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = MyApp()
ex.initUI()
sys.exit(app.exec_())