adapt folders to MVC
This commit is contained in:
@@ -3,19 +3,16 @@ import json
|
||||
from models.player import Player
|
||||
|
||||
|
||||
class Participant(UserDict):
|
||||
class Participants(UserDict):
|
||||
"""Dict of players and score attending a tournament
|
||||
|
||||
takes tournament's name and list of object Player
|
||||
returns dict with player: score"""
|
||||
def __init__(self, player_list = None):
|
||||
def __init__(self, player_list): #player_list FOR TEST ; to feed when creating object
|
||||
#self.tournament
|
||||
self.player_list = player_list
|
||||
self.identifiant = ()
|
||||
self.data = {}
|
||||
self.PLAYERS_FILE = "./data/players/player_list.json"
|
||||
# initiate list
|
||||
|
||||
self.PLAYERS_FILE = "./data/players/player_list.json" #FOR TEST
|
||||
|
||||
def create_participant_from_list(self, players):
|
||||
for item in players:
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
class ScoreList(list):
|
||||
"""Player tuple (name, lastname) and score"""
|
||||
def __init__(self):
|
||||
@@ -1,4 +1,4 @@
|
||||
from models.participant import Participant
|
||||
from models.participant import Participants
|
||||
from models.turn import Turn
|
||||
|
||||
|
||||
@@ -25,7 +25,4 @@ class Tournament:
|
||||
self.description = "Pas encore de description"
|
||||
self.turn_list = []
|
||||
|
||||
def run_turns(self):
|
||||
pass
|
||||
#if self.current_turn == "Round 1":
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from random import choice, shuffle
|
||||
from models.participant import Participant
|
||||
from models.participant import Participants
|
||||
from models.match import Match
|
||||
|
||||
class Turn:
|
||||
@@ -15,35 +15,25 @@ class Turn:
|
||||
self.match_result = []
|
||||
self.player_list = []
|
||||
|
||||
def create_player_list(self): #not used for now
|
||||
"""name list from dict"""
|
||||
for player in self.participants:
|
||||
self.player_list.append([player[0], player[1]])
|
||||
|
||||
def ramble_player_list(self):
|
||||
"""shuffle player's list"""
|
||||
return shuffle(self.player_list)
|
||||
|
||||
def sort_scores(self, player_list):
|
||||
"""order players on score"""
|
||||
def score(couple):
|
||||
return couple[1]
|
||||
return sorted(player_list, key=score)
|
||||
|
||||
def sort_players_by_score(self):
|
||||
"""orders dict on value and returns sorted list"""
|
||||
return sorted(self.participants.items(), key=lambda t: t[1])
|
||||
|
||||
|
||||
def create_match(self):
|
||||
print("Liste des joueurs: ", self.player_list)
|
||||
j = 0
|
||||
k = 0
|
||||
for i in range(0, len(self.player_list), 2):
|
||||
j += 1
|
||||
match = Match(self.player_list[i][0], self.player_list[i+1][0])
|
||||
match.name = "match" + str(j)
|
||||
|
||||
if match in self.match_history: # If match has already been made, choose the next player
|
||||
match = Match(self.player_list[i][0], self.player_list[i+2][0])
|
||||
while match in self.match_history:
|
||||
k += 1# If match has already been made, choose the next player
|
||||
match = Match(self.player_list[i][0], self.player_list[i+k][0])
|
||||
self.match_list.append(match)
|
||||
else:
|
||||
self.match_list.append(match)
|
||||
|
||||
Reference in New Issue
Block a user