Unicornherder

Herd unicorns into their pen.

Player AiPlayer;
Player Neutral;
Player P1;
Location uniLoc;

void configGame()
{
   setMapSize(17,17);
   setNumFluxWells(0);
   addAIPlayer("Evil Fish","Crypt Doctor",0);
   dontNeedDecks();
	setTurnTime(121);
}

void randUnicorn(){
   bool done = false;
   while(!done){
      uniLoc = createLocation(rand(17),rand(17));
      Entity fig = getFigure(uniLoc);
      if(getTopo(uniLoc) != 1 && !fig.doesExist() && !(uniLoc.getY() > 12 && uniLoc.getX() < 4)){
         createEntity("Veldan Unicorn", uniLoc, P1);
         done = true;
      }
   }
}

void beforeStart()
{
   fogMap();
   AiPlayer = getAIPlayer(0); 
   P1 = getHumanPlayer(0); 
   int ds=P1.deckSize();
   for(int n=0; n<ds; n++) P1.removeDeckCard(0);
   int ds2=AiPlayer.deckSize();
   for(int n=0; n<ds2; n++) AiPlayer.removeDeckCard(0);

   Entity herald = createEntity("Imperial Herald",3,13,P1);
   herald.addTokens("vision",1);
   herald.addTokens("attack",-2);
   Entity dog1= createEntity("Abyssal Bloodhound",3,14,P1);
   dog1.addTokens("maxhp",1);
   dog1.addTokens("vision",-1);
   Entity dog2= createEntity("Abyssal Bloodhound",2,14,P1);
   dog2.addTokens("maxhp",1);
   dog2.addTokens("vision",-1);

   for(int x = 0; x < 4; x++){
      for(int y = 13; y < 18; y++){
         setTerrain(createLocation(x,y),3,2);
      }
   }
   createEntity("Force Fence",2,13,P1);
   createEntity("Force Fence",1,13,P1);
   createEntity("Force Fence",0,13,P1);
   createEntity("Force Fence",3,15,P1);
   createEntity("Force Fence",3,16,P1);

   randUnicorn();
   randUnicorn();
   randUnicorn();
   randUnicorn();
   randUnicorn();

}

void onNewRound()
{
   P1.addFlux(-2);

   forEachEntity();
}

bool entityCallback(Entity ent){
   if(ent.getName() == "Veldan Unicorn"){
      uniLoc = ent.getLoc();
      if(uniLoc.getY() > 12 && uniLoc.getX() < 4){
         ent.remove();
         P1.addGlory(2);
         randUnicorn();
      }
   }
   return true;
}