File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -12,12 +12,25 @@ import (
1212 "github.com/lithammer/fuzzysearch/fuzzy"
1313)
1414
15+ const doubleWOTHMarker = "*"
16+
1517func (tracker * Tracker ) AddWOTH (str string ) bool {
1618 if len (tracker .woths ) >= 5 {
1719 log .Printf ("warning: WotHs maxed out at 5" )
1820 return false
1921 }
2022
23+ // Handle Double-WOTH
24+ // Each hint is doubled, two WoTH mean you have either seen all of them
25+ // _or_ there might be two WoTH hints for the same area.
26+ // A third WOTH will add a new line.
27+ for k , v := range tracker .woths {
28+ if v == str {
29+ tracker .woths [k ] += doubleWOTHMarker
30+ return true
31+ }
32+ }
33+
2134 tracker .woths = append (tracker .woths , str )
2235 return true
2336}
Original file line number Diff line number Diff line change 11package tracker
22
3- import "log"
3+ import (
4+ "log"
5+ "strings"
6+ )
47
58// undoStackEntry represents an action (upgrade/downgrade) that happened on an item.
69type undoStackEntry struct {
@@ -47,7 +50,7 @@ func (tracker *Tracker) undo() {
4750 if entry .IsHint {
4851 switch entry .HintType {
4952 case hintTypeWOTH :
50- tracker .woths = tracker . woths [: len ( tracker . woths ) - 1 ]
53+ tracker .undoWOTH ( entry )
5154 case hintTypeBarren :
5255 tracker .barrens = tracker .barrens [:len (tracker .barrens )- 1 ]
5356 case hintTypeSometimes :
@@ -66,6 +69,19 @@ func (tracker *Tracker) undo() {
6669 }
6770}
6871
72+ func (tracker * Tracker ) undoWOTH (entry undoStackEntry ) {
73+ // Clear last added double woth or last woth
74+ double := entry .HintText + doubleWOTHMarker
75+ for i := len (tracker .woths ) - 1 ; i >= 0 ; i -- {
76+ if tracker .woths [i ] == double {
77+ tracker .woths [i ] = strings .TrimSuffix (tracker .woths [i ], doubleWOTHMarker )
78+ return
79+ }
80+ }
81+
82+ tracker .woths = tracker .woths [:len (tracker .woths )- 1 ]
83+ }
84+
6985func (tracker * Tracker ) redo () {
7086 if len (tracker .redoStack ) == 0 {
7187 log .Printf ("no action to redo" )
You can’t perform that action at this time.
0 commit comments