forked from oplancelot/shelllab
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp_gameobjects.go
More file actions
65 lines (59 loc) · 2.23 KB
/
Copy pathapp_gameobjects.go
File metadata and controls
65 lines (59 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"fmt"
"inklab/backend/database"
)
// GetObjectTypes returns all object types
func (a *App) GetObjectTypes() []*database.ObjectType {
fmt.Println("[API] GetObjectTypes called")
types, err := a.objectRepo.GetObjectTypes()
if err != nil {
fmt.Printf("[API] Error getting object types: %v\n", err)
return []*database.ObjectType{}
}
fmt.Printf("[API] GetObjectTypes returning %d types\n", len(types))
return types
}
// GetObjectsByType returns objects filtered by type
func (a *App) GetObjectsByType(typeID int, nameFilter string) []*database.GameObject {
fmt.Printf("[API] GetObjectsByType called: type=%d, filter='%s'\n", typeID, nameFilter)
objects, err := a.objectRepo.GetObjectsByType(typeID, nameFilter)
if err != nil {
fmt.Printf("[API] Error browsing objects: %v\n", err)
return []*database.GameObject{}
}
fmt.Printf("[API] GetObjectsByType returning %d objects\n", len(objects))
return objects
}
// SearchObjects searches for objects by name
func (a *App) SearchObjects(query string) []*database.GameObject {
objects, err := a.objectRepo.SearchObjects(query)
if err != nil {
fmt.Printf("Error searching objects: %v\n", err)
return []*database.GameObject{}
}
return objects
}
// GetObjectDetail returns detailed information about a game object
func (a *App) GetObjectDetail(entry int) *database.GameObjectDetail {
fmt.Printf("[API] GetObjectDetail called: %d\n", entry)
detail, err := a.objectRepo.GetObjectDetail(entry)
if err != nil {
fmt.Printf("[API] Error getting object detail: %v\n", err)
return nil
}
return detail
}
// SyncObject scrapes this object's octowow.st page and refreshes both its spawn
// points and (for chests) its loot, returning the refreshed detail. This is how
// users without a MySQL connection populate object spawn maps and fill custom
// loot missing from our world-DB snapshot (and the item pages' "Contained In").
func (a *App) SyncObject(entry int) *database.GameObjectDetail {
fmt.Printf("[API] SyncObject called: %d\n", entry)
if a.npcService != nil {
if err := a.npcService.SyncObjectFromWeb(entry); err != nil {
fmt.Printf("[API] SyncObject error: %v\n", err)
}
}
return a.GetObjectDetail(entry)
}