2022-08-31 16:49:08 +09:00
|
|
|
package schema
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
"math/rand"
|
|
|
|
"entgo.io/ent"
|
|
|
|
"entgo.io/ent/schema/edge"
|
|
|
|
"entgo.io/ent/schema/field"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Card holds the schema definition for the Card entity.
|
|
|
|
type Card struct {
|
|
|
|
ent.Schema
|
|
|
|
}
|
|
|
|
var url = "https://card.syui.ai"
|
|
|
|
|
|
|
|
var card int
|
|
|
|
var super string
|
2023-05-03 19:16:36 +09:00
|
|
|
var skill string
|
2022-08-31 16:49:08 +09:00
|
|
|
var cp int
|
|
|
|
|
|
|
|
func (Card) Fields() []ent.Field {
|
|
|
|
return []ent.Field{
|
2023-04-05 15:05:14 +09:00
|
|
|
|
|
|
|
field.String("password").
|
|
|
|
NotEmpty().
|
|
|
|
Immutable().
|
|
|
|
Sensitive(),
|
|
|
|
|
2022-08-31 16:49:08 +09:00
|
|
|
field.Int("card").
|
|
|
|
DefaultFunc(func() int {
|
|
|
|
rand.Seed(time.Now().UnixNano())
|
|
|
|
var a = rand.Intn(10)
|
|
|
|
if a == 1 {
|
2023-04-09 16:18:10 +09:00
|
|
|
card = rand.Intn(16)
|
2022-08-31 16:49:08 +09:00
|
|
|
} else {
|
|
|
|
card = 0
|
|
|
|
}
|
2023-04-09 22:54:51 +09:00
|
|
|
|
2022-08-31 16:49:08 +09:00
|
|
|
if card == 13 {
|
2023-07-23 23:40:24 +09:00
|
|
|
card = 29
|
2023-04-28 23:34:59 +09:00
|
|
|
}
|
|
|
|
|
2023-04-09 20:05:44 +09:00
|
|
|
// 2023/04/09 premium card id:15
|
2023-04-09 22:54:51 +09:00
|
|
|
if card == 15 {
|
2023-04-28 23:34:59 +09:00
|
|
|
card = 3
|
2023-04-09 22:54:51 +09:00
|
|
|
}
|
2023-04-13 16:50:11 +09:00
|
|
|
|
|
|
|
if card == 16 {
|
2023-04-28 23:34:59 +09:00
|
|
|
card = 4
|
2023-04-13 16:50:11 +09:00
|
|
|
}
|
2023-05-01 23:00:17 +09:00
|
|
|
|
|
|
|
if card == 17 {
|
|
|
|
card = 5
|
|
|
|
}
|
|
|
|
|
|
|
|
if card == 18 {
|
|
|
|
card = 6
|
|
|
|
}
|
|
|
|
|
2023-11-03 11:24:42 +09:00
|
|
|
//var card = rand.Intn(91)
|
2022-08-31 16:49:08 +09:00
|
|
|
return card
|
|
|
|
}).
|
|
|
|
Optional(),
|
|
|
|
|
2023-05-03 19:16:36 +09:00
|
|
|
field.String("skill").
|
|
|
|
DefaultFunc(func() string {
|
|
|
|
rand.Seed(time.Now().UnixNano())
|
|
|
|
var a = rand.Intn(12)
|
|
|
|
if a == 1 {
|
|
|
|
skill = "critical"
|
|
|
|
} else {
|
|
|
|
skill = "normal"
|
|
|
|
}
|
|
|
|
if card == 0 {
|
|
|
|
skill = "normal"
|
|
|
|
}
|
|
|
|
return skill
|
|
|
|
}).
|
|
|
|
Optional(),
|
|
|
|
|
2022-08-31 16:49:08 +09:00
|
|
|
field.String("status").
|
2023-07-01 23:21:48 +09:00
|
|
|
//Immutable().
|
2022-08-31 16:49:08 +09:00
|
|
|
DefaultFunc(func() string {
|
|
|
|
rand.Seed(time.Now().UnixNano())
|
|
|
|
var a = rand.Intn(10)
|
|
|
|
if a == 1 {
|
|
|
|
super = "super"
|
|
|
|
} else {
|
|
|
|
super = "normal"
|
|
|
|
}
|
|
|
|
if card == 0 {
|
|
|
|
super = "normal"
|
|
|
|
}
|
|
|
|
return super
|
|
|
|
}).
|
|
|
|
Optional(),
|
|
|
|
|
2023-07-01 23:21:48 +09:00
|
|
|
field.String("token").
|
|
|
|
Optional().
|
|
|
|
Sensitive(),
|
|
|
|
|
2022-08-31 16:49:08 +09:00
|
|
|
field.Int("cp").
|
2023-07-01 23:21:48 +09:00
|
|
|
//Immutable().
|
2022-08-31 16:49:08 +09:00
|
|
|
DefaultFunc(func() int {
|
|
|
|
rand.Seed(time.Now().UnixNano())
|
2023-07-23 23:40:24 +09:00
|
|
|
var cp = 1 + rand.Intn(200)
|
2023-04-06 12:38:49 +09:00
|
|
|
if cp == 2 {
|
2023-07-23 23:40:24 +09:00
|
|
|
cp = 50 + rand.Intn(300)
|
2022-08-31 16:49:08 +09:00
|
|
|
}
|
2023-04-08 11:23:05 +09:00
|
|
|
if card >= 1 {
|
2023-07-23 23:40:24 +09:00
|
|
|
cp = 200 + cp + rand.Intn(500)
|
2022-08-31 16:49:08 +09:00
|
|
|
}
|
|
|
|
if super == "super" {
|
2023-07-23 23:40:24 +09:00
|
|
|
cp = 400 + cp + rand.Intn(700)
|
2022-08-31 16:49:08 +09:00
|
|
|
}
|
|
|
|
|
2023-05-21 15:45:18 +09:00
|
|
|
if skill == "critical" {
|
2023-07-23 23:40:24 +09:00
|
|
|
cp = 400 + cp + rand.Intn(700)
|
2023-05-21 15:45:18 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
if card == 22 {
|
|
|
|
cp = 800 + cp + rand.Intn(1500)
|
|
|
|
}
|
|
|
|
|
2023-05-24 18:36:44 +09:00
|
|
|
if card == 25 {
|
|
|
|
cp = 0
|
|
|
|
}
|
|
|
|
|
2022-08-31 16:49:08 +09:00
|
|
|
return cp
|
|
|
|
}).
|
|
|
|
Optional(),
|
|
|
|
|
|
|
|
field.String("url").
|
|
|
|
Default(url).
|
|
|
|
Optional(),
|
|
|
|
|
2023-08-21 22:13:44 +09:00
|
|
|
field.Int("count").
|
|
|
|
Optional(),
|
|
|
|
|
|
|
|
field.String("author").
|
|
|
|
Optional(),
|
|
|
|
|
2022-08-31 16:49:08 +09:00
|
|
|
field.Time("created_at").
|
|
|
|
Immutable().
|
|
|
|
Optional().
|
|
|
|
Default(func() time.Time {
|
|
|
|
return time.Now().In(jst)
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (Card) Edges() []ent.Edge {
|
|
|
|
return []ent.Edge{
|
|
|
|
edge.From("owner", User.Type).
|
|
|
|
Ref("card").
|
|
|
|
Unique().
|
|
|
|
Required(),
|
2023-04-05 15:05:14 +09:00
|
|
|
|
2022-08-31 16:49:08 +09:00
|
|
|
}
|
|
|
|
}
|