def evolution(self, raw_list, user_id, pay_time): """ 进化(吞噬) :param raw_list: 原材料,只能为同等级的材料 :return: """ if (not raw_list) or len(raw_list) == 0: logger.exception('原材料为空!') raise RuntimeError('原材料列表为空') raw_material_level = raw_list[0].level if raw_material_level + 1 not in self.cards.keys(): logger.info('已经是最高级的卡牌,不能合成') return None logger.info('删除原材料') # 删除原材料 for raw_material in raw_list: mysql_util.query(""" UPDATE `draw_record` SET is_valid=0 WHERE id=%s """, (raw_material.id,)) # 从高1级的卡中获得一张 new_card = util.choice(self.cards[raw_material_level + 1]) logger.debug('合成的新卡: %s' % new_card) mysql_util.query(""" INSERT INTO `draw_record` (`supporter_id`, `card_id`, `draw_time`, `is_valid`) VALUES (%s, %s, %s, %s) """, (user_id, new_card.id, pay_time, 1)) logger.info('合卡完成')
def can_draw(self): """ 是否可以抽中卡, 概率1/3 :return: """ candidates = [i for i in range(3)] rst = util.choice(candidates) logger.debug('是否抽中卡: %s' % (rst[0] < 1)) return rst[0] < 1
def random_move(self): """ 随机移动 :return: """ ds = [Direction.UP, Direction.DOWN, Direction.LEFT, Direction.RIGHT] random_direction = util.choice(ds)[0] random_dist = random.randint(1, GAME_MAP.row) my_logger.info('随机移动') result = '移动方向: {}, 移动距离: {}, '.format(random_direction, random_dist) self.move(random_direction, random_dist) result += '当前位置: {}\n'.format(self.current_point) return result
def draw_lottery(user_id, group_id): """ 抽签 :param user_id: :param group_id: :return: """ logger.info('抽签,QQ={}, group_id={}'.format(user_id, group_id)) cursor_2 = lottery_db.cursor() res_str = '' try: # 是否有抽签记录 c = cursor_2.execute( """ SELECT `lot_date` FROM `t_lot` WHERE user_id=? and group_id=? """, (user_id, group_id)) rst = c.fetchone() can_lot = True # 是否可以抽签 now_date = date.today() if rst: last_lot_date = datetime.datetime.strptime(rst[0], "%Y-%m-%d").date() logger.info('上次抽签日期: {}, 今天日期为: {}'.format(last_lot_date, now_date)) if last_lot_date >= now_date: can_lot = False if not can_lot: return '[CQ:at,qq={}] 你今天已经抽过签了,请明天再来!'.format(user_id) # 抽签步骤:随机抽取,存进DB current_lot = util.choice(lottery_data)[0] logger.info('本次抽签: {}'.format(current_lot)) cursor_2.execute( """ INSERT OR REPLACE INTO `t_lot` (`user_id`, `group_id`, `lot_date`, `lot_id`, `has_solve`) VALUES (?, ?, ?, ?, ?) """, (user_id, group_id, now_date.strftime('%Y-%m-%d'), current_lot['ID'], 0)) lottery_db.commit() res_str = '[CQ:at,qq={}] 您抽到了第{}签:{}'.format(user_id, current_lot['ID'], current_lot['抽签']) logger.info(res_str) except Exception as e: logger.exception(e) finally: cursor_2.close() return res_str
def create_character(modian_id, modian_name): """ 创建人物 :return: """ my_logger.info('创建人物, modian_id: %s' % modian_id) # 随机生成属性 prop1 = random.randint(40, 70) prop2 = random.randint(30, 60) prop3 = random.randint(5, 20) prop4 = random.randint(0, 50) prop5 = random.randint(30, 50) mysql_util.query( """ INSERT INTO `t_character` (`modian_id`, `name`, `prop1`, `prop2`, `prop3`, `prop4`, `prop5`) VALUES (%s, %s, %s, %s, %s, %s, %s) """, (modian_id, modian_name, prop1, prop2, prop3, prop4, prop5)) intro_words = [ "樱桃树绽放出粉红的花朵,当微风吹过的时候,花瓣便在树枝上轻轻抖动,在这段沿盘山的小路上走来一位魔法师,胸前的徽章上似乎是一只小熊猫,那是【{}】。" .format(modian_name), "一道高大的身影出现在城堡正门前,遮住了门外照进的阳光,他似乎抬头望向了“瘦夫人”的画像,“吾【{}】,请问此处可是“葛绿元少”?”". format(modian_name), "纯血即是正义!我是高贵!纯真!有抱负的【{}】,“丝来特别灵”是我的目标".format(modian_name), "“啊啊啊啊啊”伴随着一阵高昂的惨叫声,“啦闻唠嗑”的塔楼上方划过一道骑着扫帚的身影。那是!恐高症的【{}】".format( modian_name), "窗外,一阵急促的扑打翅膀的声音传来,一只猫头鹰停在了窗台前,它伸出了左爪将一封有着红色蜡封和盾牌纹章的羊皮信放在了窗台上。【{}】拿起了这封信。" .format(modian_name) ] # 随机挑选一个出场方式 intro = util.choice(intro_words) report_str = '%s\n' % intro[0] report_str += '【%s】的魔法世界开启, 属性:\n攻: %s, 防: %s, 气: %s, 运: %s, 魅力: %s\n' % ( modian_name, prop1, prop2, prop3, prop4, prop5) return report_str
def create_character(modian_id): """ 创建人物 :return: """ my_logger.info('创建人物, modian_id: %s' % modian_id) # 随机姓名 random_name = TOTAL_NAMES.pop() my_logger.debug('随机姓名: %s' % random_name) # 随机生成属性 prop1 = random.randint(40, 70) prop2 = random.randint(30, 60) prop3 = random.randint(5, 20) prop4 = random.randint(0, 50) prop5 = random.randint(30, 50) mysql_util.query( """ INSERT INTO `t_character` (`modian_id`, `name`, `prop1`, `prop2`, `prop3`, `prop4`, `prop5`) VALUES (%s, %s, %s, %s, %s, %s, %s) """, (modian_id, random_name, prop1, prop2, prop3, prop4, prop5)) intro_words = [ "郁雷之声渐响,轰轰不绝。河海尚远,而耳中尽是浪涛之声。 似有一名字伴雷声入耳,仔细辨来,名为:【{}】。".format( random_name), "湖山深处,但见竹木阴森,苍翠重叠,不雨而润,不烟而晕, 晨雾朦胧处现一少年,“在下【{}】,请问此处可是星梦谷?”".format( random_name), "月照竹林风飞叶,竹影之下见刀光。小侠籍籍无名,仅有此片竹林识得其名为【{}】".format(random_name), "嗖的一声,一支羽箭从山坳后射了出来,呜呜声响,划过长空,【{}】松开弓弦,雁落平沙。".format(random_name), "灯宵月夕,雪际花时,市集喧闹却也听得句柔声细语:“这文书写有【{}】之名,可是你掉的?”".format(random_name) ] # 随机挑选一个出场方式 intro = util.choice(intro_words) report_str = '%s\n' % intro[0] report_str += '%s的武侠世界开启, 属性:\n攻: %s, 防: %s, 气: %s, 运: %s, 魅力: %s\n' % ( random_name, prop1, prop2, prop3, prop4, prop5) return report_str
def draw(self, user_id, nickname, backer_money, pay_time): logger.info('抽卡: user_id: %s, nickname: %s, backer_money: %s, pay_time: %s', user_id, nickname, backer_money, pay_time) # 计算抽卡张数 card_num = self.compute_draw_nums(backer_money) if card_num == 0: logger.info('集资未达到标准,无法抽卡') return '' logger.info('共抽卡%d张', card_num) rst = {} rst_type = {} rst_level = {} level_list = [CardLevel.R, CardLevel.SR, CardLevel.SSR, CardLevel.UR] type_dict = { # CardType.STAR: '星组', # CardType.MOON: '月组', # CardType.SUN: '日组', CardType.NORMAL: '普通', CardType.SPECIAL: '活动限定' } # 获取此ID已抽中的全部卡牌 rst_tmp = mysql_util.select_all(""" SELECT distinct(`card_id`) from `draw_record` where supporter_id="%s" """, (user_id,)) card_has = set() # 该用户已经拥有的卡片 card_new = set() # 该用户收集到的新卡 if rst_tmp and len(rst_tmp) > 0: for tmp in rst_tmp: card_has.add(tmp[0]) logger.debug('摩点ID: {}, 当前拥有的卡片: {}'.format(user_id, card_has)) score_add = 0 insert_sql = 'INSERT INTO `draw_record` (`supporter_id`, `card_id`, `draw_time`, `backer_money`) VALUES ' flag = False for no in range(card_num): # 先判断能否抽中卡,如果抽不中,直接跳过 # draw_rst = self.can_draw() # if not draw_rst: # continue flag = True # 卡片类型 idx = util.weight_choice(level_list, self.weights) card_type = level_list[idx] # 在对应卡片类型中,抽出一张卡 card = util.choice(self.cards[card_type])[0] logger.debug('抽出的卡: %s' % card) if card.id in card_has: logger.debug('卡片{}已经拥有,积分+1') # 如果已经拥有该卡片,积分+1 score_add += 1 else: card_new.add(card.id) card_has.add(card.id) # card = self.base_cards[card_index] insert_sql += """("%s", %s, '%s', %s),""" % (user_id, card.id, pay_time, backer_money) # 此种类型的卡如果已经达到了1张,则将该卡片从卡池中移除 # if card.id in ACTIVITY_CARD_ID: # rst2 = mysql_util.select_one(""" # SELECT count(*) from `draw_record` WHERE `card_id` = %s # """, (card.id,)) # if rst2: # if rst2[0] == 1: # if card in self.cards[card.level]: # self.cards[card.level].remove(card) if card in rst: rst[card] += 1 else: rst[card] = 1 if card.level not in rst_level: rst_level[card.level] = [] if card not in rst_level[card.level]: rst_level[card.level].append(card) if card.type0 not in rst_type: rst_type[card.type0] = [] if card not in rst_type[card.type0]: rst_type[card.type0].append(card) print(insert_sql[:-1]) logger.debug(insert_sql[:-1]) logger.debug('摩点ID: {}, 抽到的新卡片: {}'.format(user_id, card_new)) img_flag = True img_report = '' report = '恭喜抽中:\n' card_new_list = [] # 用来发图的 if CardLevel.UR in rst_level and len(rst_level[CardLevel.UR]) > 0: report += '【UR】: ' for card in rst_level[CardLevel.UR]: # report += '{}-{}*{}, '.format(type_dict[card.type0], card.name, rst[card]) new_flag = '' if card.id in card_new: new_flag = emojis.encode('(:new:)') card_new_list.append(self.cards_single[card.id]) report += '{}*{}{}, '.format(card.name, rst[card], new_flag) if img_flag: if len(card_new_list) > 0: img = util.choice(card_new_list)[0] else: img = util.choice(rst_level[CardLevel.UR])[0] img_report = '[CQ:image,file={}]\n'.format(img.url) img_flag = False report += '\n' if CardLevel.SSR in rst_level and len(rst_level[CardLevel.SSR]) > 0: report += '【SSR】: ' for card in rst_level[CardLevel.SSR]: # report += '{}-{}*{}, '.format(type_dict[card.type0], card.name, rst[card]) new_flag = '' if card.id in card_new: new_flag = emojis.encode('(:new:)') card_new_list.append(self.cards_single[card.id]) report += '{}*{}{}, '.format(card.name, rst[card], new_flag) if img_flag: if len(card_new_list) > 0: img = util.choice(card_new_list)[0] else: img = util.choice(rst_level[CardLevel.SSR])[0] img_report = '[CQ:image,file={}]\n'.format(img.url) img_flag = False report += '\n' if CardLevel.SR in rst_level and len(rst_level[CardLevel.SR]) > 0: report += '【SR】: ' for card in rst_level[CardLevel.SR]: # report += '{}{}*{}, '.format(type_dict[card.type0], card.sub_id, rst[card]) # report += '{}-{}*{}, '.format(type_dict[card.type0], card.name, rst[card]) new_flag = '' if card.id in card_new: new_flag = emojis.encode('(:new:)') card_new_list.append(self.cards_single[card.id]) report += '{}*{}{}, '.format(card.name, rst[card], new_flag) if img_flag: if len(card_new_list) > 0: img = util.choice(card_new_list)[0] else: img = util.choice(rst_level[CardLevel.SR])[0] img_report = '[CQ:image,file={}]\n'.format(img.url) img_flag = False report += '\n' if CardLevel.R in rst_level and len(rst_level[CardLevel.R]) > 0: report += '【R】: ' for card in rst_level[CardLevel.R]: # report += '{}{}*{}, '.format(type_dict[card.type0], card.sub_id, rst[card]) # report += '{}-{}*{}, '.format(type_dict[card.type0], card.name, rst[card]) new_flag = '' if card.id in card_new: new_flag = emojis.encode('(:new:)') card_new_list.append(self.cards_single[card.id]) report += '{}*{}{}, '.format(card.name, rst[card], new_flag) if img_flag: if len(card_new_list) > 0: img = util.choice(card_new_list)[0] else: img = util.choice(rst_level[CardLevel.R])[0] img_report = '[CQ:image,file={}]\n'.format(img.url) img_flag = False report += '\n' report += img_report if flag: # 如果一张都没有抽中,就不执行sql语句 mysql_util.query(insert_sql[:-1]) # 积分保存到数据库 if score_add > 0: mysql_util.query(""" INSERT INTO `t_card_score` (`modian_id`, `score`) VALUES (%s, %s) """, (user_id, score_add)) report += '通过重复卡获取积分: {}\n'.format(score_add) report += '当前积分为: {}\n'.format(self.get_current_score(user_id)) logger.debug(report) return report
def handle_event(pay_amount, character): if game_is_over(character.id): return '游戏结束' result = '' event_list_j = event_json[str(int(pay_amount))] event_list = [] weight_list = [] for event_j in event_list_j: event = Event(event_j['id'], event_j['name'], pay_amount, event_j['weight']) event_list.append(event) weight_list.append(event_j['weight']) # 按概率选出是哪个大类的事件 idx = util.weight_choice(event_list, weight_list) choice = event_list[idx] my_logger.debug('触发事件前属性: %s' % character) my_logger.info('触发事件: %s' % choice.name) event_id = choice.id event_remark = '' if choice.id == 401: # 个体-遇见NPC monsters = ['本院教师', '别院教师', '皮皮鬼', '托尼老师', '款款'] weights = [30, 30, 30, 8, 2] hit_idx = util.weight_choice(monsters, weights) hit = monsters[hit_idx] event_remark = hit if hit == '款款': # 赠送梦的碎片 result += '【{}】在身边发现款款!\n款款赠与了一块梦的碎片,并说了声再见。\n【{}】运气+10,魅力+5\n'.format( character.name, character.name, character.name) character.use_good(Good('款款', 0, 0, 0, 10, 5)) character.num_of_fragment += 1 event_id = 4011 else: result += '{}突然出现在【{}】附近\n'.format(character.name, hit) rand_int = random.randint(1, 100) if rand_int <= 75: # 75%几率获胜 result += '运气看来不错,{}并没有看到你。\n【{}】运气+5,专注+3\n'.format( hit, character.name, hit, character.name) character.use_good(Good('没有被NPC发现', 0, 3, 0, 5, 0)) event_id = 4012 else: result += '{}发现你啦,{}被遣送回学院\n运气-2,专注-5,返回出生点\n'.format( hit, character.name, character.name) character.use_good(Good('战斗胜利', 0, -5, 0, -2, 0)) # 返回出生点 character.return_to_origin() event_id = 4013 result += character.random_move() save_character(character) elif choice.id == 402: # 个体-物品 idx = random.randint(0, 1) if idx == 0: # 拾取 rand_int = random.randint(1, 100) if rand_int <= 90: # 普通事件 locations = ['门后', '台阶', '转角处', '草丛中', '路边'] item = util.choice(item_list)[0] result += '【{}】在 {} 拾到 {},\n{}\n'.format( character.name, util.choice(locations)[0], item.name, item.property_change()) character.use_good(item) event_id = 4021 event_remark = item.name else: # 物品2类 equipment = util.choice(equipment_list)[0] result += '{}在无意中发现了什么。去看看。这是什么?\n {}获得了{}精神+15,运气+15,魅力+10'.format( character.name, character.name, equipment.name) # result += '【{}】在草丛中发现一把绝世好刀,动了动食指,点击一下,获得屠龙宝刀。\n【{}】攻击+15,运+15,魅力+10\n'.format(character.name, # character.name) character.prop1 += 15 character.prop4 += 15 character.prop5 += 10 event_id = 4022 event_remark = equipment.name else: # 交易 locations = ['商店'] location = util.choice(locations)[0] equipment = util.choice(equipment_list)[0] rand_int = random.randint(1, 100) if rand_int <= 100: # 普通事件 result += '【{}】在 {} 处购得{},{}\n'.format( character.name, location, equipment.name, equipment.property_change()) character.use_good(equipment) event_id = 4023 event_remark = equipment.name # else: # # 假货 # result += '【{}】在 {} 处购得{},不料过了半日才发现竟是被奸商所骗,{}竟是赝品,运-8\n'.format(character.name, location, equipment.name, # equipment.name) # character.use_good(Good('奸商', 0, 0, 0, -8, 0)) # event_id = 4024 # event_remark = equipment.name result += character.random_move() save_character(character) elif choice.id == 403: # 互动-相识 all_character = get_all_character() rand_character = util.choice(all_character)[0] # locations = ['酒肆', '茶馆', '驿站'] # location = util.choice(locations)[0] result += '【{}】在这看到了一个身影,原来也是偷跑出来的【{}】,认识一下吧。\n'.format( character.name, rand_character.name) result += character.random_move() save_character(character) event_remark = rand_character.name elif choice.id == 404: # 互动-交恶 all_character = get_all_character() rand_character = util.choice(all_character)[0] result += '【{}】发现,原来这里还有【{}】,不能让他就这么溜过去,让他暴露吧。\n'.format( character.name, rand_character.name) result += character.random_move() save_character(character) event_remark = rand_character.name elif choice.id == 405: # 互动-PK all_character = get_all_character() rand_character = util.choice(all_character)[0] word_list = [ '【{}】只顾低头行走,被【{}】一头撞上,两人发生争执,要分个高下才肯罢休。\n'.format( character.name, rand_character.name), '【{}】和【{}】在城堡里狭路相逢,既然躲不过,那么来较量一下吧。\n'.format( character.name, rand_character.name) ] event_remark = rand_character.name result += util.choice(word_list)[0] pk_rst = character.pk(rand_character) if pk_rst: result += '【{}】魔法略胜一筹,多年的勤学苦练终于派上用场。\n【{}】精神+6,专注+5,智慧+5,运气+3,魅力+8;\n【{}】精神-6,专注-5,智慧-5,运气-3,魅力-8\n'.format( character.name, character.name, rand_character.name) character.use_good(Good('PK胜利', 6, 5, 5, 3, 8)) rand_character.use_good(Good('PK失败', -6, -5, -5, -3, -8)) event_id = 4051 else: result += '【{}】在较量中棋差一招,只怪自己学艺不精,道歉认输便得作罢。\n【{}】精神-6,专注-5,智慧-5,运气-3,魅力-8;\n【{}】精神+6,专注+5,智慧+5,运气+3,魅力+8\n'.format( character.name, character.name, rand_character.name) character.use_good(Good('PK失败', -6, -5, -5, -3, -8)) rand_character.use_good(Good('PK胜利', 6, 5, 5, 3, 8)) event_id = 4052 result += character.random_move() save_character(character) save_character(rand_character) elif choice.id == 406: # 互动-学院势力 # TODO result += '学院压制' event_remark = '学院压制' result += character.random_move() elif choice.id == 301: # 学艺-基础 skill = util.choice(skill1_list)[0] character.use_good(skill) result += '【{}】刻苦修炼,终于习得【{}】,\n{}\n'.format(character.name, skill.name, skill.property_change()) event_remark = skill.name result += character.random_move() save_character(character) elif choice.id == 302: # 学艺-进阶 skill = util.choice(skill2_list)[0] character.use_good(skill) result += '【{}】刻苦修炼,终于习得【{}】,\n{}\n'.format(character.name, skill.name, skill.property_change()) event_remark = skill.name result += character.random_move() save_character(character) elif choice.id == 201: # 门派 mentor = util.choice(SCHOOLS)[0] result += '【{}】骨骼精奇天资聪慧,{}对他青睐有加,亲自传授本门武功。\n【{}】获得真传,攻+35,防+30,气+30,运+20,魅力+40\n'.format( character.name, mentor, character.name) character.prop1 += 35 character.prop2 += 30 character.prop3 += 30 character.prop4 += 20 character.prop5 += 40 event_remark = mentor result += character.random_move() save_character(character) elif choice.id == 101: # 其他-得子 name = ['子', '女', '哪吒'] choice_name = util.choice(name)[0] result += '行走江湖,总有意外,【{}】十月怀胎,诞下一{}。\n'.format(character.name, choice_name) event_remark = choice_name result += character.random_move() save_character(character) elif choice.id == 102: # 其他-称号升级 result += '【{}】武功日益精进,救死扶伤匡扶正义,昔日的【无名小侠】如今已【名震江湖】,魅力+88\n'.format( character.name, ) character.prop5 += 88 result += character.random_move() save_character(character) event_remark = '称号升级' my_logger.debug('触发事件后属性: %s' % character) save_event(character.id, event_id, event_remark) return result
def handle_event(pay_amount, character): result = '' event_list_j = event_json[str(int(pay_amount))] event_list = [] weight_list = [] for event_j in event_list_j: event = Event(event_j['id'], event_j['name'], pay_amount, event_j['weight']) event_list.append(event) weight_list.append(event_j['weight']) # 按概率选出是哪个大类的事件 idx = util.weight_choice(event_list, weight_list) choice = event_list[idx] my_logger.debug('触发事件前属性: %s' % character) my_logger.info('触发事件: %s' % choice.name) event_id = choice.id event_remark = '' if choice.id == 401: # 个体-遇怪 monsters = ['山猴子', '宵小之徒', '小毛贼', '蒙面强盗', '皮卡丘'] weights = [24, 24, 24, 24, 4] hit_idx = util.weight_choice(monsters, weights) hit = monsters[hit_idx] event_remark = hit if hit == '皮卡丘': # 遇到皮卡丘必败 result += '【{}】在路边发现一只皮卡丘!\n皮卡丘突然发动攻击,使出十万伏特,没有人能够抵抗,【{}】落败。\n【{}】气-2,运-10\n'.format( character.name, character.name, character.name) character.use_good(Good('皮卡丘', 0, 0, -2, -10, 0)) event_id = 4011 else: result += '【{}】受到{}的突然袭击。\n'.format(character.name, hit) rand_int = random.randint(1, 100) if rand_int <= 80: # 80%几率获胜 result += '区区{}哪里是【{}】的对手,{}仓皇而逃。\n【{}】攻+5,防+3\n'.format( hit, character.name, hit, character.name) character.use_good(Good('战斗胜利', 5, 3, 0, 0, 0)) event_id = 4012 else: result += '堂堂侠客却被{}打伤,【{}】伤势过重只得遁走。\n【{}】防-3,气-2,运-2,魅力-5\n'.format( hit, character.name, character.name) character.use_good(Good('战斗胜利', 0, -3, -2, -2, -5)) event_id = 4013 save_character(character) elif choice.id == 402: # 个体-物品 idx = random.randint(0, 1) if idx == 0: # 拾取 rand_int = random.randint(1, 100) if rand_int <= 90: # 普通事件 locations = ['路边', '树林', '衙门口', '肉铺', '荒井边'] item = util.choice(item_list)[0] result += '【{}】在 {} 拾到 {},\n{}\n'.format( character.name, util.choice(locations)[0], item.name, item.property_change()) character.use_good(item) event_id = 4021 event_remark = item.name else: # 屠龙宝刀 result += '【{}】在草丛中发现一把绝世好刀,动了动食指,点击一下,获得屠龙宝刀。\n【{}】攻击+15,运+15,魅力+10\n'.format( character.name, character.name) character.prop1 += 15 character.prop4 += 15 character.prop5 += 10 event_id = 4022 else: # 交易 locations = ['店里', '小摊', '行脚商', '毛头小孩'] location = util.choice(locations)[0] equipment = util.choice(equipment_list)[0] rand_int = random.randint(1, 100) if rand_int <= 90: # 普通事件 result += '【{}】在 {} 处购得{},{}\n'.format( character.name, location, equipment.name, equipment.property_change()) character.use_good(equipment) event_id = 4023 event_remark = equipment.name else: # 假货 result += '【{}】在 {} 处购得{},不料过了半日才发现竟是被奸商所骗,{}竟是赝品,运-8\n'.format( character.name, location, equipment.name, equipment.name) character.use_good(Good('奸商', 0, 0, 0, -8, 0)) event_id = 4024 event_remark = equipment.name save_character(character) elif choice.id == 403: # 互动-相识 all_character = get_all_character() rand_character = util.choice(all_character)[0] locations = ['酒肆', '茶馆', '驿站'] location = util.choice(locations)[0] result += '【{}】在 {} 与一陌生公子交谈甚欢,问得其名为【{}】,两人因此相识。\n'.format( character.name, location, rand_character.name) event_remark = rand_character.name elif choice.id == 404: # 互动-交恶 all_character = get_all_character() rand_character = util.choice(all_character)[0] result += '【{}】正要拿起包子铺里的最后一个包子,却被【{}】抢了先,于是二人结仇。\n'.format( character.name, rand_character.name) event_remark = rand_character.name elif choice.id == 405: # 互动-PK all_character = get_all_character() rand_character = util.choice(all_character)[0] word_list = [ '【{}】在市集散步,突然被【{}】踩了脚,两人发生争执,兵刃相向。\n'.format( character.name, rand_character.name), '【{}】在雨天步行赶路,【{}】骑马奔驰溅了他一身泥水,两人发生争执,兵刃相向。\n'.format( character.name, rand_character.name) ] event_remark = rand_character.name result += util.choice(word_list)[0] pk_rst = character.pk(rand_character) if pk_rst: result += '【{}】武功略胜一筹,心想江湖恩怨也不过如此。\n【{}】攻+6,防+5,气+5,运+3,魅力+8;\n【{}】攻-6,防-5,气-5,运-3,魅力-8\n'.format( character.name, character.name, rand_character.name) character.use_good(Good('PK失败', 6, 5, 5, 3, 8)) rand_character.use_good(Good('PK胜利', -6, -5, -5, -3, -8)) event_id = 4051 else: result += '【{}】在打斗中身负重伤,恩怨情仇总不如命重要,道歉认输便得作罢。\n【{}】攻-6,防-5,气-5,运-3,魅力-8;\n【{}】攻+6,防+5,气+5,运+3,魅力+8\n'.format( character.name, character.name, rand_character.name) character.use_good(Good('PK失败', -6, -5, -5, -3, -8)) rand_character.use_good(Good('PK胜利', 6, 5, 5, 3, 8)) event_id = 4052 save_character(character) save_character(rand_character) elif choice.id == 301: # 学艺-基础 skill = util.choice(skill1_list)[0] character.use_good(skill) result += '【{}】刻苦修炼,终于习得【{}】,\n{}\n'.format(character.name, skill.name, skill.property_change()) event_remark = skill.name save_character(character) elif choice.id == 302: # 学艺-进阶 skill = util.choice(skill2_list)[0] character.use_good(skill) result += '【{}】刻苦修炼,终于习得【{}】,\n{}\n'.format(character.name, skill.name, skill.property_change()) event_remark = skill.name save_character(character) elif choice.id == 201: # 门派 mentor = util.choice(SCHOOLS)[0] result += '【{}】骨骼精奇天资聪慧,{}对他青睐有加,亲自传授本门武功。\n【{}】获得真传,攻+35,防+30,气+30,运+20,魅力+40\n'.format( character.name, mentor, character.name) character.prop1 += 35 character.prop2 += 30 character.prop3 += 30 character.prop4 += 20 character.prop5 += 40 event_remark = mentor save_character(character) elif choice.id == 101: # 其他-得子 name = ['子', '女', '哪吒'] choice_name = util.choice(name)[0] result += '行走江湖,总有意外,【{}】十月怀胎,诞下一{}。\n'.format(character.name, choice_name) event_remark = choice_name elif choice.id == 102: # 其他-称号升级 result += '【{}】武功日益精进,救死扶伤匡扶正义,昔日的【无名小侠】如今已【名震江湖】,魅力+88\n'.format( character.name, ) character.prop5 += 88 save_character(character) my_logger.debug('触发事件后属性: %s' % character) save_event(character.id, event_id, event_remark) return result