From 57bde4ac3c32a5e5e4e573985dbba201ceae32ed Mon Sep 17 00:00:00 2001 From: Jeffrey Duroyon Date: Mon, 23 Aug 2021 23:46:28 +0200 Subject: [PATCH] feat(golden): add the possibility of a golden hamster --- storage/model/hamster.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/storage/model/hamster.go b/storage/model/hamster.go index 626b525..d09552a 100644 --- a/storage/model/hamster.go +++ b/storage/model/hamster.go @@ -45,6 +45,7 @@ type Hamster struct { Height float64 `json:"height"` Alive bool `json:"alive"` Sold bool `json:"sold"` + Golden bool `json:"golden"` Gestation bool `json:"gestation"` GestationPeriod int8 `json:"gestation_period"` GestationCooldown int8 `json:"gestation_cooldown"` @@ -63,7 +64,12 @@ func (h *Hamster) DeterminatePrice() int { if h.Age >= 600 { return 0 } + var price = 50 + + if h.Golden { + price += 100 + } if h.Age >= 60 && h.Age <= 300 { var diffAge, quotient int diffAge = 300 - h.Age @@ -195,6 +201,7 @@ func Born(father *Hamster, mother *Hamster) ([]*Hamster, error) { ThirstLevel: Full, Alive: true, Sold: false, + Golden: false, Gestation: false, GestationPeriod: 0, GestationCooldown: 30, @@ -203,6 +210,12 @@ func Born(father *Hamster, mother *Hamster) ([]*Hamster, error) { mother.Child = append(mother.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 { var dieRoll = randNumber(0, 100) if (mother.Age < 525 && dieRoll <= 5) ||