arnaucube
arnaucube/gogame-oldPublic Self-hosted repository
add countdown indicator on building
arnaucube arnaucube@gmail.com
Mon, 17 Jun 2019 19:50:49 +0200
commit

992894c87bfdb565d90ff09b774afb07553c5896

parent

edfa4e6751025943a9117b9dd1712b02df556500

1 files changed, 7 insertions(+), 3 deletions(-)

jump to
M models/planet.go → models/planet.go

@@ -11,9 +11,10 @@ )

type Process struct { // if Title == "", is not active, and can build other buildings/research - Title string // building name / research name + level - Building string - Ends time.Time + Title string // building name / research name + level + Building string + Ends time.Time + CountDown int64 } type Resources struct {

@@ -221,6 +222,8 @@ return true, err

} return false, nil } + p.CurrentBuild.CountDown = p.CurrentBuild.Ends.Unix() - time.Now().Unix() + return true, nil } return false, nil

@@ -253,6 +256,7 @@ // add current task to planet

p.CurrentBuild.Building = building p.CurrentBuild.Title = building + " - Level " + strconv.Itoa(int(p.Buildings[building])) p.CurrentBuild.Ends = endsTime + p.CurrentBuild.CountDown = p.CurrentBuild.Ends.Unix() - time.Now().Unix() // store planet in db err = p.Db.Planets.Update(bson.M{"_id": p.Id}, p)