Exemplo n.º 1
0
func InitGameItems() {
	db := connect.CreateConnect()
	rows, _ := db.Query("SELECT id, name, atype, weight, allocation_info, power_info, message, description, bonus, effects FROM artifacts")
	for rows.Next() {
		var (
			id                                                                                        int64
			weight                                                                                    int
			atype_str, name, alloc_info_str, power_info_str, msg, desc, bonusesStr, effectsStr, power string
		)
		rows.Scan(&id, &name, &atype_str, &weight, &alloc_info_str, &power_info_str, &msg, &desc, &bonusesStr, &effectsStr)
		atype := strings.Split(atype_str, ":")
		power_arry := strings.Split(power_info_str, ":")
		if len(power_arry) > 1 {
			power = power_arry[1]
		}
		gameItems.items[id] = &ItemKind{id, name, weight, power, msg, desc, utils.ParseInt(atype[0]), utils.ParseInt(atype[1]), utils.ParseInt(atype[2]), make([]*Bonus, 0, 30), make([]Effecter, 0, 30)}
		alloc_info := strings.Split(alloc_info_str, ":")
		prob := utils.ParseInt(alloc_info[0])
		min_d := utils.ParseInt64(alloc_info[1]) - 1
		max_d := utils.ParseInt64(alloc_info[2]) - 1
		for i := min_d; i <= max_d; i++ {
			gameItems.items_depth_gen[i] = append(gameItems.items_depth_gen[i], &gameItemGen{gameItems.items[id], prob})
		}
		if len(bonusesStr) > 0 {
			for _, bonusStr := range strings.Split(bonusesStr, "@") {
				for _, bonus := range parseBonusFromDB(bonusStr) {
					gameItems.items[id].bonuses = append(gameItems.items[id].bonuses, bonus)
				}
			}
		}
		if len(effectsStr) > 0 {
			for _, effectStr := range strings.Split(effectsStr, "@") {
				for _, effect := range parseEffectFromDB(effectStr) {
					gameItems.items[id].effects = append(gameItems.items[id].effects, effect)
				}
			}
		}
	}
}
Exemplo n.º 2
0
func (ml *mobList) initializeMobTypes() consts.JsonType {
	blows.InitMobBlows()
	gameObjectsFlags.InitFlags(&GetInstance().field, GetInstance().msgsChannel)
	db := connect.CreateConnect()
	rows, _ := db.Query("SELECT name, base_hp, hp_inc, symbol, description, blow_method, flags, level_info FROM mobs_types")
	mobDictionary := make(consts.JsonType)
	for rows.Next() {
		var (
			base_hp                                                    int
			name, hp_inc, symbol, desc, flags, blowMethods, level_info string
		)
		rows.Scan(&name, &base_hp, &hp_inc, &symbol, &desc, &blowMethods, &flags, &level_info)
		depth := utils.ParseInt64(strings.Split(level_info, "|")[0])
		ml.mobsDepth[depth] = append(ml.mobsDepth[depth], gameObjects.CreateMobKind(name, base_hp, hp_inc, desc, blowMethods, flags))
		mobDictionary[symbol] = name
	}
	return mobDictionary
}
Exemplo n.º 3
0
func (ml *mobList) initializeMobsGenerators(filename string) {
	areas, _ := os.Open(consts.PATH_TO_MAPS + filename)
	defer areas.Close()
	reader := bufio.NewReader(areas)
	for {
		bytes, _, err := reader.ReadLine()
		if err == nil {
			data := strings.Split(string(bytes), ":")
			l, r := utils.ParseFloat(data[0]), utils.ParseFloat(data[1])
			t, b := utils.ParseFloat(data[2]), utils.ParseFloat(data[3])
			depth := utils.ParseInt64(data[4])
			duration := utils.ParseFloat(data[5])
			area := geometry.MakeRectangle(geometry.MakePoint(l, t), geometry.MakePoint(r, b))
			if kinds, isExist := ml.mobsDepth[depth]; isExist {
				ml.addGen(NewMobGenerator(&kinds, area, depth, duration, ml.pipeline))
			}
		} else {
			break
		}
	}
}