This commit is contained in:
aozhiwei 2024-06-21 12:01:32 +08:00
parent 51763fc58a
commit b0cd82dd97
6 changed files with 66 additions and 4 deletions

View File

@ -4,3 +4,8 @@ const (
NFT_TYPE_CFHERO = 1 NFT_TYPE_CFHERO = 1
NFT_TYPE_GOLD_BULLION = 11 NFT_TYPE_GOLD_BULLION = 11
) )
const (
ITEM_TYPE_HERO = 3
ITEM_TYPE_GOLD_BULLION = 31
)

View File

@ -4,6 +4,7 @@ import (
"q5" "q5"
"f5" "f5"
"mtb" "mtb"
"jccommon"
"strings" "strings"
) )
@ -25,6 +26,24 @@ func (this *ItemTable) Load() {
this.itemIdHash = new(q5.ConcurrentMap[int64, *Item]) this.itemIdHash = new(q5.ConcurrentMap[int64, *Item])
} }
func (this *ItemTable) PostInit1() {
items := []*struct {
Id int32 `json:"id"`
Name int32 `json:"name"`
Type int32 `json:"type"`
SubType int32 `json:"sub_type"`
}{}
this.Traverse(
func (ele *Item) bool {
if ele.GetType() == jccommon.ITEM_TYPE_HERO ||
ele.GetType() == jccommon.ITEM_TYPE_GOLD_BULLION {
p := q5.NewSliceElement(&items)
p.Id = ele.GetId()
}
return true
})
}
func (this *ItemTable) Search(name string, itemIds map[int32]int32) { func (this *ItemTable) Search(name string, itemIds map[int32]int32) {
name = strings.ToLower(name) name = strings.ToLower(name)
this.Traverse( this.Traverse(

View File

@ -5,10 +5,12 @@ go 1.20
require q5 v1.0.0 require q5 v1.0.0
require f5 v1.0.0 require f5 v1.0.0
require mtb v1.0.0 require mtb v1.0.0
require jccommon v1.0.0
require ( require (
) )
replace q5 => ../../../third_party/q5 replace q5 => ../../../third_party/q5
replace f5 => ../../../third_party/f5 replace f5 => ../../../third_party/f5
replace jccommon => ../../jccommon
replace mtb => ../mtb replace mtb => ../mtb

View File

@ -57,6 +57,8 @@ type Config struct {
type Item struct { type Item struct {
name string name string
id int32 id int32
type_ int32
sub_type int32
_flags1_ uint64 _flags1_ uint64
_flags2_ uint64 _flags2_ uint64
@ -253,6 +255,22 @@ func (this *Item) HasId() bool {
return (this._flags1_ & (uint64(1) << 2)) > 0 return (this._flags1_ & (uint64(1) << 2)) > 0
} }
func (this *Item) GetType() int32 {
return this.type_
}
func (this *Item) HasType() bool {
return (this._flags1_ & (uint64(1) << 3)) > 0
}
func (this *Item) GetSubType() int32 {
return this.sub_type
}
func (this *Item) HasSubType() bool {
return (this._flags1_ & (uint64(1) << 4)) > 0
}
func (this *Contract) GetName() string { func (this *Contract) GetName() string {
return this.name return this.name
} }
@ -316,6 +334,8 @@ func (this *Config) LoadFromKv(kv map[string]interface{}) {
func (this *Item) LoadFromKv(kv map[string]interface{}) { func (this *Item) LoadFromKv(kv map[string]interface{}) {
f5.ReadMetaTableField(&this.name, "name", &this._flags1_, 1, kv) f5.ReadMetaTableField(&this.name, "name", &this._flags1_, 1, kv)
f5.ReadMetaTableField(&this.id, "id", &this._flags1_, 2, kv) f5.ReadMetaTableField(&this.id, "id", &this._flags1_, 2, kv)
f5.ReadMetaTableField(&this.type_, "type", &this._flags1_, 3, kv)
f5.ReadMetaTableField(&this.sub_type, "sub_type", &this._flags1_, 4, kv)
} }
func (this *Contract) LoadFromKv(kv map[string]interface{}) { func (this *Contract) LoadFromKv(kv map[string]interface{}) {

View File

@ -46,6 +46,8 @@ message Item
{ {
optional string name = 1; optional string name = 1;
optional int32 id = 2; optional int32 id = 2;
optional int32 type = 3;
optional int32 sub_type = 4;
} }
message Contract message Contract

View File

@ -343,7 +343,8 @@ import (
( (
(item2, index) => { (item2, index) => {
assert(item2.id <= 127); assert(item2.id <= 127);
data += ` ${item2.name} ` + this.dumpClassField(item, item2, index) + `\n`; const newFieldName = this.keyWordReplace(item2.name);
data += ` ${newFieldName} ` + this.dumpClassField(item, item2, index) + `\n`;
} }
); );
data += ` data += `
@ -363,7 +364,8 @@ import (
const newName = this.converUpperCamelCaseName(item2.name); const newName = this.converUpperCamelCaseName(item2.name);
data += `func (this *${item.name}) Get${newName}() ` + data += `func (this *${item.name}) Get${newName}() ` +
this.dumpClassField(item, item2, index) + ` {\n`; this.dumpClassField(item, item2, index) + ` {\n`;
data += ` return this.${item2.name}\n`; const newFieldName = this.keyWordReplace(item2.name);
data += ` return this.${newFieldName}\n`;
data += `}\n\n`; data += `}\n\n`;
data += `func (this *${item.name}) Has${newName}() bool {\n`; data += `func (this *${item.name}) Has${newName}() bool {\n`;
if (item2.id < 64) { if (item2.id < 64) {
@ -384,10 +386,11 @@ func (this *${item.name}) LoadFromKv(kv map[string]interface{}) {
item.fieldsArray.forEach item.fieldsArray.forEach
( (
(item2, index) => { (item2, index) => {
const newFieldName = this.keyWordReplace(item2.name);
if (item2.id < 64) { if (item2.id < 64) {
data += ` f5.ReadMetaTableField(&this.${item2.name}, "${item2.name}", &this._flags1_, ${item2.id}, kv)\n`; data += ` f5.ReadMetaTableField(&this.${newFieldName}, "${item2.name}", &this._flags1_, ${item2.id}, kv)\n`;
} else { } else {
data += ` f5.ReadMetaTableField(&this.${item2.name}, "${item2.name}", &this._flags2_, ${item2.id} - 64, kv)\n`; data += ` f5.ReadMetaTableField(&this.${newFieldName}, "${item2.name}", &this._flags2_, ${item2.id} - 64, kv)\n`;
} }
} }
); );
@ -455,6 +458,17 @@ func (this *${item.name}) LoadFromKv(kv map[string]interface{}) {
return newName; return newName;
} }
keyWordReplace(name) {
const keyWords = {
"type": 1
};
if (keyWords[name]) {
return name + "_";
} else {
return name;
}
}
} }
(new PBTools).init(); (new PBTools).init();