Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var TestBookSystem = server.CreateSystemFromRequestHandler(func(ctx *server.TransactionCtx[*pb_test.C2S_Test]) { req := ctx.Req.Data w := ctx.W playerID := int(req.GetIdentityPayload().GetPlayerId()) for _, bookInfo := range req.BookInfos { switch bookInfo.Op { case pb_test.Operation_Add: bookTable.Add(w, Book{ Title: bookInfo.Title, Author: bookInfo.Author, OwnerID: playerID, }) case pb_test.Operation_AddSpecific: bookTable.AddSpecific(w, int(bookInfo.Entity), Book{ Title: bookInfo.Title, Author: bookInfo.Author, OwnerID: playerID, }) case pb_test.Operation_Remove: server.QueueTxFromInternal(w, ctx.GameCtx.GameTick.TickNumber+1, server.NewKeystoneTx(testRemoveRequest{ Title: bookInfo.Title, Author: bookInfo.Author, PlayerID: playerID, }, nil), "") case pb_test.Operation_Update: book := bookTable.Get(w, int(bookInfo.Entity)) if book.Title == "" { ctx.EmitError(fmt.Sprintf("no book to update with entity %v", bookInfo.Entity), []int{playerID}) return } book.Title = bookInfo.Title book.Author = bookInfo.Author bookTable.Set(w, int(bookInfo.Entity), book) } } })
View Source
var TestRemoveBookSystem = server.CreateSystemFromRequestHandler(func(ctx *server.TransactionCtx[testRemoveRequest]) { req := ctx.Req.Data w := ctx.GameCtx.World bookFilter := Book{Author: req.Author, Title: req.Title, OwnerID: req.PlayerID} fieldNames := []string{"OwnerID"} if req.Author == "" && req.Title == "" { ctx.EmitError("author or title must be provided to remove a book", []int{req.PlayerID}) return } if req.Author != "" { fieldNames = append(fieldNames, "Author") } if req.Title != "" { fieldNames = append(fieldNames, "Title") } bookEntities := bookTable.Filter(w, bookFilter, fieldNames) for _, e := range bookEntities { bookTable.RemoveEntity(w, e) } })
Functions ¶
This section is empty.
Types ¶
type Committee ¶ added in v0.1.12
type Committee struct {
CommitteeOwners utils.SerializableArray[Owner] `gorm:"serializer:json"`
}
type PetCommunity ¶ added in v0.1.11
type PetCommunity struct { Owners utils.SerializableArray[Owner] `gorm:"serializer:json"` Committee Committee `gorm:"embedded"` Id int `gorm:"primaryKey;autoIncrement:false"` }
Click to show internal directories.
Click to hide internal directories.