def lost_hp(self, num, user, type=0): if (self.mark_pos[user.pos] > 0): x = -1 while (x == -1): op.choices_num = [0] * 120 x = op.judge( ("是否发动技能【瞬身】减少飞雷神(%d)抵消此伤害?" % (self.mark_pos[user.pos])), 360, 30, ["确定", "取消"], 400, 30, 0) if (x == 0): print("%s发动技能【瞬身】抵消了伤害" % (self.name)) self.mark_pos[user.pos] -= 1 self.attack_dis = max(self.mark_pos) return 0 if (self.equip[1].id == 35): if (num > 1): print("%s使用了[%s]" % (self.name, cd.card_nm[self.equip[1].id])) num = 1 st = [ "%s被掌力击退,向后直跌了%d步,", "%s中了一击,吐出%d口鲜血,", "%s眉头一皱,只知这一掌下去功力已失了%d成," ] tmp = st[random.randint(0, 2)] print(tmp % (self.name, num)) self.hp -= num while (self.hp < 1): if (self.dying() == 0): break else: self.hp += 1 if (self.hp < 1): self.died() return num pl.upload([4, user, num, self, type]) return num
def lost_hp(self, num, user, type=0): if (self.equip[1].id == 35): if (num > 1): print("%s使用了[%s]" % (self.name, cd.card_nm[self.equip[1].id])) num = 1 st = [ "%s被掌力击退,向后直跌了%d步,", "%s中了一击,吐出%d口鲜血,", "%s眉头一皱,只知这一掌下去功力已失了%d成," ] tmp = st[random.randint(0, 2)] print(tmp % (self.name, num)) self.hp -= num while (self.hp < 1): if (self.dying() == 0): break else: self.hp += 1 if (self.hp < 1): if (self.limit == 1): print("%s发动技能【爽朗】" % (self.name)) self.limit = 0 self.hp = 2 self.max_hp = 2 else: self.died() return num pl.upload([4, user, num, self, type]) return num
def lost_hp(self, num, user, type = 0): self.hp -= num while (self.hp < 1): if (self.dying() == 0): break else: self.hp += 1 if (self.hp < 1): self.died() return num if (self.dead == 0): print("%s发动了技能【神奇】增加了%d点体力上限" % (self.name,num)) self.max_hp += num pl.upload([4, user, num, self,type]) return num
def lost_hp(self, num, user,type= 0): print("%s发动技能【尊上】" % (self.name)) if (len(pl.player_in_game[user.pos].has_card) < 2): return if (pl.player_in_game[user.pos].multi_need([1, 2, 3, 4, 5, 6]) == 0): return st = ["%s被掌力击退,向后直跌了%d步,", "%s中了一击,吐出%d口鲜血,", "%s眉头一皱,只知这一掌下去功力已失了%d成,"] tmp = st[random.randint(0, 2)] print(tmp % (self.name, num)) self.hp -= num while (self.hp < 1): if (self.dying() == 0): break else: self.hp += 1 if (self.hp < 1): self.died() return num pl.upload([4, user, num, self,type]) return num
def wave(self): if(self.flip): self.flip = 0 print("%s结束翻面状态"%(self.name)) return if(self.get_in[0] and self.dead == 0): self.chosen = [0]*100 self.now_stage = 0 pl.upload([1, self, 0, 0]) self.prepare() pl.upload([1, self, 0, 1]) if(self.get_in[1] and self.dead == 0): self.chosen = [0] * 100 self.now_stage = 1 pl.upload([1, self, 1, 0]) self.in_judge() pl.upload([1, self, 1, 1]) if(self.get_in[2] and self.dead == 0): self.chosen = [0] * 100 self.now_stage = 2 pl.upload([1, self, 2, 0]) self.get_card() pl.upload([1, self, 2, 1]) if(self.get_in[3] and self.dead == 0): self.chosen = [0] * 100 self.now_stage = 3 pl.upload([1, self, 3, 0]) self.event() pl.upload([1, self, 3, 1]) if(pl.game_over()): return if(self.get_in[4] and self.dead == 0): self.chosen = [0] * 100 self.now_stage = 4 pl.upload([1, self, 4, 0]) self.throw(max(0, len(self.has_card) - self.hp)) pl.upload([1, self, 4, 1]) if(self.get_in[5] and self.dead == 0): self.chosen = [0] * 100 self.now_stage = 5 pl.upload([1, self, 5, 0]) self.end() pl.upload([1, self, 3, 1]) self.get_in = [1, 1, 1, 1, 1, 1] self.use_kill = 0 self.drink = 0 self.now_stage = -1 pl.waves_score[self.pos] += 1
def use(now_card: Card, user, aimer, defence=1): tot = len(pl.player_in_game) x = user.pos y = aimer.pos nid = now_card.id throw_queue.append(now_card) op.use_card_arrow(user.seat, aimer.seat) pl.cd_score[x] += 1 pl.upload([2,user,aimer,now_card]) #结算前视为指定目标 if (nid in [1, 2, 3, 7, 8, 9, 10, 16, 17, 18, 19, 20]): if (pl.player_in_game[y].be_used(now_card, user) == 0): pl.upload([3, user, aimer, now_card]) return # op.use_card_arrow(x, y) if (nid > 0 and nid < 4): st = user.skill[nid - 1] print("对%s使出一招“%s”," % (aimer.name, st)) if (user.gender != aimer.gender and user.equip[0].id == 23): print("%s使用了[%s]" % (user.name, card_nm[user.equip[0].id])) if(aimer.auto): if (len(aimer.has_card) > 2): tmp = pl.player_in_game[y].has_card.pop() print("%s丢掉了" % (aimer.name), end="") tmp.show() throw_queue.append(tmp) else: tmp = get_new_card() print("%s得到了" % (user.name), end="") tmp.show() pl.player_in_game[x].has_card.append(tmp) else: x = op.judge(("如何响应%s的%s?"%(user.name,card_nm[23])),380,30,["弃置一张牌","给对方一张牌"],420,30,0) if(x != 0): tmp = get_new_card() print("%s得到了" % (user.name), end="") tmp.show() pl.player_in_game[x].has_card.append(tmp) else: aimer.can_choose = 1 x = 1 while(sum(aimer.chosen)<1 or x!=0): op.choices_num = [0]*120 x = op.judge("请弃置1张牌",380,30,["确定"],420,30,0) for i in range(len(aimer.chosen)): if(aimer.chosen[i] == 1): tmp = pl.player_in_game[y].has_card.pop(i) print("%s丢掉了" % (aimer.name), end="") tmp.show() throw_queue.append(tmp) break added = pl.player_in_game[x].drink in_lost = 0 if (defence == 0): added += (aimer.equip[1].id == 34 and nid == 2) in_lost = added + 1 elif (pl.player_in_game[y].need(4, user) == 0): added += (aimer.equip[1].id == 34 and nid == 2) in_lost = added + 1 else: if (pl.player_in_game[x].be_defenced()): added += (aimer.equip[1].id == 34 and nid == 2) in_lost = added + 1 if (in_lost): if (user.equip[0].id == 24 and len(aimer.has_card) > 1): x = 0 if(user.auto == 0): op.choices_num = [0] * 120 x = op.judge(("是否使用%s?"%(card_nm[24])), 380, 30, ["使用","不使用"], 420, 30, 0) op.has_end, op.has_confirm, op.has_cancel = 0, 0, 0 op.task_queue.clear() op.task_queue.append(op.Button("结束出牌", 750, 400, 30, op.end_stage)) op.task_queue.append(op.Button("确定", 460, 400, 30, op.confirm)) op.task_queue.append(op.Button("取消", 590, 400, 30, op.cancel)) if(x == 0): print("%s使用了[%s]" % (user.name, card_nm[user.equip[0].id])) for _ in range(2): dan_max, dan_pos = 95, -1 for i in range(0, 5): if (danger_lvl[aimer.equip[i].id] < dan_max): dan_max = danger_lvl[aimer.equip[i].id] dan_pos = i if (dan_pos >= 0): tmp_card = pl.player_in_game[y].equip[dan_pos] print("丢弃了%s的" % (aimer.name), end="") tmp_card.show() print(",") if (tmp_card.id == 35): if (pl.player_in_game[y].hp < pl.player_in_game[y].max_hp): print("丢掉了[%s]并回复1点体力" % (card_nm[35])) pl.player_in_game[y].hp += 1 pl.player_in_game[y].equip[dan_pos] = Card(0, 0, 0, dan_pos == 0) continue tmp = random.randint(0, len(aimer.has_card) - 1) tmp_card = aimer.has_card[tmp] print("丢弃了%s的" % (aimer.name), end="") tmp_card.show() print(",") throw_queue.append(tmp_card) # op.play(user) pl.player_in_game[y].has_card.pop(tmp) else: pl.player_in_game[y].lost_hp(in_lost, user,now_card.id - 1) else: if (user.equip[0].id == 28): print("%s使用了[%s]" % (user.name, card_nm[user.equip[0].id])) if (aimer.equip[2].id != 0): print("丢弃了%s的" % (aimer.name), end="") aimer.equip[2].show() pl.player_in_game[y].equip[2] = Card(0, 0, 0, 0) elif (aimer.equip[3].id != 0): print("丢弃了%s的" % (aimer.name), end="") aimer.equip[3].show() pl.player_in_game[y].equip[3] = Card(0, 0, 0, 0) pl.player_in_game[y].lost_hp(in_lost, user,now_card.id - 1) pl.upload([3, user, aimer, now_card]) return print("对%s使出了一记“%s”," % (aimer.name, card_nm[now_card.id])) if (nid == 7): if (defence == 1 and pl.player_in_game[y].need(18, user) != 0): pl.upload([3, user, aimer, now_card]) return if (pl.player_in_game[y].multi_need([1, 2, 3]) == 0): pl.player_in_game[y].lost_hp(1, user) else: use(now_card, aimer, user, 0) elif (nid == 8): if (defence == 1 and pl.player_in_game[y].need(18, user) != 0): return if (len(aimer.has_card) <= 0): return tmp_n = 0 if(len(aimer.has_card)>1): tmp_n = random.randint(0, len(aimer.has_card) - 1) print(tmp_n, len(aimer.has_card)) tmp_card = aimer.has_card[tmp_n] print("%s 亮出了 " % (aimer.name), end="") tmp_card.show() print(",") for i in range(0, len(user.has_card)): if (user.has_card[i].type == tmp_card.type): print("%s接了" % (user.name), end=" ") user.has_card[i].show() print(",") pl.player_in_game[x].has_card.pop(i) added = (aimer.equip[1].id == 34) pl.player_in_game[y].lost_hp(added + 1, user,1) break elif (nid == 9): if (defence == 1 and pl.player_in_game[y].need(18, user) != 0): return dan_max, dan_pos = 95, -1 for i in range(0, 5): if (danger_lvl[aimer.equip[i].id] < dan_max): dan_max = danger_lvl[aimer.equip[i].id] dan_pos = i if (dan_pos >= 0): tmp_card = pl.player_in_game[y].equip[dan_pos] print("丢弃了%s的" % (aimer.name), end="") tmp_card.show() print(",") if (tmp_card.id == 35): if (pl.player_in_game[y].hp < pl.player_in_game[y].max_hp): print("丢掉了[%s]并回复1点体力" % (card_nm[35])) pl.player_in_game[y].hp += 1 throw_queue.append(tmp_card) pl.player_in_game[y].equip[dan_pos] = Card(0, 0, 0, dan_pos == 0) pl.upload([3, user, aimer, now_card]) return if(len(aimer.has_card)<=0):return tmp_n = 0 if (len(aimer.has_card) > 1): tmp_n = random.randint(0, len(aimer.has_card) - 1) print(tmp_n,len(aimer.has_card)) tmp_card = aimer.has_card[tmp_n] throw_queue.append(tmp_card) print("丢弃了%s的" % (aimer.name), end="") tmp_card.show() print(",") pl.player_in_game[y].has_card.pop(tmp_n) elif (nid == 10): if (defence == 1 and pl.player_in_game[y].need(18, user) != 0): pl.upload([3, user, aimer, now_card]) return dan_max, dan_pos = 95, -1 for i in range(0, 5): if (danger_lvl[aimer.equip[i].id] < dan_max): dan_max = danger_lvl[aimer.equip[i].id] dan_pos = i if (dan_pos >= 0): tmp_card = pl.player_in_game[y].equip[dan_pos] print("得到了%s的" % (aimer.name), end="") tmp_card.show() print(",") if (tmp_card.id == 35): if (pl.player_in_game[y].hp < pl.player_in_game[y].max_hp): print("丢掉了[%s]并回复1点体力" % (card_nm[35])) pl.player_in_game[y].hp += 1 pl.player_in_game[y].equip[dan_pos] = Card(0, 0, 0, dan_pos == 0) pl.player_in_game[x].has_card.append(tmp_card) pl.upload([3, user, aimer, now_card]) return if (len(aimer.has_card) <= 0): return tmp_n = random.randint(0, len(aimer.has_card) - 1) print(tmp_n, len(aimer.has_card)) tmp_card = aimer.has_card[tmp_n] print("得到了%s的" % (aimer.name), end="") tmp_card.show() print(",") pl.player_in_game[x].has_card.append(tmp_card) pl.player_in_game[y].has_card.pop(tmp_n) elif (nid == 16): if (defence == 1 and pl.player_in_game[y].need(18, user) != 0): pl.upload([3, user, aimer, now_card]) return used = pl.player_in_game[y].multi_need([1, 2, 3]) if (used != 0): new_aimer = aiming(used, aimer) if (new_aimer != 0): use(used, aimer, new_aimer) pl.upload([3, user, aimer, now_card]) return pl.player_in_game[x].has_card.append(pl.player_in_game[y].equip[0]) print("得到了%s的" % (aimer.name)) pl.player_in_game[y].equip[0].show() pl.player_in_game[y].equip[0] = Card(0, 0, 0, 1) elif (nid == 17): if(aimer.connect == 0): print("横置了%s" % (aimer.name)) else: print("解除了%s的横置" % (aimer.name)) aimer.connect ^= 1 elif (nid == 19): pl.player_in_game[y].judge.append(now_card) elif (nid == 20): pl.player_in_game[y].judge.append(now_card) elif (nid > 21): if (nid > 21 and nid < 32): print("拾起了%s," % (card_nm[now_card.id])) if (pl.player_in_game[x].equip[0].id != 0): pl.player_in_game[x].equip[0].alpha = 255 throw_queue.append(pl.player_in_game[x].equip[0]) pl.player_in_game[x].equip[0] = now_card elif (nid > 31 and nid < 36): print("装上了%s," % (card_nm[now_card.id])) if (pl.player_in_game[x].equip[1].id == 35): if (pl.player_in_game[x].hp < pl.player_in_game[x].max_hp): print("丢掉了[%s]并回复1点体力" % (card_nm[35])) pl.player_in_game[x].hp += 1 if (pl.player_in_game[x].equip[1].id != 0): pl.player_in_game[x].equip[1].alpha = 255 throw_queue.append(pl.player_in_game[x].equip[1]) pl.player_in_game[x].equip[1] = now_card elif (nid > 35 and nid < 39): if (pl.player_in_game[x].equip[2].id != 0): pl.player_in_game[x].equip[2].alpha = 255 throw_queue.append(pl.player_in_game[x].equip[2]) print("骑上了%s," % (card_nm[now_card.id])) pl.player_in_game[x].equip[2] = now_card elif (nid > 38 and nid < 42): if (pl.player_in_game[x].equip[3].id != 0): pl.player_in_game[x].equip[3].alpha = 255 throw_queue.append(pl.player_in_game[x].equip[3]) print("骑上了%s," % (card_nm[now_card.id])) pl.player_in_game[x].equip[3] = now_card elif (nid == 42): if (pl.player_in_game[x].equip[4].id != 0): pl.player_in_game[x].equip[4].alpha = 255 throw_queue.append(pl.player_in_game[x].equip[4]) print("发现了%s," % (card_nm[now_card.id])) pl.player_in_game[x].equip[4] = now_card else: if (nid == 5): if (pl.player_in_game[y].be_used(now_card, user) == 0): pl.upload([3, user, aimer, now_card]) return print("吃了口“%s”," % (card_nm[now_card.id])) pl.player_in_game[x].hp += 1 return elif (nid == 6): if (pl.player_in_game[y].be_used(now_card, user) == 0): pl.upload([3, user, aimer, now_card]) return print("喝了口“%s”," % (card_nm[now_card.id])) pl.player_in_game[x].drink = 1 return elif (nid == 15): if (pl.player_in_game[y].be_used(now_card, user) == 0): pl.upload([3, user, aimer, now_card]) return print("以内功“%s”," % (card_nm[now_card.id])) pl.player_in_game[x].has_card.append(get_new_card()) pl.player_in_game[x].has_card.append(get_new_card()) # elif (nid == 17): # if (pl.player_in_game[y].be_used(now_card, user) == 0): # pl.upload([3, user, aimer, now_card]) # return # print("重铸了“%s”," % (card_nm[now_card.id])) # pl.player_in_game[x].has_card.append(get_new_card()) else: print("%s趁众人不备,用出了“%s”," % (user.name, card_nm[now_card.id])) if (nid == 11): for item in pl.player_in_game: if (item.dead or item.pos == x or item.be_aimed(now_card, user) == 0): continue if (defence == 1 and pl.player_in_game[item.pos].need(18, user) != 0): continue if (pl.player_in_game[item.pos].be_used(now_card, user) == 0): continue op.use_card_arrow(x, item.seat) if (pl.player_in_game[item.pos].need(4, user) == 0): pl.player_in_game[item.pos].lost_hp(1, user) elif (nid == 12): for item in pl.player_in_game: if (item.dead or item.pos == x or item.be_aimed(now_card, user) == 0): continue if (defence == 1 and pl.player_in_game[item.pos].need(18, user) != 0): continue if (pl.player_in_game[item.pos].be_used(now_card, user) == 0): continue op.use_card_arrow(x, item.seat) if (pl.player_in_game[item.pos].multi_need([1, 2, 3]) == 0): pl.player_in_game[item.pos].lost_hp(1, user) elif (nid == 13): for item in pl.player_in_game: y = item.pos if (pl.player_in_game[item.pos].be_used(now_card, user) == 0): continue op.use_card_arrow(x, item.seat) if (item.dead == 0 and item.be_aimed(now_card, user)): pl.player_in_game[y].hp += 1 elif (nid == 14): tmp_card_list = [] for item in pl.player_in_game: if(item.dead == 0): tmp_card_list.append(get_new_card()) tmp_card_list.sort(key= lambda x:x.defence_level) for item in tmp_card_list: print(card_nm[item.id]) for item in pl.player_in_game: y = item.pos if (item.dead == 1 or pl.player_in_game[item.pos].be_used(now_card, user) == 0): continue op.use_card_arrow(x, item.seat) if (item.be_aimed(now_card, user)): tmp_card = tmp_card_list.pop(0) print("%s拿到了%s," % (item.name, card_nm[tmp_card.id])) pl.player_in_game[y].has_card.append(tmp_card) print() pl.upload([3, user, aimer, now_card])