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

Make the base_type of classed draconians their corresponding colors instead of randomly chosen. (Fix #4001) #4181

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

code2828
Copy link

In #4001, when you lookup information about draconian stormcaller, the color is randomly generated instead of white. This is because of lines lookup-help.cc:1061-1062. This commit attempts to fix that by assigning colors to them using a switch-case statement. Info about which color should be which is grabbed from lines mon-util.cc:2723-2728.

Should resolve #4001.

@code2828 code2828 changed the title Make the base_type of classed draconians their corresponding colors instead of randomly chosen. Make the base_type of classed draconians their corresponding colors instead of randomly chosen. (Fix #4001) Dec 20, 2024
@@ -1059,7 +1059,32 @@ static int _describe_monster(const string &key, const string &suffix,
// Might be better to show all possible combinations rather than picking
// one at random as this does?
if (mons_is_draconian_job(mon_num))
base_type = random_draconian_monster_species();
{
// Classed draconians have fixed colours since 0.28
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be nice to have a dictionary instead of a case statement.
And the bit in the comment about 0.28 doesn't quite make sense to me?

But overall, looks reasonable to me.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for your review!

About the comment, The 0.28 release notes said that "Classed draconians have a fixed colour per job." so I figured that it might be good to note here since this is where the issue rose.

Copy link
Author

Choose a reason for hiding this comment

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

I wonder if it looks good now.

Copy link
Contributor

@Cgettys Cgettys Feb 2, 2025

Choose a reason for hiding this comment

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

Better, but this is now assigning a base_type to non-draconians by mistake. It also does a double lookup in the success case.

I think it should probably be something like this:

    monster_type base_type = MONS_NO_MONSTER;
    if (mons_is_draconian_job(mon_num))
    {
        // Classed draconians have fixed colours since 0.28
        const auto colour_it = draconian_job_to_color.find(mon_num);
        if (colour_it != draconian_job_to_colour.end())
            base_type = colour_it->second;
        else 
            // Might be better to show all possible combinations rather than
            // picking one at random as this does?
            base_type = random_draconian_monster_species();
    }

nit: this codebase afaik uses the British spelling of colour

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Monster lookup shows random draconian colours for classed draconians
2 participants