update item data in party
This commit is contained in:
@@ -8,11 +8,22 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Inventory struct {
|
type Inventory struct {
|
||||||
Belt Belt
|
Belt Belt
|
||||||
AllItems []Item
|
AllItems []Item
|
||||||
Gold int
|
Gold int
|
||||||
StashedGold [6]int // [0]=personal, [1..5]=shared stash pages
|
StashedGold [6]int // [0]=personal, [1..5]=shared stash pages
|
||||||
SharedStashPages int // Number of shared stash units detected (3=non-DLC, 5+=DLC)
|
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) {
|
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 {
|
for _, l := range locations {
|
||||||
if it.Location.LocationType == l {
|
if it.Location.LocationType == l && i.CheckMySharedItem(it) {
|
||||||
return it, true
|
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) {
|
func (i Inventory) FindByID(unitID UnitID) (Item, bool) {
|
||||||
for _, it := range i.AllItems {
|
for _, it := range i.AllItems {
|
||||||
if it.UnitID == unitID {
|
if it.UnitID == unitID && i.CheckMySharedItem(it) {
|
||||||
return it, true
|
return it, true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,7 +60,7 @@ func (i Inventory) ByLocation(locations ...item.LocationType) []Item {
|
|||||||
|
|
||||||
for _, it := range i.AllItems {
|
for _, it := range i.AllItems {
|
||||||
for _, l := range locations {
|
for _, l := range locations {
|
||||||
if it.Location.LocationType == l {
|
if it.Location.LocationType == l && i.CheckMySharedItem(it) {
|
||||||
items = append(items, it)
|
items = append(items, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,9 +51,10 @@ func (gd *GameReader) Inventory(rawPlayerUnits RawPlayerUnits, hover data.HoverD
|
|||||||
}
|
}
|
||||||
|
|
||||||
inventory := data.Inventory{
|
inventory := data.Inventory{
|
||||||
Gold: inventoryGold.Value,
|
Gold: inventoryGold.Value,
|
||||||
StashedGold: stashedGold,
|
StashedGold: stashedGold,
|
||||||
SharedStashPages: len(stashPlayerUnitOrder),
|
SharedStashPages: len(stashPlayerUnitOrder),
|
||||||
|
MySharedStashPage: int(stashUnitIDToPage[uint(mainPlayer.UnitID)]),
|
||||||
}
|
}
|
||||||
belt := data.Belt{}
|
belt := data.Belt{}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user