示例#1
0
    def get_participant(self):
        for i in self.idplayer:
            json = db.get_player_by_id(i)
            play = players.deserialize(json)

            self.entrant.append(play)
            self.list_player_json.append(jsons.dump(play))
示例#2
0
 def return_list_object_from_dict(cls, dic):
     list_obj = []
     for k, v in dic.items():
         json = db.get_player_by_id(k)
         play = Player.deserialize(json)
         list_obj.append(play)
     return list_obj
示例#3
0
    def split_player_by_score(liste):
        list_obj = []
        for k, v in liste.items():
            json = db.get_player_by_id(k)
            play = Player.deserialize(json)
            list_obj.append(play)
        liste_a = list_obj[0:4]
        liste_b = list_obj[4:8]

        return liste_a, liste_b
示例#4
0
 def __call__(self):
     self.view.display_player()
     id = self.view.get_user_choice()
     all_id = db.get_all_id_pl()
     while not id.isdigit() or int(id) not in all_id:
         id = self.view.get_user_choice()
     json = db.get_player_by_id(id)
     p = players.deserialize(json)
     self.view.display_player_choice(p)
     rank = self.view.change_value()
     db.update_player_rank(id, rank)
     left = self.view.left()
     while left != "":
         left = self.view.left()
     PlayerMenuController().__call__()
示例#5
0
    def ranking_by_rank(dic):
        old_id = ""
        old_score = ""
        list_same = []
        dd = {}
        d2 = {}
        alls = []
        count = 0

        for k, v in dic.items():
            if v == old_score:
                if old_id not in list_same:
                    list_same.append(old_id)
                if k not in list_same:
                    list_same.append(k)
                if old_id in alls:
                    alls.pop()

                if count == 7:

                    for i in list_same:
                        json = db.get_player_by_id(i)
                        obj = Player.deserialize(json)
                        dd[obj.rank] = obj.id
                        d2 = OrderedDict(
                            sorted(dd.items(),
                                   key=lambda t: t[0],
                                   reverse=False))

                    for ke, va in d2.items():
                        alls.append(va)

                    d2.clear()
                    dd.clear()
                    list_same.clear()

            else:

                if len(list_same) > 1:
                    for i in list_same:
                        json = db.get_player_by_id(i)
                        obj = Player.deserialize(json)
                        dd[obj.rank] = obj.id
                        d2 = OrderedDict(
                            sorted(dd.items(),
                                   key=lambda t: t[0],
                                   reverse=False))
                    for ke, va in d2.items():
                        alls.append(va)
                    d2.clear()
                    dd.clear()
                    list_same.clear()
                    alls.append(k)

                else:
                    if k not in alls:
                        alls.append(k)

            old_id = k
            old_score = v
            count += 1

        dictio = {}
        for i in alls:
            for k, v in dic.items():
                if k == i:
                    dictio[i] = v

        return dictio