feat(golden): add the possibility of a golden hamster
This commit is contained in:
@@ -45,6 +45,7 @@ type Hamster struct {
|
|||||||
Height float64 `json:"height"`
|
Height float64 `json:"height"`
|
||||||
Alive bool `json:"alive"`
|
Alive bool `json:"alive"`
|
||||||
Sold bool `json:"sold"`
|
Sold bool `json:"sold"`
|
||||||
|
Golden bool `json:"golden"`
|
||||||
Gestation bool `json:"gestation"`
|
Gestation bool `json:"gestation"`
|
||||||
GestationPeriod int8 `json:"gestation_period"`
|
GestationPeriod int8 `json:"gestation_period"`
|
||||||
GestationCooldown int8 `json:"gestation_cooldown"`
|
GestationCooldown int8 `json:"gestation_cooldown"`
|
||||||
@@ -63,7 +64,12 @@ func (h *Hamster) DeterminatePrice() int {
|
|||||||
if h.Age >= 600 {
|
if h.Age >= 600 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
var price = 50
|
var price = 50
|
||||||
|
|
||||||
|
if h.Golden {
|
||||||
|
price += 100
|
||||||
|
}
|
||||||
if h.Age >= 60 && h.Age <= 300 {
|
if h.Age >= 60 && h.Age <= 300 {
|
||||||
var diffAge, quotient int
|
var diffAge, quotient int
|
||||||
diffAge = 300 - h.Age
|
diffAge = 300 - h.Age
|
||||||
@@ -195,6 +201,7 @@ func Born(father *Hamster, mother *Hamster) ([]*Hamster, error) {
|
|||||||
ThirstLevel: Full,
|
ThirstLevel: Full,
|
||||||
Alive: true,
|
Alive: true,
|
||||||
Sold: false,
|
Sold: false,
|
||||||
|
Golden: false,
|
||||||
Gestation: false,
|
Gestation: false,
|
||||||
GestationPeriod: 0,
|
GestationPeriod: 0,
|
||||||
GestationCooldown: 30,
|
GestationCooldown: 30,
|
||||||
@@ -203,6 +210,12 @@ func Born(father *Hamster, mother *Hamster) ([]*Hamster, error) {
|
|||||||
mother.Child = append(mother.Child, child...)
|
mother.Child = append(mother.Child, child...)
|
||||||
father.Child = append(father.Child, child...)
|
father.Child = append(father.Child, child...)
|
||||||
|
|
||||||
|
var goldenRoll = randNumber(1, 4096)
|
||||||
|
if goldenRoll == 42 {
|
||||||
|
var goldenChild = randNumber(0, numberOfChild-1)
|
||||||
|
child[goldenChild].Golden = true
|
||||||
|
}
|
||||||
|
|
||||||
if mother.Age >= 500 {
|
if mother.Age >= 500 {
|
||||||
var dieRoll = randNumber(0, 100)
|
var dieRoll = randNumber(0, 100)
|
||||||
if (mother.Age < 525 && dieRoll <= 5) ||
|
if (mother.Age < 525 && dieRoll <= 5) ||
|
||||||
|
|||||||
Reference in New Issue
Block a user