This commit is contained in:
aozhiwei 2024-06-21 13:52:44 +08:00
parent 9bc2e93721
commit 82d320a067
5 changed files with 60 additions and 7 deletions

View File

@ -23,12 +23,9 @@ func (this *Item) Init1() {
this.lowerName = strings.ToLower(this.GetName())
}
func (this *ItemTable) Load() {
this.itemIdHash = new(q5.ConcurrentMap[int64, *Item])
}
func (this *ItemTable) PostInit1() {
items := []*struct {
this.itemIdHash = new(q5.ConcurrentMap[int64, *Item])
items := []struct {
Id int32 `json:"id"`
Name string `json:"name"`
Type int32 `json:"type"`
@ -38,9 +35,10 @@ func (this *ItemTable) PostInit1() {
func (ele *Item) bool {
if ele.GetType() == jccommon.ITEM_TYPE_HERO ||
ele.GetType() == jccommon.ITEM_TYPE_GOLD_BULLION {
p := *q5.NewSliceElement(&items)
langMeta := Table.Language.GetByName(ele.GetName())
p := q5.NewSliceElement(&items)
p.Id = ele.GetId()
p.Name = ele.GetName()
p.Name = langMeta.GetEn()
p.Type = ele.GetType()
p.SubType = ele.GetSubType()
}

View File

@ -0,0 +1,14 @@
package mt
import (
"f5"
"mtb"
)
type Language struct {
mtb.Language
}
type LanguageTable struct {
f5.NameMetaTable[Language]
}

View File

@ -11,6 +11,7 @@ type table struct {
GameDb *GameDbTable
Config *ConfigTable
Item *ItemTable
Language *LanguageTable
Contract *ContractTable
Web3ServiceCluster *Web3ServiceClusterTable
}
@ -46,6 +47,11 @@ var Table = f5.New(func(this *table) {
this.PrimKey = "id"
})
this.Language = f5.New(func(this *LanguageTable) {
this.FileName = "../res/language@language.json"
this.PrimKey = "info"
})
this.Contract = f5.New(func(this *ContractTable) {
this.FileName = "../config/contract.json"
this.PrimKey = "name"

View File

@ -64,6 +64,14 @@ type Item struct {
_flags2_ uint64
}
type Language struct {
info string
en string
_flags1_ uint64
_flags2_ uint64
}
type Contract struct {
name string
address string
@ -271,6 +279,22 @@ func (this *Item) HasSubType() bool {
return (this._flags1_ & (uint64(1) << 4)) > 0
}
func (this *Language) GetInfo() string {
return this.info
}
func (this *Language) HasInfo() bool {
return (this._flags1_ & (uint64(1) << 1)) > 0
}
func (this *Language) GetEn() string {
return this.en
}
func (this *Language) HasEn() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0
}
func (this *Contract) GetName() string {
return this.name
}
@ -338,6 +362,11 @@ func (this *Item) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.sub_type, "sub_type", &this._flags1_, 4, kv)
}
func (this *Language) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.info, "info", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.en, "en", &this._flags1_, 2, kv)
}
func (this *Contract) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.name, "name", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.address, "address", &this._flags1_, 4, kv)

View File

@ -50,6 +50,12 @@ message Item
optional int32 sub_type = 4;
}
message Language
{
optional string info = 1;
optional string en = 2;
}
message Contract
{
optional string name = 1;