Esempio n. 1
0
    def load_from_db(self, id):
        rows = self.select_by_id('player', id)
        for row in rows:
            self.id = row[0]
            self.name = row[1]
            self.password = row[2]
            self.email = row[3]

            with self.connection:
                cursor = self.connection.cursor()
                cursor.execute(
                    "select achievement_id from achievement_player where player_id={}".format(id))

                for achievement_player_row in cursor.fetchall():
                    achievement_id = achievement_player_row[0]
                    achievement = Achievement(self.connection)
                    self.achievements.append(achievement.load_from_db(achievement_id))

                cursor.execute(
                    "select counter_id from counter_player where player_id={}".format(id))

                for counter_player_row in cursor.fetchall():
                    counter_id = counter_player_row[0]
                    counter = Counter(self.connection)
                    self.counters.append(counter.load_from_db(counter_id))

                cursor.execute("select id from money where player_id={}".format(id))
                for money_row in cursor.fetchall():
                    money_id = money_row[0]
                    money = Money(self.connection)
                    money.load_from_db(money_id)
                    self.wallet[money.type] = money
Esempio n. 2
0
    def load_from_db(self, nickname):
        sql_data = {'nickname': nickname}
        sql_query = """SELECT id, role, nickname, email, password, banned,
                       description FROM user WHERE nickname=%(nickname)s"""

        with self.connect:
            cur = self.connect.cursor()
            cur.execute(sql_query, sql_data)

        result = cur.fetchone()
        if not result:
            return False

        user = UserFactory.create_user(result)
        achievements = Achievement.load_from_db(user.user_id, self.connect)
        user.achievements = {}
        for achievement in achievements:
            user.achievements[achievement[1]] = Achievement(
                achievement[1], achievement[0])

        currencies = Currency.load_from_db(user.user_id, self.connect)
        user.currency = {}
        for currency in currencies:
            user.currency[currency[2]] = Currency(currency[2], currency[0],
                                                  currency[1])

        progresses = Progress.load_from_db(user.user_id, self.connect)
        user.progresses = {}
        for progress in progresses:
            user.progresses[progress[0]] = Progress(progress[0], progress[1],
                                                    progress[2], progress[3])

        return user
Esempio n. 3
0
    def load_from_db(self, nickname):
        sql_data = {
            'nickname': nickname
        }
        sql_query = """SELECT id, role, nickname, email, password, banned,
                       description FROM user WHERE nickname=%(nickname)s"""

        with self.connect:
            cur = self.connect.cursor()
            cur.execute(sql_query, sql_data)

        result = cur.fetchone()
        if not result:
            return False

        user = UserFactory.create_user(result)
        achievements = Achievement.load_from_db(user.user_id, self.connect)
        user.achievements = {}
        for achievement in achievements:
            user.achievements[achievement[1]] = Achievement(achievement[1],
                                                            achievement[0])

        currencies = Currency.load_from_db(user.user_id, self.connect)
        user.currency = {}
        for currency in currencies:
            user.currency[currency[2]] = Currency(currency[2], currency[0],
                                                  currency[1])

        progresses = Progress.load_from_db(user.user_id, self.connect)
        user.progresses = {}
        for progress in progresses:
            user.progresses[progress[0]] = Progress(progress[0], progress[1],
                                                    progress[2], progress[3])

        return user
Esempio n. 4
0
    def _give_achievement(self):
        """
        >>> progress = Progress(Progress.EXPERIENCE_ID, 'Experience')
        >>> progress._give_achievement()
        Give achievement: ACHIEVEMENT_Experience
        ACHIEVEMENT_Experience
        """
        achievement_name = 'ACHIEVEMENT_' + self.name
        print('Give achievement: {}'.format(achievement_name))
        achievement = Achievement(self.progress_type, achievement_name)

        return achievement
Esempio n. 5
0
File: main.py Progetto: mansxu/2048
	def build(self):
		global app, achievement
		app = self
		achievement = Achievement(self)
		achievement.set_config(app.config)
		achievement.setup_ui()
Esempio n. 6
0
 def _is_achievement(self):
     achievements = Achievement.load_from_db(self.user_id, self.connect)
     return achievements
Esempio n. 7
0
 def storeAchievement(self, name, value=0.0, rating=0):
     Achievement.upsert(self, name, value, rating)
Esempio n. 8
0
 def _is_achievement(self):
     achievements = Achievement.load_from_db(self.user_id, self.connect)
     return achievements
    def _give_achievement(self):
        achievement_name = 'ACHIEVEMENT_' + self.name
        print('Give achievement: {}'.format(achievement_name))
        achievement = Achievement(self.progress_type, achievement_name)

        return achievement
Esempio n. 10
0
 def storeAchievement(self, name, value=0.0, rating=0):
     Achievement.upsert(self, name, value, rating)
Esempio n. 11
0
 def __initEmptyAchievementList(self):
     # as a general guideline, I should have the hidden achievements last in the list        
     self.achievementList.clear()
     self.achievementList.append(Achievement("Pe toate ma ?", False, "Find all the images", None, FoundAllImagesProperty(self.__imageFolderPath), Constants.TRIGGER_FOUND_IMAGE))
     self.achievementList.append(Achievement("Ce-o zis ala ba ?", False, "Find (almost) all the sound cues", SoundCue(self.__determineSoundCuePath(StatsRepository.TONTULE)), FoundAllSoundCuesProperty(self.__soundCueFolderPath), Constants.TRIGGER_FOUND_SOUND_CUE))
     self.achievementList.append(Achievement("You did it. You crazy son of a bitch, you did it", False, "Perfect level", SoundCue(self.__determineSoundCuePath(StatsRepository.ESTI_TAMPIT)), PerfectLevelProperty(), Constants.TRIGGER_END_LEVEL))
     
     self.achievementList.append(Achievement("Bei azi, mori maine", False, "Drink Freedom", SoundCue(self.__determineSoundCuePath(StatsRepository.SPALA_TE_JEGOSULE)), BoughtFreedomProperty(), Constants.TRIGGER_BOUGHT_DRINK))
     self.achievementList.append(Achievement("Alcoholic", False, "Drink Timisoreana", SoundCue(self.__determineSoundCuePath(StatsRepository.TRAFIC_MOLDOVEAN)), BoughtTimisoreanaProperty(), Constants.TRIGGER_BOUGHT_DRINK))
     self.achievementList.append(Achievement("Betting veteran", False, "Bet 100 times", SoundCue(self.__determineSoundCuePath(StatsRepository.ERNEST_MINTILE)), BetVeteranProperty(), Constants.TRIGGER_MADE_BET))
     self.achievementList.append(Achievement("High risk, high reward", False, "Win big", SoundCue(self.__determineSoundCuePath(StatsRepository.PACANELE_BIG_WIN)), LargeWinProperty(), Constants.TRIGGER_MADE_BET))
     self.achievementList.append(Achievement("High risk, low reward", False, "Lose big", None, LargeLossProperty(), Constants.TRIGGER_MADE_BET))
     
     self.achievementList.append(Achievement("Cioaca in libertate", True, "Find Elodia", SoundCue(self.__determineSoundCuePath(StatsRepository.DACA_TACI)), FoundImageProperty(StatsRepository.ELODIA_IMAGE_TITLE), Constants.TRIGGER_FOUND_IMAGE))
     self.achievementList.append(Achievement("Somn usor", True, "Find CV", None, FoundImageProperty(StatsRepository.CV_IMAGE_TITLE), Constants.TRIGGER_FOUND_IMAGE))
     self.achievementList.append(Achievement("One small step for a man...", True, "...one giant leap for mankind", None, FoundImageProperty(StatsRepository.BECALI_ASTRONAUT_IMAGE_TITLE), Constants.TRIGGER_FOUND_IMAGE))
     self.achievementList.append(Achievement("Buna bata", True, "Buna, Tarzan!", None, FoundImageProperty(StatsRepository.TARZAN_IMAGE_TITLE), Constants.TRIGGER_FOUND_IMAGE))
     self.achievementList.append(Achievement("5 RON", True, "Sora-ta ce mai face ?", None, FoundImageProperty(StatsRepository.SILVIU_IMAGE_TITLE), Constants.TRIGGER_FOUND_IMAGE))
     
     self.achievementList.append(Achievement("Cam atat stiu restu", True, "Americandrim", None, FoundAmericandrimGuysProperty(), Constants.TRIGGER_FOUND_IMAGE))
     self.achievementList.append(Achievement("Aia importanti din Valahia", True, "Traistariu & Costi", None, FoundValahiaGuysProperty(), Constants.TRIGGER_FOUND_IMAGE))
     
     self.achievementList.append(Achievement("Tot in familie", True, "Reunite La Familia", None, FoundSpecialPairProperty(StatsRepository.PUYA_IMAGE_TITLE, StatsRepository.SISU_IMAGE_TITLE), Constants.TRIGGER_FOUND_IMAGE))
     self.achievementList.append(Achievement("Surprize, surprize", True, "Surprise Andreea Marin-Banica", None, FoundSpecialPairProperty(StatsRepository.MARIN_IMAGE_TITLE, StatsRepository.BANICA_IMAGE_TITLE), Constants.TRIGGER_FOUND_IMAGE))
     self.achievementList.append(Achievement("Of, viata mea", True, "Revolutionize the music industry", None, FoundSpecialPairProperty(StatsRepository.COSTI_IMAGE_TITLE, StatsRepository.MINUNE_IMAGE_TITLE), Constants.TRIGGER_FOUND_IMAGE))
     self.achievementList.append(Achievement("Hey Scotty", True, "Jesus, man!", None, FoundSpecialPairProperty(StatsRepository.JESUSMAN_IMAGE_TITLE, StatsRepository.SCOTTY_IMAGE_TITLE), Constants.TRIGGER_FOUND_IMAGE))
     self.achievementList.append(Achievement("Dillon!", True, "You son of a bitch!", None, FoundSpecialPairProperty(StatsRepository.ARNOLD_IMAGE_TITLE, StatsRepository.DILLON_IMAGE_TITLE), Constants.TRIGGER_FOUND_IMAGE))
     self.achievementList.append(Achievement("Baia Mare", True, "Baia Maree", None, FoundSpecialPairProperty(StatsRepository.IAN_IMAGE_TITLE, StatsRepository.AZTECA_IMAGE_TITLE), Constants.TRIGGER_FOUND_IMAGE))
     self.achievementList.append(Achievement("200 Million", True, "Florinel Mbappe", None, FoundSpecialPairProperty(StatsRepository.COMAN_IMAGE_TITLE, StatsRepository.MBAPPE_IMAGE_TITLE), Constants.TRIGGER_FOUND_IMAGE))
     self.achievementList.append(Achievement("Ce faci F.O.C.A. ?", True, "Da bine MO, uite..", None, FoundSpecialPairProperty(StatsRepository.MO_IMAGE_TITLE, StatsRepository.FOCA_IMAGE_TITLE), Constants.TRIGGER_FOUND_IMAGE))
     self.achievementList.append(Achievement("Vezi ca stiu ceva despre tine", True, "Nini ai grija!", None, FoundSpecialPairProperty(StatsRepository.ASAFACI_IMAGE_TITLE, StatsRepository.IESIACASA_IMAGE_TITLE), Constants.TRIGGER_FOUND_IMAGE))
     
     self.achievementList.append(Achievement("Zi-le Guta!", True, "Guta^2", None, PictureSongComboProperty("GUTA"), Constants.TRIGGER_FOUND_COMBO))
     self.achievementList.append(Achievement("Fantastick", True, "Como bombastick", None, PictureSongComboProperty("ROMEO"), Constants.TRIGGER_FOUND_COMBO))
     self.achievementList.append(Achievement("Forrrrrrza", True, "Forrrrrrza", None, PictureSongComboProperty("COSTI"), Constants.TRIGGER_FOUND_COMBO))
     self.achievementList.append(Achievement("Regele Manasturului", True, "Stie tata!", None, PictureSongComboProperty("NELSON"), Constants.TRIGGER_FOUND_COMBO))
     self.achievementList.append(Achievement("Freestyle tiganesc", True, "Bahoi^2", None, PictureSongComboProperty("BAHOI"), Constants.TRIGGER_FOUND_COMBO))
     self.achievementList.append(Achievement("Chica Bomb", True, "Chica Bomb de la Dan Balan", None, PictureSongComboProperty("BALAN"), Constants.TRIGGER_FOUND_COMBO))
     self.achievementList.append(Achievement("Nane 2008 ?", True, "Nane 2019 ?", None, PictureSongComboProperty("NANE"), Constants.TRIGGER_FOUND_COMBO))
     self.achievementList.append(Achievement("$1", True, "4 lei", None, PictureSongComboProperty("FIFTY"), Constants.TRIGGER_FOUND_COMBO))
     self.achievementList.append(Achievement("Am vazut-o pe strada", True, "De ce n-ai mers la ea ?", None, PictureSongComboProperty("ZMAILI"), Constants.TRIGGER_FOUND_COMBO))
     self.achievementList.append(Achievement("Eurovision 2006", True, "Tomberon", None, PictureSongComboProperty("TRAISTARIU"), Constants.TRIGGER_FOUND_COMBO))
     self.achievementList.append(Achievement("Let me live my americandrim", True, "Zice bine Puya", None, PictureSongComboProperty("PUYA"), Constants.TRIGGER_FOUND_COMBO))
     
     self.achievementList.append(Achievement("K House", True, "Usile vol. 2", None, SetNameProperty(["specii"]), Constants.TRIGGER_SET_NAME))
     self.achievementList.append(Achievement("Suntem", True, "Mr. Chinese", SoundCue(self.__determineSoundCuePath(StatsRepository.MR_CHINESE)), SetNameProperty(["chin", "china", "domnul"]), Constants.TRIGGER_SET_NAME))
     
     self.__saveAchievements()