services.quests
Módulo quests.py
[PT-BR] Gera uma descrição aleatória de "missão" para cada página crawleada, inspirada em desafios de jogos da franquia Pokémon.
[EN] Generates a random "quest" description for each crawled page, inspired by challenges from the Pokémon game series.
Uso / Usage: from services.quests import QuestPokemon quest = QuestPokemon(url) print(quest.generate_description())
1""" 2Módulo quests.py 3================== 4 5[PT-BR] Gera uma descrição aleatória de "missão" para cada página crawleada, 6inspirada em desafios de jogos da franquia Pokémon. 7 8[EN] Generates a random "quest" description for each crawled page, 9inspired by challenges from the Pokémon game series. 10 11Uso / Usage: 12 from services.quests import QuestPokemon 13 quest = QuestPokemon(url) 14 print(quest.generate_description()) 15""" 16import random 17from typing import Optional, Sequence 18 19class QuestPokemon: 20 """ 21 [PT-BR] Gera uma descrição de "missão" simulada para cada URL, inspirada em desafios da franquia. 22 [EN] Generates a simulated "quest" description for each URL, inspired by the franchise's challenges. 23 """ 24 25 DEFAULT_ENVIRONMENTS = [ 26 "Dense forest", "Dark cave", "Busy city", 27 "Scorching desert", "Snowy mountain", "Ancient ruins", 28 "Gloomy swamp", "Frozen lake", "Mysterious village" 29 ] 30 31 DEFAULT_DIFFICULTIES = ["Easy", "Medium", "Hard", "Epic"] 32 33 DEFAULT_REWARDS = [ 34 "You found a special Poké Ball!", 35 "You received a rare TM.", 36 "An NPC healed your Pokémon.", 37 "You caught a rare wild Pokémon.", 38 "You received 2000 PokéDollars.", 39 "You obtained an evolution item.", 40 "You unlocked a new map area.", 41 "You received a mysterious egg." 42 ] 43 44 DEFAULT_CHALLENGES = [ 45 "Trainer uses only Fire-type Pokémon", 46 "Double battle against twin trainers", 47 "Only status moves are allowed (e.g., Growl, Sleep Powder)" 48 ] 49 50 def __init__( 51 self, 52 url: str, 53 rng: Optional[random.Random] = None, 54 environments: Optional[Sequence[str]] = None, 55 difficulties: Optional[Sequence[str]] = None, 56 rewards: Optional[Sequence[str]] = None, 57 challenges: Optional[Sequence[str]] = None, 58 ): 59 """ 60 [PT-BR] Constrói uma missão com sorteio interno. 61 [EN] Builds a quest with internal random selection. 62 """ 63 self.url = url 64 self.rng = rng or random.Random() 65 66 self.environment = self.rng.choice(environments or self.DEFAULT_ENVIRONMENTS) 67 self.difficulty = self.rng.choice(difficulties or self.DEFAULT_DIFFICULTIES) 68 self.challenge = self.rng.choice(challenges or self.DEFAULT_CHALLENGES) 69 self.reward = self.rng.choice(rewards or self.DEFAULT_REWARDS) 70 71 def to_text(self) -> str: 72 """ 73 [PT-BR] Retorna uma representação textual da missão. 74 [EN] Returns a textual representation of the quest. 75 """ 76 return ( 77 f"\n" 78 f"Environment: {self.environment}\n" 79 f"Path: {self.url}\n" 80 f"Challenge: {self.challenge}\n" 81 f"Difficulty: {self.difficulty}\n" 82 f"Reward: {self.reward}\n" 83 ) 84 85 def __str__(self) -> str: 86 return self.to_text()
20class QuestPokemon: 21 """ 22 [PT-BR] Gera uma descrição de "missão" simulada para cada URL, inspirada em desafios da franquia. 23 [EN] Generates a simulated "quest" description for each URL, inspired by the franchise's challenges. 24 """ 25 26 DEFAULT_ENVIRONMENTS = [ 27 "Dense forest", "Dark cave", "Busy city", 28 "Scorching desert", "Snowy mountain", "Ancient ruins", 29 "Gloomy swamp", "Frozen lake", "Mysterious village" 30 ] 31 32 DEFAULT_DIFFICULTIES = ["Easy", "Medium", "Hard", "Epic"] 33 34 DEFAULT_REWARDS = [ 35 "You found a special Poké Ball!", 36 "You received a rare TM.", 37 "An NPC healed your Pokémon.", 38 "You caught a rare wild Pokémon.", 39 "You received 2000 PokéDollars.", 40 "You obtained an evolution item.", 41 "You unlocked a new map area.", 42 "You received a mysterious egg." 43 ] 44 45 DEFAULT_CHALLENGES = [ 46 "Trainer uses only Fire-type Pokémon", 47 "Double battle against twin trainers", 48 "Only status moves are allowed (e.g., Growl, Sleep Powder)" 49 ] 50 51 def __init__( 52 self, 53 url: str, 54 rng: Optional[random.Random] = None, 55 environments: Optional[Sequence[str]] = None, 56 difficulties: Optional[Sequence[str]] = None, 57 rewards: Optional[Sequence[str]] = None, 58 challenges: Optional[Sequence[str]] = None, 59 ): 60 """ 61 [PT-BR] Constrói uma missão com sorteio interno. 62 [EN] Builds a quest with internal random selection. 63 """ 64 self.url = url 65 self.rng = rng or random.Random() 66 67 self.environment = self.rng.choice(environments or self.DEFAULT_ENVIRONMENTS) 68 self.difficulty = self.rng.choice(difficulties or self.DEFAULT_DIFFICULTIES) 69 self.challenge = self.rng.choice(challenges or self.DEFAULT_CHALLENGES) 70 self.reward = self.rng.choice(rewards or self.DEFAULT_REWARDS) 71 72 def to_text(self) -> str: 73 """ 74 [PT-BR] Retorna uma representação textual da missão. 75 [EN] Returns a textual representation of the quest. 76 """ 77 return ( 78 f"\n" 79 f"Environment: {self.environment}\n" 80 f"Path: {self.url}\n" 81 f"Challenge: {self.challenge}\n" 82 f"Difficulty: {self.difficulty}\n" 83 f"Reward: {self.reward}\n" 84 ) 85 86 def __str__(self) -> str: 87 return self.to_text()
[PT-BR] Gera uma descrição de "missão" simulada para cada URL, inspirada em desafios da franquia. [EN] Generates a simulated "quest" description for each URL, inspired by the franchise's challenges.
51 def __init__( 52 self, 53 url: str, 54 rng: Optional[random.Random] = None, 55 environments: Optional[Sequence[str]] = None, 56 difficulties: Optional[Sequence[str]] = None, 57 rewards: Optional[Sequence[str]] = None, 58 challenges: Optional[Sequence[str]] = None, 59 ): 60 """ 61 [PT-BR] Constrói uma missão com sorteio interno. 62 [EN] Builds a quest with internal random selection. 63 """ 64 self.url = url 65 self.rng = rng or random.Random() 66 67 self.environment = self.rng.choice(environments or self.DEFAULT_ENVIRONMENTS) 68 self.difficulty = self.rng.choice(difficulties or self.DEFAULT_DIFFICULTIES) 69 self.challenge = self.rng.choice(challenges or self.DEFAULT_CHALLENGES) 70 self.reward = self.rng.choice(rewards or self.DEFAULT_REWARDS)
[PT-BR] Constrói uma missão com sorteio interno. [EN] Builds a quest with internal random selection.
72 def to_text(self) -> str: 73 """ 74 [PT-BR] Retorna uma representação textual da missão. 75 [EN] Returns a textual representation of the quest. 76 """ 77 return ( 78 f"\n" 79 f"Environment: {self.environment}\n" 80 f"Path: {self.url}\n" 81 f"Challenge: {self.challenge}\n" 82 f"Difficulty: {self.difficulty}\n" 83 f"Reward: {self.reward}\n" 84 )
[PT-BR] Retorna uma representação textual da missão. [EN] Returns a textual representation of the quest.