fix finding towns during movement

This commit is contained in:
Sky Johnson 2025-08-22 09:23:10 -05:00
parent 35d58476dc
commit 8a3486487b
3 changed files with 1 additions and 7 deletions

Binary file not shown.

View File

@ -54,7 +54,7 @@ func Move(user *users.User, dir Direction) (string, int, int, error) {
return user.Currently, user.X, user.Y, fmt.Errorf("You've hit the edge of the world.")
}
if towns.ExistsAt(newX, newY) {
if town, _ := towns.ByCoords(newX, newY); town != nil {
return "In Town", newX, newY, nil
}

View File

@ -112,12 +112,6 @@ func ByCoords(x, y int) (*Town, error) {
return &town, nil
}
func ExistsAt(x, y int) bool {
var count int
err := database.Get(&count, "SELECT COUNT(*) FROM towns WHERE x = %d AND y = %d", x, y)
return err == nil && count > 0
}
func ByDistance(fromX, fromY, maxDistance int) ([]*Town, error) {
var towns []*Town
err := database.Select(&towns, "SELECT * FROM towns")