Skip to content

Commit

Permalink
WIP: Quest title (#1189)
Browse files Browse the repository at this point in the history
 Master 9d9bd33
  • Loading branch information
Grennith committed Oct 16, 2021
1 parent 79fe546 commit 8bf9412
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ifdef OS
pip := $(shell Get-Command pip | Select-Object -ExpandProperty Source)
precommit := $(shell Get-Command pre-commit | Select-Object -ExpandProperty Source)
docker := $(shell Get-Command docker | Select-Object -ExpandProperty Source)
docker_compose := $(shell Get-Command docker-compose -f ${COMPOSE_FILE_DEV} | Select-Object -ExpandProperty Source)
docker_compose := $(shell (Get-Command docker-compose | Select-Object -ExpandProperty Source) -f ${COMPOSE_FILE_DEV})
UID ?= 1000
GID ?= 1000
else
Expand Down
2 changes: 1 addition & 1 deletion configs/config.ini.example
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
#home_lat: # Center Lat of your scan location (Default: 0.0)
#home_lng: # Center Lng of your scan location (Default: 0.0)
#language: # Language for several things like quests or mon names in the IV list (default:en - others: de, fr )

#no_quest_titles # Do not fetch quest title resources from pokeminers. Will instead use internal parsing

# MADmin
######################
Expand Down
6 changes: 5 additions & 1 deletion locale/en/types.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
},
"29": {
"prototext": "QUEST_BATTLE_TEAM_ROCKET",
"text": "Battle {0} Team Rocket Grunts"
"text": "{verb} {0} Team GO Rocket members"
},
"30": {
"prototext": "QUEST_PURIFY_POKEMON",
Expand Down Expand Up @@ -155,6 +155,10 @@
"prototext": "GEOTARGETED_AR_SCAN",
"text": "Scan pokestop"
},
"56": {
"prototext": "QUEST_EARN_FORT_POWER_UP_POINTS ",
"text": "Earn {0} points powering up a Pokéstop or Gym"
},
"57": {
"prototext": "QUEST_TAKE_WILD_SNAPSHOT ",
"text": "Take {0} snapshots of wild pokemon"
Expand Down
7 changes: 5 additions & 2 deletions mapadroid/db/DbPogoProtoSubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,8 @@ async def quest(self, session: AsyncSession, quest_proto: dict):
rewards = protoquest.get("quest_rewards", None)
if not rewards:
return False
protoquest_display = quest_proto["challenge_quest"]["quest_display"]
quest_title_resource_id = protoquest_display.get("title", None)
reward = rewards[0]
item = reward['item']
encounter = reward['pokemon_encounter']
Expand Down Expand Up @@ -661,8 +663,8 @@ async def quest(self, session: AsyncSession, quest_proto: dict):
condition = goal.get("condition", None)

json_condition = json.dumps(condition)
task = await questtask(int(quest_type), json_condition, int(target), str(quest_template))

task = await questtask(int(quest_type), json_condition, int(target), str(quest_template),
quest_title_resource_id)
quest: Optional[TrsQuest] = await TrsQuestHelper.get(session, fort_id)
if not quest:
quest = TrsQuest()
Expand All @@ -681,6 +683,7 @@ async def quest(self, session: AsyncSession, quest_proto: dict):
quest.quest_reward = json.dumps(rewards)
quest.quest_task = task
quest.quest_template = quest_template
quest.quest_title = quest_title_resource_id

logger.debug3("DbPogoProtoSubmit::quest submitted quest type {} at stop {}", quest_type, fort_id)
async with session.begin_nested() as nested_transaction:
Expand Down
1 change: 1 addition & 0 deletions mapadroid/db/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ class TrsQuest(Base):
quest_task = Column(String(150, 'utf8mb4_unicode_ci'))
quest_pokemon_form_id = Column(SMALLINT(6), nullable=False, server_default=text("'0'"))
quest_pokemon_costume_id = Column(SMALLINT(6), nullable=False, server_default=text("'0'"))
quest_title = Column(String(100, 'utf8mb4_unicode_ci'), nullable=True, server_default=None)


class TrsS2Cell(Base):
Expand Down
10 changes: 9 additions & 1 deletion mapadroid/utils/questGen.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import gettext
import json
import re
from typing import Dict

from mapadroid.db.model import TrsQuest, Pokestop
from mapadroid.utils.gamemechanicutil import form_mapper
from mapadroid.utils.language import i8ln, open_json_file


QUEST_LANGUAGES: Dict[str, str] = {
'de': 'German',
'en': 'English',
'fr': 'French'
}


def install_language():
# TODO: Check if this makes translations persistent if called only once
gettext.find('quest', 'locales', all=True)
Expand Down Expand Up @@ -90,7 +98,7 @@ async def generate_quest(stop: Pokestop, quest: TrsQuest):
'quest_condition': quest.quest_condition,
'quest_template': quest.quest_template,
'is_ar_scan_eligible': stop.is_ar_scan_eligible,

'quest_title': quest.quest_title
})
return quest_raw

Expand Down
4 changes: 3 additions & 1 deletion mapadroid/utils/walkerArgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,9 @@ def parse_args():
help=('Set Lng from the center of your scan location.'
'Especially for using MADBOT (User submitted Raidscreens). Default: 0.0'))
parser.add_argument('-L', '--language', default='en',
help=('Set Language for MadMin / Quests. Default: en'))
help=('Set Language for Madmin / Quests. Default: en'))
parser.add_argument('--no_quest_titles', default=False, action='store_true',
help='Do not download quest title resources')
parser.add_argument('-wfdsd', '--wait_for_data_sleep_duration', default='1.0', type=float,
help=('Time in seconds (floating point) to sleep inbetween checks of data in workers. '
'Default: 1.0'))
Expand Down
1 change: 1 addition & 0 deletions mapadroid/webhook/webhookworker.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ def __construct_quest_payload(self, transformed_quest: Dict) -> Dict:
"quest_condition": transformed_quest["quest_condition"].replace("'", '"').lower(),
"quest_template": transformed_quest["quest_template"],
"is_ar_scan_eligible": transformed_quest["is_ar_scan_eligible"],
"quest_title": transformed_quest["quest_title"]
}

# Other known type is Poracle/RDM compatible.
Expand Down

0 comments on commit 8bf9412

Please sign in to comment.