What is the Best Thing I can do to edit my code for equinox I'm not sure what I'm doing wrong with my code and I need help

function championAct(data) {
const champion = data.champion;
while (true) {
let en = champion.findNearestEnemy();
if (en) {
champion.attack(en);
}
}
}

hero.on(‘spawn-ranger’, championAct);
hero.on(‘spawn-mage’, championAct);

hero.build("archer", "a")
hero.build("cannon", "b")
hero.build("ice", "c")
hero.build("ice","d")
hero.build("farm","e")
hero.build("farm","f")
hero.build("farm","g")
hero.build("farm","h")

const allsquares = ‘abcdefgh’;
const tower = {

const tower = {
a: {name: ‘archer’, level: 0},
b: {name: ‘cannon’, level: 0},
c: {name: ‘ice’, level: 0},
d: {name: ‘ice’, level: 0},
e: {name: ‘farm’, level: 0},
f: {name: ‘farm’, level: 0},
g: {name: ‘farm’, level: 0},
h: {name: ‘farm’, level: 0}
};

const allsquares = ‘abcdefgh’;

const build = (t, s) => {
if (s.length > 1) {
let letters = s.split(‘’);
for (let letter of letters) build(t, letter);
return;
}
hero.build(t, s);
tower[s].name = t;
tower[s].level += 1;
};

const towers = (start, end) => {
start = (start + 0 === start + ‘0’) ? allsquares.indexOf(start) : start;
end = (end + 0 === end + ‘0’) ? (allsquares.indexOf(end) + 2) : end;
let returnVar = ;
for (let i = start; i < end; i++) returnVar.push(tower[allsquares.charAt(i)]);
return returnVar;
};

const squares = (start, end) => {
start = (start + 0 === start + ‘0’) ? allsquares.indexOf(start) : start;
end = (end + 0 === end + ‘0’) ? (allsquares.indexOf(end) + 2) : end;
return allsquares.substring(start, end);
};

function upgrade (…args) {
args = args.length > 1 ? args : args[0].split(‘’);
for (let s of args) build(tower[s].name, s);
}

Hey @Kimmy. Welcome to the forum :slight_smile: This is a family-friendly place where coders can share bugs, ask for help on any CodeCombat level (don’t forget to post your code correctly), or just hang out with other coders. But before you proceed, please check out our guidelines: this topic.

What is it that you’re asking about your code? Is there a problem with your code, and if so, could you please describe it?

function championAct(data) {
const champion = data.champion;
while (true) {
let en = champion.findNearestEnemy();
if (en) {
champion.attack(en);
}
}
}

hero.on(‘spawn-ranger’, championAct);
hero.on(‘spawn-mage’, championAct);

hero.build("archer", "a")
hero.build("cannon", "b")
hero.build("ice", "c")
hero.build("ice","d")
hero.build("farm","e")
hero.build("farm","f")
hero.build("farm","g")
hero.build("farm","h")
const allsquares = ‘abcdefgh’;
const tower = {

a: {name: 'archer', level: 0}, 
b: {name: 'cannon', level: 0}, 
c: {name: 'ice', level: 0}, 
d: {name: 'ice', level: 0}, 
e: {name: 'farm', level: 0}, 
f: {name: 'farm', level: 0}, 
g: {name: 'farm', level: 0}, 
h: {name: 'far,', level: 0}
} const allsquares = ‘abcdefgh’;

};
const build = (t, s) => {
if (s.length > 1) {
let letters = s.split(‘’);
for (let letter of letters) build(t, letter);
return;
}
hero.build(t, s);
tower[s].name = t;
tower[s].level = tower[s].level + 1;
};
const towers = (start, end) => {
start = (start + 0 === start + ‘0’) ? allsquares.indexOf(start) : start;
end = (end + 0 === end + ‘0’) ? (allsquares.indexOf(end) + 2) : end;
let returnVar = ;
for (let i = start; i < end; i++) returnVar.push(tower[allsquares.charAt(i)]);
return returnVar;
}
const squares = (start, end) => {
start = (start + 0 === start + ‘0’) ? allsquares.indexOf(start) : start;
end = (end + 0 === end + ‘0’) ? (allsquares.indexOf(end) + 2) : end;
return allsquares.substring(start, end - start);
};
function upgrade (…args) {
args = args.length > 1 ? args : args[0].split(‘’);
for (let s of args) build(tower[s].name, s);
}






formatted it.

1 Like

I’m blind ignore me-
oh god that’s embarrassing when I do that…

2 Likes

thanks, it was very helpful

1 Like

Wait all Jacob did was format your code correctly…was that what you were asking?

@Kimmy He didn’t find the bug in your code also could you please describe what is wrong with it?

it looks like you’re trying to use my equinox code clip but then modifying it? I’m not exactly sure what you’re trying to achieve here… (also I highly recommend you DONT modify my code unless you know what you’re doing since… no offense… but I highly doubt you understand it :sweat_smile:)

4 Likes

I suggest you to add a statement in the champion function:

champion.special();

oh, I’m so sorry if I took your code my brother helped me make this code so he might have used to to help me right the code I did a bunch of revisions on it after this and hopefully fixed it. I do find the code really confusing lol.

Yes, he did format it, but it helped me understand the code a bit more so I could hopefully fix what I was doing. I don’t know if I really did well I ended up fixing some bugs even though I’m still not sure it works correctly. Here is the code I created to fix the bugs even if it is unformatted again.

function championAct(data) {
const champion = data.champion;
while (true) {
let en = champion.findNearestEnemy();
if (en) {
champion.attack(en);
}
}
}

hero.on(‘spawn-ranger’, (event) => championAct(event));
hero.on(‘spawn-mage’, (event) => championAct(event));

hero.build(“archer”, “a”);
hero.build(“cannon”, “b”);
hero.build(“ice”, “c”);
hero.build(“ice”, “d”);
hero.build(“farm”, “e”);
hero.build(“farm”, “f”);
hero.build(“farm”, “g”);
hero.build(“farm”, “h”);

const allsquares = ‘abcdefgh’;
const tower = {
a: {name: ‘archer’, level: 0},
b: {name: ‘cannon’, level: 0},
c: {name: ‘ice’, level: 0},
d: {name: ‘ice’, level: 0},
e: {name: ‘farm’, level: 0},
f: {name: ‘farm’, level: 0},
g: {name: ‘farm’, level: 0},
h: {name: ‘farm’, level: 0}
};

const build = (t, s) => {
if (s.length > 1) {
let letters = s.split(‘’);
for (let letter of letters) build(t, letter);
return;
}
hero.build(t, s);
tower[s].name = t;
tower[s].level = tower[s].level + 1;
};

const towers = (start, end) => {
start = (start + 0 === start + ‘0’) ? allsquares.indexOf(start) : start;
end = (end + 0 === end + ‘0’) ? (allsquares.indexOf(end) + 2) : end;
let returnVar = ;
for (let i = start; i < end; i++) returnVar.push(tower[allsquares.charAt(i)]);
return returnVar;
};

const squares = (start, end) => {
start = (start + 0 === start + ‘0’) ? allsquares.indexOf(start) : start;
end = (end + 0 === end + ‘0’) ? (allsquares.indexOf(end) + 2) : end;
return allsquares.substring(start, end);
};

function upgrade (…args) {
args = args.length > 1 ? args : args[0].split(‘’);
for (let s of args) build(tower[s].name, s);
}
function heroAction() {
hero.ability(“shockwave”);
}

// Repeat heroAction every 10 seconds
while (true) {
heroAction();
hero.findNearestEnemy(10);
}

function championAct(data) {
const champion = data.champion;
while (true) {
let en = champion.findNearestEnemy();
if (en) {
champion.attack(en);
}
}
}

hero.on(‘spawn-ranger’, (event) => championAct(event));
hero.on(‘spawn-mage’, (event) => championAct(event));

hero.build(“archer”, “a”);
hero.build(“cannon”, “b”);
hero.build(“ice”, “c”);
hero.build(“ice”, “d”);
hero.build(“farm”, “e”);
hero.build(“farm”, “f”);
hero.build(“farm”, “g”);
hero.build(“farm”, “h”);

const allsquares = ‘abcdefgh’;
const tower = {
a: {name: ‘archer’, level: 0},
b: {name: ‘cannon’, level: 0},
c: {name: ‘ice’, level: 0},
d: {name: ‘ice’, level: 0},
e: {name: ‘farm’, level: 0},
f: {name: ‘farm’, level: 0},
g: {name: ‘farm’, level: 0},
h: {name: ‘farm’, level: 0}
};

const build = (t, s) => {
if (s.length > 1) {
let letters = s.split(‘’);
for (let letter of letters) build(t, letter);
return;
}
hero.build(t, s);
tower[s].name = t;
tower[s].level = tower[s].level + 1;
};

const towers = (start, end) => {
start = (start + 0 === start + ‘0’) ? allsquares.indexOf(start) : start;
end = (end + 0 === end + ‘0’) ? (allsquares.indexOf(end) + 2) : end;
let returnVar = ;
for (let i = start; i < end; i++) returnVar.push(tower[allsquares.charAt(i)]);
return returnVar;
};

const squares = (start, end) => {
start = (start + 0 === start + ‘0’) ? allsquares.indexOf(start) : start;
end = (end + 0 === end + ‘0’) ? (allsquares.indexOf(end) + 2) : end;
return allsquares.substring(start, end);
};

function upgrade (…args) {
args = args.length > 1 ? args : args[0].split(‘’);
for (let s of args) build(tower[s].name, s);
}
function heroAction() {
hero.ability(“shockwave”);
}

// Repeat heroAction every 10 seconds
while (true) {
heroAction();
hero.findNearestEnemy(10);
}

Please remember to format your code using this button:
Screenshot 2023-04-19 8.27.52 PM

This way, it is easier to see the code.

I posted the code so people could use it, but I’m just really confused on what is happening with it lol

1 Like

bruh you didn’t format it correctly

function championAct(data) {
    const champion = data.champion;
    while (true) {
        let en = champion.findNearestEnemy();
        if (en) {
            champion.attack(en);
        }
    }
}

hero.on(‘spawn-ranger’, (event) => championAct(event));
hero.on(‘spawn-mage’, (event) => championAct(event));

hero.build(“archer”, “a”);
hero.build(“cannon”, “b”);
hero.build(“ice”, “c”);
hero.build(“ice”, “d”);
hero.build(“farm”, “e”);
hero.build(“farm”, “f”);
hero.build(“farm”, “g”);
hero.build(“farm”, “h”);
function heroAction() {
    hero.ability(“shockwave”);
}

// Repeat heroAction every 10 seconds
while (true) {
    heroAction();
    hero.findNearestEnemy(10);
}
1 Like

Also I removed all of my code from that since 1. it wasn’t being used anywhere, 2. even if it was being used it wouldn’t work correctly

@Kimmy would you like me to fix the current errors I see and add my latest code?

1 Like

sure that would be really helpful thank you so much