Exemple #1
0
        /// <summary>
        /// Removes a charcter with a whole saved game.
        /// </summary>
        /// <param name="save">
        /// Character to remove.
        /// </param>
        public async Task Remove(CharacterModel save)
        {
            _gameDataAccess.StartTransaction();
            var character = await _gameDataAccess.Get(new Character { Name = save.Name });

            //remove character
            await _gameDataAccess.Remove(character);

            //remove equipement
            if (character.WeaponID != null)
            {
                await _gameDataAccess.Remove(new Weapon { WeaponID = character.WeaponID.Value });
            }
            if (character.ArmourID != null)
            {
                await _gameDataAccess.Remove(new Armour { ArmourID = character.ArmourID.Value });
            }
            if (character.PotionID != null)
            {
                await _gameDataAccess.Remove(new Potion { PotionID = character.PotionID.Value });
            }

            var room = new Room {
                RoomID = character.RoomID
            };

            //remove game map
            await Collapse(room, room);

            _gameDataAccess.Save();
        }