mirror of
https://github.com/arnaucube/gogame.git
synced 2026-02-07 11:36:40 +01:00
add countdown indicator on building
This commit is contained in:
@@ -14,6 +14,7 @@ type Process struct {
|
|||||||
Title string // building name / research name + level
|
Title string // building name / research name + level
|
||||||
Building string
|
Building string
|
||||||
Ends time.Time
|
Ends time.Time
|
||||||
|
CountDown int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type Resources struct {
|
type Resources struct {
|
||||||
@@ -221,6 +222,8 @@ func (p *Planet) CheckCurrentBuild() (bool, error) {
|
|||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
p.CurrentBuild.CountDown = p.CurrentBuild.Ends.Unix() - time.Now().Unix()
|
||||||
|
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
return false, nil
|
return false, nil
|
||||||
@@ -253,6 +256,7 @@ func (p *Planet) UpgradeBuilding(building string) error {
|
|||||||
p.CurrentBuild.Building = building
|
p.CurrentBuild.Building = building
|
||||||
p.CurrentBuild.Title = building + " - Level " + strconv.Itoa(int(p.Buildings[building]))
|
p.CurrentBuild.Title = building + " - Level " + strconv.Itoa(int(p.Buildings[building]))
|
||||||
p.CurrentBuild.Ends = endsTime
|
p.CurrentBuild.Ends = endsTime
|
||||||
|
p.CurrentBuild.CountDown = p.CurrentBuild.Ends.Unix() - time.Now().Unix()
|
||||||
|
|
||||||
// store planet in db
|
// store planet in db
|
||||||
err = p.Db.Planets.Update(bson.M{"_id": p.Id}, p)
|
err = p.Db.Planets.Update(bson.M{"_id": p.Id}, p)
|
||||||
|
|||||||
Reference in New Issue
Block a user