Item price support

This commit is contained in:
2026-03-05 22:45:55 -06:00
parent 4282c2a770
commit d920a1e62d
15 changed files with 834 additions and 26 deletions

View File

@@ -18,16 +18,19 @@ type MappingCache struct {
byID map[int]*MappingItem
byName map[string]*MappingItem
cacheDir string
game string
}
// NewMappingCache creates a mapping cache backed by the given client.
func NewMappingCache(client *Client) *MappingCache {
// The game parameter scopes the cache file (e.g. "osrs" or "rs3").
func NewMappingCache(client *Client, game string) *MappingCache {
home, _ := os.UserHomeDir()
return &MappingCache{
client: client,
byID: make(map[int]*MappingItem),
byName: make(map[string]*MappingItem),
cacheDir: filepath.Join(home, ".rsw", "cache"),
game: game,
}
}
@@ -81,7 +84,8 @@ func (mc *MappingCache) index() {
}
func (mc *MappingCache) cachePath() string {
return filepath.Join(mc.cacheDir, "mapping.json")
filename := mc.game + "_mapping.json"
return filepath.Join(mc.cacheDir, filename)
}
func (mc *MappingCache) loadFromDisk() bool {