Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nicolas #6

Merged
merged 34 commits into from
Dec 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d084a28
create readme in controller and model folders
Nicolas-Turck Dec 3, 2019
8186268
Merge pull request #1 from Nicolas-Turck/dev
Nicolas-Turck Dec 3, 2019
79761b1
create main.py
Nicolas-Turck Dec 4, 2019
12d4491
write method name_entry and level_choice
Nicolas-Turck Dec 4, 2019
76b4c76
write method random choice and add_list_choice
Nicolas-Turck Dec 4, 2019
41a904e
write method player_entry, add_user_list, and compare_list
Nicolas-Turck Dec 4, 2019
10eb1d0
started creation of method clear_terminal
Nicolas-Turck Dec 4, 2019
a02e993
create new class player game and change method player entry and add u…
Nicolas-Turck Dec 5, 2019
3a53e01
import sleep method for terminal and write method for compare list
Nicolas-Turck Dec 5, 2019
2a90ac8
Merge pull request #2 from Nicolas-Turck/dev
Nicolas-Turck Dec 5, 2019
ddef422
add three level to random method progam numbers
Nicolas-Turck Dec 5, 2019
107b6f8
write #mesages in main.py and program class
Nicolas-Turck Dec 5, 2019
4254507
work in progress in loops for game and compare list
Nicolas-Turck Dec 5, 2019
835cf38
change clear method for clear prompt
Nicolas-Turck Dec 6, 2019
64abfcc
modify display elem in program list
Nicolas-Turck Dec 6, 2019
0a5422b
start modify compare methode
Nicolas-Turck Dec 6, 2019
450db44
Merge pull request #3 from Nicolas-Turck/dev
Nicolas-Turck Dec 6, 2019
eb5688b
change method compare
Nicolas-Turck Dec 6, 2019
3a66e51
change method compare and is not finish
Nicolas-Turck Dec 6, 2019
4540a93
add comment in main.py
Dec 7, 2019
f434b4d
write in readme
Dec 7, 2019
009e198
write in readme
Dec 7, 2019
573a413
work in method play again choice
Dec 8, 2019
9108d43
delete player-entry class
Dec 8, 2019
fc87ece
Merge pull request #4 from Nicolas-Turck/dev
Nicolas-Turck Dec 8, 2019
987ea6f
change main.py
Dec 8, 2019
cf9af8c
Delete vcs.xml
Nicolas-Turck Dec 8, 2019
4733bea
Delete simon_game.iml
Nicolas-Turck Dec 8, 2019
71da177
Delete modules.xml
Nicolas-Turck Dec 8, 2019
33c8df5
Delete misc.xml
Nicolas-Turck Dec 8, 2019
9848102
Delete .gitignore
Nicolas-Turck Dec 8, 2019
3b880df
Delete profiles_settings.xml
Nicolas-Turck Dec 8, 2019
a289d7d
Delete .DS_Store
Nicolas-Turck Dec 8, 2019
7d54b70
Merge pull request #5 from Nicolas-Turck/dev
Nicolas-Turck Dec 8, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added CONTROLLER/.DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions CONTROLLER/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions CONTROLLER/.idea/CONTROLLER.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions CONTROLLER/.idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions CONTROLLER/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions CONTROLLER/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions CONTROLLER/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions CONTROLLER/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# folder controller
# in this folder
three file one file main for run program simon game
i use for this project "object attributes and method in pyhon"
i have create two files for two class and i create and instancies objet
Binary file added CONTROLLER/__pycache__/main.cpython-38.pyc
Binary file not shown.
Binary file added CONTROLLER/__pycache__/player.cpython-36.pyc
Binary file not shown.
Binary file added CONTROLLER/__pycache__/player.cpython-38.pyc
Binary file not shown.
Binary file added CONTROLLER/__pycache__/player_game.cpython-36.pyc
Binary file not shown.
Binary file added CONTROLLER/__pycache__/program.cpython-36.pyc
Binary file not shown.
Binary file added CONTROLLER/__pycache__/program.cpython-38.pyc
Binary file not shown.
34 changes: 34 additions & 0 deletions CONTROLLER/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#! /usr/bin/env python3
# coding: utf-8
from player import *
from program import *

if __name__ == "__main__":
print("Hello start game")
player = Player()
#ask method name entry in player.py
player.name_entry()
#ask method level choice for user select level
player.level_choice()
game = Program()
#result_lists = True
restart = True
result_lists = True
while result_lists != False:
# ask method to use level in program
game.get_level(player.level)
# ask method random number
game.random_choice()
# ask method for save number in list
game.add_list_choice()
# method for clear prompt
game.clear_terminal()
# ask method for compare number user and program list
game.compare_list(player.player_numbers, result_lists)

#if result_lists == False:
#game.play_again_choice()
if restart == True:
__name__ == "__main__"


30 changes: 30 additions & 0 deletions CONTROLLER/player.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import os
from time import sleep
from program import *
class Player:
"""method for initialyse name"""
def __init__(self):
self.name = ""
self.level = None
self.player_numbers = 0

"""method for ask and save name entry"""
def name_entry(self):
name = input("enter your name :")
if name == "":
name = "GHOST"
self.name = name.upper()

def level_choice(self):
"""method for user choice level"""
level = ""
while level != "1" and level != "2" and level != "3":
level = input("...{} enter number of difficulty choice\n 1:easy 2:midle 3:hard\n".format(self.name))
self.level = int(level)
print("{} you choice level {} start game ..........".format(self.name,level))
sleep(2)
os.system("clear")
return level



94 changes: 94 additions & 0 deletions CONTROLLER/program.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
from random import *
import os
from time import sleep
from player import *
from main import *

class Program:
"""class for program controller """
def __init__(self):
self.program_list = []
self.numbers_program = None
self.number_user = 0
self.level_choice = None
self.play_again = None
self.result_lists = None
self.player_numbers = 0

def get_level(self, level):
"""method for save level choice user"""
self.level_choice = level

def random_choice(self):
"""method for choice random number """
if self.level_choice == 3:
# select number betwen 1 and 100
self.numbers_program = randrange(1, 100)

if self.level_choice == 2:
# select number betwen 1 and 20
self.numbers_program = randrange(1, 20)

if self.level_choice == 1:
# select number between 1 and 10
self.numbers_program = randrange(1, 10)

def add_list_choice(self):
"""add to empty list number choice"""
self.program_list.append(self.numbers_program)

def clear_terminal(self):
"""method for clear prompt after display number"""
if self.level_choice == 1:
for i in self.program_list:
print("> {}".format(i))
sleep(3)
os.system("clear")

if self.level_choice == 2:
for i in self.program_list:
print("> {}".format(i))
sleep(2)
os.system("clear")

if self.level_choice == 3:
for i in self.program_list:
print("> {}".format(i))
sleep(1)
os.system("clear")

def compare_list(self, player_numbers, program_lists):
"""compare list user and list program """
#player_numbers = int(input("enter numbers ......:"))
for i in self.program_list:
self.player_numbers = self.player_numbers_entry()
if self.player_numbers != i:
result_lists = False

pursuite = self.play_again_choice()
"""else:
result_lists = True
return result_lists"""

def player_numbers_entry(self):
"""method for verify if number is an integer"""
try:
self.player_numb = int(input("enter numbers........:"))
except:
print("not good")
return self.player_numb

def play_again_choice(self):
"""ask to player if his play again"""
while self.play_again != "yes" or self.play_again != "no":
self.play_again = input("do you want to play again enter yes or no :")
if self.play_again == "yes":
restart = True
return restart

else:
print("good bye")
exit()



Empty file added MODEL/README.md
Empty file.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#python game "simon"
this an model of pyhton game "simon"
i have create this game for project in python
i use class method object and attributes for this game