مشروع لعبة حجر ورقة مقص
# بدء اللعبة بي رسالة ترحيبية و إختيار المستخدم هل يحتاج المساعدة في اللعبة ام لا
Start = input('Welcome to the Rock, Paper, Scissors game: \nPress Enter to continue or type (Help) for the rules ').lower()
# بدء التحقق من إختيار المستخدم إذا كان يريد المساعدة ام لا
if Start == 'help':
print('''\n
******** RULES *******
1) You choose and the computer chooses
2) Rock smashes Scissors -> Rock wins
3) Scissors cut Paper -> Scissors win
4) Paper covers Rock -> Paper wins
''')
# بدء لعبة و عمل امر ليختار المستخدم حجر او ورقة او مقص
Start_Chose = input('\nEnter your choice (Rock, Paper, Scissors): ').capitalize()
# التحقق ماذا اختار هل المستخدم شيئ من ثلاث الإختيارات ام لا
if Start_Chose == 'Paper' or Start_Chose == 'Scissors' or Start_Chose == 'Rock':
# إستدعاء مكتبة العشوائية
import random
# عمل متغير يحتوي على اختيار عشوائي
Chose_random = random.randint(0,2)
# التحقق ماذا اختار الكمبيوتر
if Chose_random == 0:
choice_computer = 'Paper'
Choose_computer = '''\nComputer chose:
\n
Paper\n
_______
---' ____)____
______)
_______)
_______)
---.__________)'''
elif Chose_random == 1:
choice_computer = 'Scissors'
Choose_computer = '''\nComputer chose:
\n
Scissors\n
_______
---' ____)____
______)
__________)
(____)
---.__(___)
'''
elif Chose_random == 2:
choice_computer = 'Rock'
Choose_computer = '''\nComputer chose:
\n
Rock\n
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)
''' # التحقق ماذا اختار المستخدم
if Start_Chose == 'Paper':
Start_Chose1 = '''\nYou chose:
\n
Paper\n
_______
---' ____)____
______)
_______)
_______)
---.__________)
'''
elif Start_Chose == 'Scissors':
Start_Chose1 = '''\nYou chose:
\n
Scissors\n
_______
---' ____)____
______)
__________)
(____)
---.__(___)'''
elif Start_Chose == 'Rock':
Start_Chose1 = '''\nYou chose:
\n
Rock\n
_______
---' ____)
(_____)
(_____)
(____)
---.__(___)'''
# عرض إختيار المستخدم و الكمبيوتر
print(f'{Start_Chose1} \n\n{Choose_computer}')
# التحقق و عرض من الفائز
if choice_computer == Start_Chose:
print('\nYou tied')
elif Start_Chose == 'Rock' and choice_computer == 'Scissors':
print(f'\nWell done, you won, Pick {Start_Chose} wins over Pick {choice_computer}')
elif Start_Chose == 'Paper' and choice_computer == 'Rock':
print(f'\nWell done, you won, Pick {Start_Chose} wins over Pick {choice_computer}')
elif Start_Chose == 'Scissors' and choice_computer == 'Paper':
print(f'\nWell done, you won, Pick {Start_Chose} wins over Pick {choice_computer}')
else:
print(f'\nSorry you lost, computer choice {choice_computer} your choice loses {Start_Chose}')
else:
print('Invalid choice. Please run the program and choose rock, paper, or scissors.')