-
Notifications
You must be signed in to change notification settings - Fork 7
/
model.go
89 lines (73 loc) · 3.23 KB
/
model.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package gaming
import (
"gopkg.in/mgo.v2/bson"
"time"
)
type Rules struct {
Updated time.Time `json:"updated_at"`
Rules []RuleModel `json:"rules"`
Badges []BadgeModel `json:"badges,omitempty"`
}
type RuleModel struct {
Level int `json:"level"`
Name string `json:"name"`
Start int `json:"swords_start"`
End int `json:"swords_end"`
Tribute int `json:"tribute"`
Shit int `json:"shit"`
Coins int `json:"coins"`
}
type BadgeModel struct {
Id bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty"`
Type string `bson:"type" json:"type"`
TypeLabel string `bson:"type_label" json:"type_label"`
Slug string `bson:"slug" json:"slug"`
Name string `bson:"name" json:"name"`
Description string `bson:"description" json:"description"`
Coins int `bson:"coins,omitempty" json:"coins,omitempty"`
RequiredBadge bson.ObjectId `bson:"required_badge,omitempty" json:"required_badge,omitempty"`
RequiredLevel int `bson:"required_level,omitempty" json:"required_level,omitempty"`
Avaliable bool `bson:"available" json:"available"`
}
type RankingModel struct {
Id bson.ObjectId `bson:"_id,omitempty" json:"id,omitempty"`
UserId bson.ObjectId `bson:"user_id" json:"user_id"`
Badges int `bson:"badges" json:"badges"`
Swords int `bson:"swords" json:"swords"`
Coins int `bson:"coins" json:"coins"`
Position RankingPositionModel `bson:"position" json:"position"`
Before RankingPositionModel `bson:"before" json:"before"`
User RankingUserModel `bson:"-" json:"user,omitempty"`
Created time.Time `bson:"created_at" json:"created_at"`
}
type RankingPositionModel struct {
Wealth int `bson:"wealth" json:"wealth"`
Swords int `bson:"swords" json:"swords"`
Badges int `bson:"badges" json:"badges"`
}
type RankingUserModel struct {
Id bson.ObjectId `bson:"_id,omitempty" json:"id"`
UserName string `bson:"username" json:"username"`
Image string `bson:"image" json:"image,omitempty"`
Gaming map[string]interface{} `bson:"gaming" json:"gaming,omitempty"`
}
type RankPosition struct {
Id string
Value int
}
type RankPositions []RankPosition
func (a RankPositions) Len() int { return len(a) }
func (a RankPositions) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a RankPositions) Less(i, j int) bool { return a[i].Value > a[j].Value }
type RankBySwords []RankingModel
func (a RankBySwords) Len() int { return len(a) }
func (a RankBySwords) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a RankBySwords) Less(i, j int) bool { return a[i].Swords > a[j].Swords }
type RankByCoins []RankingModel
func (a RankByCoins) Len() int { return len(a) }
func (a RankByCoins) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a RankByCoins) Less(i, j int) bool { return a[i].Coins > a[j].Coins }
type RankByBadges []RankingModel
func (a RankByBadges) Len() int { return len(a) }
func (a RankByBadges) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a RankByBadges) Less(i, j int) bool { return a[i].Badges > a[j].Badges }