package config import ( "encoding/json" "io/ioutil" "log" "math/rand" ) var AllItemConfig map[int32]*Item var GemConfig map[int32]*Gem var ExtraAttributeConfig map[int32][]*ExtraAttribute var StructureConfig map[int32]*Structure var SynthesisConfig map[int32]*Synthesis var InitialVillagerConfig map[int32]*InitialVillager var PersonalityLabelConfig map[int32]*PersonalityLabel var VillagerEndWordsConfig map[int32][]*VillagerEndWords var WorldParametersConfig *WorldParameters var VillagerSkillConfig map[int32]*VillagerSkill var SkillBuffConfig map[int32]*SkillBuff var SpecialStatusConfig map[int32]*SpecialStatus var NpcConfig map[int32]*Npc var GoodsForRecycleConfig map[int32][]*GoodsForRecycle var BusinessManConfig map[int32]*BusinessMan var SkillEffectConfig map[int32]*SkillEffect var WeatherConfig map[int32]*Weather var ResourcesPointConfig map[int32]*ResourcesPoint var ResourcesConfig map[int32]*Resources var BehaviourTypeConfig map[int32]*BehaviourType var BehaviourEventConfig map[int32]*BehaviourEvent func init() { AllItemConfig = make(map[int32]*Item) readItem() GemConfig = make(map[int32]*Gem) readGem() ExtraAttributeConfig = make(map[int32][]*ExtraAttribute) readExtraAttribute() StructureConfig = make(map[int32]*Structure) readStructure() SynthesisConfig = make(map[int32]*Synthesis) readSynthesis() InitialVillagerConfig = make(map[int32]*InitialVillager) readInitialVillager() PersonalityLabelConfig = make(map[int32]*PersonalityLabel) readPersonalityLabel() VillagerEndWordsConfig = make(map[int32][]*VillagerEndWords) readVillagerEndWords() WorldParametersConfig = new(WorldParameters) readWorldParameters() VillagerSkillConfig = make(map[int32]*VillagerSkill) readVillagerSkill() SkillBuffConfig = make(map[int32]*SkillBuff) readSkillBuff() SpecialStatusConfig = make(map[int32]*SpecialStatus) readSpecialStatus() NpcConfig = make(map[int32]*Npc) readNpc() GoodsForRecycleConfig = make(map[int32][]*GoodsForRecycle) readGoodsForRecycle() BusinessManConfig = make(map[int32]*BusinessMan) readBusinessMan() SkillEffectConfig = make(map[int32]*SkillEffect) readSkillEffect() WeatherConfig = make(map[int32]*Weather) readWeather() ResourcesPointConfig = make(map[int32]*ResourcesPoint) readResourcesPoint() ResourcesConfig = make(map[int32]*Resources) readResources() BehaviourTypeConfig = make(map[int32]*BehaviourType) readBehaviourType() BehaviourEventConfig = make(map[int32]*BehaviourEvent) readBehaviourEvent() } func readItem() { // 获取数据,按照文件 fileName := "AllItemConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var users []Item json.Unmarshal(byteValue, &users) // 循环取数据 //fmt.Println("+++++++++", users) for i := 0; i < len(users); i++ { Infotmp := new(Item) Infotmp.Id = users[i].Id Infotmp.Name = users[i].Name Infotmp.Type = users[i].Type Infotmp.RelatedId = users[i].RelatedId Infotmp.SuperpositionMax = users[i].SuperpositionMax Infotmp.StorageMax = users[i].StorageMax AllItemConfig[Infotmp.Id] = Infotmp } } func readGem() { // 获取数据,按照文件 fileName := "GemConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []Gem json.Unmarshal(byteValue, &config) // 循环取数据 //fmt.Println("+++++++++", users) for i := 0; i < len(config); i++ { Infotmp := new(Gem) Infotmp.Id = config[i].Id Infotmp.Name = config[i].Name Infotmp.Type = config[i].Type Infotmp.Natural = config[i].Natural Infotmp.ExtraAttributeGroup = config[i].ExtraAttributeGroup GemConfig[Infotmp.Id] = Infotmp } } func readExtraAttribute() { // 获取数据,按照文件 fileName := "ExtraAttributeConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []ExtraAttribute json.Unmarshal(byteValue, &config) // 循环取数据 //fmt.Println("+++++++++", users) for i := 0; i < len(config); i++ { Infotmp := new(ExtraAttribute) Infotmp.Id = config[i].Id Infotmp.Name = config[i].Name Infotmp.Type = config[i].Type Infotmp.GroupId = config[i].GroupId Infotmp.RelatedId = config[i].RelatedId Infotmp.SuperpositionMax = config[i].SuperpositionMax Infotmp.AttributesId = config[i].AttributesId Infotmp.AttributesValue = config[i].AttributesValue if ExtraAttributeConfig[Infotmp.Id] == nil { ExtraAttributeConfig[Infotmp.Id] = []*ExtraAttribute{} } ExtraAttributeConfig[Infotmp.Id] = append(ExtraAttributeConfig[Infotmp.Id], Infotmp) } } func readStructure() { // 获取数据,按照文件 fileName := "StructureConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []Structure json.Unmarshal(byteValue, &config) // 循环取数据 for i := 0; i < len(config); i++ { Infotmp := new(Structure) Infotmp.Id = config[i].Id Infotmp.EngineeringQuantity = config[i].EngineeringQuantity StructureConfig[Infotmp.Id] = Infotmp } } func readSynthesis() { // 获取数据,按照文件 fileName := "SynthesisConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []Synthesis json.Unmarshal(byteValue, &config) for i := 0; i < len(config); i++ { Infotmp := new(Synthesis) Infotmp.Id = config[i].Id Infotmp.MixtureID = config[i].MixtureID Infotmp.MixtureType = config[i].MixtureType SynthesisConfig[Infotmp.Id] = Infotmp } } func readInitialVillager() { // 获取数据,按照文件 fileName := "InitialVillagerConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []InitialVillager json.Unmarshal(byteValue, &config) for i := 0; i < len(config); i++ { infotmp := new(InitialVillager) infotmp.Id = config[i].Id infotmp.FirstName = config[i].FirstName infotmp.Name = config[i].Name infotmp.Gender = config[i].Gender infotmp.Genegration = config[i].Genegration infotmp.Personality = config[i].Personality infotmp.Physique = config[i].Physique infotmp.Age = config[i].Age infotmp.LifeMax = config[i].LifeMax infotmp.StartHp = config[i].StartHp infotmp.StartATK = config[i].StartATK infotmp.StartDEF = config[i].StartDEF infotmp.HitRate = config[i].HitRate infotmp.Hit = config[i].Hit infotmp.DodgeRate = config[i].DodgeRate infotmp.Dodge = config[i].Dodge infotmp.Labor = config[i].Labor infotmp.Wisdom = config[i].Wisdom infotmp.MoveSpeed = config[i].MoveSpeed infotmp.Skill = config[i].Skill infotmp.SurvivalStatus = config[i].SurvivalStatus infotmp.DisplayState = config[i].DisplayState InitialVillagerConfig[infotmp.Id] = infotmp } } func readPersonalityLabel() { // 获取数据,按照文件 fileName := "PersonalityLabelConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []PersonalityLabel json.Unmarshal(byteValue, &config) for i := 0; i < len(config); i++ { infotmp := new(PersonalityLabel) infotmp.Id = config[i].Id infotmp.ActionFlow = config[i].ActionFlow infotmp.EndWords = config[i].EndWords PersonalityLabelConfig[infotmp.Id] = infotmp } } func readVillagerEndWords() { // 获取数据,按照文件 fileName := "VillagerEndWordsConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []VillagerEndWords json.Unmarshal(byteValue, &config) for i := 0; i < len(config); i++ { infotmp := new(VillagerEndWords) infotmp.Id = config[i].Id infotmp.GroupId = config[i].GroupId if VillagerEndWordsConfig[infotmp.GroupId] == nil { VillagerEndWordsConfig[infotmp.GroupId] = []*VillagerEndWords{} } VillagerEndWordsConfig[infotmp.GroupId] = append(VillagerEndWordsConfig[infotmp.GroupId], infotmp) } } func GetRandomConfigIdByGroup(groupId int32) int32 { // 获取数据,按照文件 index := rand.Intn(len(VillagerEndWordsConfig[groupId])) return VillagerEndWordsConfig[groupId][index].Id } func readWorldParameters() { // 获取数据,按照文件 fileName := "WorldParametersConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config WorldParameters json.Unmarshal(byteValue, &config) WorldParametersConfig = &config } func readVillagerSkill() { // 获取数据,按照文件 fileName := "VillagerSkillConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []VillagerSkill json.Unmarshal(byteValue, &config) for i := 0; i < len(config); i++ { infotmp := new(VillagerSkill) infotmp.Id = config[i].Id infotmp.Group = config[i].Group infotmp.Grade = config[i].Grade infotmp.State = config[i].State VillagerSkillConfig[infotmp.Id] = infotmp } } func readSkillBuff() { // 获取数据,按照文件 fileName := "SkillBuffConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []SkillBuff json.Unmarshal(byteValue, &config) for i := 0; i < len(config); i++ { infotmp := new(SkillBuff) infotmp.Id = config[i].Id infotmp.Name = config[i].Name infotmp.TriggerTime = config[i].TriggerTime infotmp.TriggerParameter = config[i].TriggerParameter infotmp.Gain = config[i].Gain infotmp.Immunity = config[i].Immunity infotmp.Disperse = config[i].Disperse infotmp.BuffProbability = config[i].BuffProbability infotmp.LinkEffect = config[i].LinkEffect infotmp.ContinuedType = config[i].ContinuedType infotmp.ContinuedParameter = config[i].ContinuedParameter infotmp.Overlay = config[i].Overlay infotmp.OverlayMax = config[i].OverlayMax infotmp.SequenceId = config[i].SequenceId infotmp.SequenceLv = config[i].SequenceLv infotmp.BattleShow = config[i].BattleShow infotmp.SpecialStatus = config[i].SpecialStatus infotmp.DisplayLocation = config[i].DisplayLocation infotmp.Icon = config[i].Icon infotmp.Describe = config[i].Describe SkillBuffConfig[infotmp.Id] = infotmp } } func readSpecialStatus() { // 获取数据,按照文件 fileName := "SpecialStatusConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []SpecialStatus json.Unmarshal(byteValue, &config) for i := 0; i < len(config); i++ { infotmp := new(SpecialStatus) infotmp.Id = config[i].Id infotmp.Type = config[i].Type infotmp.Name = config[i].Name infotmp.Describe = config[i].Describe SpecialStatusConfig[infotmp.Id] = infotmp } } func readNpc() { // 获取数据,按照文件 fileName := "NpcConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []Npc json.Unmarshal(byteValue, &config) for i := 0; i < len(config); i++ { infotmp := new(Npc) infotmp.Id = config[i].Id infotmp.Type = config[i].Type infotmp.Name = config[i].Name infotmp.RelatedId = config[i].RelatedId infotmp.DialogueWithOptions = config[i].DialogueWithOptions infotmp.FixedPoint = config[i].FixedPoint infotmp.MoveSpeed = config[i].MoveSpeed infotmp.Area = config[i].Area infotmp.ShowCondition = config[i].ShowCondition infotmp.ShowParameter = config[i].ShowParameter infotmp.Icon = config[i].Icon infotmp.Prefab = config[i].Prefab infotmp.DialogueWay = config[i].DialogueWay infotmp.Disappear = config[i].Disappear infotmp.Repeat = config[i].Repeat NpcConfig[infotmp.Id] = infotmp } } func readGoodsForRecycle() { // 获取数据,按照文件 fileName := "GoodsForRecycleConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []GoodsForRecycle json.Unmarshal(byteValue, &config) for i := 0; i < len(config); i++ { infotmp := new(GoodsForRecycle) infotmp.Id = config[i].Id infotmp.GroupId = config[i].GroupId infotmp.ItemId = config[i].ItemId infotmp.SaleNum = config[i].SaleNum infotmp.Weight = config[i].Weight infotmp.SaleCondition = config[i].SaleCondition infotmp.SaleConditionParemeter = config[i].SaleConditionParemeter infotmp.SellingCurrencyType = config[i].SellingCurrencyType infotmp.Price = config[i].Price infotmp.Discount = config[i].Discount infotmp.DiscountWeight = config[i].DiscountWeight infotmp.SaleMax = config[i].SaleMax if GoodsForRecycleConfig[infotmp.GroupId] == nil { GoodsForRecycleConfig[infotmp.GroupId] = []*GoodsForRecycle{} } GoodsForRecycleConfig[infotmp.GroupId] = append(GoodsForRecycleConfig[infotmp.GroupId], infotmp) } } func readBusinessMan() { // 获取数据,按照文件 fileName := "BusinessManConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []BusinessMan json.Unmarshal(byteValue, &config) for i := 0; i < len(config); i++ { infotmp := new(BusinessMan) infotmp.Id = config[i].Id infotmp.Type = config[i].Type infotmp.TypeParameter = config[i].TypeParameter infotmp.AppearTime = config[i].AppearTime infotmp.ItemGroup = config[i].ItemGroup infotmp.DiscountNum = config[i].DiscountNum infotmp.ExtraItemGroup = config[i].ExtraItemGroup infotmp.ExtraItemNum = config[i].ExtraItemNum infotmp.CommonRecycleItem = config[i].CommonRecycleItem infotmp.RecycleItem = config[i].RecycleItem infotmp.RecycleItemNum = config[i].RecycleItemNum infotmp.HighPricedNum = config[i].HighPricedNum infotmp.SaleRefreshTimes = config[i].SaleRefreshTimes infotmp.RecycleRefreshTimes = config[i].RecycleRefreshTimes infotmp.ResetType = config[i].ResetType infotmp.ResetTypeParameter = config[i].ResetTypeParameter BusinessManConfig[infotmp.Id] = infotmp } } func readSkillEffect() { // 获取数据,按照文件 fileName := "SkillEffectConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []SkillEffect json.Unmarshal(byteValue, &config) for i := 0; i < len(config); i++ { infotmp := new(SkillEffect) infotmp.Id = config[i].Id infotmp.EffectType = config[i].EffectType infotmp.NumericExpression = config[i].NumericExpression infotmp.WhetherCrit = config[i].WhetherCrit SkillEffectConfig[infotmp.Id] = infotmp } } func readWeather() { // 获取数据,按照文件 fileName := "WeatherConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []Weather json.Unmarshal(byteValue, &config) for i := 0; i < len(config); i++ { infotmp := new(Weather) infotmp.Id = config[i].Id infotmp.Name = config[i].Name infotmp.Type = config[i].Type infotmp.PureIllness = config[i].PureIllness infotmp.PureInjury = config[i].PureInjury infotmp.Illness = config[i].Illness infotmp.DurableDestroy = config[i].DurableDestroy infotmp.SkillBUFF = config[i].SkillBUFF infotmp.Duration = config[i].Duration infotmp.CD = config[i].CD infotmp.WeaterEffect = config[i].WeaterEffect infotmp.SpecialEfficacyCD = config[i].SpecialEfficacyCD infotmp.ICON = config[i].ICON infotmp.Sound = config[i].Sound WeatherConfig[infotmp.Id] = infotmp } } func readResourcesPoint() { // 获取数据,按照文件 fileName := "ResourcesPointConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []ResourcesPoint json.Unmarshal(byteValue, &config) for i := 0; i < len(config); i++ { infotmp := new(ResourcesPoint) infotmp.Id = config[i].Id infotmp.ResourcesPointName = config[i].ResourcesPointName infotmp.Type = config[i].Type infotmp.AccessableCondition = config[i].AccessableCondition infotmp.AccessableParameter = config[i].AccessableParameter infotmp.WorkerType = config[i].WorkerType infotmp.RelatedResources = config[i].RelatedResources infotmp.RootOut = config[i].RootOut infotmp.SaplingItemId = config[i].SaplingItemId infotmp.Enter = config[i].Enter infotmp.Disperse = config[i].Disperse infotmp.DisperseRadius = config[i].DisperseRadius infotmp.Prefab = config[i].Prefab infotmp.MoonnightPrefab = config[i].MoonnightPrefab infotmp.NamePicture = config[i].NamePicture infotmp.Description = config[i].Description ResourcesPointConfig[infotmp.Id] = infotmp } } func readResources() { // 获取数据,按照文件 fileName := "ResourcesConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []Resources json.Unmarshal(byteValue, &config) for i := 0; i < len(config); i++ { infotmp := new(Resources) infotmp.Id = config[i].Id infotmp.BehaviourType = config[i].BehaviourType infotmp.ResourcesName = config[i].ResourcesName infotmp.MutexBehaviour = config[i].MutexBehaviour infotmp.WorkerNumber = config[i].WorkerNumber infotmp.RebornCondition = config[i].RebornCondition infotmp.RebornConditionParameters = config[i].RebornConditionParameters infotmp.ShowCondition = config[i].ShowCondition infotmp.ShowConditionParameter = config[i].ShowConditionParameter infotmp.Disappear = config[i].Disappear infotmp.InResource = config[i].InResource infotmp.BaseOut = config[i].BaseOut infotmp.OutAmount = config[i].OutAmount infotmp.BaseEfficient = config[i].BaseEfficient infotmp.OutInterval = config[i].OutInterval infotmp.ExtraOut = config[i].ExtraOut infotmp.ExtraOutProbability = config[i].ExtraOutProbability infotmp.TriggerEvent = config[i].TriggerEvent infotmp.MoonnightOut = config[i].MoonnightOut infotmp.MoonnightOutProbability = config[i].MoonnightOutProbability ResourcesConfig[infotmp.Id] = infotmp } } func readBehaviourType() { // 获取数据,按照文件 fileName := "BehaviourTypeConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []BehaviourType json.Unmarshal(byteValue, &config) for i := 0; i < len(config); i++ { infotmp := new(BehaviourType) infotmp.Id = config[i].Id infotmp.BehaviourName = config[i].BehaviourName infotmp.InjuryProbability = config[i].InjuryProbability infotmp.BehaviourEventId1 = config[i].BehaviourEventId1 infotmp.DistractedProbability = config[i].DistractedProbability infotmp.BehaviourEventId2 = config[i].BehaviourEventId2 infotmp.SpecialItemProbability = config[i].SpecialItemProbability infotmp.BehaviourEventId3 = config[i].BehaviourEventId3 infotmp.OtherProbability = config[i].OtherProbability infotmp.BehaviourEventId4 = config[i].BehaviourEventId4 infotmp.Sound = config[i].Sound BehaviourTypeConfig[infotmp.Id] = infotmp } } func readBehaviourEvent() { // 获取数据,按照文件 fileName := "BehaviourEventConfigCategory.json" fileName = "./config/" + fileName byteValue, err := ioutil.ReadFile(fileName) if err != nil { log.Fatal("Error when opening file: ", err) } // 读取文件数据 var config []BehaviourEvent json.Unmarshal(byteValue, &config) for i := 0; i < len(config); i++ { infotmp := new(BehaviourEvent) infotmp.Id = config[i].Id infotmp.GroupId = config[i].GroupId infotmp.EventName = config[i].EventName infotmp.Weight = config[i].Weight infotmp.DropGroup = config[i].DropGroup infotmp.InjuryValue = config[i].InjuryValue BehaviourEventConfig[infotmp.Id] = infotmp } }