/// <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); }
/// <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); }
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); } } }
/// <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); }
/// <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", "")); } }
public void AttachToBorder(BorderEntity borderEntity, Direction direction) { BorderEntities[direction] = borderEntity; }