elthran / RPG-Game

0 stars 1 forks source link

Condition objects are being overwritten between user accounts. #277

Closed klondikemarlen closed 6 years ago

klondikemarlen commented 6 years ago

Each Trigger should have it's own Condition created from a template condition. Right now there is only 2 Conditions that refer to 4 triggers. This results in the last referenced trigger being the trigger reference by the Condition object.

def update(self, template_trigger):
        """Change the values of this trigger.

        Essential make a new trigger without producing a tonne of spam
        defunct triggers.
        """
        assert template_trigger.template

        self.event_name = template_trigger.event_name
        self.conditions = template_trigger.conditions
        self.extra_info_for_humans = template_trigger.extra_info_for_humans
        self.completed = False

And

    # One to many with Conditions. Each trigger might have many conditions.
    conditions = relationship('Condition', back_populates='trigger')

Results in the last built Trigger taking over the condition. Do to the back_population. Which then breaks below where the condition calls its 'trigger'

    def __init__(self, hero_attribute, comparison, object_of_comparison):
        """Build a condition object.

        The default initial comparison is:
        self.trigger.hero._some_passed_attribute_name_.id
        NOTE: id is applied automatically this will need to be re-specced.
        """
        condition_attribute = object_of_comparison.__table__.name

        self.code = 'self.trigger.hero.{}.id {} self.{}.id'.format(
            hero_attribute, comparison, condition_attribute)

        # Should for example do:
        # self.location = the location I passed.
        setattr(self, condition_attribute, object_of_comparison)
klondikemarlen commented 6 years ago

Made Trigger to Condition relationship many to many. Maybe that will fix it?

klondikemarlen commented 6 years ago

Needs to be tested ... might be fixed.

klondikemarlen commented 6 years ago

Not fixed. Working on in https://github.com/elthran/RPG-Game/tree/events. I need a test suite for this.

Change conditions to use TemplateMixin.

klondikemarlen commented 6 years ago

Fixed as of now!