Beispiel #1
0
    def save(self):
        from the_tale.game.artifacts.storage import artifacts_storage

        if id(self) != id(artifacts_storage[self.id]):
            raise exceptions.SaveNotRegisteredArtifactError(mob=self.id)

        linguistics_logic.sync_restriction(group=linguistics_relations.TEMPLATE_RESTRICTION_GROUP.ARTIFACT,
                                           external_id=self.id,
                                           name=self.name)

        self._model.data = s11n.to_json(self.data)
        self._model.save()

        artifacts_storage._update_cached_data(self)
        artifacts_storage.update_version()
Beispiel #2
0
    def save(self):
        from the_tale.game.artifacts.storage import artifacts_storage

        if id(self) != id(artifacts_storage[self.id]):
            raise exceptions.SaveNotRegisteredArtifactError(mob=self.id)

        linguistics_logic.sync_restriction(
            group=linguistics_relations.TEMPLATE_RESTRICTION_GROUP.ARTIFACT,
            external_id=self.id,
            name=self.name)

        self._model.data = s11n.to_json(self.data)
        self._model.save()

        artifacts_storage._update_cached_data(self)
        artifacts_storage.update_version()
Beispiel #3
0
    def create(
        cls,
        uuid,
        level,
        utg_name,
        description,
        type_,
        power_type,
        mob=None,
        editor=None,
        state=relations.ARTIFACT_RECORD_STATE.DISABLED,
        rare_effect=relations.ARTIFACT_EFFECT.NO_EFFECT,
        epic_effect=relations.ARTIFACT_EFFECT.NO_EFFECT,
        special_effect=relations.ARTIFACT_EFFECT.NO_EFFECT,
    ):

        from the_tale.game.artifacts.storage import artifacts_storage

        model = ArtifactRecord.objects.create(
            uuid=uuid,
            level=level,
            name=utg_name.normal_form(),
            description=description,
            data=s11n.to_json({"name": utg_name.serialize()}),
            mob=mob._model if mob else None,
            type=type_,
            power_type=power_type,
            rare_effect=rare_effect,
            epic_effect=epic_effect,
            special_effect=special_effect,
            state=state,
            editor=editor._model if editor else None,
        )

        prototype = cls(model)

        linguistics_logic.sync_restriction(
            group=linguistics_relations.TEMPLATE_RESTRICTION_GROUP.ARTIFACT,
            external_id=prototype.id,
            name=prototype.name,
        )

        artifacts_storage.add_item(prototype.id, prototype)
        artifacts_storage.update_version()

        return prototype
Beispiel #4
0
    def create(cls,
               uuid,
               level,
               utg_name,
               description,
               type_,
               power_type,
               mob=None,
               editor=None,
               state=relations.ARTIFACT_RECORD_STATE.DISABLED,
               rare_effect=relations.ARTIFACT_EFFECT.NO_EFFECT,
               epic_effect=relations.ARTIFACT_EFFECT.NO_EFFECT,
               special_effect=relations.ARTIFACT_EFFECT.NO_EFFECT):

        from the_tale.game.artifacts.storage import artifacts_storage

        model = ArtifactRecord.objects.create(
            uuid=uuid,
            level=level,
            name=utg_name.normal_form(),
            description=description,
            data=s11n.to_json({'name': utg_name.serialize()}),
            mob=mob._model if mob else None,
            type=type_,
            power_type=power_type,
            rare_effect=rare_effect,
            epic_effect=epic_effect,
            special_effect=special_effect,
            state=state,
            editor=editor._model if editor else None)

        prototype = cls(model)

        linguistics_logic.sync_restriction(
            group=linguistics_relations.TEMPLATE_RESTRICTION_GROUP.ARTIFACT,
            external_id=prototype.id,
            name=prototype.name)

        artifacts_storage.add_item(prototype.id, prototype)
        artifacts_storage.update_version()

        return prototype