Exemple #1
0
 def set_trade_return(self):
     #move item and gold to trade_return_list and trade_return_gold
     #must check_trade_list before
     with self.lock and self.user.lock:
         if not self.online:
             return
         general.log("[ pc  ] set_trade_return")
         script.takegold(self, self.trade_gold)
         self.trade_return_gold = self.trade_gold
         for iid, count in self.trade_list:
             item = self.item.get(iid)
             if item.count > count:
                 item.count -= count
                 item_return = general.copy(item)
                 item_return.count = count
                 self.trade_return_list.append(item_return)
                 #self.map_send("09cf", item, iid) #アイテム個数変化
                 script.msg(self, "%sを%s個失いました" % (item.name, count))
             else:
                 item_return = self.item_pop(iid)
                 item_return.count = count
                 self.trade_return_list.append(item_return)
Exemple #2
0
	def set_trade_return(self):
		#move item and gold to trade_return_list and trade_return_gold
		#must check_trade_list before
		with self.lock and self.user.lock:
			if not self.online:
				return
			general.log("[ pc  ] set_trade_return")
			script.takegold(self, self.trade_gold)
			self.trade_return_gold = self.trade_gold
			for iid, count in self.trade_list:
				item = self.item.get(iid)
				if item.count > count:
					item.count -= count
					item_return = general.copy(item)
					item_return.count = count
					self.trade_return_list.append(item_return)
					#self.map_send("09cf", item, iid) #アイテム個数変化
					script.msg(self, "%sを%s個失いました"%(item.name, count))
				else:
					item_return = self.item_pop(iid)
					item_return.count = count
					self.trade_return_list.append(item_return)
Exemple #3
0
 def do_0614(self, data_io):
     #NPCショップのアイテム購入
     general.log("[ map ] npcshop")
     with self.pc.lock:
         if self.pc.shop_open is None:
             general.log_error("do_0614: shop_open is None")
             return
         if hasattr(self.pc.shop_open, "__iter__"):
             shop_item_list = self.pc.shop_open
         else:
             shop = db.shop.get(self.pc.shop_open)
             if not shop:
                 general.log_error("do_0614 error: shop_id not exist",
                                   self.pc.shop_open)
                 return
             shop_item_list = shop.item
     item_id_list = io_unpack_array(io_unpack_int, data_io)
     item_count_list = io_unpack_array(io_unpack_int, data_io)
     item_buy_list = zip(item_id_list, item_count_list)
     general.log("[ map ] item_buy_list", item_buy_list)
     if len(self.pc.item) + len(item_buy_list) > env.MAX_ITEM_STOCK:
         script.msg(self.pc, "npcshop buy error: stock limit")
         return
     for item_id, item_count in item_buy_list:
         if not item_count:
             general.log_error("do_0614 error: item_count is 0", item_count)
             continue
         if item_id not in shop_item_list:
             general.log_error(
                 "do_0614 error: item_id not in shop_item_list", item_id,
                 shop_item_list)
             continue
         item = db.item.get(item_id)
         if not item:
             general.log_error("do_0614 error: item_id not exist", item_id)
             continue
         if script.takegold(self.pc,
                            (int(item.price / 10.0) or 1) * item_count):
             script.item(self.pc, item_id, item_count)
     self.pc.update_item_status()
	def do_0614(self, data_io):
		#NPCショップのアイテム購入
		general.log("[ map ] npcshop")
		with self.pc.lock:
			if self.pc.shop_open is None:
				general.log_error("do_0614: shop_open is None")
				return
			if hasattr(self.pc.shop_open, "__iter__"):
				shop_item_list = self.pc.shop_open
			else:
				shop = db.shop.get(self.pc.shop_open)
				if not shop:
					general.log_error(
						"do_0614 error: shop_id not exist", self.pc.shop_open)
					return
				shop_item_list = shop.item
		item_id_list = io_unpack_array(io_unpack_int, data_io)
		item_count_list = io_unpack_array(io_unpack_int, data_io)
		item_buy_list = zip(item_id_list, item_count_list)
		general.log("[ map ] item_buy_list", item_buy_list)
		if len(self.pc.item)+len(item_buy_list) > env.MAX_ITEM_STOCK:
			script.msg(self.pc, "npcshop buy error: stock limit")
			return
		for item_id, item_count in item_buy_list:
			if not item_count:
				general.log_error("do_0614 error: item_count is 0", item_count)
				continue
			if item_id not in shop_item_list:
				general.log_error("do_0614 error: item_id not in shop_item_list", 
					item_id, shop_item_list)
				continue
			item = db.item.get(item_id)
			if not item:
				general.log_error("do_0614 error: item_id not exist", item_id)
				continue
			if script.takegold(self.pc, (int(item.price/10.0) or 1)*item_count):
				script.item(self.pc, item_id, item_count)
		self.pc.update_item_status()