-
Notifications
You must be signed in to change notification settings - Fork 7
/
model.go
96 lines (83 loc) · 3.06 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
90
91
92
93
94
95
96
package persistence
import (
"github.com/sunist-c/genius-invokation-simulator-backend/entity/model"
"github.com/sunist-c/genius-invokation-simulator-backend/enum"
"github.com/sunist-c/genius-invokation-simulator-backend/protocol/websocket/message"
"time"
)
// Card 被持久化模块托管的Card工厂的产品
type Card struct {
Cacheable
Card model.Card
}
// Skill 被持久化模块托管的Skill工厂的产品
type Skill struct {
Cacheable
Skill model.Skill
}
// RuleSet 被持久化模块托管的RuleSet工厂的产品
type RuleSet struct {
Cacheable
Rule model.RuleSet
}
// Summon 被持久化模块托管的Summon工厂的产品
type Summon struct {
Cacheable
// todo: add summon interfaces
}
// Event 被持久化模块托管的Event工厂的产品
type Event struct {
Cacheable
Event model.Event
}
// Character 被持久化模块托管的CharacterInfo工厂的产品
type Character struct {
Cacheable
TypeID uint64
Affiliation enum.Affiliation
Vision enum.ElementType
Weapon enum.WeaponType
MaxHP uint
MaxMP uint
Skills []uint64
}
func (c Character) ID() uint64 { return c.TypeID }
// Player 被持久化模块托管的Player信息
type Player struct {
UID uint64 `xorm:"pk autoincr notnull unique index"` // UID Player的UID,主键
NickName string `xorm:"notnull varchar(64)"` // NickName Player的昵称
Password string `xorm:"notnull varchar(64)"` // Password Player的密码Hash
}
// CardDeck 被持久化模块托管的CardDeck信息
type CardDeck struct {
ID uint64 `xorm:"pk autoincr notnull unique index" json:"id"` // ID CardDeck的记录ID,主键
OwnerUID uint64 `xorm:"notnull index" json:"owner_uid"` // OwnerUID CardDeck的持有者
RequiredPackages []string `xorm:"notnull json" json:"required_packages"` // RequiredPackages CardDeck需要的包
Cards []uint64 `xorm:"notnull json" json:"cards"` // Cards CardDeck包含的卡组
Characters []uint64 `xorm:"notnull json" json:"characters"` // Characters CardDeck包含的角色
}
// Token 被持久化模块托管的Token缓存
type Token struct {
UID uint64 // UID Token持有者的UID
ID string // ID Token的ID
}
// RoomInfo 被持久化模块托管的RoomInfo缓存
type RoomInfo struct {
RoomID uint64 `json:"room_id"`
CreatedAt time.Time `json:"created_at"`
CreatorID uint64 `json:"creator_id"`
Token string `json:"token"`
Players []uint64 `json:"players"`
Viewers uint64 `json:"viewers"`
RequiredPackages []string `json:"required_packages"`
GameOptions message.GameOptions `json:"game_options"`
}
// ModInfo 被持久化模块托管的ModInfo缓存
type ModInfo struct {
PackageName string `json:"package_name"`
Events []uint `json:"events"`
Characters []uint `json:"characters"`
Cards []uint `json:"cards"`
Skills []uint `json:"skills"`
Summons []uint `json:"summons"`
}