Skip to content

Commit

Permalink
Support requiring any of a set of items
Browse files Browse the repository at this point in the history
  • Loading branch information
Iapetus-11 committed Jun 22, 2024
1 parent df41fe1 commit 480b10f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
12 changes: 10 additions & 2 deletions bot/cogs/core/quests.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ def __init__(self, bot: VillagerBotCluster):
def db(self) -> "Database":
return typing.cast("Database", self.bot.get_cog("Database"))

def get_quest_embed(self, loc: CustomContext | commands.Context | discord.User, quest: UserQuest):
def get_quest_embed(
self, loc: CustomContext | commands.Context | discord.User, quest: UserQuest
):
lang = self.bot.l["en"]
if isinstance(loc, CustomContext | commands.Context):
lang = loc.l
Expand Down Expand Up @@ -118,7 +120,13 @@ async def get_random_quest_to_store(self, user_id: int) -> typing.TypedDict(
quest_key: str = random.choice(list(self.d.normalized_quests.keys()))
quest_def = self.d.normalized_quests[quest_key]

while quest_def.required_item and await self.db.fetch_item(user_id, quest_def.required_item) is None:
while (
quest_def.required_item
and all(
await self.db.fetch_item(user_id, required_item) is None
for required_item in quest_def.required_item.split(' | ')
)
):
quest_key: str = random.choice(list(self.d.normalized_quests.keys()))
quest_def = self.d.normalized_quests[quest_key]

Expand Down
3 changes: 3 additions & 0 deletions common/data/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -2747,6 +2747,7 @@
},
"difficulty_eval_multi": "2 if pickaxe_level > 4 else 1",
"acceptance_eval": "value >= target",
"required_item": "Iron Sword | Gold Sword | Diamond Sword | Netherite Sword",
"reward_item": "emerald",
"emoji": "stevegun"
},
Expand All @@ -2759,6 +2760,7 @@
},
"difficulty_eval_multi": "2 if pickaxe_level > 4 else 1",
"acceptance_eval": "value >= target",
"required_item": "Diamond Sword | Netherite Sword",
"reward_item": "emerald",
"emoji": "stevegun"
},
Expand All @@ -2771,6 +2773,7 @@
},
"difficulty_eval_multi": "2 if pickaxe_level > 4 else 1",
"acceptance_eval": "value >= target",
"required_item": "Gold Sword | Diamond Sword | Netherite Sword",
"reward_item": "emerald",
"emoji": "stevegun"
}
Expand Down

0 comments on commit 480b10f

Please sign in to comment.