diff --git a/data/dk.db b/data/dk.db index c3fbe10..f34a5f3 100644 Binary files a/data/dk.db and b/data/dk.db differ diff --git a/internal/actions/move.go b/internal/actions/move.go index 02942ea..c2690ed 100644 --- a/internal/actions/move.go +++ b/internal/actions/move.go @@ -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 } diff --git a/internal/models/towns/towns.go b/internal/models/towns/towns.go index e70f366..b5906c1 100644 --- a/internal/models/towns/towns.go +++ b/internal/models/towns/towns.go @@ -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")