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 AddNewMonsterToStagesWhere & AddSelectedNewMonsters, and publicize base AddNewMonster #382

Merged

Conversation

bb010g
Copy link
Contributor

@bb010g bb010g commented Apr 9, 2022

Example code without AddSelectedNewMonsters or public AddNewMonster:

MonsterActions += (dccsPool, mixEnemyArtifactMonsters, currentStage) => {
    DirectorCardHolder? monsterCardHolder;
    monsterCardHoldersByStage.TryGetValue(currentStage.ToInternalStageName(), out monsterCardHolder);
    if (monsterCardHolder is not null) {
        bool addToFamilies = false;

        if (dccsPool) {
            ForEachPoolCategoryInDccsPool(dccsPool, (poolCategory) => {
                var isNotAFamilyCategory = poolCategory.name != MonsterPoolCategories.Family;
                var isAFamilyCategoryAndShouldAddToIt = addToFamilies && poolCategory.name == MonsterPoolCategories.Family;
                if (isNotAFamilyCategory || isAFamilyCategoryAndShouldAddToIt) {
                    ForEachPoolEntryInDccsPoolCategory(poolCategory, (poolEntry) => {
                        AddMonsterToPoolEntry(monsterCardHolder, poolEntry);
                    });
                }
            });
        }

        mixEnemyArtifactMonsters.Add(monsterCardHolder);
    }
};

Example code with AddSelectedNewMonsters (EDIT: removed):

AddSelectedNewMonsters(IEnumerable<Tuple<DirectorCardHolder, bool>> (currentStage) => {
    DirectorCardHolder? monsterCardHolder;
    monsterCardHoldersByStage.TryGetValue(currentStage.ToInternalStageName(), out monsterCardHolder);
    if (monsterCardHolder is not null) {
        return new Tuple<DirectorCardHolder, bool>[] { new(monsterCardHolder, false) };
    }
    return Enumerable.Empty<Tuple<DirectorCardHolder, bool>>();
});

Example code with public AddNewMonster:

MonsterActions += (dccsPool, mixEnemyArtifactMonsters, currentStage) => {
    DirectorCardHolder? monsterCardHolder;
    monsterCardHoldersByStage.TryGetValue(currentStage.ToInternalStageName(), out monsterCardHolder);
    if (monsterCardHolder is not null) {
        AddNewMonster(dccsPool, mixEnemyArtifactMonsters, monsterCardHolder, addToFamilies: false);
    }
};

This AddNewMonster overload is a lot safer to publicize now thanks to the new DCCS system's consistent use and the addition of AddSelectedNewMonsters, which should cover most simple use cases that would otherwise have to use this
function.

@CLAassistant
Copy link

CLAassistant commented Apr 9, 2022

CLA assistant check
All committers have signed the CLA.

@bb010g
Copy link
Contributor Author

bb010g commented Apr 15, 2022

Requesting review from @xiaoxiao921.

/// Second component of a return tuple is whether to also add to existing monster families.
/// </summary>
/// <param name="monstersSelector"></param>
public static void AddSelectedNewMonsters(Func<StageInfo, IEnumerable<Tuple<DirectorCardHolder, bool>>> monstersSelector) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Seem really awkward to call? If one already has an ienumerable of directorCardHolders, you could iterate over AddNewMonsterToStagesWhere yorself

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd be alright with dropping it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed.

This is a lot safer to publicize now thanks to the new DCCS system's
consistent use and the addition of `AddSelectedNewMonsters`, which
should cover most simple use cases that would otherwise have to use this
function.
@tristanmcpherson tristanmcpherson merged commit c85a4fe into risk-of-thunder:master Apr 25, 2022
@bb010g bb010g deleted the addNewMonsterToStagesWhere branch April 25, 2022 13:39
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.

None yet

4 participants