def test_checkShopitemStatus_failed(self):
     # no item
     result1 = InventoryUtil.checkShopitemStatus(guild_id=1,
                                                 item_name="hello")
     assert result1 == -1
     # no shopitem
     ItemUtil.createItem(guild_id=1,
                         item_name="hello",
                         item_type=ItemType.ATTACK,
                         buff_type=BuffType.ATTACK,
                         buff_value=-1,
                         buff_round=2,
                         level_required=0,
                         price=10)
     result2 = InventoryUtil.checkShopitemStatus(guild_id=1,
                                                 item_name="hello")
     assert result2 == -2
 def test_checkShopitemStatus_success(self):
     ItemUtil.createItem(guild_id=1,
                         item_name="hello",
                         item_type=ItemType.ATTACK,
                         buff_type=BuffType.ATTACK,
                         buff_value=-1,
                         buff_round=2,
                         level_required=0,
                         price=10)
     InventoryUtil.addItemToShop(guild_id=1, item_name="hello", amount=10)
     result = InventoryUtil.checkShopitemStatus(guild_id=1,
                                                item_name="hello")
     assert result.hidden == False
Ejemplo n.º 3
0
 async def check_Shopitem_status(self, ctx: commands.Command,
                                 item_name: str):
     result = InventoryUtil.checkShopitemStatus(ctx.guild.id, item_name)
     if result == -1:
         await ctx.send("查無此項目,請確認商品名稱是否輸入錯誤!")
     elif result == -2:
         await ctx.send(f"{item_name}存在但尚未上架!")
     else:
         msg = f"{item_name}已上架,狀態為"
         if result.hidden is True:
             msg += "隱藏"
         else:
             msg += "顯示"
         await ctx.send(msg)