/// <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)); }
/// <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()}."); }
/// <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); } }
/// <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); }
/// <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()); }
/// <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?.Injure(); }
/// <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 : OnPostInjury(person)); }
/// <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); }
/// <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); }
/// <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); }
/// <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."); }
/// <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(); }
/// <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(); }
/// <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."); }
/// <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()); }
/// <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); }
/// <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."); }
/// <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}"); } } }
/// <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="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);
/// <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()); }
/// <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(_eventText.ToString()); }
/// <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(_passengerDeath.ToString()); }
/// <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) { // Nothing to see here, move along... }
/// <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 injures leg---you have to put it down"); }
/// <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... }
/// <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);
/// <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)); }
/// <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"); }
/// <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 fruit."); }