fix finding towns during movement
This commit is contained in:
parent
35d58476dc
commit
8a3486487b
BIN
data/dk.db
BIN
data/dk.db
Binary file not shown.
@ -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
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user