Exemple #1
0
 def do_07e4(self, data_io):
     #pick up item request
     mapitem_id = io_unpack_int(data_io)
     general.log("[ map ] pick up item: mapitem_id", mapitem_id)
     if len(self.pc.item) >= env.MAX_ITEM_STOCK:
         script.msg(self.pc, "pick up item error: stock limit")
         return
     with self.pc.lock:
         if self.pc.trade:
             #pick up item error, トレード中はアイテムを拾うことが出来ません
             self.send("07e6", -8)
             return
         if self.pc.event_id:
             #pick up item error, イベント中はアイテムを拾うことが出来ません
             self.send("07e6", -9)
             return
         mapitem_obj = self.pc.map_obj.mapitem_pop(mapitem_id)
         if not mapitem_obj:
             #pick up item error, 存在しないアイテムです
             self.send("07e6", -1)
             return
         self.send_map("07df", mapitem_obj)  #pick up item
         item = mapitem_obj.item
         if item.stock:
             script.item(self.pc, item.item_id, item.count)
         else:
             self.pc.item_append(mapitem_obj.item)
     self.pc.update_item_status()
	def do_07e4(self, data_io):
		#pick up item request
		mapitem_id = io_unpack_int(data_io)
		general.log("[ map ] pick up item: mapitem_id", mapitem_id)
		if len(self.pc.item) >= env.MAX_ITEM_STOCK:
			script.msg(self.pc, "pick up item error: stock limit")
			return
		with self.pc.lock:
			if self.pc.trade:
				#pick up item error, トレード中はアイテムを拾うことが出来ません
				self.send("07e6", -8)
				return
			if self.pc.event_id:
				#pick up item error, イベント中はアイテムを拾うことが出来ません
				self.send("07e6", -9)
				return
			mapitem_obj = self.pc.map_obj.mapitem_pop(mapitem_id)
			if not mapitem_obj:
				#pick up item error, 存在しないアイテムです
				self.send("07e6", -1)
				return
			self.send_map("07df", mapitem_obj) #pick up item
			item = mapitem_obj.item
			if item.stock:
				script.item(self.pc, item.item_id, item.count)
			else:
				self.pc.item_append(mapitem_obj.item)
		self.pc.update_item_status()
Exemple #3
0
 def do_060f(self, data_io):
     """染色アイテム決定"""
     #所持状態が検査されていないため要変更
     unknown = io_unpack_int(data_io)
     iid = io_unpack_int(data_io)
     target_id = io_unpack_int(data_io)
     script.takeitem_byiid(self.pc, iid, 1)
     script.item(self.pc, target_id, 1)
     script.dyeing(self.pc)
Exemple #4
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()
	def do_09fb(self, data_io):
		#倉庫から取り出す
		if len(self.pc.item) >= env.MAX_ITEM_STOCK:
			#倉庫から取り出した時の結果 #キャラのアイテム数が100個を超えてしまうためキャンセルされました
			self.send("09fc", -5)
			return
		item_iid = io_unpack_int(data_io)
		item_count = io_unpack_short(data_io)
		general.log("[ map ] take item from warehouse", item_iid, item_count)
		with self.pc.lock:
			if self.pc.warehouse_open is None:
				#倉庫から取り出した時の結果 #倉庫を開けていません
				self.send("09fc", -1)
				return
			if item_iid not in self.pc.warehouse:
				#倉庫から取り出した時の結果 #指定されたアイテムは存在しません
				self.send("09fc", -2)
				return
			item = self.pc.warehouse[item_iid]
			if item.count < item_count:
				#倉庫から取り出した時の結果 #指定された数量が不正です
				self.send("09fc", -3)
				return
			elif item.count == item_count:
				self.pc.warehouse_pop(item_iid)
			else:
				item.count -= item_count
				script.msg(self.pc, "%sを%s個取り出しました"%(item.name, item_count))
			if item.stock:
				script.item(self.pc, item.item_id, item_count)
			else:
				item_take = general.copy(item)
				item_take.count = item_count
				item_take.warehouse = 0
				self.pc.item_append(item_take)
			#倉庫から取り出した時の結果 #成功
			self.send("09fc", 0)
		self.pc.update_item_status()
Exemple #7
0
 def do_09fb(self, data_io):
     #倉庫から取り出す
     if len(self.pc.item) >= env.MAX_ITEM_STOCK:
         #倉庫から取り出した時の結果 #キャラのアイテム数が100個を超えてしまうためキャンセルされました
         self.send("09fc", -5)
         return
     item_iid = io_unpack_int(data_io)
     item_count = io_unpack_short(data_io)
     general.log("[ map ] take item from warehouse", item_iid, item_count)
     with self.pc.lock:
         if self.pc.warehouse_open is None:
             #倉庫から取り出した時の結果 #倉庫を開けていません
             self.send("09fc", -1)
             return
         if item_iid not in self.pc.warehouse:
             #倉庫から取り出した時の結果 #指定されたアイテムは存在しません
             self.send("09fc", -2)
             return
         item = self.pc.warehouse[item_iid]
         if item.count < item_count:
             #倉庫から取り出した時の結果 #指定された数量が不正です
             self.send("09fc", -3)
             return
         elif item.count == item_count:
             self.pc.warehouse_pop(item_iid)
         else:
             item.count -= item_count
             script.msg(self.pc, "%sを%s個取り出しました" % (item.name, item_count))
         if item.stock:
             script.item(self.pc, item.item_id, item_count)
         else:
             item_take = general.copy(item)
             item_take.count = item_count
             item_take.warehouse = 0
             self.pc.item_append(item_take)
         #倉庫から取り出した時の結果 #成功
         self.send("09fc", 0)
     self.pc.update_item_status()
Exemple #8
0
 def _set_trade_finish(self):
     if not self.check_trade_list():
         self.cancel_trade()
         return
     if not self.trade:
         return
     self.trade_state = 1  #トレード完了してる状態
     p = self.get_trade_target()
     if p:
         with p.lock and p.user.lock:
             if not p.trade:
                 return
             if len(self.item) + len(p.trade_list) > env.MAX_ITEM_STOCK:
                 script.msg(self, "trade error: self stock limit")
                 script.msg(p, "trade error: target stock limit")
                 self.cancel_trade()
                 p.cancel_trade()
                 return
             if len(p.item) + len(self.trade_list) > env.MAX_ITEM_STOCK:
                 script.msg(self, "trade error: target stock limit")
                 script.msg(p, "trade error: self stock limit")
                 self.cancel_trade()
                 p.cancel_trade()
                 return
             if p.trade_state == 1:  #exchange item and gold
                 if not p.check_trade_list():
                     self.cancel_trade()
                     return
                 self.set_trade_return()
                 p.set_trade_return()
                 if self.trade_return_gold:
                     script.gold(p, self.trade_return_gold)
                 for item in self.trade_return_list:
                     if item.stock:
                         script.item(p, item.item_id, item.count)
                     else:
                         p.item_append(item)
                 if p.trade_return_gold:
                     script.gold(self, p.trade_return_gold)
                 for item in p.trade_return_list:
                     if item.stock:
                         script.item(self, item.item_id, item.count)
                     else:
                         self.item_append(item)
                 self.reset_trade()
                 p.reset_trade()
                 self.map_send("0a1c")  #トレード終了通知
                 p.map_send("0a1c")  #トレード終了通知
                 self.update_item_status()
                 p.update_item_status()
                 script.update_item(self)
                 script.update_item(p)
             else:  #send trade status
                 #自分・相手がOKやキャンセルを押した際に双方に送信される
                 self.map_send("0a19", self, p)
                 #自分・相手がOKやキャンセルを押した際に双方に送信される
                 p.map_send("0a19", p, self)
     elif p is False:
         #target offline or map changed
         self.cancel_trade()
     else:  #p is None: npctrade
         self.set_trade_return()
         self.reset_trade(False)  #don't clear return list
         self.map_send("0a1c")  #トレード終了通知
         self.update_item_status()
         script.update_item(self)
Exemple #9
0
	def _set_trade_finish(self):
		if not self.check_trade_list():
			self.cancel_trade()
			return
		if not self.trade:
			return
		self.trade_state = 1 #トレード完了してる状態
		p = self.get_trade_target()
		if p:
			with p.lock and p.user.lock:
				if not p.trade:
					return
				if len(self.item)+len(p.trade_list) > env.MAX_ITEM_STOCK:
					script.msg(self, "trade error: self stock limit")
					script.msg(p, "trade error: target stock limit")
					self.cancel_trade()
					p.cancel_trade()
					return
				if len(p.item)+len(self.trade_list) > env.MAX_ITEM_STOCK:
					script.msg(self, "trade error: target stock limit")
					script.msg(p, "trade error: self stock limit")
					self.cancel_trade()
					p.cancel_trade()
					return
				if p.trade_state == 1: #exchange item and gold
					if not p.check_trade_list():
						self.cancel_trade()
						return
					self.set_trade_return()
					p.set_trade_return()
					if self.trade_return_gold:
						script.gold(p, self.trade_return_gold)
					for item in self.trade_return_list:
						if item.stock:
							script.item(p, item.item_id, item.count)
						else:
							p.item_append(item)
					if p.trade_return_gold:
						script.gold(self, p.trade_return_gold)
					for item in p.trade_return_list:
						if item.stock:
							script.item(self, item.item_id, item.count)
						else:
							self.item_append(item)
					self.reset_trade()
					p.reset_trade()
					self.map_send("0a1c") #トレード終了通知
					p.map_send("0a1c") #トレード終了通知
					self.update_item_status()
					p.update_item_status()
					script.update_item(self)
					script.update_item(p)
				else: #send trade status
					#自分・相手がOKやキャンセルを押した際に双方に送信される
					self.map_send("0a19", self, p)
					#自分・相手がOKやキャンセルを押した際に双方に送信される
					p.map_send("0a19", p, self)
		elif p is False:
			#target offline or map changed
			self.cancel_trade()
		else: #p is None: npctrade
			self.set_trade_return()
			self.reset_trade(False) #don't clear return list
			self.map_send("0a1c") #トレード終了通知
			self.update_item_status()
			script.update_item(self)
Exemple #10
0
 def do_18ec(self, data_io):
     """ゴレカタでアイテム検索したときに送信される"""
     #TODO: アイテム取り出しにしておく
     script.item(self.pc, io_unpack_int(data_io))