Get the latest combat report for a coord
@@ -85,6 +85,8 @@ type Wrapper interface {
GetEspionageReportMessages() ([]EspionageReportSummary, error)
GetEspionageReportFor(Coordinate) (EspionageReport, error)
GetEspionageReport(msgID int) (EspionageReport, error)
+ GetCombatReportSummaryFor(Coordinate) (CombatReportSummary, error)
+ //GetCombatReport(msgID int) (CombatReport, error)
DeleteMessage(msgID int) error
Distance(origin, destination Coordinate) int
FlightTime(origin, destination Coordinate, speed Speed, ships ShipsInfos) (secs, fuel int)
@@ -2281,6 +2283,27 @@ func (b *OGame) getCombatReportMessages() ([]CombatReportSummary, error) {
return msgs, nil
}
+func (b *OGame) getCombatReportFor(coord Coordinate) (CombatReportSummary, error) {
+ tabid := 20
+ page := 1
+ nbPage := 1
+ for page <= nbPage {
+ pageHTML, err := b.getPageMessages(page, tabid)
+ if err != nil {
+ return CombatReportSummary{}, err
+ }
+ newMessages, newNbPage := extractCombatReportMessagesSummary(pageHTML)
+ for _, m := range newMessages {
+ if m.Destination.Equal(coord) {
+ return m, nil
+ }
+ }
+ nbPage = newNbPage
+ page++
+ }
+ return CombatReportSummary{}, errors.New("combat report not found for " + coord.String())
+}
+
// EspionageReport detailed espionage report
type EspionageReport struct {
Resources
@@ -3306,6 +3329,18 @@ func (b *OGame) SendIPM(planetID PlanetID, coord Coordinate, nbr int, priority I
return b.WithPriority(Normal).SendIPM(planetID, coord, nbr, priority)
}
+// GetCombatReportSummaryFor gets the latest combat report for a given coordinate
+func (b *Prioritize) GetCombatReportSummaryFor(coord Coordinate) (CombatReportSummary, error) {
+ b.begin("GetCombatReportSummaryFor")
+ defer b.done()
+ return b.bot.getCombatReportFor(coord)
+}
+
+// GetCombatReportSummaryFor gets the latest combat report for a given coordinate
+func (b *OGame) GetCombatReportSummaryFor(coord Coordinate) (CombatReportSummary, error) {
+ return b.WithPriority(Normal).GetCombatReportSummaryFor(coord)
+}
+
// GetEspionageReportFor gets the latest espionage report for a given coordinate
func (b *Prioritize) GetEspionageReportFor(coord Coordinate) (EspionageReport, error) {
b.begin("GetEspionageReportFor")
