Skip to content

Commit d5fb388

Browse files
dzaimadavidje13
authored andcommitted
Make queen food movement match reference implementation
- fix from trichoplaxify
1 parent 74fd329 commit d5fb388

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

games/formic/GameManager.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ define([
328328
}
329329

330330
moveAnt(index, ant, action, rotation) {
331+
/* jshint maxcomplexity:15 */ //Complex interactions for a complex game
331332
const p = this.offsetPos(ant, ROTATIONS[rotation][action.cell]);
332333
if(action.color) {
333334
setColourAtI(this.board, p.i, action.color);
@@ -356,7 +357,26 @@ define([
356357
ant.y = p.y;
357358
ant.i = p.i;
358359
}
359-
if(ant.type !== QUEEN) {
360+
if(ant.type === QUEEN) {
361+
for(let i = 0; i < 9; ++ i) {
362+
const target = this.antGrid[this.offsetPos(ant, i).i];
363+
if(
364+
target && target.type !== QUEEN &&
365+
target.entry !== ant.entry
366+
) {
367+
transferFood(target, ant);
368+
}
369+
}
370+
for(let i = 0; i < 9; ++ i) {
371+
const target = this.antGrid[this.offsetPos(ant, i).i];
372+
if(
373+
target && target.type !== QUEEN &&
374+
target.entry === ant.entry
375+
) {
376+
transferFood(target, ant);
377+
}
378+
}
379+
} else {
360380
for(let i = 0; i < 9; ++ i) {
361381
const target = this.antGrid[this.offsetPos(ant, i).i];
362382
if(

0 commit comments

Comments
 (0)