swordio
Version:
A medieval warrior-based programming language
19 lines (14 loc) • 497 B
JavaScript
function MultiplyCell(map) {
this.map = map;
}
MultiplyCell.type = "M";
MultiplyCell.prototype.encounter = function(enemy, vector) {
var targetX = this.x + vector.x;
var targetY = this.y + vector.y;
var enemyValue = enemy.stack.pop();
var cellValue = this.map.get(targetX, targetY).type.charCodeAt(0) - 32;
this.map.set(enemy.x, enemy.y, String.fromCharCode(enemyValue * cellValue + 32));
enemy.x = targetX;
enemy.y = targetY;
};
module.exports = MultiplyCell;