This repository has been archived by the owner on May 8, 2023. It is now read-only.
/
operation_auction_get_offers.go
63 lines (49 loc) · 1.72 KB
/
operation_auction_get_offers.go
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
package client
import (
"encoding/json"
"github.com/regner/albiondata-client/lib"
"github.com/regner/albiondata-client/log"
"github.com/regner/albiondata-client/notification"
)
type operationAuctionGetOffers struct {
Category string `mapstructure:"1"`
SubCategory string `mapstructure:"2"`
Quality string `mapstructure:"3"`
Enchantment uint32 `mapstructure:"4"`
EnchantmentLevel string `mapstructure:"8"`
ItemIds []uint16 `mapstructure:"6"`
MaxResults uint32 `mapstructure:"9"`
IsAscendingOrder bool `mapstructure:"11"`
}
func (op operationAuctionGetOffers) Process(state *albionState) {
log.Debug("Got AuctionGetOffers operation...")
}
type operationAuctionGetOffersResponse struct {
MarketOrders []string `mapstructure:"0"`
}
func (op operationAuctionGetOffersResponse) Process(state *albionState) {
log.Debug("Got response to AuctionGetOffers operation...")
if state.LocationId == -1 {
log.Error("The players location has not yet been set. Please transition zones so the location can be identified.")
notification.Push("The players location has not yet been set. Please transition zones so the location can be identified.")
return
}
orders := []*lib.MarketOrder{}
for _, v := range op.MarketOrders {
order := &lib.MarketOrder{}
err := json.Unmarshal([]byte(v), order)
if err != nil {
log.Errorf("Problem converting market order to internal struct: %v", err)
}
order.LocationID = state.LocationId
orders = append(orders, order)
}
if len(orders) < 1 {
return
}
upload := lib.MarketUpload{
Orders: orders,
}
log.Infof("Sending %d market offers to ingest", len(orders))
sendMsgToPublicUploaders(upload, lib.NatsMarketOrdersIngest, state)
}