« get me outta code hell

Pick random target in AI - 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-16 09:20:15 -0300
committerFlorrie <towerofnix@gmail.com>2018-08-16 09:20:15 -0300
commit841b9d8f83bda72ddd8326b77e3696ca1ca24812 (patch)
tree033a81496a310f4c3caa0cc540d10a2045605adb /index.js
parentc8090b52793cbdec4c28ceea3acddf19fc167cfd (diff)
Pick random target in AI
Diffstat (limited to 'index.js')
-rw-r--r--index.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/index.js b/index.js
index 2762bf6..c7327d6 100644
--- a/index.js
+++ b/index.js
@@ -613,7 +613,8 @@ class BattleCharacter extends Sprite {
   determineNewTarget(targetType) {
     const targets = this.getValidTargets(targetType)
     if (targets.length) {
-      this.targetCharacter = targets[0]
+      // TODO: Some sort of "follow the leader" mechanic
+      this.targetCharacter = targets[Math.floor(Math.random() * targets.length)]
     } else {
       this.targetCharacter = null
     }