Ejemplo n.º 1
0
        /// <summary>
        /// Converts the domain model into an entity.
        /// </summary>
        /// <returns>The entity.</returns>
        /// <param name="border">Border.</param>
        internal static BorderEntity ToEntity(this Border border)
        {
            BorderEntity borderEntity = new BorderEntity
            {
                Province1Id = border.SourceProvinceId,
                Province2Id = border.TargetProvinceId
            };

            return(borderEntity);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Converts the entity into a domain model.
        /// </summary>
        /// <returns>The domain model.</returns>
        /// <param name="borderEntity">Border entity.</param>
        internal static Border ToDomainModel(this BorderEntity borderEntity)
        {
            Border border = new Border
            {
                SourceProvinceId = borderEntity.Province1Id,
                TargetProvinceId = borderEntity.Province2Id
            };

            return(border);
        }
Ejemplo n.º 3
0
 private void CheckPlayerMovement(IMovementController movementController, Cell from, Cell to)
 {
     foreach (Direction direction in Direction.Values)
     {
         BorderEntity borderEntity = to.BorderEntities[direction];
         if (borderEntity != null && borderEntity.transparency != Transparency.Opaque)
         {
             Cell cell = to.Stage.GetCell(to, direction);
             RevealRoom(cell.Room);
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the border with the specified faction and unit identifiers.
        /// </summary>
        /// <returns>The border.</returns>
        /// <param name="province1Id">First province identifier.</param>
        /// <param name="province2Id">Second province identifier.</param>
        public BorderEntity Get(string province1Id, string province2Id)
        {
            List <BorderEntity> borderEntities = xmlDatabase.LoadEntities().ToList();
            BorderEntity        borderEntity   = borderEntities.FirstOrDefault(x => x.Province1Id == province1Id &&
                                                                               x.Province2Id == province2Id);

            if (borderEntity == null)
            {
                throw new EntityNotFoundException($"{borderEntity.Province1Id}-{borderEntity.Province2Id}", nameof(BorderEntity).Replace("Entity", ""));
            }

            return(borderEntity);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Adds the specified border.
        /// </summary>
        /// <param name="borderEntity">Border.</param>
        public void Add(BorderEntity borderEntity)
        {
            List <BorderEntity> borderEntities = xmlDatabase.LoadEntities().ToList();

            borderEntities.Add(borderEntity);

            try
            {
                xmlDatabase.SaveEntities(borderEntities);
            }
            catch
            {
                throw new DuplicateEntityException($"{borderEntity.Province1Id}-{borderEntity.Province2Id}", nameof(BorderEntity).Replace("Entity", ""));
            }
        }
Ejemplo n.º 6
0
 public void AttachToBorder(BorderEntity borderEntity, Direction direction)
 {
     BorderEntities[direction] = borderEntity;
 }