本文整理汇总了Python中match.Match.winner方法的典型用法代码示例。如果您正苦于以下问题:Python Match.winner方法的具体用法?Python Match.winner怎么用?Python Match.winner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类match.Match
的用法示例。
在下文中一共展示了Match.winner方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_winner
# 需要导入模块: from match import Match [as 别名]
# 或者: from match.Match import winner [as 别名]
def test_winner(self):
game1 = Game(Team("Cate"), Team("Opponent1"), Team("Cate"))
game2 = Game(Team("Cate"), Team("Opponent1"), Team("Cate"))
games = []
for x in range(0, 6):
games.append(game1)
set1 = Set(games)
sets = []
for x in range(0, 18):
sets.append(set1)
match1 = Match(sets, game1.teamA, game1.teamB)
self.assertEqual(game1.teamA, match1.winner())
示例2: parse_input
# 需要导入模块: from match import Match [as 别名]
# 或者: from match.Match import winner [as 别名]
def parse_input(self, input):
self.interface = Interface()
inputs = input.split(" ")
games = []
sets = []
game = None
teamA_name = ""
teamB_name = ""
playersA = ""
playersB = ""
game_score = ""
row = 1
col = 1
num_sets = 0
for line in inputs:
#reading the input one line at a time, will start with teamA_name, teamB_name, etc)
if teamA_name == "":
teamA_name = line
elif teamB_name == "":
teamB_name = line
elif playersA == "":
playersA = line
elif playersB == "":
playersB = line
elif game_score == "":
game_score = line
if teamA_name != "" and teamB_name != "" and playersA != "" and playersB != "" and game_score != "":
#constructing the games sets match
team1 = Team(teamA_name)
team2 = Team(teamB_name)
scores = game_score.split("-")
game = Game(team1, team2, int(scores[0]), int(scores[1]))
games.append(game)
print "num_sets: " + str(num_sets)
set = Set(games, teamA_name, teamB_name, playersA.split(",")[num_sets%3], playersB.split(",")[num_sets%3])
match = Match(sets, team1, team2)
print "games : " + str(len(games))
#checking if there is a set winner, and then updating the user-interface in the table
if set.winner() != None:
num_sets += 1
score = str(set.get_teamA_wins()) + '-' + str(set.get_teamB_wins())
self.interface.t.set(row, col, score)
if row == 1 and col == 1:
self.interface.t.set(4, col, set.playersA)
self.interface.t.set(row, 4, set.playersB)
if row == 2 and col == 2:
self.interface.t.set(4, col, set.playersA)
self.interface.t.set(row, 4, set.playersB)
if row == 3 and col == 3:
self.interface.t.set(4, 3, set.playersA)
self.interface.t.set(3, 4, set.playersB)
self.interface.t.set(4, 4, "Players")
print "row: " + str(row) + " col: " + str(col) + " score: " + str(score)
print "set.playersA: " + str(set.playersA)
print "set.playersB: " + str(set.playersB)
if col < 3: #setting up the players in the table
col += 1
else:
col = 1
row += 1
if row == 4:
col = 1
row = 1
sets.append(set)
games = []
if match.winner() != None: #emptying out the lists of games and sets everytime a new match is started
games = []
sets = []
game_score = ""
return match