Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for pages in hints #319

Merged
merged 4 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/open_dread_rando/files/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,11 @@
"pattern": "[A-Z]+?_[0-9]+"
},
"text": {
"type": "string"
"type": ["string", "array"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a description to this field, so it's clear why it can be two types?

"items": {
"type": "string"
},
"description": "If a string, the Adam dialogue will be replaced with a single page containing the string. If an array, a page will be created for each element."
}
},
"required": [
Expand Down
15 changes: 12 additions & 3 deletions src/open_dread_rando/misc_patches/text_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,21 @@

# update hint text
hint_id = f"DIAG_ADAM_{hint['hint_id']}"
string_key = f"{hint_id}_PAGE_1"

hint_text = hint["text"]

Check warning on line 63 in src/open_dread_rando/misc_patches/text_patches.py

View check run for this annotation

Codecov / codecov/patch

src/open_dread_rando/misc_patches/text_patches.py#L63

Added line #L63 was not covered by tests

if isinstance(hint_text, str):
hint_text = [hint_text]

Check warning on line 66 in src/open_dread_rando/misc_patches/text_patches.py

View check run for this annotation

Codecov / codecov/patch

src/open_dread_rando/misc_patches/text_patches.py#L65-L66

Added lines #L65 - L66 were not covered by tests

pages = {

Check warning on line 68 in src/open_dread_rando/misc_patches/text_patches.py

View check run for this annotation

Codecov / codecov/patch

src/open_dread_rando/misc_patches/text_patches.py#L68

Added line #L68 was not covered by tests
f"{hint_id}_PAGE_{i + 1}": hint
for i, hint in enumerate(hint_text)
}

usable.tCaptionList = {
hint_id: [string_key]
hint_id: list(pages) or [f"{hint_id}_PAGE_1"]
}
patch_text(editor, string_key, hint["text"])
apply_text_patches(editor, pages)

Check warning on line 76 in src/open_dread_rando/misc_patches/text_patches.py

View check run for this annotation

Codecov / codecov/patch

src/open_dread_rando/misc_patches/text_patches.py#L76

Added line #L76 was not covered by tests


_PROJECT_MEMBERS = {
Expand Down
44 changes: 33 additions & 11 deletions tests/test_files/april_fools_patcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -3528,7 +3528,9 @@
"actor": "PRP_CV_AccessPoint002"
},
"hint_id": "CAVE_2",
"text": "Can you guess where a {c1}Progressive Suit{c0} goes?|That's right! It goes in the {c5}Cataris{c0} hole!"
"text": [
"Can you guess where a {c1}Progressive Suit{c0} goes?|That's right! It goes in the {c5}Cataris{c0} hole!"
]
},
{
"accesspoint_actor": {
Expand All @@ -3537,7 +3539,9 @@
"actor": "PRP_CV_AccessPoint001"
},
"hint_id": "CAVE_1",
"text": "Can you guess where the {c1}Power Bomb{c0} goes?|That's right! It goes in the {c5}Artaria{c0} hole!"
"text": [
"Can you guess where the {c1}Power Bomb{c0} goes?|That's right! It goes in the {c5}Artaria{c0} hole!"
]
},
{
"accesspoint_actor": {
Expand All @@ -3546,7 +3550,9 @@
"actor": "accesspoint"
},
"hint_id": "MAGMA_1",
"text": "Can you guess where the {c1}Wave Beam{c0} goes?|That's right! It goes in the {c5}Ghavoran{c0} hole!"
"text": [
"Can you guess where the {c1}Wave Beam{c0} goes?|That's right! It goes in the {c5}Ghavoran{c0} hole!"
]
},
{
"accesspoint_actor": {
Expand All @@ -3555,7 +3561,9 @@
"actor": "accesspoint_000"
},
"hint_id": "MAGMA_2",
"text": "Can you guess where the {c1}Wide Beam{c0} goes?|That's right! It goes in the {c5}Ghavoran{c0} hole!"
"text": [
"Can you guess where the {c1}Wide Beam{c0} goes?|That's right! It goes in the {c5}Ghavoran{c0} hole!"
]
},
{
"accesspoint_actor": {
Expand All @@ -3564,7 +3572,9 @@
"actor": "accesspoint_000"
},
"hint_id": "LAB_1",
"text": "Can you guess where the {c1}Spider Magnet{c0} goes?|That's right! It goes in the {c5}Artaria{c0} hole!"
"text": [
"Can you guess where the {c1}Spider Magnet{c0} goes?|That's right! It goes in the {c5}Artaria{c0} hole!"
]
},
{
"accesspoint_actor": {
Expand All @@ -3573,7 +3583,9 @@
"actor": "accesspoint_001"
},
"hint_id": "LAB_2",
"text": "{c4}A joke hint.{c0}"
"text": [
"{c4}A joke hint.{c0}"
]
},
{
"accesspoint_actor": {
Expand All @@ -3582,7 +3594,9 @@
"actor": "accesspoint_000"
},
"hint_id": "AQUA_1",
"text": "Can you guess where the {c1}Screw Attack{c0} goes?|That's right! It goes in the {c5}Burenia{c0} hole!"
"text": [
"Can you guess where the {c1}Screw Attack{c0} goes?|That's right! It goes in the {c5}Burenia{c0} hole!"
]
},
{
"accesspoint_actor": {
Expand All @@ -3591,7 +3605,9 @@
"actor": "accesspoint_001"
},
"hint_id": "AQUA_2",
"text": "Can you guess where a {c1}Progressive Bomb{c0} goes?|That's right! It goes in the {c5}Burenia{c0} hole!"
"text": [
"Can you guess where a {c1}Progressive Bomb{c0} goes?|That's right! It goes in the {c5}Burenia{c0} hole!"
]
},
{
"accesspoint_actor": {
Expand All @@ -3600,7 +3616,9 @@
"actor": "accesspoint_000"
},
"hint_id": "SANC_1",
"text": "Can you guess where the {c1}Storm Missile{c0} goes?|That's right! It goes in the {c5}Ferenia{c0} hole!"
"text": [
"Can you guess where the {c1}Storm Missile{c0} goes?|That's right! It goes in the {c5}Ferenia{c0} hole!"
]
},
{
"accesspoint_actor": {
Expand All @@ -3609,7 +3627,9 @@
"actor": "accesspoint_000"
},
"hint_id": "FOREST_1",
"text": "Can you guess where the {c1}Flash Shift{c0} goes?|That's right! It goes in the {c5}Ghavoran{c0} hole!"
"text": [
"Can you guess where the {c1}Flash Shift{c0} goes?|That's right! It goes in the {c5}Ghavoran{c0} hole!"
]
},
{
"accesspoint_actor": {
Expand All @@ -3618,7 +3638,9 @@
"actor": "accesspoint_000"
},
"hint_id": "SHIP_1",
"text": "Can you guess where a {c1}Progressive Suit{c0} goes?|That's right! It goes in the {c5}Artaria{c0} hole!"
"text": [
"Can you guess where a {c1}Progressive Suit{c0} goes?|That's right! It goes in the {c5}Artaria{c0} hole!"
]
}
],
"text_patches": {
Expand Down
44 changes: 33 additions & 11 deletions tests/test_files/starter_preset_patcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -3592,7 +3592,9 @@
"actor": "PRP_CV_AccessPoint002"
},
"hint_id": "CAVE_2",
"text": "A {c1}Progressive Beam{c0} can be found in {c5}Cataris{c0}."
"text": [
"A {c1}Progressive Beam{c0} can be found in {c5}Cataris{c0}."
]
},
{
"accesspoint_actor": {
Expand All @@ -3601,7 +3603,9 @@
"actor": "PRP_CV_AccessPoint001"
},
"hint_id": "CAVE_1",
"text": "A {c1}Progressive Beam{c0} can be found in {c5}Artaria{c0}."
"text": [
"A {c1}Progressive Beam{c0} can be found in {c5}Artaria{c0}."
]
},
{
"accesspoint_actor": {
Expand All @@ -3610,7 +3614,9 @@
"actor": "accesspoint"
},
"hint_id": "MAGMA_1",
"text": "A {c1}Progressive Bomb{c0} can be found in {c5}Artaria{c0}."
"text": [
"A {c1}Progressive Bomb{c0} can be found in {c5}Artaria{c0}."
]
},
{
"accesspoint_actor": {
Expand All @@ -3619,7 +3625,9 @@
"actor": "accesspoint_000"
},
"hint_id": "MAGMA_2",
"text": "A {c1}Progressive Suit{c0} can be found in {c5}Ghavoran{c0}."
"text": [
"A {c1}Progressive Suit{c0} can be found in {c5}Ghavoran{c0}."
]
},
{
"accesspoint_actor": {
Expand All @@ -3628,7 +3636,9 @@
"actor": "accesspoint_000"
},
"hint_id": "LAB_1",
"text": "A {c1}Progressive Spin{c0} can be found in {c5}Burenia{c0}."
"text": [
"A {c1}Progressive Spin{c0} can be found in {c5}Burenia{c0}."
]
},
{
"accesspoint_actor": {
Expand All @@ -3637,7 +3647,9 @@
"actor": "accesspoint_001"
},
"hint_id": "LAB_2",
"text": "The {c1}Grapple Beam{c0} can be found in {c5}Burenia{c0}."
"text": [
"The {c1}Grapple Beam{c0} can be found in {c5}Burenia{c0}."
]
},
{
"accesspoint_actor": {
Expand All @@ -3646,7 +3658,9 @@
"actor": "accesspoint_000"
},
"hint_id": "AQUA_1",
"text": "The {c1}Storm Missile{c0} can be found in {c5}Cataris{c0}."
"text": [
"The {c1}Storm Missile{c0} can be found in {c5}Cataris{c0}."
]
},
{
"accesspoint_actor": {
Expand All @@ -3655,7 +3669,9 @@
"actor": "accesspoint_001"
},
"hint_id": "AQUA_2",
"text": "The {c1}Power Bomb{c0} can be found in {c5}Dairon{c0}."
"text": [
"The {c1}Power Bomb{c0} can be found in {c5}Dairon{c0}."
]
},
{
"accesspoint_actor": {
Expand All @@ -3664,7 +3680,9 @@
"actor": "accesspoint_000"
},
"hint_id": "SANC_1",
"text": "A {c1}Progressive Bomb{c0} can be found in {c5}Dairon{c0}."
"text": [
"A {c1}Progressive Bomb{c0} can be found in {c5}Dairon{c0}."
]
},
{
"accesspoint_actor": {
Expand All @@ -3673,7 +3691,9 @@
"actor": "accesspoint_000"
},
"hint_id": "FOREST_1",
"text": "The {c1}Spider Magnet{c0} can be found in {c5}Artaria{c0}."
"text": [
"The {c1}Spider Magnet{c0} can be found in {c5}Artaria{c0}."
]
},
{
"accesspoint_actor": {
Expand All @@ -3682,7 +3702,9 @@
"actor": "accesspoint_000"
},
"hint_id": "SHIP_1",
"text": "The {c1}Screw Attack{c0} can be found in {c5}Ferenia{c0}."
"text": [
"The {c1}Screw Attack{c0} can be found in {c5}Ferenia{c0}."
]
}
],
"text_patches": {
Expand Down
Loading