Ejemplo n.º 1
0
 def load_tournament_list(self):
     my_list = Tournament.load_all()
     for tournament in my_list:
         player_list = [
             Participant(participant['id'], participant['score'], set(participant['old_matchs']))
             for participant in tournament['players']
         ]
         round_list = self.round_controller.load_round(tournament['round_list'])
         tournoi = Tournament(
             tournament.doc_id,
             tournament['name'],
             tournament['start_date'],
             tournament['end_date'],
             tournament['location'],
             player_list,
             tournament['time_control'],
             tournament['max_turn']
         )
         tournoi.round_list = round_list
         tournoi.actual_turn = tournament['actual_turn']
         self.tournament_list.append(tournoi)
Ejemplo n.º 2
0
 def create_new_tournament(self):
     while True:
         (
             t_name,
             t_location,
             t_start_date,
             t_end_date,
             t_max_turn,
             t_player_cnt,
             t_play_style
         ) = self.view.new_tournament()
         tournament_validator = TournamentForm(
             t_name, t_location,
             t_start_date, t_end_date,
             t_max_turn, t_player_cnt, t_play_style
         )
         if tournament_validator.is_valid():
             break
     tournoi = Tournament(
         len(self.tournament_list),
         t_name,
         t_start_date,
         t_end_date,
         t_location,
         [],
         t_play_style,
         int(t_max_turn)
     )
     while len(tournoi.players) < int(t_player_cnt):
         player = self.player_controller.get_player()
         if not tournoi.check_by_id(player.id):
             tournoi.players.append(Participant(player.id))
         else:
             print('Ce joueur est déja présent dans le tournoi')
     self.tournament_list.append(tournoi)
     return tournoi
Ejemplo n.º 3
0
 def __init__(self, db):
     self.db = db
     self.pv_hook = PV(db)
     self.point_hook = Point(db)
     self.participant_hook = Participant(db)
Ejemplo n.º 4
0
 def __init__(self, db):
     self.db = db
     self.participant_hook = Participant(db)
Ejemplo n.º 5
0
    def __init__(self, db):
        self.service_hook = Participant(db)

        self.service_name = "participant"

        super(Participant_Service, self).__init__()
 def post( self ):
     new_participant = Participant( name=request.json[ 'name' ] )
     db.session.add( new_participant )
     db.session.commit()
     return participant_schema.dump( new_participant )
Ejemplo n.º 7
0
try:
    db_module = __import__('database.' + options.db_module,
                           fromlist=['database'])
except ImportError:
    print('DB Error.')
    exit(1)

# Connecting to database
db_hook = db_module.DBModule(options.database, options.username,
                             options.password)

# Loading models
pv_hook = PV(db_hook)
point_hook = Point(db_hook)
proposition_hook = Proposition(db_hook)
participant_hook = Participant(db_hook)

# Building tables
pv_hook.create_table()
point_hook.create_table()
proposition_hook.create_table()
participant_hook.create_table()


def setup_routes(obj):
    for kw in dir(obj):
        attr = getattr(obj, kw)
        if hasattr(attr, 'route'):
            if hasattr(attr, 'method'):
                print('routing ' + str(attr) + ' with ' + attr.route + ', ' +
                      attr.method)