]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/tracker/ToggleIcon.js
separate bottle tracking
[alttp.git] / resources / js / components / tracker / ToggleIcon.js
index 3966506d2b2b815868b5553bbdce64287af992ff..c1a193c209f9540457cc7d223a6c9f54f7734430 100644 (file)
@@ -97,6 +97,27 @@ const previousString = property => (state, setState, icons) => {
        setState(s => ({ ...s, [property]: previous }));
 };
 
+ToggleIcon.bottleController = ctrl => ({
+       getActive: (state, icons) => state[ctrl] ? icons[state[ctrl] - 1] : null,
+       getDefault: () => 'bottle',
+       handlePrimary: (state, setState, icons) => {
+               if (state[ctrl] === 0) {
+                       // skip over mushroom
+                       setState(s => ({ ...s, [ctrl]: 2 }));
+               } else {
+                       setState(increment(ctrl, icons.length));
+               }
+       },
+       handleSecondary: (state, setState, icons) => {
+               if (state[ctrl] === 2) {
+                       // skip over mushroom
+                       setState(s => ({ ...s, [ctrl]: 0 }));
+               } else {
+                       setState(decrement(ctrl, icons.length));
+               }
+       },
+});
+
 ToggleIcon.countController = max => ({
        getActive: highestActive,
        getDefault: firstIcon,