From fcff52d2794fa49b07a62de78ead7d2582d4c173 Mon Sep 17 00:00:00 2001 From: Alain Gilbert Date: Sun, 22 Nov 2020 11:39:16 -0800 Subject: [PATCH] Add vacation mode in preferences --- extracts_v6.go | 6 ++++++ ogame.go | 1 + ogame_test.go | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/extracts_v6.go b/extracts_v6.go index 71aae4ba..a423059f 100644 --- a/extracts_v6.go +++ b/extracts_v6.go @@ -1025,6 +1025,7 @@ func extractPreferencesFromDocV6(doc *goquery.Document) Preferences { EconomyNotifications: extractEconomyNotificationsFromDocV6(doc), ShowActivityMinutes: extractShowActivityMinutesFromDocV6(doc), PreserveSystemOnPlanetChange: extractPreserveSystemOnPlanetChangeFromDocV6(doc), + UrlaubsModus: extractUrlaubsModus(doc), } if prefs.MobileVersion { prefs.Notifications.BuildList = extractNotifBuildListFromDocV6(doc) @@ -1284,6 +1285,11 @@ func extractMobileVersionFromDocV6(doc *goquery.Document) bool { return exists } +func extractUrlaubsModus(doc *goquery.Document) bool { + _, exists := doc.Find("input[name=urlaubs_modus]").Attr("checked") + return exists +} + func extractShowOldDropDownsFromDocV6(doc *goquery.Document) bool { _, exists := doc.Find("input[name=showOldDropDowns]").Attr("checked") return exists diff --git a/ogame.go b/ogame.go index f25df60d..fec02df7 100644 --- a/ogame.go +++ b/ogame.go @@ -121,6 +121,7 @@ type Preferences struct { EconomyNotifications bool ShowActivityMinutes bool PreserveSystemOnPlanetChange bool + UrlaubsModus bool // Vacation mode // Mobile only Notifications struct { diff --git a/ogame_test.go b/ogame_test.go index 8ed2eb32..e5e90748 100644 --- a/ogame_test.go +++ b/ogame_test.go @@ -1099,6 +1099,7 @@ func TestExtractPreferences(t *testing.T) { pageHTMLBytes, _ := ioutil.ReadFile("samples/preferences.html") prefs := NewExtractorV6().ExtractPreferences(pageHTMLBytes) assert.Equal(t, int64(10), prefs.SpioAnz) + assert.False(t, prefs.UrlaubsModus) assert.False(t, prefs.DisableChatBar) assert.False(t, prefs.DisableOutlawWarning) assert.False(t, prefs.MobileVersion) @@ -1122,6 +1123,7 @@ func TestExtractPreferences(t *testing.T) { pageHTMLBytes, _ = ioutil.ReadFile("samples/preferences_reverse.html") prefs = NewExtractorV6().ExtractPreferences(pageHTMLBytes) assert.Equal(t, int64(2), prefs.SpioAnz) + assert.False(t, prefs.UrlaubsModus) assert.True(t, prefs.DisableChatBar) assert.True(t, prefs.DisableOutlawWarning) assert.False(t, prefs.MobileVersion) @@ -1145,6 +1147,7 @@ func TestExtractPreferences(t *testing.T) { pageHTMLBytes, _ = ioutil.ReadFile("samples/preferences_mobile.html") prefs = NewExtractorV6().ExtractPreferences(pageHTMLBytes) assert.Equal(t, int64(3), prefs.SpioAnz) + assert.False(t, prefs.UrlaubsModus) assert.False(t, prefs.DisableChatBar) // no mobile assert.False(t, prefs.DisableOutlawWarning) assert.True(t, prefs.MobileVersion) @@ -1177,6 +1180,7 @@ func TestExtractPreferences(t *testing.T) { pageHTMLBytes, _ = ioutil.ReadFile("samples/preferences_reverse_mobile.html") prefs = NewExtractorV6().ExtractPreferences(pageHTMLBytes) assert.Equal(t, int64(2), prefs.SpioAnz) + assert.False(t, prefs.UrlaubsModus) assert.False(t, prefs.DisableChatBar) // no mobile assert.True(t, prefs.DisableOutlawWarning) assert.True(t, prefs.MobileVersion)