update item data in party

This commit is contained in:
vietdungdev
2026-04-24 19:14:48 +07:00
parent 4381127bb9
commit fea62bbe31
2 changed files with 23 additions and 11 deletions

View File

@@ -13,6 +13,17 @@ type Inventory struct {
Gold int
StashedGold [6]int // [0]=personal, [1..5]=shared stash pages
SharedStashPages int // Number of shared stash units detected (3=non-DLC, 5+=DLC)
MySharedStashPage int // 1-based page index belonging to the current player (0 if not in party)
}
func (i Inventory) CheckMySharedItem(it Item) bool {
if i.MySharedStashPage == 0 {
return true
}
if it.Location.LocationType != item.LocationSharedStash {
return true
}
return it.Location.Page == i.MySharedStashPage
}
func (i Inventory) Find(name item.Name, locations ...item.LocationType) (Item, bool) {
@@ -24,7 +35,7 @@ func (i Inventory) Find(name item.Name, locations ...item.LocationType) (Item, b
}
for _, l := range locations {
if it.Location.LocationType == l {
if it.Location.LocationType == l && i.CheckMySharedItem(it) {
return it, true
}
}
@@ -36,7 +47,7 @@ func (i Inventory) Find(name item.Name, locations ...item.LocationType) (Item, b
func (i Inventory) FindByID(unitID UnitID) (Item, bool) {
for _, it := range i.AllItems {
if it.UnitID == unitID {
if it.UnitID == unitID && i.CheckMySharedItem(it) {
return it, true
}
}
@@ -49,7 +60,7 @@ func (i Inventory) ByLocation(locations ...item.LocationType) []Item {
for _, it := range i.AllItems {
for _, l := range locations {
if it.Location.LocationType == l {
if it.Location.LocationType == l && i.CheckMySharedItem(it) {
items = append(items, it)
}
}

View File

@@ -54,6 +54,7 @@ func (gd *GameReader) Inventory(rawPlayerUnits RawPlayerUnits, hover data.HoverD
Gold: inventoryGold.Value,
StashedGold: stashedGold,
SharedStashPages: len(stashPlayerUnitOrder),
MySharedStashPage: int(stashUnitIDToPage[uint(mainPlayer.UnitID)]),
}
belt := data.Belt{}