diff options
author | Devine Lu Linvega <[email protected]> | 2018-10-14 20:42:51 +1200 |
---|---|---|
committer | Devine Lu Linvega <[email protected]> | 2018-10-14 20:42:51 +1200 |
commit | 54c94e3ed3287a9641da9b01b711ae21c8385154 (patch) | |
tree | 76acfdbb00ecd8121aaf41f0deffd4fa121222f1 | |
parent | 59997abbbdc7df2de1684b0c9957122fb977afbd (diff) | |
download | Orca-54c94e3ed3287a9641da9b01b711ae21c8385154.tar.gz Orca-54c94e3ed3287a9641da9b01b711ae21c8385154.zip |
Implemented haste
-rw-r--r-- | core/lib/_base.js | 4 | ||||
-rw-r--r-- | core/lib/_move.js | 2 | ||||
-rw-r--r-- | core/lib/e.js | 2 | ||||
-rw-r--r-- | core/lib/n.js | 2 | ||||
-rw-r--r-- | core/lib/s.js | 2 | ||||
-rw-r--r-- | core/lib/w.js | 2 | ||||
-rw-r--r-- | core/pico.js | 7 | ||||
-rw-r--r-- | examples/issue1.pico | 37 |
8 files changed, 38 insertions, 20 deletions
diff --git a/core/lib/_base.js b/core/lib/_base.js index aefbc65..6765f90 100644 --- a/core/lib/_base.js +++ b/core/lib/_base.js @@ -13,6 +13,10 @@ function FnBase (pico, x, y) { return this.x + (this.y * pico.h) } + this.haste = function () { + + } + this.run = function () { this.operation() } diff --git a/core/lib/_move.js b/core/lib/_move.js index c31da31..b5e0d44 100644 --- a/core/lib/_move.js +++ b/core/lib/_move.js @@ -5,6 +5,8 @@ const FnBase = require('./_base') function FnMove (pico, x, y) { FnBase.call(this, pico, x, y) + this.direction = true + this.proceed = function (ahead, behind, paral_g, perpe_g, pos_ahead, move_left, move_across, move_right) { const wire_ahead = ahead && ahead.glyph == paral_g const wire_behind = behind && (behind.glyph == paral_g || behind.glyph == '*' || behind.glyph == '+') diff --git a/core/lib/e.js b/core/lib/e.js index e02218c..eece133 100644 --- a/core/lib/e.js +++ b/core/lib/e.js @@ -9,7 +9,7 @@ function FnE (pico, x, y) { this.glyph = 'e' this.info = 'Moves eastward, or bangs.' - this.operation = function () { + this.haste = function () { if (this.signal()) { return } if (this.is_free(1, 0) != true) { this.replace('b'); this.lock(); return } this.move(1, 0) diff --git a/core/lib/n.js b/core/lib/n.js index f4bee1c..e53e513 100644 --- a/core/lib/n.js +++ b/core/lib/n.js @@ -9,7 +9,7 @@ function FnN (pico, x, y) { this.glyph = 'n' this.info = 'Moves Northward, or bangs.' - this.operation = function () { + this.haste = function () { if (this.signal()) { return } if (this.is_free(0, -1) != true) { this.replace('b'); this.lock(); return } this.move(0, -1) diff --git a/core/lib/s.js b/core/lib/s.js index f8a1b74..7af5d9d 100644 --- a/core/lib/s.js +++ b/core/lib/s.js @@ -9,7 +9,7 @@ function FnS (pico, x, y) { this.glyph = 's' this.info = 'Moves southward, or bangs.' - this.operation = function () { + this.haste = function () { if (this.signal()) { return } if (this.is_free(0, 1) != true) { this.replace('b'); this.lock(); return } this.move(0, 1) diff --git a/core/lib/w.js b/core/lib/w.js index f6fab5f..8d54d6c 100644 --- a/core/lib/w.js +++ b/core/lib/w.js @@ -9,7 +9,7 @@ function FnW (pico, x, y) { this.glyph = 'w' this.info = 'Moves westward, or bangs.' - this.operation = function () { + this.haste = function () { if (this.signal()) { return } if (this.is_free(-1, 0) != true) { this.replace('b'); this.lock(); return } this.move(-1, 0) diff --git a/core/pico.js b/core/pico.js index 5f000d9..242dbe4 100644 --- a/core/pico.js +++ b/core/pico.js @@ -62,6 +62,13 @@ function Pico (w, h) { } this.run_fns = function (fns) { + // Move + for (const id in fns) { + const p = fns[id] + if (p.is_move) { if (this.is_locked(p.x, p.y)) { continue } } + p.haste() + } + // Operate for (const id in fns) { const p = fns[id] if (this.is_locked(p.x, p.y)) { continue } diff --git a/examples/issue1.pico b/examples/issue1.pico index 82b8904..12cc4f4 100644 --- a/examples/issue1.pico +++ b/examples/issue1.pico @@ -1,16 +1,21 @@ -........................................................... -........................................................... -........................................................... -........................................................... -...e..*--*----*....*----*--*..w............................ -.........|....|....|....|.................................. -.........|....|....|....|.................................. -.........*----*....*----*.................................. -........................................................... -........................................................... -........................e..*--+----*....*----+--*..w....... -..............................|....|....|....|............. -..............................|....|....|....|............. -..............................*----*....*----*............. -........................................................... -...........................................................
\ No newline at end of file +.................................................................. +.................................................................. +...................e..*--+----*....*----+--*..w................... +.........................|....|....|....|......................... +.........................|....|....|....|......................... +.........................*----*....*----*......................... +...............................d..d............................... +...................e..*--*----*....*----*--*..w................... +.........................|....|....|....|......................... +.........................|....|....|....|......................... +.........................*----*....*----*......................... +...............................d..d............................... +.........................*----*....*----*......................... +.........................|....|t...|....|t........................ +.........................|....|....|....|......................... +.........................*----*g..g*----*......................... +.................................................................. +..............................n....n.............................. +.................................................................. +.................................................................. +..................................................................
\ No newline at end of file |