Bernadette in Zero Sum error


#1

http://imgur.com/bHupL4i

In Zero Sum, I’m getting this error about 1:15 minutes into the match. I read in another post that it might have to do with zombies dying and switching teams while still in the friends array; what’s the command to check what team a unit is on? I figure if I put an “if friend.team == friend” statement in before the attack command I should be able to fix it. There is a function for team, right? I can’t find it in the list at the bottom :frowning:


#2

Yes, soldiers and the hero have a .team property to access.


#3

ok, and what are the values in team? “ogre” and “friend” or something else? in zero sum is it “red” and “blue”? the number one thing that annoys the heck out of me about code combat is that there’s no list of what all the unit types are. i’m sick to death of having to run code just to find out what self.say(self.findNearestEnemy.type) is.


#4

The teams are "ogres" and "humans".

As for finding out what types there are, look through this list:

codecombat.com/editor/thang

This provides a list of all the types of enemies, friends, and other items.


#5

Ok, tried doing some stuff but it didnt fix my problem. What the heck is unit bernadette? I tried doing this:

if friend.type == “Bernadette”:
self.say(friend.pos)
else:
self.command(friend, “attack”, nearFriend)

to try and find out what the heck bernadette is but it still gives me the “Bernadette has no attack command” error. And every time it’s bernadette, and every time it’s right after a raise corpse command. It’s driving me nuts


#6

You will have to run run self.say(…) or equivalent in every programming language and every project.
Yes, the codeCombat editor is not as powerful as Visual Studio but that doesn’t change anything: by principle you always have to run unit tests on your code.

I usually pick and empty level (forest flower grove or agrippa defence) and test my code there if needed or if I am not sure about how things work.

As for determining what API can you use, or get info about “Bernadette”, try this JavaScript code:

//get some object you want to know about:
for(var i in my_object)
    this.say(i);
    //if you want to know also the values use
   //this.say(i+":"+my_object[i]);

If you want more, the next fragment automatically tracks every single object type you encounter in codeCombat and gives you info about it;
Copy paste it in every level you ever write.

//put every object you are not interested about in your list
var type_known={"munchkin":true,"thrower":true};

//get a list of objects you want to know about. They can be 
//items, friends, enemies, heroes, hazards, missiles 
for(var i in my_list){
  // skip object if it is null or its type is known
  if(!my_list[i] || (my_list[i].type in type_known)) continue;
  // new object detected
 for(var j in my_list[i])
     this.say(j+":"+my_list[i][j]);
//add the object type to the list of types already known
 types_known[my_list[i].type]=true;
}

Keep every piece of code saved in a source control like gitHub,
Reuse your code.
Edit your code in an outside editor if you have to write more than 2 screens of codeCombat code.


#7

"Bernadette" is the name of a thing that you summoned. You would access that trait using friend.id.