update item data in party
This commit is contained in:
@@ -8,11 +8,22 @@ import (
|
||||
)
|
||||
|
||||
type Inventory struct {
|
||||
Belt Belt
|
||||
AllItems []Item
|
||||
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)
|
||||
Belt Belt
|
||||
AllItems []Item
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,9 +51,10 @@ func (gd *GameReader) Inventory(rawPlayerUnits RawPlayerUnits, hover data.HoverD
|
||||
}
|
||||
|
||||
inventory := data.Inventory{
|
||||
Gold: inventoryGold.Value,
|
||||
StashedGold: stashedGold,
|
||||
SharedStashPages: len(stashPlayerUnitOrder),
|
||||
Gold: inventoryGold.Value,
|
||||
StashedGold: stashedGold,
|
||||
SharedStashPages: len(stashPlayerUnitOrder),
|
||||
MySharedStashPage: int(stashUnitIDToPage[uint(mainPlayer.UnitID)]),
|
||||
}
|
||||
belt := data.Belt{}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user