Example #1
0
func LoadWorldmap(_hood *hood.Hood) {
	if loaded {
		panic("Worldmap has already been loaded!")
	}

	// Load maps
	var maps []entities.Map
	if err := _hood.Find(&maps); err != nil {
		panic(err)
	}

	if len(maps) > 0 {
		for _, mapEntity := range maps {
			mapId := int(mapEntity.MapId)
			worldmap[mapId] = NewTilePointTable(mapEntity.Name)
		}

		numOfProcessRoutines = len(maps)
		go internalLoadWorldmap(_hood)

		waitForLoadComplete()
	} else {
		log.Warning("World", "LoadWorldmap", "No maps found in the database")
	}

	loaded = true
}
Example #2
0
func loadMoves(_hood *hood.Hood) {
	log.Verbose("Pokemon.Manager", "loadMoves", "Loading pokemon moves from database")

	var moves []entities.Move
	if err := _hood.Find(&moves); err != nil {
		log.Error("Pokemon.Manager", "loadMoves", "Error while loading moves: %s", err.Error())
	} else {
		for _, moveEntity := range moves {
			move := NewMove(&moveEntity)
			movesStore[move.GetMoveId()] = move
		}
	}
}
Example #3
0
func GetWorkers(tx *hood.Hood) []*Worker {
	var results []Worker
	err := tx.Find(&results)
	if err != nil {
		panic(err)
	}

	// Should return pointers to the result objects so that
	// they can be mutated
	pointerResults := make([]*Worker, len(results))
	for i := range results {
		pointerResults[i] = &results[i]
	}

	return pointerResults
}
Example #4
0
func loadMap(_hood *hood.Hood, _mapId int, _tilePointTable *TilePointTable) {
	// Create select query to get all tilepoints and layers as one result
	_hood.Select("tilepoint", "tilepoint.x", "tilepoint.y", "tilepointlayer.level", "tilepointlayer.blocking", "tilepointtilelayer.layer", "tilepointtilelayer.tileId")
	_hood.Join(hood.LeftJoin, "tilepointlayer", "tilepointlayer.tilePointId", "tilepoint.tilePointId")
	_hood.Join(hood.LeftJoin, "tilepointtilelayer", "tilepointtilelayer.tilePointLayerId", "tilepointlayer.tilePointLayerId")

	var tilePointRows []TilePointRow
	if err := _hood.Find(&tilePointRows); err != nil {
		log.Error("World", "loadMap", "Error fetching tilepoints from database:\n%s", err.Error())
	} else {
		for _, row := range tilePointRows {
			processTilePoints(row, _tilePointTable)
		}
	}

	processExitChan <- true
}
Example #5
0
func loadPokemon(_hood *hood.Hood) {
	log.Verbose("Pokemon.Manager", "loadPokemon", "Loading pokemon from database")

	var pokemon []entities.Pokemon
	if err := _hood.Find(&pokemon); err != nil {
		log.Error("Pokemon.Manager", "loadPokemon", "Error while loading pokemon: %s", err.Error())
	} else {
		for _, pokemonEntity := range pokemon {
			poke := NewPokemon(&pokemonEntity)

			if err := poke.LinkMoves(_hood); err != nil {
				log.Error("Pokemon.Manager", "loadPokemon", "Failed to link moves to Pokemon %d. Error: %s", poke.GetPokemonId(), err.Error())
			} else {
				pokemonStore[poke.GetPokemonId()] = poke
			}
		}
	}
}