Exemple #1
0
 def _try_create_char(char_values, consts):
     char_data = None
     with DB.atomic() as transaction:
         try:
             char_data = _CharacterCreator._create_char(char_values, consts)
         except PeeweeException as exc:
             LOG.error("An error occured while creating character:")
             LOG.error(str(exc))
             transaction.rollback()
             return None
     return char_data
Exemple #2
0
 def _try_create_char(char_values, consts):
     char_data = None
     with DB.atomic() as transaction:
         try:
             char_data = _CharacterCreator._create_char(char_values, consts)
         except PeeweeException as exc:
             LOG.error("An error occured while creating character:")
             LOG.error(str(exc))
             transaction.rollback()
             return None
     return char_data
Exemple #3
0
 def delete_char(guid):
     """ Try to delete character and all associated data from the database.
     Return 0 on success, 1 on error. """
     with DB.atomic() as transaction:
         try:
             _CharacterDestructor._delete_char(guid)
         except PeeweeException as exc:
             LOG.error("An error occured while deleting character:")
             LOG.error(str(exc))
             transaction.rollback()
             return 1
     return 0
Exemple #4
0
 def delete_char(guid):
     """ Try to delete character and all associated data from the database.
     Return 0 on success, 1 on error. """
     with DB.atomic() as transaction:
         try:
             _CharacterDestructor._delete_char(guid)
         except PeeweeException as exc:
             LOG.error("An error occured while deleting character:")
             LOG.error(str(exc))
             transaction.rollback()
             return 1
     return 0
Exemple #5
0
    def save_player(self, player):
        char_data = CharacterManager.get_char_data(player.guid)

        with DB.atomic() as transaction:
            try:
                ObjectManager.save_object_coords(player, char_data.position)
                ObjectManager.save_object_fields(player, char_data)
                _UnitManager.save_unit_fields(player, char_data)
                _PlayerManager.save_player_fields(player, char_data)
                char_data.save()
            except PeeweeException as exc:
                LOG.error("An error occured while creating character:")
                LOG.error(str(exc))
                transaction.rollback()
                return None
Exemple #6
0
    def save_player(self, player):
        char_data = CharacterManager.get_char_data(player.guid)

        with DB.atomic() as transaction:
            try:
                ObjectManager.save_object_coords(player, char_data.position)
                ObjectManager.save_object_fields(player, char_data)
                _UnitManager.save_unit_fields(player, char_data)
                _PlayerManager.save_player_fields(player, char_data)
                char_data.save()
            except PeeweeException as exc:
                LOG.error("An error occured while creating character:")
                LOG.error(str(exc))
                transaction.rollback()
                return None