Here is the current code for the take_damage function in objects/living.rb:
def take_damage amount, type = :health
case type
when :health
info.stats.health and info.stats.health -= amount
when :stamina
info.stats.stamina and info.stat.stamina -= amount
when :fortitude
info.stats.fortitude and info.stats.stamina -= amount
else
log "Do not know this kind of damage: #{type}"
end
end
Here is what it should be:
def take_damage amount, type = :health
case type
when :health
info.stats.health and info.stats.health -= amount
if info.stats.health < 0
info.stats.health = 0
end
when :stamina
info.stats.stamina and info.stat.stamina -= amount
if info.stats.stamina < 0
info.stats.stamina = 0
end
when :fortitude
info.stats.fortitude and info.stats.fortitude -= amount
if info.stats.fortitude < 0
info.stats.fortitude = 0
end
else
log "Do not know this kind of damage: #{type}"
end
end
This function is called each time your character is supposed to get hurt and detracts from that characters health/fortitude/stamina stats. However, in its current incarnation, when a user takes so much damage that it brings him below 0 health (If for example, he was at 3 health, and took 5 damage, it would bring him to -2 health), it is displayed in the prompt as a negative number. The new code forces a 0 whenever a players health drops below 0, so that it never falls into the negative numbers.
Also, the part for detracting from fortitude was detracting from the stamina stat, so that's corrected as well.