Skip to content

Instantly share code, notes, and snippets.

View tawanda-profuse's full-sized avatar
👋
Available

Tawanda Andrew Msengezi tawanda-profuse

👋
Available
View GitHub Profile
@tawanda-profuse
tawanda-profuse / Code Combat backwoods standoff solution .javascript
Created July 26, 2017 07:57
The solution for the code combat game level called "Backwoods standoff"
loop {
hero.shield();
if (hero.isReady ("cleave")) {
hero.findNearestEnemy();
hero.cleave(enemy);
}
else {
var enemy = hero.findNearestEnemy();
hero.attack(enemy);
hero.attack(enemy);
// Build traps on the path when the hero sees a munchkin!
while(true) {
hero.moveXY(41, 20);
var enemy = hero.findNearestEnemy();
if(enemy) {
// Build a "fire-trap" at the Red X (41, 24)
hero.buildXY("fire-trap", 41, 24);
}
// Add an else below to move back to the clearing
else {
permat = 0
katasandi = "Abracadabra"
while true:
hero.moveRight()
hero.moveUp(2)
enemy = hero.findNearestEnemy()
if enemy: hero.attack (enemy)
if enemy: hero.attack (enemy)
hero.moveLeft()
hero.moveUp(2)