Загрузка данных
import random
items = ["Кола", "Чупа чупс", "браслет", "Сони эриксон", "линейка", "Карточка потри-понюхай", "Карточка уно"]
player1inv = []
player2inv = []
player1hp = 3
player2hp = 3
bullets = []
hod1 = True
hod2 = False
def switch():
global hod1
global hod2
if hod1 is True:
hod1 = False
hod2 = True
elif hod2 is True:
hod1 = True
hod2 = False
def bulets_up():
for i in range(6):
bullets.append(random.randint(0, 1))
for i in range(4):
player1inv.append(items[random.randint(0, 6)])
player2inv.append(items[random.randint(0, 6)])
def cola():
if hod1 is True:
player1inv.remove("Кола")
elif hod2 is True:
player2inv.remove("Кола")
a = bullets.pop()
if a == 1:
return "Был выброшел боевой патрон"
else:
return "Был выброшен холостой паторон"
while player1hp > 0 or player2hp > 0:
if bullets == []:
bulets_up()
print("Перезарядка патронов")
if hod1:
print(f"-")
print(f"Сейчас ход 1 игрока")
print(f"-")
else:
print(f"-")
print(f"Сейчас ход 2 игрока")
print(f"-")
print("Команды: 1 - посмотреть инвентарь, 2 - использовать предмет, 3 - выстрел, 4 - посмотреть свое хп, 5 - посмотреть хп противника")
command = int(input())
if command == 1:
if hod1 is True:
print(player1inv)
elif hod2 is True:
print(player2inv)
elif command == 2:
continue
elif command == 3:
print("1 - Выстрел в себя, 2 - выстрел в противника")
who = int(input())
if who == 1:
if hod1 is True:
vistrel = bullets.pop()
if vistrel == 0:
print(f"Патрон холостой, ваше хп {player1hp} ед")
elif vistrel == 1:
player1hp -= 1
print(f"Патрон боевой, ваше хп {player1hp} ед")
switch()
else:
vistrel = bullets.pop()
if vistrel == 0:
print(f"Патрон холостой, ваше хп {player2hp} ед")
elif vistrel == 1:
player2hp -= 1
print(f"Патрон боевой, ваше хп {player2hp} ед")
switch()
switch()
elif who == 2:
if hod1 is True:
vistrel = bullets.pop()
if vistrel == 0:
print(f"Патрон холостой, хп противника {player2hp} ед")
switch()
elif vistrel == 1:
player2hp -= 1
print(f"Патрон боевой, хп противника {player2hp} ед")
else:
vistrel = bullets.pop()
if vistrel == 0:
print(f"Патрон холостой, хп противника {player1hp} ед")
switch()
elif vistrel == 1:
player1hp -= 1
print(f"Патрон боевой, хп противника {player1hp} ед")
elif command == 4:
if hod1 is True:
print(f"Ваше хп: {player1hp}")
elif hod2 is True:
print(f"Ваше хп: {player2hp}")
elif command == 5:
if hod1 is True:
print(f"Хп противника: {player2hp}")
elif hod2 is True:
print(f"Хп противника: {player1hp}")
if player1hp == 0:
print("Игра завершена, победил 2 игрок")
elif player2hp == 0:
print("Игра завершена, победил 1 игрок")