1
This commit is contained in:
parent
51763fc58a
commit
b0cd82dd97
@ -4,3 +4,8 @@ const (
|
||||
NFT_TYPE_CFHERO = 1
|
||||
NFT_TYPE_GOLD_BULLION = 11
|
||||
)
|
||||
|
||||
const (
|
||||
ITEM_TYPE_HERO = 3
|
||||
ITEM_TYPE_GOLD_BULLION = 31
|
||||
)
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"q5"
|
||||
"f5"
|
||||
"mtb"
|
||||
"jccommon"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@ -25,6 +26,24 @@ func (this *ItemTable) Load() {
|
||||
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) {
|
||||
name = strings.ToLower(name)
|
||||
this.Traverse(
|
||||
|
@ -5,10 +5,12 @@ go 1.20
|
||||
require q5 v1.0.0
|
||||
require f5 v1.0.0
|
||||
require mtb v1.0.0
|
||||
require jccommon v1.0.0
|
||||
|
||||
require (
|
||||
)
|
||||
|
||||
replace q5 => ../../../third_party/q5
|
||||
replace f5 => ../../../third_party/f5
|
||||
replace jccommon => ../../jccommon
|
||||
replace mtb => ../mtb
|
@ -57,6 +57,8 @@ type Config struct {
|
||||
type Item struct {
|
||||
name string
|
||||
id int32
|
||||
type_ int32
|
||||
sub_type int32
|
||||
|
||||
_flags1_ uint64
|
||||
_flags2_ uint64
|
||||
@ -253,6 +255,22 @@ func (this *Item) HasId() bool {
|
||||
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 {
|
||||
return this.name
|
||||
}
|
||||
@ -316,6 +334,8 @@ func (this *Config) 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.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{}) {
|
||||
|
@ -46,6 +46,8 @@ message Item
|
||||
{
|
||||
optional string name = 1;
|
||||
optional int32 id = 2;
|
||||
optional int32 type = 3;
|
||||
optional int32 sub_type = 4;
|
||||
}
|
||||
|
||||
message Contract
|
||||
|
@ -343,7 +343,8 @@ import (
|
||||
(
|
||||
(item2, index) => {
|
||||
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 += `
|
||||
@ -363,7 +364,8 @@ import (
|
||||
const newName = this.converUpperCamelCaseName(item2.name);
|
||||
data += `func (this *${item.name}) Get${newName}() ` +
|
||||
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 += `func (this *${item.name}) Has${newName}() bool {\n`;
|
||||
if (item2.id < 64) {
|
||||
@ -384,10 +386,11 @@ func (this *${item.name}) LoadFromKv(kv map[string]interface{}) {
|
||||
item.fieldsArray.forEach
|
||||
(
|
||||
(item2, index) => {
|
||||
const newFieldName = this.keyWordReplace(item2.name);
|
||||
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 {
|
||||
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;
|
||||
}
|
||||
|
||||
keyWordReplace(name) {
|
||||
const keyWords = {
|
||||
"type": 1
|
||||
};
|
||||
if (keyWords[name]) {
|
||||
return name + "_";
|
||||
} else {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
(new PBTools).init();
|
||||
|
Loading…
x
Reference in New Issue
Block a user