def set_user_exp_up_campaign(self, user_data_model, user_ids, is_win): now_datetime = get_now_datetime() now_time = get_serial_date() using_data = user_data_model.get_enable_protein_effect(user_ids) effect_time = 0 if is_win: effect_time = self.__war_win_exp_up_campaign_time else: effect_time = self.__war_lose_exp_up_campaign_time using_ids = [] insert_data = [] # 既に使用中のユーザは終了直後に発動 for row in using_data: using_ids.append(int(row['user_id'])) insert_data.append([row['user_id'], row['end_time'], row['end_time'] + effect_time, now_date]) for user_id in user_ids: if int(user_id) in using_ids: continue insert_data.append([user_id, now_time, now_time + effect_time, now_datetime]) # プロテイン効果を登録 user_data_model.insert_protein_effect(user_ids, insert_data)
def update_unregist_child_team(self, team_id): now_datetime = get_now_datetime() # 敗北チームに傘下がいた場合は解放 sql = 'update team set parent_team_id = null, updated = %s where parent_team_id = %s' self._db.execute(sql, (now_datetime, team_id))
def update_team_as_war_lose(self, team_id, war_class_id): now_datetime = get_now_datetime() # 傘下には入らず敗北数更新 sql = 'update team set lose = lose + 1, win_straight_count = 0, child_team_id = null, war_class_id = %s, updated = %s where id = %s' self._db.execute(sql, (war_class_id, now_datetime, team_id))
def get_war_exp_campaign_data(self): now_datetime = get_now_datetime() sql = 'select id from campaign where name = %s and open_datetime <= %s and end_datetime >= %s' self._db.execute(sql, ('war_exp_up', now_datetime, now_datetime)) return self._db.fetchone()
def insert_war_victory_log(self, war_id, team_id, victory_count): now_datetime = get_now_datetime() now = datetime.now() sql = 'insert into war_victory_log (war_result_id, team_id, year, month, day, hour, victory, created) values (%s, %s, %s, %s, %s, %s, %s, %s)' self._db.execute(sql, (war_id, team_id, now.year, now.month, now.day, now.hour, victory_count, now_datetime))
def insert_team_ranking_point(self, event_id, type, win_team_id, lose_team_id, ranking_point): now_datetime = get_now_datetime() sql = 'insert into team_ranking_point_record (event_id, type, team_id, point, created) values (%s, %s, %s, %s, %s)' values = [] values.append( (event_id, type, win_team_id, ranking_point, now_datetime)) values.append( (event_id, type, lose_team_id, -ranking_point, now_datetime)) self._db.executemany(sql, values)
def add_exp_to_user(self, user_id, user_exp): now_datetime = get_now_datetime() sql = ''' insert into pending_exp (user_id, exp, updated, created) values (%s, %s, %s, %s) on duplicate key update exp=exp+%s, updated=%s ''' # 場数付与 self._db.execute(sql, (user_id, user_exp, now_datetime, now_datetime, user_exp, now_datetime))
def get_successive_victory_present_list(self, user_data_list, prize_data_list, victory_count): now_datetime = get_now_datetime() now_time = get_serial_date() present_list = [] for prize in prize_data_list: for user_data in user_data_list: present_list.append( (user_data['id'], prize['item_type'], prize['item_id'], self.get_victory_prize_message(victory_count), prize['quantity'], now_time, now_datetime)) return present_list
def insert_war_shuffle_result_log( self, war_league_schedule_mst_id, war_result_id, win_team_id, win_team_prev_war_class_mst_id, win_team_post_war_class_mst_id, lose_team_id, lose_team_prev_war_class_mst_id, lose_team_post_war_class_mst_id): sql = 'insert into war_shuffle_result_log (war_league_schedule_mst_id, war_result_id, win_team_id, win_team_prev_war_class_mst_id, win_team_post_war_class_mst_id, lose_team_id, lose_team_prev_war_class_mst_id, lose_team_post_war_class_mst_id, created)' sql += ' values(%s, %s, %s, %s, %s, %s, %s, %s, %s)' now_datetime = get_now_datetime() params = (war_league_schedule_mst_id, war_result_id, win_team_id, win_team_prev_war_class_mst_id, win_team_post_war_class_mst_id, lose_team_id, lose_team_prev_war_class_mst_id, lose_team_post_war_class_mst_id, now_datetime) self._db.execute(sql, params)
def set_value(self, user_id, condition_type, amount, test_opr=None): result_set = self.__get_status_by_condition_type( user_id, condition_type) # 各ステータスの値を更新 for row in result_set: # 初期値チェック row['count'] = row['count'] if row['count'] else 0 row['lv'] = row['lv'] if row['lv'] else 0 row['prize_received'] = row['prize_received'] if row[ 'prize_received'] else 0 if row['prize_received'] == 0: if test_opr is None or eval('%s %s %s' % (amount, test_opr, row['count'])): # カウントアップ row['count'] = amount now_datetime = get_now_datetime() # 各行を初期化、更新 self._db.execute( ''' insert into mission_user_status (mission_id, user_id, count, lv, updated, created) values (%s, %s, %s, %s, %s, %s) on duplicate key update count=%s, lv=%s, updated=%s ''', ( # 初期化用 row['mission_id'], user_id, row['count'], row['lv'], now_datetime, now_datetime, # 更新用 row['count'], row['lv'], now_datetime))
def get_win_present_list(self, user_id_list, result_data): now_datetime = get_now_datetime() now_time = get_serial_date() present_list = [] if len(user_id_list) == 0: return present_list prize_data_list = json.loads(result_data['get_item']) for user_id in user_id_list: for win_item in prize_data_list: present_list.append( (user_id, int(win_item['item_type']), int(win_item['item_id']), self.get_win_present_message(), int(win_item['quantity']), now_time, now_datetime)) return present_list
def get_beginner_exp_campaign_data(self): now_datetime = get_now_datetime() # キャンペーン取得 campaign_names = [ 'beginer_exp_up_%' ] sql = ''' SELECT id, name, setting_value, open_datetime, end_datetime FROM campaign WHERE name like %s AND open_datetime <= %s AND end_datetime > %s AND is_valid = 1 ''' self._db.execute(sql, (campaign_names, now_datetime, now_datetime)) return self._db.fetchall()
def get_exp_campaign_data(self): now_datetime = get_now_datetime() # キャンペーン取得 campaign_names = [ 'exp_up' ] sql = ''' SELECT id, name, setting_value, open_datetime, end_datetime FROM campaign WHERE name in (%s) AND open_datetime <= %s AND end_datetime > %s AND is_valid = 1 ''' % (','.join(['%s' for row in campaign_names]), '%s', '%s') self._db.execute(sql, campaign_names + [now_datetime, now_datetime]) return self._db.fetchall()
def update_team_status(self, team_id, win_count, war_class_id): now_datetime = get_now_datetime() sql = 'update team set win = %s, win_straight_count = win_straight_count + 1, war_class_id = %s, updated = %s where id = %s' self._db.execute(sql, (win_count, war_class_id, now_datetime, team_id))