Skip to content

Commit

Permalink
Add health feedback when examining a character
Browse files Browse the repository at this point in the history
  • Loading branch information
jskz committed Oct 24, 2021
1 parent 0fe5986 commit 1795a7c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/act_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,33 @@ import (
"time"
)

func (ch *Character) getHealthFeedback(viewer *Character) string {
healthPercentage := ch.Health * 100 / ch.MaxHealth

if healthPercentage >= 100 {
return fmt.Sprintf("{G%s{G is in perfect health.{x", ch.GetShortDescriptionUpper(viewer))
} else if healthPercentage >= 80 {
return fmt.Sprintf("{g%s{g is barely scratched.{x", ch.GetShortDescriptionUpper(viewer))
} else if healthPercentage >= 60 {
return fmt.Sprintf("{w%s{w has several cuts and scratches.{x", ch.GetShortDescriptionUpper(viewer))
} else if healthPercentage >= 40 {
return fmt.Sprintf("{Y%s{Y has quite a few wounds.{x", ch.GetShortDescriptionUpper(viewer))
} else if healthPercentage >= 25 {
return fmt.Sprintf("{M%s{M looks pretty hurt.{x", ch.GetShortDescriptionUpper(viewer))
} else if healthPercentage >= 10 {
return fmt.Sprintf("{R%s{R is in awful condition.{x", ch.GetShortDescriptionUpper(viewer))
} else {
return fmt.Sprintf("{D%s{D is about to die.{x", ch.GetShortDescriptionUpper(viewer))
}
}

func (ch *Character) examineCharacter(other *Character) {
if other.Flags&CHAR_IS_PLAYER == 0 {
ch.Send(fmt.Sprintf("{G%s{x\r\n", other.Description))
}

ch.Send(fmt.Sprintf("%s\r\n", other.getHealthFeedback(ch)))

for i := WearLocationNone + 1; i < WearLocationMax; i++ {
var obj *ObjectInstance = other.getEquipment(i)

Expand Down

0 comments on commit 1795a7c

Please sign in to comment.