56 lines
1.5 KiB
Python
56 lines
1.5 KiB
Python
import baseballgameclass
|
|
|
|
|
|
|
|
# initial fucntion
|
|
size = []
|
|
cGameNumber = baseballgameclass.GameNumber()
|
|
guess = []
|
|
checknewgame = 0
|
|
inputset = {}
|
|
inputset = set()
|
|
|
|
# assign class
|
|
cInputNumber = baseballgameclass.InputNumber()
|
|
cCheckNumber = baseballgameclass.CheckNumber()
|
|
cPrintResult = baseballgameclass.PrintResult()
|
|
|
|
|
|
welcome = """
|
|
################################
|
|
### welcome to baseball gaem ###
|
|
###############################
|
|
"""
|
|
print(welcome)
|
|
|
|
|
|
while True:
|
|
|
|
if checknewgame == 0: # check new game
|
|
# get game size and max of number
|
|
size = cInputNumber.getGameSize()
|
|
inputset = cGameNumber.createNumberSet(size[1], size[0])
|
|
number = cGameNumber.createGameNumber(inputset)
|
|
checknewgame = 1
|
|
elif checknewgame != 3: # running game
|
|
while True:
|
|
guess = cInputNumber.getNumber(size[0]) # get created gaem number
|
|
result3 = cCheckNumber.compareNumber(number, guess) # compare input number and game number
|
|
cPrintResult.printResult(result3) # print result
|
|
# print(number)
|
|
if result3[0] == size[0]:
|
|
print('You win.')
|
|
newgame = input('continue a game (y or n) : ')
|
|
if newgame == 'y':
|
|
checknewgame = 0 # continue game
|
|
break
|
|
else:
|
|
checknewgame = 3 # stop game
|
|
break
|
|
elif checknewgame == 3: # exit game
|
|
break
|
|
|
|
|
|
|
|
|
|
|