def add_material(self, mat_id, num, where=""): ''' *添加素材 ''' #获取添加前的数量 before = self.materials.get(mat_id, 0) if mat_id not in self.materials: self.materials[mat_id] = abs(num) else: self.materials[mat_id] += abs(num) #获取添加后的数量 after = self.materials[mat_id] log_data = { 'where': where, 'mat_id': mat_id, 'num': num, 'after': after, 'before': before } data_log_mod.set_log('MatProduct', self, **log_data) #加入图鉴 UserCollection.get_instance(self.uid).add_collected_card( mat_id, 'materials') self.put()
def get_collection(rk_user, params): """取得用户的图鉴信息 """ return 0, { 'collection': UserCollection.get_instance(rk_user.uid).get_collected_cards() }
def __add_card(self, cid, lv, where=None): """ 新加武将 """ ucid = create_gen_id() is_first = False if not self.cards.has_key(ucid): clv = lv exp_type = self.game_config.card_config[cid].get('exp_type', 'a') #取得卡片的技能ID self.cards[ucid] = { 'cid': cid, 'lv': clv, 'exp': self.game_config.card_level_config['exp_type'][exp_type][str( clv)], 'talent_lv': 0, 'upd_time': int(time.time()), } is_first = UserCollection.get_instance( self.uid).add_collected_card(cid) self.put() return ucid, is_first
def add_material(self, mat_id, num, where=""): ''' *添加素材 ''' #获取添加前的数量 before = self.materials.get(mat_id, 0) if mat_id not in self.materials: self.materials[mat_id] = abs(num) else: self.materials[mat_id] += abs(num) #获取添加后的数量 after = self.materials[mat_id] log_data = {'where': where, 'mat_id':mat_id, 'num':num, 'after': after, 'before': before} data_log_mod.set_log('MatProduct', self, **log_data) #加入图鉴 UserCollection.get_instance(self.uid).add_collected_card(mat_id, 'materials') self.put()
def get_collection(rk_user,params): """取得装备,材料的图鉴信息 """ user_collect_obj = UserCollection.get_instance(rk_user.uid) return 0,{ 'collection':{ 'equips':user_collect_obj.get_collected_cards('equips'), 'materials':user_collect_obj.get_collected_cards('materials'), 'props':user_collect_obj.get_collected_cards('props'), } }
def get_collection(rk_user, params): """取得装备,材料的图鉴信息 """ user_collect_obj = UserCollection.get_instance(rk_user.uid) return 0, { 'collection': { 'equips': user_collect_obj.get_collected_cards('equips'), 'materials': user_collect_obj.get_collected_cards('materials'), 'props': user_collect_obj.get_collected_cards('props'), } }
def __add_card(self,cid,lv,where=None): """ 新加武将 """ ucid = create_gen_id() is_first = False if not self.cards.has_key(ucid): clv = lv exp_type = self.game_config.card_config[cid].get('exp_type','a') #取得卡片的技能ID self.cards[ucid] = { 'cid':cid, 'lv':clv, 'exp':self.game_config.card_level_config['exp_type'][exp_type][str(clv)], 'talent_lv':0, 'upd_time':int(time.time()), } is_first = UserCollection.get_instance(self.uid).add_collected_card(cid) self.put() return ucid,is_first
def __add_equip(self, eid): """增加装备逻辑处理 Args: eid: 装备唯一标示符 """ ueid = create_gen_id() is_first = False ret = False star = self.game_config.equip_config[eid].get('star', 1) eqtype = self.game_config.equip_config[eid]['eqtype'] #因为普通装备的经验和金钱是等价的所以这里使用common_gold if eqtype <= 4: base_exp = self.game_config.equip_exp_config['common_gold'].get( '1', 500) coefficient = self.game_config.equip_exp_config[ 'common_gold_coe'].get(star, 1) else: base_exp = self.game_config.equip_exp_config['treasure_exp'].get( '1', 50) coefficient = self.game_config.equip_exp_config[ 'treasure_exp_coe'].get(star, 1) #系数coefficient real_exp = int(base_exp * coefficient) #取得卡片的技能ID self.equips[ueid] = { 'eid': eid, 'upd_time': int(time.time()), 'used_by': '', 'cur_lv': 1, 'cur_experience': real_exp, 'star': star # 装备星级 由品质 决定 } is_first = UserCollection.get_instance(self.uid).add_collected_card( eid, 'equips') ret = True self.put() return ret, ueid, is_first
def __add_equip(self, eid): """增加装备逻辑处理 Args: eid: 装备唯一标示符 """ ueid = create_gen_id() is_first = False ret = False star = self.game_config.equip_config[eid].get('star', 1) eqtype = self.game_config.equip_config[eid]['eqtype'] #因为普通装备的经验和金钱是等价的所以这里使用common_gold if eqtype<=4: base_exp = self.game_config.equip_exp_config['common_gold'].get('1', 500) coefficient = self.game_config.equip_exp_config['common_gold_coe'].get(star, 1) else: base_exp = self.game_config.equip_exp_config['treasure_exp'].get('1', 50) coefficient = self.game_config.equip_exp_config['treasure_exp_coe'].get(star, 1) #系数coefficient real_exp = int(base_exp*coefficient) #取得卡片的技能ID self.equips[ueid] = { 'eid':eid, 'upd_time':int(time.time()), 'used_by':'', 'cur_lv':1, 'cur_experience':real_exp, 'star': star # 装备星级 由品质 决定 } is_first = UserCollection.get_instance(self.uid).add_collected_card(eid,'equips') ret = True self.put() return ret, ueid, is_first