Beispiel #1
0
        /// <summary>
        ///     Fired when the event handler associated with this enum type triggers action on target entity. Implementation is
        ///     left completely up to handler.
        /// </summary>
        /// <param name="eventExecutor">
        ///     Entities which the event is going to directly affect. This way there is no confusion about
        ///     what entity the event is for. Will require casting to correct instance type from interface instance.
        /// </param>
        public override void Execute(RandomEventInfo eventExecutor)
        {
            // Cast the source entity as vehicle.
            var vehicle = eventExecutor.SourceEntity as Entity.Vehicle.Vehicle;

            vehicle?.Inventory[Entities.Food].AddQuantity(17);
        }
Beispiel #2
0
        /// <summary>
        ///     Fired when the event handler associated with this enum type triggers action on target entity. Implementation is
        ///     left completely up to handler.
        /// </summary>
        /// <param name="eventExecutor">
        ///     Entities which the event is going to directly affect. This way there is no confusion about
        ///     what entity the event is for. Will require casting to correct instance type from interface instance.
        /// </param>
        public override void Execute(RandomEventInfo eventExecutor)
        {
            // Clear out the text from the string builder.
            _eventText.Clear();

            // Show the pre item destruction text if it exists.
            var preDestoyPrompt = OnPreDestroyItems();
            if (!string.IsNullOrEmpty(preDestoyPrompt))
                _eventText.AppendLine(preDestoyPrompt);

            // Destroy some items at random and get a list back of what and how much.
            var _destroyedItems = GameSimulationApp.Instance.Vehicle.DestroyRandomItems();

            // Show the post item destruction text if it exists.
            var postDestroyPrompt = OnPostDestroyItems(_destroyedItems);
            if (!string.IsNullOrEmpty(postDestroyPrompt))
                _eventText.AppendLine(postDestroyPrompt);

            // Skip if destroyed items count is zero.
            if (!(_destroyedItems?.Count > 0))
                return;

            // Loop through all of the destroyed items and add them to string builder.
            foreach (var destroyedItem in _destroyedItems)
                if (_destroyedItems.Last().Equals(destroyedItem))
                    _eventText.Append($"{destroyedItem.Value.ToString("N0")} {destroyedItem.Key}");
                else
                    _eventText.AppendLine($"{destroyedItem.Value.ToString("N0")} {destroyedItem.Key}");
        }
Beispiel #3
0
        /// <summary>
        ///     Fired when the event handler associated with this enum type triggers action on target entity. Implementation is
        ///     left completely up to handler.
        /// </summary>
        /// <param name="eventExecutor">
        ///     Entities which the event is going to directly affect. This way there is no confusion about
        ///     what entity the event is for. Will require casting to correct instance type from interface instance.
        /// </param>
        public override void Execute(RandomEventInfo eventExecutor)
        {
            // Clear out the text from the string builder.
            _eventText.Clear();

            // Add the pre-create message if it exists.
            var preCreatePrompt = OnPreCreateItems();
            if (!string.IsNullOrEmpty(preCreatePrompt))
                _eventText.AppendLine(preCreatePrompt);

            // Create some items at random and get a list back of what and how much.
            var createdItems = GameSimulationApp.Instance.Vehicle.CreateRandomItems();

            // Add the post create message if it exists.
            var postCreatePrompt = OnPostCreateItems(createdItems);
            if (!string.IsNullOrEmpty(postCreatePrompt))
                _eventText.AppendLine(postCreatePrompt);

            // Skip if created items count is zero.
            if (!(createdItems?.Count > 0))
                return;

            // Loop through all of the created items and add them to string builder.
            foreach (var createdItem in createdItems)
                if (createdItems.Last().Equals(createdItem))
                    _eventText.Append($"{createdItem.Value.ToString("N0")} {createdItem.Key}");
                else
                    _eventText.AppendLine($"{createdItem.Value.ToString("N0")} {createdItem.Key}");
        }
        /// <summary>
        ///     Fired when the event handler associated with this enum type triggers action on target entity. Implementation is
        ///     left completely up to handler.
        /// </summary>
        /// <param name="userData">
        ///     Entities which the event is going to directly affect. This way there is no confusion about
        ///     what entity the event is for. Will require casting to correct instance type from interface instance.
        /// </param>
        public override void Execute(RandomEventInfo userData)
        {
            // Cast the source entity as vehicle.
            var vehicle = userData.SourceEntity as Entity.Vehicle.Vehicle;

            // Break some random part on the vehicle.
            vehicle?.BreakRandomPart();
        }
Beispiel #5
0
        /// <summary>
        ///     Fired when the event handler associated with this enum type triggers action on target entity. Implementation is
        ///     left completely up to handler.
        /// </summary>
        /// <param name="eventExecutor">
        ///     Entities which the event is going to directly affect. This way there is no confusion about
        ///     what entity the event is for. Will require casting to correct instance type from interface instance.
        /// </param>
        public override void Execute(RandomEventInfo eventExecutor)
        {
            // Cast the source entity as vehicle.
            var vehicle = eventExecutor.SourceEntity as Entity.Vehicle.Vehicle;

            // Reduce the total possible mileage of the vehicle this turn.
            vehicle?.ReduceMileage(17);
        }
Beispiel #6
0
        /// <summary>
        ///     Fired when the event handler associated with this enum type triggers action on target entity. Implementation is
        ///     left completely up to handler.
        /// </summary>
        /// <param name="eventExecutor">
        ///     Entities which the event is going to directly affect. This way there is no confusion about
        ///     what entity the event is for. Will require casting to correct instance type from interface instance.
        /// </param>
        public override void Execute(RandomEventInfo eventExecutor)
        {
            // Cast the source entity as vehicle.
            var vehicle = eventExecutor.SourceEntity as Entity.Vehicle.Vehicle;

            // Reduce the total possible mileage of the vehicle this turn.
            vehicle?.ReduceMileage(vehicle.Mileage - 10 - 5*GameSimulationApp.Instance.Random.Next());
        }
Beispiel #7
0
        /// <summary>
        ///     Fired when the event handler associated with this enum type triggers action on target entity. Implementation is
        ///     left completely up to handler.
        /// </summary>
        /// <param name="eventExecutor">
        ///     Entities which the event is going to directly affect. This way there is no confusion about
        ///     what entity the event is for. Will require casting to correct instance type from interface instance.
        /// </param>
        public override void Execute(RandomEventInfo eventExecutor)
        {
            // Cast the source entity as person.
            var person = eventExecutor.SourceEntity as Entity.Person.Person;

            // We are going to inflict enough damage to probably kill the person.
            person?.Damage(100);
        }
Beispiel #8
0
        /// <summary>
        ///     Fired when the simulation would like to render the event, typically this is done AFTER executing it but this could
        ///     change depending on requirements of the implementation.
        /// </summary>
        /// <param name="userData"></param>
        /// <returns>Text user interface string that can be used to explain what the event did when executed.</returns>
        protected override string OnRender(RandomEventInfo userData)
        {
            // Cast the source entity as person.
            var person = userData.SourceEntity as Entity.Person.Person;

            // Skip if the source entity is not a person.
            return person == null ? string.Empty : OnPostInfection(person);
        }
Beispiel #9
0
        /// <summary>
        ///     Fired when the event handler associated with this enum type triggers action on target entity. Implementation is
        ///     left completely up to handler.
        /// </summary>
        /// <param name="eventExecutor">
        ///     Entities which the event is going to directly affect. This way there is no confusion about
        ///     what entity the event is for. Will require casting to correct instance type from interface instance.
        /// </param>
        public override void Execute(RandomEventInfo eventExecutor)
        {
            // Cast the source entity as person.
            var person = eventExecutor.SourceEntity as Entity.Person.Person;

            // Sets flag on person making them more susceptible to further complications.
            person?.Infect();
        }
Beispiel #10
0
        /// <summary>
        ///     Fired when the simulation would like to render the event, typically this is done AFTER executing it but this could
        ///     change depending on requirements of the implementation.
        /// </summary>
        /// <param name="userData"></param>
        /// <returns>Text user interface string that can be used to explain what the event did when executed.</returns>
        protected override string OnRender(RandomEventInfo userData)
        {
            // Cast the source entity as a player.
            var person = userData.SourceEntity as Entity.Person.Person;

            // Skip if the source entity is not a person.
            return person == null ? "nobody is well again." : $"{person.Name} is well again.";
        }
Beispiel #11
0
        /// <summary>
        ///     Fired when the event handler associated with this enum type triggers action on target entity. Implementation is
        ///     left completely up to handler.
        /// </summary>
        /// <param name="eventExecutor">
        ///     Entities which the event is going to directly affect. This way there is no confusion about
        ///     what entity the event is for. Will require casting to correct instance type from interface instance.
        /// </param>
        public override void Execute(RandomEventInfo eventExecutor)
        {
            // Cast the source entity as person.
            var person = eventExecutor.SourceEntity as Entity.Person.Person;

            // Removes all infections, injuries, and heals the person in full.
            person?.HealEntirely();
        }
Beispiel #12
0
        /// <summary>
        ///     Fired when the event handler associated with this enum type triggers action on target entity. Implementation is
        ///     left completely up to handler.
        /// </summary>
        /// <param name="eventExecutor">
        ///     Entities which the event is going to directly affect. This way there is no confusion about
        ///     what entity the event is for. Will require casting to correct instance type from interface instance.
        /// </param>
        public override void Execute(RandomEventInfo eventExecutor)
        {
            // Cast the source entity as vehicle.
            var vehicle = eventExecutor.SourceEntity as Entity.Vehicle.Vehicle;

            // Indians hook you up with free food, what nice guys.
            vehicle?.Inventory[Entities.Food].AddQuantity(14);
        }
Beispiel #13
0
 /// <summary>
 ///     Fired when the simulation would like to render the event, typically this is done AFTER executing it but this could
 ///     change depending on requirements of the implementation.
 /// </summary>
 /// <param name="userData">
 ///     Entities which the event is going to directly affect. This way there is no confusion about
 ///     what entity the event is for. Will require casting to correct instance type from interface instance.
 /// </param>
 /// <returns>Text user interface string that can be used to explain what the event did when executed.</returns>
 protected override string OnRender(RandomEventInfo userData)
 {
     var repairPrompt = new StringBuilder();
     repairPrompt.AppendLine("You did not repair the broken ");
     repairPrompt.AppendLine(
         $"{GameSimulationApp.Instance.Vehicle.BrokenPart.Name.ToLowerInvariant()}. You must replace it with a ");
     repairPrompt.Append("spare part.");
     return repairPrompt.ToString();
 }
Beispiel #14
0
        /// <summary>
        ///     Fired when the simulation would like to render the event, typically this is done AFTER executing it but this could
        ///     change depending on requirements of the implementation.
        /// </summary>
        /// <param name="userData"></param>
        /// <returns>Text user interface string that can be used to explain what the event did when executed.</returns>
        protected override string OnRender(RandomEventInfo userData)
        {
            // Cast the source entity as person.
            var person = userData.SourceEntity as Entity.Person.Person;

            // Skip if the source entity is not a person.
            return person == null
                ? "Nobody has taken a turn for the worse."
                : $"{person.Name} has taken a turn for the worse.";
        }
Beispiel #15
0
        /// <summary>
        ///     Fired when the event handler associated with this enum type triggers action on target entity. Implementation is
        ///     left completely up to handler.
        /// </summary>
        /// <param name="eventExecutor">
        ///     Entities which the event is going to directly affect. This way there is no confusion about
        ///     what entity the event is for. Will require casting to correct instance type from interface instance.
        /// </param>
        public override void Execute(RandomEventInfo eventExecutor)
        {
            // Cast the source entity as a player.
            var sourcePerson = eventExecutor.SourceEntity as Entity.Person.Person;
            if (sourcePerson == null)
                throw new ArgumentNullException(nameof(eventExecutor), "Could not cast source entity as player.");

            // Check to make sure this player is the leader (aka the player).
            if (!sourcePerson.Leader)
                throw new ArgumentException("Cannot kill this person because it is not the player!");

            _leaderDeath.AppendLine($"{sourcePerson.Name} has died.");
        }
Beispiel #16
0
        /// <summary>
        ///     Fired when the event handler associated with this enum type triggers action on target entity. Implementation is
        ///     left completely up to handler.
        /// </summary>
        /// <param name="eventExecutor">
        ///     Entities which the event is going to directly affect. This way there is no confusion about
        ///     what entity the event is for. Will require casting to correct instance type from interface instance.
        /// </param>
        public override void Execute(RandomEventInfo eventExecutor)
        {
            // Cast the source entity as vehicle.
            var vehicle = eventExecutor.SourceEntity as Entity.Vehicle.Vehicle;

            // Skip if the source entity is not a vehicle.
            if (vehicle == null)
                return;

            // Damages the oxen, could make vehicle stuck.
            vehicle.Inventory[Entities.Animal].ReduceQuantity(1);

            // Reduce the total possible mileage of the vehicle this turn.
            vehicle.ReduceMileage(25);
        }
Beispiel #17
0
        /// <summary>
        ///     Fired when the event handler associated with this enum type triggers action on target entity. Implementation is
        ///     left completely up to handler.
        /// </summary>
        /// <param name="eventExecutor">
        ///     Entities which the event is going to directly affect. This way there is no confusion about
        ///     what entity the event is for. Will require casting to correct instance type from interface instance.
        /// </param>
        public override void Execute(RandomEventInfo eventExecutor)
        {
            // Cast the source entity as person.
            var person = eventExecutor.SourceEntity as Entity.Person.Person;

            // Skip if the source entity is not a person.
            if (person == null)
                return;

            // Ammo used to kill the snake.
            GameSimulationApp.Instance.Vehicle.Inventory[Entities.Ammo].ReduceQuantity(10);

            // Damage the person that was bit by the snake, it might be a little or a huge poisonousness bite.
            if (GameSimulationApp.Instance.Random.NextBool())
            {
                person.Infect();
                person.Damage(256);
            }
            else
            {
                person.Damage(5);
            }
        }
Beispiel #18
0
        /// <summary>
        ///     Fired when the event handler associated with this enum type triggers action on target entity. Implementation is
        ///     left completely up to handler.
        /// </summary>
        /// <param name="eventExecutor">
        ///     Entities which the event is going to directly affect. This way there is no confusion about
        ///     what entity the event is for. Will require casting to correct instance type from interface instance.
        /// </param>
        public override void Execute(RandomEventInfo eventExecutor)
        {
            // Cast the source entity as vehicle.
            var vehicle = eventExecutor.SourceEntity as Entity.Vehicle.Vehicle;

            // Skip if the source entity is not a vehicle.
            if (vehicle == null)
                return;

            // Check there is food to even remove.
            if (vehicle.Inventory[Entities.Food].Quantity <= 0)
                return;

            // Check if there is enough food to cut up into four pieces.
            if (vehicle.Inventory[Entities.Food].Quantity < 4)
                return;

            // Determine the amount of food we will destroy up to.
            var spoiledFood = vehicle.Inventory[Entities.Food].Quantity/4;

            // Remove some random amount of food, the minimum being three pieces.
            vehicle.Inventory[Entities.Food].ReduceQuantity(GameSimulationApp.Instance.Random.Next(3, spoiledFood));
        }
Beispiel #19
0
 /// <summary>
 ///     Fired when the simulation would like to render the event, typically this is done AFTER executing it but this could
 ///     change depending on requirements of the implementation.
 /// </summary>
 /// <param name="userData">
 ///     Entities which the event is going to directly affect. This way there is no confusion about
 ///     what entity the event is for. Will require casting to correct instance type from interface instance.
 /// </param>
 /// <returns>Text user interface string that can be used to explain what the event did when executed.</returns>
 protected abstract string OnRender(RandomEventInfo userData);
Beispiel #20
0
 /// <summary>
 ///     Fired when the simulation would like to render the event, typically this is done AFTER executing it but this could
 ///     change depending on requirements of the implementation.
 /// </summary>
 /// <param name="userData">
 ///     Entities which the event is going to directly affect. This way there is no confusion about
 ///     what entity the event is for. Will require casting to correct instance type from interface instance.
 /// </param>
 /// <returns>Text user interface string that can be used to explain what the event did when executed.</returns>
 protected override string OnRender(RandomEventInfo userData)
 {
     return "lose your way in heavy fog---time is lost";
 }
Beispiel #21
0
 /// <summary>
 ///     Fired when the simulation would like to render the event, typically this is done AFTER executing it but this could
 ///     change depending on requirements of the implementation.
 /// </summary>
 /// <param name="userData"></param>
 /// <returns>Text user interface string that can be used to explain what the event did when executed.</returns>
 protected override string OnRender(RandomEventInfo userData)
 {
     return "ox wanders off---spend time looking for it";
 }
Beispiel #22
0
 /// <summary>
 ///     Fired when the event handler associated with this enum type triggers action on target entity. Implementation is
 ///     left completely up to handler.
 /// </summary>
 /// <param name="eventExecutor">
 ///     Entities which the event is going to directly affect. This way there is no confusion about
 ///     what entity the event is for. Will require casting to correct instance type from interface instance.
 /// </param>
 public abstract void Execute(RandomEventInfo eventExecutor);
Beispiel #23
0
 /// <summary>
 ///     Fired when the simulation would like to render the event, typically this is done AFTER executing it but this could
 ///     change depending on requirements of the implementation.
 /// </summary>
 /// <param name="userData"></param>
 /// <returns>Text user interface string that can be used to explain what the event did when executed.</returns>
 protected override string OnRender(RandomEventInfo userData)
 {
     return OnFoodSpoilReason();
 }
Beispiel #24
0
 /// <summary>
 ///     Fired when the simulation would like to render the event, typically this is done AFTER executing it but this could
 ///     change depending on requirements of the implementation.
 /// </summary>
 /// <param name="userData">
 ///     Entities which the event is going to directly affect. This way there is no confusion about
 ///     what entity the event is for. Will require casting to correct instance type from interface instance.
 /// </param>
 /// <returns>Text user interface string that can be used to explain what the event did when executed.</returns>
 protected override string OnRender(RandomEventInfo userData)
 {
     return OnLostTimeReason();
 }
Beispiel #25
0
 /// <summary>
 ///     Fired when the event handler associated with this enum type triggers action on target entity. Implementation is
 ///     left completely up to handler.
 /// </summary>
 /// <param name="eventExecutor">
 ///     Entities which the event is going to directly affect. This way there is no confusion about
 ///     what entity the event is for. Will require casting to correct instance type from interface instance.
 /// </param>
 public override void Execute(RandomEventInfo eventExecutor)
 {
     // Add to the days to skip since multiple events in a chain could keep adding to the total.
     eventExecutor.DaysToSkip += DaysToSkip();
 }
 /// <summary>
 ///     Fired when the simulation would like to render the event, typically this is done AFTER executing it but this could
 ///     change depending on requirements of the implementation.
 /// </summary>
 /// <param name="userData"></param>
 /// <returns>Text user interface string that can be used to explain what the event did when executed.</returns>
 protected override string OnRender(RandomEventInfo userData)
 {
     // Cast the source entity as vehicle.
     var vehicle = userData.SourceEntity as Entity.Vehicle.Vehicle;
     return $"Broken {vehicle?.BrokenPart.Name.ToLowerInvariant()}.";
 }
Beispiel #27
0
 /// <summary>
 ///     Fired when the event is closed by the user or system after being executed and rendered out on text user interface.
 /// </summary>
 /// <param name="userData">
 ///     Random event information such as source entity and the actual event itself and any custom data
 ///     required to check state.
 /// </param>
 public virtual void OnEventClose(RandomEventInfo userData)
 {
     // Nothing to see here, move along...
 }
Beispiel #28
0
 /// <summary>
 ///     Fired when the simulation would like to render the event, typically this is done AFTER executing it but this could
 ///     change depending on requirements of the implementation.
 /// </summary>
 /// <param name="userData">
 ///     Entities which the event is going to directly affect. This way there is no confusion about
 ///     what entity the event is for. Will require casting to correct instance type from interface instance.
 /// </param>
 /// <returns>Text user interface string that can be used to explain what the event did when executed.</returns>
 public string Render(RandomEventInfo userData)
 {
     return OnRender(userData);
 }
Beispiel #29
0
 /// <summary>
 ///     Fired when the simulation would like to render the event, typically this is done AFTER executing it but this could
 ///     change depending on requirements of the implementation.
 /// </summary>
 /// <param name="userData"></param>
 /// <returns>Text user interface string that can be used to explain what the event did when executed.</returns>
 protected override string OnRender(RandomEventInfo userData)
 {
     return _leaderDeath.ToString();
 }
Beispiel #30
0
 /// <summary>
 ///     Fired when the simulation would like to render the event, typically this is done AFTER executing it but this could
 ///     change depending on requirements of the implementation.
 /// </summary>
 /// <param name="userData"></param>
 /// <returns>Text user interface string that can be used to explain what the event did when executed.</returns>
 protected override string OnRender(RandomEventInfo userData)
 {
     return "Find wild berries";
 }