def st(self, attribute, group_id, qq): if not self.attribute.__contains__(group_id): self.attribute[group_id] = {} if self.attribute[group_id].__contains__(qq): del self.attribute[group_id][qq] self.sta(attribute, group_id, qq) dataManage.save_obj(self.attribute, 'data/TRPG/coc') return '覆盖成功!目前有属性个数:' + str(len(self.attribute[group_id][qq]))
def add_role(self, attribute, group_id, role_name): if role_name.isdigit(): return '人物模板名不能全为数字!' if self.role.__contains__(role_name): del self.role[role_name] self.role[role_name], edit_number = str_to_attribute(self.role[role_name], attribute, 0) dataManage.save_obj(self.role, 'data/TRPG/cocRole') return '人物' + role_name + '已修改'
def pick(self): if len(self.bottle['message']) == 0: return '没有漂流瓶了呢~不妨扔一个' data = random.choice(self.bottle['message']) self.bottle['message'].remove(data) if data['qq'] != 1394144014: dataManage.save_obj(self.bottle, 'data/Function/Bottle/bottle') return data['text'] + '——' + data['date']
def sc(self, success, fail_dick_number, fail_dick_size, fail_dick_base, group_id, qq): if not self.attribute.__contains__(group_id): return '未能找到san值、意志两个属性,请使用rd命令手动检验' if not self.attribute[group_id].__contains__(qq): return '未能找到san值、意志两个属性,请使用rd命令手动检验' san = -1 powe = -1 result = '鉴定结果如下:' if self.attribute[group_id][qq].__contains__('san'): san = self.attribute[group_id][qq]['san'] elif self.attribute[group_id][qq].__contains__('san值'): san = self.attribute[group_id][qq]['san值'] elif self.attribute[group_id][qq].__contains__('理智'): san = self.attribute[group_id][qq]['理智'] elif self.attribute[group_id][qq].__contains__('理智值'): san = self.attribute[group_id][qq]['理智值'] if self.attribute[group_id][qq].__contains__('意志'): powe = self.attribute[group_id][qq]['意志'] elif self.attribute[group_id][qq].__contains__('pow'): powe = self.attribute[group_id][qq]['pow'] if san == -1 or powe == -1: return '未能找到san值、意志两个属性,请使用rd命令手动检验' tmp = dick_sys(100) if tmp <= powe: result = '鉴定成功!' san -= success if san <= 0: san = 0 result += '\nsan值减少:' + str(success) result += '\n目前san值:' + str(san) + '/' + str(powe) self.attribute[group_id][qq]['san'] = san self.attribute[group_id][qq]['san值'] = san self.attribute[group_id][qq]['理智'] = san self.attribute[group_id][qq]['理智值'] = san else: sum = fail_dick_base while fail_dick_number > 0: fail_dick_number -= 1 sum += dick_sys(fail_dick_size) result = '鉴定失败!' san -= sum if san <= 0: san = 0 result += '\nsan值减少:' + str(sum) result += '\n目前san值:' + str(san) + '/' + str(powe) self.attribute[group_id][qq]['san'] = san self.attribute[group_id][qq]['san值'] = san self.attribute[group_id][qq]['理智'] = san self.attribute[group_id][qq]['理智值'] = san dataManage.save_obj(self.attribute, 'data/TRPG/coc') return result
def stc(self, attribute, group_id, qq): if not self.attribute.__contains__(group_id): return '不存在该属性' if not self.attribute[group_id].__contains__(qq): return '不存在该属性' self.attribute[group_id][qq], edit_number = str_to_attribute(self.attribute[group_id][qq], attribute, 1) dataManage.save_obj(self.attribute, 'data/TRPG/coc') return '成功修改' + str(edit_number) + '个属性'
def sta(self, attribute, group_id, qq): if not self.attribute.__contains__(group_id): self.attribute[group_id] = {} if not self.attribute[group_id].__contains__(qq): self.attribute[group_id][qq] = {} self.attribute[group_id][qq], edit_number = str_to_attribute(self.attribute[group_id][qq], attribute, 0) dataManage.save_obj(self.attribute, 'data/TRPG/coc') return '追加成功!' + '\n追加属性个数:' + str(edit_number) + '\n目前有属性个数:' + str(len(self.attribute[group_id][qq]))
def copy_role(self, role_name, group_id, qq): if not self.attribute.__contains__(group_id): self.attribute[group_id] = {} if not self.attribute[group_id].__contains__(qq): self.attribute[group_id][qq] = {} if not self.role.__contains__(role_name): return '不存在该人物' self.attribute[group_id][qq] = self.role[role_name] dataManage.save_obj(self.attribute, 'data/TRPG/coc') return '已将人物模板' + role_name + '的属性复制给你~'
def std(self, attribute, group_id, qq): if not self.attribute.__contains__(group_id): return '不存在该属性' if not self.attribute[group_id].__contains__(qq): return '不存在该属性' attributeList = attribute.split(' ') edit_number = 0 for i in attributeList: i = i.strip() if not self.attribute[group_id][qq].__contains__(i): continue edit_number += 1 del self.attribute[group_id][qq][i] dataManage.save_obj(self.attribute, 'data/TRPG/coc') return '成功删除' + str(edit_number) + '个属性'
def clear_single(self, group_id, qq): if self.attribute.__contains__(group_id): if self.attribute[group_id].__contains__(qq): del self.attribute[group_id][qq] dataManage.save_obj(self.attribute, 'data/TRPG/coc') return '清空成功!'
def clear_all(self, group_id): if self.attribute.__contains__(group_id): del self.attribute[group_id] dataManage.save_obj(self.attribute, 'data/TRPG/coc') return '清空成功!'
def write_file(self): dataManage.save_obj(self.luck, self.luck_file)
if not groups.__contains__(id): groups[id] = dataManage.read_group(id) groups[id]['config']['limit_RPG'] = True dataManage.save_group(id, groups[id]) print('基本信息转移完成···') weather = load_obj('data2/weather') with open('data/Function/Weather/weather.txt', 'w', encoding='utf-8') as f: for key, value in weather.items(): f.write(key + '=' + str(value) + '\n') print('天气信息转移完成···') activity = load_obj('data2/activity') dataManage.save_obj(activity, 'data/ClockActivity/activity') print('活动数据转移完成···') clock = load_obj('data2/clockIn') dataManage.save_obj(activity, 'data/ClockActivity/clockIn') print('打卡数据转移完成···') screen = load_obj('data2/AIScreenWords') with open('data/screenWords.txt', 'w', encoding='utf-8') as f: for i in screen: f.write(i + '\n') print('屏蔽词转移完成···')