def up_horse(self, socket_id, horse_id): # 上马 from core.horse import Horse try: this_socket = self.formation.sockets[str(socket_id)] except KeyError: raise SanguoException(errormsg.FORMATION_NONE_EXIST_SOCKET, self.char_id, "Formation Up Horse", "Socket {0} not exist".format(socket_id)) horse = Horse(self.char_id) if not horse.has_horse(horse_id): raise SanguoException( errormsg.HORSE_NOT_EXIST, self.char_id, "formation Up Horse", "horse, {0} not belong to self".format(horse_id)) changed_socket = [] this_socket.horse = horse_id for k, v in self.formation.sockets.iteritems(): if int(k) == socket_id: continue if v.horse == horse_id: v.horse = 0 changed_socket.append((int(k), v)) break changed_socket.append((socket_id, this_socket)) self.formation.save() for k, v in changed_socket: self.send_socket_changed_notify(k, v)
def _check_horses(char_id, ids, func_name=""): from core.horse import Horse horse = Horse(char_id) for _id in ids: if not horse.has_horse(_id): raise SanguoException(HORSE_NOT_ENOUGH, char_id, func_name, "horse {0} Not Enough/Exist".format(_id)) yield for _id in ids: horse.remove(_id)
def _check_horses(char_id, ids, func_name=""): from core.horse import Horse horse = Horse(char_id) for _id in ids: if not horse.has_horse(_id): raise SanguoException(HORSE_NOT_ENOUGH, char_id, func_name, "horse {0} Not Enough/Exist".format(_id)) yield for _id in ids: horse.remove(_id)
def up_horse(self, socket_id, horse_id): # 上马 from core.horse import Horse try: this_socket = self.formation.sockets[str(socket_id)] except KeyError: raise SanguoException( errormsg.FORMATION_NONE_EXIST_SOCKET, self.char_id, "Formation Up Horse", "Socket {0} not exist".format(socket_id) ) horse = Horse(self.char_id) if not horse.has_horse(horse_id): raise SanguoException( errormsg.HORSE_NOT_EXIST, self.char_id, "formation Up Horse", "horse, {0} not belong to self".format(horse_id) ) changed_socket = [] this_socket.horse = horse_id for k, v in self.formation.sockets.iteritems(): if int(k) == socket_id: continue if v.horse == horse_id: v.horse = 0 changed_socket.append((int(k), v)) break changed_socket.append((socket_id, this_socket)) self.formation.save() for k, v in changed_socket: self.send_socket_changed_notify(k, v)