diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..11f8b02 Binary files /dev/null and b/.DS_Store differ diff --git a/storage/model/hamster.go b/storage/model/hamster.go index d8a7ff3..8e63cb1 100644 --- a/storage/model/hamster.go +++ b/storage/model/hamster.go @@ -3,9 +3,10 @@ package model import ( "errors" "fmt" - uuid "github.com/satori/go.uuid" "hamster-tycoon/randomizer" "time" + + uuid "github.com/satori/go.uuid" ) const ( @@ -58,6 +59,71 @@ func (h *Hamster) Die() { h.Alive = false } +func (h *Hamster) DeterminatePrice() int { + if h.Age >= 600 { + return 0 + } + var price = 50 + if h.Age >= 60 && h.Age <= 300 { + var diffAge, quotient int + diffAge = 300 - h.Age + quotient = diffAge / 25 + price += quotient * 5 + } + if h.Sexe == FEMALE { + price += 20 + } else { + price -= 20 + } + + if h.Gestation { + if h.Age >= 500 { + price += 5 + } else { + price += 20 + } + } + + if h.Age > 300 { + var diffAge, quotient int + diffAge = h.Age - 300 + quotient = diffAge / 100 + price += quotient * 10 + } + + switch h.ThirstLevel { + case Empty: + price -= 20 + case AlmostEmpty: + price -= 10 + case AlmostFull: + price += 10 + case Full: + price += 20 + } + + switch h.HungerLevel { + case Empty: + price -= 20 + case AlmostEmpty: + price -= 10 + case AlmostFull: + price += 10 + case Full: + price += 20 + } + switch { + case h.GestationCooldown > 0 && h.GestationCooldown <= 7: + price -= 10 + case h.GestationCooldown >= 8 && h.GestationCooldown <= 14: + price -= 5 + case h.GestationCooldown > 15: + price -= 2 + } + return price + +} + func (h *Hamster) Grow() { if h.Age >= MaxAge { if randNumber(h.Age-MaxAge, 365) > 364 {