Skip to content

Commit

Permalink
updated item drop function to be templated
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshalexjacobs committed Jul 9, 2022
1 parent 76419b9 commit 83d5a3d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions SlimeBattleSystem/BattleSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ public static Participant DetermineEnemyTarget(List<Participant> playerParticipa

public static Participant DetermineEnemyTarget(List<Participant> playerParticipants, Random random)
{
// NPCs that are on the player's team have a 25% chance to be hit
// this is where you would also handle any formation based logic
// else, each player character has an equal chance to be hit by the enemy
// currently each player character has an equal chance to be hit by the enemy
return playerParticipants[random.Next(0, playerParticipants.Count )];
}

Expand Down Expand Up @@ -211,12 +209,12 @@ public static int DetermineGoldPoints(List<Participant> defeatedParticipants, Ra
return gpSum;
}

public static List<Object> DetermineItemsDropped(Dictionary<Object, int> droppableItems) {
public static List<T> DetermineItemsDropped<T>(Dictionary<T, int> droppableItems) {
return DetermineItemsDropped(droppableItems, Random);
}

public static List<Object> DetermineItemsDropped(Dictionary<Object, int> droppableItems, Random random) {
List<Object> itemsDropped = new List<Object>();
public static List<T> DetermineItemsDropped<T>(Dictionary<T, int> droppableItems, Random random) {
List<T> itemsDropped = new List<T>();

foreach (var droppableItem in droppableItems) {
if (random.Next(droppableItem.Value, 100) <= droppableItem.Value) {
Expand Down

0 comments on commit 83d5a3d

Please sign in to comment.