/// <summary> /// Adds a new link between this place and another one. /// </summary> /// <param name="newPlaceRelationship">The link to add. This method should be called by the PlaceRelationship object itself, as they add themselves automatically.</param> internal void AddLinkedPlace(PlaceRelationship newPlaceRelationship) { if (_linkedPlaces == null) { _linkedPlaces = new List <PlaceRelationship>(); } if (!_linkedPlaces.Exists(l => l.LinkedPlace == newPlaceRelationship.LinkedPlace && l.Type == newPlaceRelationship.Type)) { _linkedPlaces.Add(newPlaceRelationship); } }
/// <inheritdoc /> public override MemoryItem GetAccurateCopy() { var copy = new PlaceRelationship(LinkedPlace, Type, ReferenceId) { ItemType = ItemType, Description = Description, Started = Started, Ended = Ended, Name = Name }; return(copy); }
/// <summary> /// This creates a link between two places and adds the reference to both places /// </summary> /// <param name="firstPlaceToLink">First place to link</param> /// <param name="secondPlaceToLink">Second Place to link</param> /// <param name="firstToSecondPlaceRelationship">Nature of their link</param> /// <param name="started">Date Started</param> /// <param name="ended">Date Ended</param> /// <returns>The new links (2)</returns> public List <PlaceRelationship> CreateLinkBetweenTwoPlaces(Place firstPlaceToLink, Place secondPlaceToLink, GeographicRelationshipType firstToSecondPlaceRelationship, GameTime.GameTime started, GameTime.GameTime ended = null) { PlaceRelationship directRelationship = new PlaceRelationship(secondPlaceToLink, firstToSecondPlaceRelationship, Guid.NewGuid(), started, ended); firstPlaceToLink.AddLinkedPlace(directRelationship); PlaceRelationship reverseRelationship = new PlaceRelationship(firstPlaceToLink, GetReverseLinkType(firstToSecondPlaceRelationship), Guid.NewGuid(), started, ended); secondPlaceToLink.AddLinkedPlace(reverseRelationship); return(new List <PlaceRelationship> { directRelationship, reverseRelationship }); }
/// <inheritdoc /> public override MemoryItem GetInaccurateCopy() { GameTime.GameTime started = Started; GameTime.GameTime ended = Ended; GeographicRelationshipType type = Type; //TODO : Randomize name int falsificationCase = RandomValueGenerator.GenerateIntWithMaxValue(4); switch (falsificationCase) { case 1: int variance = RandomValueGenerator.GenerateRealWithinValues(-10, 10); started?.SetYear(started.GetYear() + variance); break; case 2: int deathVariance = RandomValueGenerator.GenerateRealWithinValues(-10, 10); ended?.SetYear(ended.GetYear() + deathVariance); break; case 3: type = (GeographicRelationshipType)RandomValueGenerator.GenerateIntWithMaxValue(Enum.GetNames(typeof(GeographicRelationshipType)).Length); break; case 4: type = (GeographicRelationshipType)RandomValueGenerator.GenerateIntWithMaxValue(Enum.GetNames(typeof(GeographicRelationshipType)).Length); variance = RandomValueGenerator.GenerateRealWithinValues(-10, 10); started?.SetYear(started.GetYear() + variance); break; } var copy = new PlaceRelationship(LinkedPlace, type, ReferenceId) { ItemType = ItemType, Description = Description, Started = started, Ended = ended, Name = Name }; return(copy); }