Skip to content

Commit

Permalink
Add vacation mode in preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
alaingilbert committed Nov 22, 2020
1 parent 88db426 commit fcff52d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions extracts_v6.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions ogame.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ type Preferences struct {
EconomyNotifications bool
ShowActivityMinutes bool
PreserveSystemOnPlanetChange bool
UrlaubsModus bool // Vacation mode

// Mobile only
Notifications struct {
Expand Down
4 changes: 4 additions & 0 deletions ogame_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit fcff52d

Please sign in to comment.