Exemplo n.º 1
0
func (this *Config) load() {
	ids := helper.GetConfigIds("conf_configuration.csv")

	if len(ids) == 0 {
		log.LogWarning("conf_configuration.csv file load failed")
		return
	}

	this.configMap = make(map[string]*KeyVal, len(ids))

	for _, id := range ids {
		conf := &KeyVal{}

		if err := helper.LoadStructByFile("conf_configuration.csv", id, conf); err != nil {
			log.LogFatalf(err)
			continue
		}

		this.configMap[conf.UniqueName] = conf
	}

	log.LogMessage("conf_configuration.csv file load ok")

	ids = helper.GetConfigIds("conf_bp_ratio.csv")

	if len(ids) == 0 {
		log.LogWarning("conf_bp_ratio.csv file load failed")
		return
	}

	for _, id := range ids {
		conf := &KeyVal{}
		tmp := &PropRatio{}
		if err := helper.LoadStructByFile("conf_bp_ratio.csv", id, tmp); err != nil {
			log.LogFatalf(err)
			continue
		}

		conf.UniqueName = "bp_" + tmp.ID
		conf.Value = tmp.BTRatio
		this.configMap[conf.UniqueName] = conf
	}

	log.LogMessage("conf_bp_ratio.csv file load ok")

}
Exemplo n.º 2
0
func (ts *TaskSystem) LoadTaskInfo() bool {
	ids := helper.GetConfigIds(TASK_INFO)
	for _, id := range ids {
		task := &Task{}
		err := helper.LoadStructByFile(TASK_INFO, id, task)
		if err != nil {
			log.LogError(err)
			continue
		}

		ts.taskinfos[id] = task
	}
	log.LogMessage("load ", TASK_INFO, " ok, total:", len(ts.taskinfos))

	ids = helper.GetConfigIds(TASK_PROP)
	for _, id := range ids {
		pc := &PropCondition{}
		err := helper.LoadStructByFile(TASK_PROP, id, pc)
		if err != nil {
			log.LogError(err)
			continue
		}
		ts.propcods[id] = pc
	}
	log.LogMessage("load ", TASK_PROP, " ok, total:", len(ts.propcods))

	ids = helper.GetConfigIds(TASK_COLL)
	for _, id := range ids {
		col := &CollCondition{}
		err := helper.LoadStructByFile(TASK_COLL, id, col)
		if err != nil {
			log.LogError(err)
			continue
		}
		ts.collcods[id] = col
	}
	log.LogMessage("load ", TASK_COLL, " ok, total:", len(ts.collcods))

	ids = helper.GetConfigIds(TASK_HUNT)
	for _, id := range ids {
		hunt := &HuntCondition{}
		err := helper.LoadStructByFile(TASK_HUNT, id, hunt)
		if err != nil {
			log.LogError(err)
			continue
		}
		ts.huntcods[id] = hunt
	}
	log.LogMessage("load ", TASK_HUNT, " ok, total:", len(ts.huntcods))

	ids = helper.GetConfigIds(TASK_EVENT)
	for _, id := range ids {
		event := &EventConditon{}
		err := helper.LoadStructByFile(TASK_EVENT, id, event)
		if err != nil {
			log.LogError(err)
			continue
		}
		ts.eventcods[id] = event
	}
	log.LogMessage("load ", TASK_EVENT, " ok, total:", len(ts.eventcods))

	ids = helper.GetConfigIds(TASK_REWARD)
	for _, id := range ids {
		reward := &RewardInfo{}
		err := helper.LoadStructByFile(TASK_REWARD, id, reward)
		if err != nil {
			log.LogError(err)
			continue
		}
		ts.rewardinfos[id] = reward
	}
	log.LogMessage("load ", TASK_REWARD, " ok, total:", len(ts.rewardinfos))
	return true
}