コード例 #1
0
ファイル: PastEvent.cs プロジェクト: FrederykMtl/RNPC.NetCore
        internal void AddEventLink(EventRelationship relationship)
        {
            if (_linkedEvents == null)
            {
                _linkedEvents = new List <EventRelationship>();
            }

            if (!_linkedEvents.Exists(e => e.LinkedEvent == relationship.LinkedEvent))
            {
                _linkedEvents.Add(relationship);
            }
        }
コード例 #2
0
        /// <inheritdoc />
        public override MemoryItem GetAccurateCopy()
        {
            var copy = new EventRelationship(LinkedEvent, Type, ReferenceId)
            {
                ItemType    = ItemType,
                Description = Description,
                Started     = Started,
                Ended       = Ended
            };

            return(copy);
        }
コード例 #3
0
        /// <summary>
        /// Creates and defines a link between 2 events and add a reference to both Events
        /// </summary>
        /// <param name="firstEvent">The first Event to link</param>
        /// <param name="secondEvent">The second Event to link</param>
        /// <param name="firstToSecondEventRelationship">The nature of the link</param>
        /// <returns>The new links (2)</returns>
        public List <EventRelationship> CreateLinkBetweenTwoEvents(PastEvent firstEvent, PastEvent secondEvent, EventRelationshipType firstToSecondEventRelationship)
        {
            string description        = string.Empty;
            string reverseDescription = string.Empty;
            EventRelationshipType inverseRelationshipType = EventRelationshipType.Followed;

            switch (firstToSecondEventRelationship)
            {
            case EventRelationshipType.Caused:
                description             = EventRelationshipDescriptions.Caused;
                reverseDescription      = EventRelationshipDescriptions.CausedBy;
                inverseRelationshipType = EventRelationshipType.CausedBy;
                break;

            case EventRelationshipType.CausedBy:
                description             = EventRelationshipDescriptions.CausedBy;
                reverseDescription      = EventRelationshipDescriptions.Caused;
                inverseRelationshipType = EventRelationshipType.Caused;
                break;

            case EventRelationshipType.Followed:
                description             = EventRelationshipDescriptions.Followed;
                reverseDescription      = EventRelationshipDescriptions.Preceded;
                inverseRelationshipType = EventRelationshipType.Preceded;
                break;

            case EventRelationshipType.PartOf:
                description             = EventRelationshipDescriptions.PartOf;
                reverseDescription      = EventRelationshipDescriptions.Included;
                inverseRelationshipType = EventRelationshipType.Included;
                break;

            case EventRelationshipType.Preceded:
                description             = EventRelationshipDescriptions.Preceded;
                reverseDescription      = EventRelationshipDescriptions.Followed;
                inverseRelationshipType = EventRelationshipType.Followed;
                break;
            }

            EventRelationship directRelationship = new EventRelationship(secondEvent, firstToSecondEventRelationship, Guid.NewGuid(), description);

            firstEvent.AddEventLink(directRelationship);

            EventRelationship reverseRelationship = new EventRelationship(firstEvent, inverseRelationshipType, Guid.NewGuid(), reverseDescription);

            secondEvent.AddEventLink(reverseRelationship);

            return(new List <EventRelationship> {
                directRelationship, reverseRelationship
            });
        }
コード例 #4
0
        /// <inheritdoc />
        public override MemoryItem GetInaccurateCopy()
        {
            GameTime.GameTime     started = Started;
            GameTime.GameTime     ended   = Ended;
            EventRelationshipType type    = Type;

            //TODO : Randomize name

            int falsificationCase = RandomValueGenerator.GenerateIntWithMaxValue(4);

            switch (falsificationCase)
            {
            case 1:
                int variance = RandomValueGenerator.GenerateRealWithinValues(-15, 15);
                started?.SetYear(started.GetYear() + variance);
                break;

            case 2:
                int deathVariance = RandomValueGenerator.GenerateRealWithinValues(-15, 15);
                ended?.SetYear(ended.GetYear() + deathVariance);
                break;

            case 3:
                type = (EventRelationshipType)RandomValueGenerator.GenerateIntWithMaxValue(Enum.GetNames(typeof(EventRelationshipType)).Length);
                break;

            case 4:
                type     = (EventRelationshipType)RandomValueGenerator.GenerateIntWithMaxValue(Enum.GetNames(typeof(EventRelationshipType)).Length);
                variance = RandomValueGenerator.GenerateRealWithinValues(-15, 15);
                started?.SetYear(started.GetYear() + variance);
                break;
            }

            var copy = new EventRelationship(LinkedEvent, type, ReferenceId)
            {
                ItemType    = ItemType,
                Description = Description,
                Started     = started,
                Ended       = ended
            };

            return(copy);
        }