This repository has been archived by the owner on May 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #95 from Regner/feature/map-data
Adding map data
- Loading branch information
Showing
6 changed files
with
155 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package client | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/regner/albiondata-client/lib" | ||
"github.com/regner/albiondata-client/log" | ||
) | ||
|
||
type operationGetClusterMapInfo struct { | ||
} | ||
|
||
func (op operationGetClusterMapInfo) Process(state *albionState, uploader iuploader) { | ||
log.Debug("Got GetClusterMapInfo operation...") | ||
} | ||
|
||
type operationGetClusterMapInfoResponse struct { | ||
ZoneID int `mapstructure:"0"` | ||
BuildingType []int `mapstructure:"5"` | ||
AvailableFood []int `mapstructure:"10"` | ||
Reward []int `mapstructure:"12"` | ||
AvailableSilver []int `mapstructure:"13"` | ||
Owners []string `mapstructure:"14"` | ||
Buildable []bool `mapstructure:"19"` | ||
IsForSale []bool `mapstructure:"27"` | ||
BuyPrice []int `mapstructure:"28"` | ||
} | ||
|
||
func (op operationGetClusterMapInfoResponse) Process(state *albionState, uploader iuploader) { | ||
log.Debug("Got response to GetClusterMapInfo operation...") | ||
|
||
data, err := json.Marshal(lib.MapDataUpload{ | ||
ZoneID: op.ZoneID, | ||
BuildingType: op.BuildingType, | ||
AvailableFood: op.AvailableFood, | ||
Reward: op.Reward, | ||
AvailableSilver: op.AvailableSilver, | ||
Owners: op.Owners, | ||
Buildable: op.Buildable, | ||
IsForSale: op.IsForSale, | ||
BuyPrice: op.BuyPrice, | ||
}) | ||
|
||
if err != nil { | ||
log.Errorf("Error while marshalling payload for market data: %v", err) | ||
return | ||
} | ||
|
||
log.Info("Sending market data to ingest") | ||
uploader.sendToIngest(data, lib.NatsMapDataIngest) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package lib | ||
|
||
// MapDataUpload contains information on zone maps | ||
type MapDataUpload struct { | ||
ZoneID int `json:"ZoneID"` | ||
BuildingType []int `json:"BuildingType"` | ||
AvailableFood []int `json:"AvailableFood"` | ||
Reward []int `json:"Reward"` | ||
AvailableSilver []int `json:"AvailableSilver"` | ||
Owners []string `json:"Owners"` | ||
Buildable []bool `json:"Buildable"` | ||
IsForSale []bool `json:"IsForSale"` | ||
BuyPrice []int `json:"BuyPrice"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters