feat(sell): add hamster selling method
This commit is contained in:
@@ -3,9 +3,10 @@ package model
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
uuid "github.com/satori/go.uuid"
|
|
||||||
"hamster-tycoon/randomizer"
|
"hamster-tycoon/randomizer"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
uuid "github.com/satori/go.uuid"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@@ -58,6 +59,71 @@ func (h *Hamster) Die() {
|
|||||||
h.Alive = false
|
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() {
|
func (h *Hamster) Grow() {
|
||||||
if h.Age >= MaxAge {
|
if h.Age >= MaxAge {
|
||||||
if randNumber(h.Age-MaxAge, 365) > 364 {
|
if randNumber(h.Age-MaxAge, 365) > 364 {
|
||||||
|
|||||||
Reference in New Issue
Block a user