« get me outta code hell

Dequeue, activate - csb-game - Pixelly spin-off of the Command Synergy Battle system used in Final Fantasy XIII
summary refs log tree commit diff
path: root/index.js
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-08-09 19:31:42 -0300
committerFlorrie <towerofnix@gmail.com>2018-08-09 19:31:42 -0300
commit4e67d00d193a214df2bb4ab2586557378a2ea0f0 (patch)
tree5c1b3ea54984fdbb3faab84d7bc950f3c00e7302 /index.js
parent6be55ba52ef79907c0ade21e77a28ddc4f82bcc9 (diff)
Dequeue, activate
Diffstat (limited to 'index.js')
-rw-r--r--index.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/index.js b/index.js
index 662edbe..ec0830a 100644
--- a/index.js
+++ b/index.js
@@ -76,6 +76,16 @@ class ATBBar {
   getRemainingSpace() {
     return this.segmentCount - this.queuedActions.reduce((acc, { size }) => acc + size, 0)
   }
+
+  dequeue() {
+    this.queuedActions.pop()
+  }
+
+  activate() {
+    this.queuedActions.splice(0)
+    // TODO: Do something
+    // (We won't actually be splicing just like that later - it'll activate actions one by one, unshifting each as it goes, with the action menu hidden until the queue is empty, or cancelled)
+  }
 }
 
 class ActionMenu {
@@ -199,7 +209,7 @@ class ActionMenu {
 }
 
 const atbBar = new ATBBar()
-// atbBar.queuedActions = [{label: 'Fire', size: 1}, {label: 'Fira', size: 2}, {label: 'Firaga', size: 3}]
+atbBar.queuedActions = [{label: 'Fire', size: 1}, {label: 'Blizz', size: 1}, {label: 'Zap', size: 1}, {label: 'Firaga', size: 3}]
 
 const actionMenu = new ActionMenu()
 
@@ -233,8 +243,12 @@ canvas.addEventListener('keypress', evt => {
     actionMenu.decreaseLevel()
   } else if (evt.keyCode === 39) {
     actionMenu.increaseLevel()
-  } else if (evt.which === 32 || evt.keyCode === 13) {
+  } else if (evt.which === 32) {
     actionMenu.queueTo(atbBar)
+  } else if (evt.keyCode === 8) {
+    atbBar.dequeue()
+  } else if (evt.keyCode === 13 || evt.key.toLowerCase() === 'e') {
+    atbBar.activate()
   }
 })