mirror of
https://github.com/arnaucube/gogame.git
synced 2026-02-06 19:16:40 +01:00
add jwt middleware
This commit is contained in:
@@ -2,21 +2,21 @@ package models
|
||||
|
||||
import "gopkg.in/mgo.v2/bson"
|
||||
|
||||
/*
|
||||
BuildingsList
|
||||
MetalMine int64
|
||||
CrystalMine int64
|
||||
DeuteriumMine int64
|
||||
EnergyMine int64
|
||||
FusionReactor int64
|
||||
RoboticsFactory int64
|
||||
Shipyard int64
|
||||
RessearchLab int64
|
||||
*/
|
||||
type Planet struct {
|
||||
Id bson.ObjectId `json:"id" bson:"_id,omitempty"`
|
||||
Size int64 // fields/slots
|
||||
Name string
|
||||
OwnerId bson.ObjectId
|
||||
Buildings map[string]int64
|
||||
/*
|
||||
Buildings types (in the map, all in lowcase):
|
||||
MetalMine int64
|
||||
CrystalMine int64
|
||||
DeuteriumMine int64
|
||||
EnergyMine int64
|
||||
FusionReactor int64
|
||||
RoboticsFactory int64
|
||||
Shipyard int64
|
||||
RessearchLab int64
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package models
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/arnaucube/gogame/database"
|
||||
@@ -107,8 +106,6 @@ func (u *User) GetResources() (*Resources, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// get u.LastUpdated
|
||||
fmt.Println(u.LastUpdated)
|
||||
// calculate Delta time = currentTime - u.LastUpdated
|
||||
delta := time.Since(u.LastUpdated)
|
||||
|
||||
@@ -122,7 +119,6 @@ func (u *User) GetResources() (*Resources, error) {
|
||||
// and calculate growth = ResourcePlant.Level for each planet
|
||||
var metalGrowth, crystalGrowth, deuteriumGrowth, energyGrowth int64
|
||||
for _, planet := range planets {
|
||||
fmt.Println("planet", planet)
|
||||
// TODO find correct formulas
|
||||
metalGrowth = metalGrowth + ((1 + planet.Buildings["metalmine"]) * int64(delta))
|
||||
crystalGrowth = crystalGrowth + ((1 + planet.Buildings["crystalmine"]) * int64(delta))
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/arnaucube/gogame/database"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
/*
|
||||
func TestCreateUser(t *testing.T) {
|
||||
db, err := database.New("127.0.0.1:27017", "gogametests")
|
||||
assert.Nil(t, err)
|
||||
@@ -15,3 +9,4 @@ func TestCreateUser(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
assert.Equal(t, user.Name, "user00")
|
||||
}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user