Skip to content

Commit

Permalink
Refactor pet feeding and cuddling logic
Browse files Browse the repository at this point in the history
  • Loading branch information
rpothin committed Apr 4, 2024
1 parent 2e27fec commit 05adec2
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,18 @@ public static bool ArePetLifePointsCorrectlyUpdatedAfterFeedingActivity(ServiceC
// Get the life points
var lifePoints = pet.GetAttributeValue<int>("rpo_lifepoints");

Console.WriteLine("lifePointsBeforeFeeding: " + lifePointsBeforeFeeding);
Console.WriteLine("foodQuantity: " + foodQuantity);
Console.WriteLine("lifePoints: " + lifePoints);
Console.WriteLine("initialLifePoints: " + _initialLifePoints);
Console.WriteLine("lifePointsBeforeFeeding + foodQuantity: " + (lifePointsBeforeFeeding + foodQuantity));

// Check if the life points are correctly updated
if (lifePointsBeforeFeeding + foodQuantity >= _initialLifePoints) {
Console.WriteLine("1");
return lifePoints == _initialLifePoints;
} else {
Console.WriteLine("2");
// Consider the option that the life points already decreased by 10
return lifePoints == lifePointsBeforeFeeding + foodQuantity || lifePoints == lifePointsBeforeFeeding + foodQuantity - 10;
}
Expand Down Expand Up @@ -195,19 +203,11 @@ public static bool ArePetHapppinessPointsCorrectlyUpdatedAfterCuddleActivity(Ser
// Get the happiness points
var happinessPoints = pet.GetAttributeValue<int>("rpo_happinesspoints");

Console.WriteLine("happinessPointsBeforeCuddle: " + happinessPointsBeforeCuddle);
Console.WriteLine("happinessPoints: " + happinessPoints);
Console.WriteLine("initialHappinessPoints: " + _initialHappinessPoints);
Console.WriteLine("cuddleHappinessPoints: " + _cuddleHappinessPoints);
Console.WriteLine("happinessPointsBeforeCuddle + _cuddleHappinessPoints: " + (happinessPointsBeforeCuddle + _cuddleHappinessPoints));

// Check if the happiness points are correctly updated
if (happinessPointsBeforeCuddle + _cuddleHappinessPoints >= _initialHappinessPoints) {
Console.WriteLine("happinessPoints == _initialHappinessPoints");
return happinessPoints == _initialHappinessPoints;
} else {
// Consider the option that the happiness points already decreased by 10
Console.WriteLine("happinessPoints == happinessPointsBeforeCuddle + _cuddleHappinessPoints || happinessPoints == happinessPointsBeforeCuddle + _cuddleHappinessPoints - 10");
return happinessPoints == happinessPointsBeforeCuddle + _cuddleHappinessPoints || happinessPoints == happinessPointsBeforeCuddle + _cuddleHappinessPoints - 10;
}
}
Expand Down

0 comments on commit 05adec2

Please sign in to comment.