def test_findShopItem_failed(self): item1 = ItemUtil.createItem(guild_id=1, item_name="hello", item_type=ItemType.ATTACK, buff_type=BuffType.ATTACK, buff_value=-1, buff_round=2) ItemUtil.createItem(guild_id=1, item_name="hey", item_type=ItemType.STATUS, buff_type=BuffType.DEFENCE, buff_value=10, buff_round=3) InventoryUtil.addItemToShop(guild_id=1, item_name="hey", amount=10) result = InventoryUtil.findShopItem(guild_id=1, item=item1) assert result == None
async def showShopitemDetail(self, ctx: commands.Command, item_name: str): item = ItemUtil.searchItem(guild_id=ctx.guild.id, item_name=item_name) if item is None: await ctx.send("找不到該商品,請確認名稱是否輸入錯誤!") result = InventoryUtil.findShopItem(ctx.guild.id, item) if result is None: await ctx.send("找不到該商品,請確認名稱是否輸入錯誤!") else: if result.item.type == ItemType.ATTACK: itemtype = "攻擊道具" elif result.item.type == ItemType.DEFENCE: itemtype = "防禦道具" elif result.item.type == ItemType.RECOVER: itemtype = "恢復道具" elif result.item.type == ItemType.STATUS: itemtype = "狀態道具" else: itemtype = "一般道具" if result.item.buff.buff_type == BuffType.ATTACK: bufftype = "攻擊力" elif result.item.buff.buff_type == BuffType.DEFENCE: bufftype = "防禦力" elif result.item.buff.buff_type == BuffType.MAGIC: bufftype = "魔法力" elif result.item.buff.buff_type == BuffType.HIT_POINT: bufftype = "生命力" else: bufftype = "無屬性" msg = "```" msg += f"商品名稱: {result.item.name}\n" msg += f"商品價錢: {result.item.token_required}\n" msg += f"等級限制: {result.item.level_required}\n" msg += f"道具種類: {itemtype}\n" msg += f"增幅種類: {bufftype}\n" msg += f"增幅數值: {result.item.buff.buff_value}\n" msg += "增幅時間: {}\n".format(result.item.buff.buff_round if result. item.buff.buff_round > 0 else "永不毀滅") msg += f"商品描述: {result.item.description}\n" msg += "```" await ctx.send(msg)