/// <summary> /// Reduces the player in this game states resources (hunger and thirst) by the move cost /// </summary> /// <param name="gs">Games State to alter</param> public void ReduceResourcesByMoveCost(GameState gs, int cost) { PCModel pcm = gs.GetPCM(); pcm.ModifyPrimaryResource(PlayerCharacter.PlayerCharacter.HUNGER, -cost); pcm.ModifyPrimaryResource(PlayerCharacter.PlayerCharacter.THIRST, -cost); }
public void PCModel_ModififyPrimaryResource() { var pc = pcm.GetPC(); var pr1 = new PrimaryResource(10, PlayerCharacter.HEALTH); var pr2 = new PrimaryResource(20, PlayerCharacter.HEALTH); var pr3 = new PrimaryResource(-30, PlayerCharacter.HEALTH); var pr4 = new PrimaryResource(-100, PlayerCharacter.HEALTH); pcm.ModifyPrimaryResource(pr1, pr1.GetAmount()); Assert.AreEqual(90, pc.GetResource(PlayerCharacter.HEALTH), "Health should be incremented by 10"); pcm.ModifyPrimaryResource(pr2, pr2.GetAmount()); Assert.AreEqual(100, pc.GetResource(PlayerCharacter.HEALTH), "Health should be capped at 100"); pcm.ModifyPrimaryResource(pr3, pr3.GetAmount()); Assert.AreEqual(70, pc.GetResource(PlayerCharacter.HEALTH), "Health should be reduced by 30"); pcm.ModifyPrimaryResource(pr4, pr4.GetAmount()); Assert.AreEqual(0, pc.GetResource(PlayerCharacter.HEALTH), "Health should be capped at 0"); }
/// <summary> /// Adjusts the player character with this events effect /// </summary> /// <param name="eventModifier">Modifier for this event</param> /// <param name="pcm">The player character model to modify with</param> public override void ResolveEffect(double eventModifier, PCModel pcm) { int value = rnd.Next(minimum, maximum); if (minimum < 0) { value = Convert.ToInt32(value * (2 - eventModifier)); } else { value = Convert.ToInt32(value * eventModifier); } if (value < minimum) { value = minimum; } else if (value > maximum) { value = maximum; } pcm.ModifyPrimaryResource(resource, value); }