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

Fixed dice should be stored in Game object #201

Open
mrbermell opened this issue Jan 17, 2022 · 1 comment
Open

Fixed dice should be stored in Game object #201

mrbermell opened this issue Jan 17, 2022 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mrbermell
Copy link
Collaborator

Currently the fixed dice are stored with a singleton pattern, namely the class itself (see code below). If fixed dice are used with multiple game objects at the same time there is a risk that a fixed dice for one game is consumed by another game. That behavior will not crash the execution and but can lead to very subtle bugs.

I propose we move information about the stored fixed rolls to the game object itself. I'm happy to write the PR if you agree.

class BBDie(Die, Immutable):
    value: BBDieResult
    FixedRolls = []

    @staticmethod
    def fix(value):
        if type(value) == BBDieResult:
            BBDie.FixedRolls.append(value)
        else:
            raise ValueError("Fixed result of BBDie must be a BBDieResult")
@mrbermell mrbermell added enhancement New feature or request good first issue Good for newcomers labels Jan 17, 2022
@njustesen
Copy link
Owner

Yeah, great idea.

Curious to see how you will implement it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants