2023-10-31 22:40:14 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-10-31 23:19:52 +00:00
|
|
|
"github.com/ectrc/snow/aid"
|
2023-10-31 22:40:14 +00:00
|
|
|
"github.com/ectrc/snow/person"
|
|
|
|
"github.com/ectrc/snow/storage"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
DROP_TABLES = true
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2023-11-01 21:51:14 +00:00
|
|
|
aid.LoadConfig()
|
2023-10-31 22:40:14 +00:00
|
|
|
|
|
|
|
var device storage.Storage
|
|
|
|
|
2023-11-01 21:51:14 +00:00
|
|
|
switch aid.Config.Database.Type {
|
2023-10-31 22:40:14 +00:00
|
|
|
case "postgres":
|
|
|
|
postgresStorage := storage.NewPostgresStorage()
|
|
|
|
|
|
|
|
if DROP_TABLES {
|
|
|
|
postgresStorage.DropTables()
|
|
|
|
}
|
|
|
|
|
|
|
|
postgresStorage.Migrate(&storage.DB_Person{}, "Persons")
|
|
|
|
postgresStorage.Migrate(&storage.DB_Loadout{}, "Loadouts")
|
|
|
|
postgresStorage.Migrate(&storage.DB_Profile{}, "Profiles")
|
|
|
|
postgresStorage.Migrate(&storage.DB_Item{}, "Items")
|
|
|
|
postgresStorage.Migrate(&storage.DB_Gift{}, "Gifts")
|
|
|
|
postgresStorage.Migrate(&storage.DB_Quest{}, "Quests")
|
|
|
|
postgresStorage.Migrate(&storage.DB_Loot{}, "Loot")
|
|
|
|
postgresStorage.Migrate(&storage.DB_VariantChannel{}, "Variants")
|
|
|
|
postgresStorage.Migrate(&storage.DB_PAttribute{}, "Attributes")
|
|
|
|
|
|
|
|
device = postgresStorage
|
|
|
|
}
|
2023-10-31 23:19:52 +00:00
|
|
|
|
2023-10-31 22:40:14 +00:00
|
|
|
storage.Repo = storage.NewStorage(device)
|
|
|
|
storage.Cache = storage.NewPersonsCacheMutex()
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
if DROP_TABLES {
|
|
|
|
user := person.NewPerson()
|
|
|
|
{
|
2023-11-01 21:33:25 +00:00
|
|
|
user.CommonCoreProfile.Attributes.AddAttribute(person.NewAttribute("xp", 1030))
|
|
|
|
user.CommonCoreProfile.Attributes.AddAttribute(person.NewAttribute("level", 100))
|
|
|
|
user.CommonCoreProfile.Attributes.AddAttribute(person.NewAttribute("quest_manager", aid.JSON{}))
|
|
|
|
|
2023-11-01 01:24:42 +00:00
|
|
|
user.CommonCoreProfile.Items.AddItem(person.NewItem("Currency:MtxPurchased", 100))
|
|
|
|
user.CommonCoreProfile.Items.AddItem(person.NewItem("Token:CampaignAccess", 1))
|
|
|
|
|
|
|
|
quest := person.NewQuest("Quest:Quest_1", "ChallengeBundle:Daily_1", "ChallengeBundleSchedule:Paid_1")
|
|
|
|
{
|
|
|
|
quest.AddObjective("quest_objective_eliminateplayers", 0)
|
|
|
|
quest.AddObjective("quest_objective_top1", 0)
|
|
|
|
quest.AddObjective("quest_objective_place_top10", 0)
|
|
|
|
|
|
|
|
quest.UpdateObjectiveCount("quest_objective_eliminateplayers", 10)
|
|
|
|
quest.UpdateObjectiveCount("quest_objective_place_top10", -3)
|
|
|
|
|
|
|
|
quest.RemoveObjective("quest_objective_top1")
|
|
|
|
}
|
|
|
|
user.AthenaProfile.Quests.AddQuest(quest)
|
|
|
|
|
|
|
|
giftBox := person.NewGift("GiftBox:GB_Default", 1, user.ID, "Hello, Bully!")
|
|
|
|
{
|
|
|
|
giftBox.AddLoot(person.NewItemWithType("AthenaCharacter:CID_002_Athena_Commando_F_Default", 1, "athena"))
|
|
|
|
}
|
|
|
|
user.CommonCoreProfile.Gifts.AddGift(giftBox)
|
2023-10-31 22:40:14 +00:00
|
|
|
}
|
2023-11-01 01:24:42 +00:00
|
|
|
user.Save()
|
2023-10-31 22:40:14 +00:00
|
|
|
|
2023-11-01 01:24:42 +00:00
|
|
|
snapshot := user.CommonCoreProfile.Snapshot()
|
2023-10-31 22:40:14 +00:00
|
|
|
{
|
2023-11-01 01:24:42 +00:00
|
|
|
vbucks := user.CommonCoreProfile.Items.GetItemByTemplateID("Currency:MtxPurchased")
|
|
|
|
vbucks.Quantity = 200
|
|
|
|
vbucks.Favorite = true
|
|
|
|
|
|
|
|
user.CommonCoreProfile.Items.DeleteItem(user.CommonCoreProfile.Items.GetItemByTemplateID("Token:CampaignAccess").ID)
|
|
|
|
user.CommonCoreProfile.Items.AddItem(person.NewItem("Token:ReceiveMtxCurrency", 1))
|
|
|
|
}
|
|
|
|
user.CommonCoreProfile.Diff(snapshot)
|
2023-11-01 21:33:25 +00:00
|
|
|
user.Save()
|
2023-10-31 22:40:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
go storage.Cache.CacheKiller()
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2023-11-01 21:51:14 +00:00
|
|
|
var users []*person.Person
|
|
|
|
|
|
|
|
aid.PrintTime("Fetching Persons", func() {
|
|
|
|
users = person.AllFromDatabase()
|
|
|
|
})
|
2023-11-01 21:33:25 +00:00
|
|
|
|
|
|
|
for _, user := range users {
|
|
|
|
aid.PrintJSON(user.Snapshot())
|
|
|
|
}
|
|
|
|
|
2023-11-01 01:24:42 +00:00
|
|
|
// aid.WaitForExit()
|
2023-10-31 22:40:14 +00:00
|
|
|
}
|