Improved map editor
made some improvements to the map editor, to change the size of the map being edited simply copy the code and change the values of xsize and ysize.
int gSeed;
Player nullPlayer;
Player gPlayer;
int[][] gTopo;
int[][] gVeg;
int xsize = 13;
int ysize = 12;
void configGame()
{
dontNeedDecks();
setMapSize(xsize,ysize);
gTopo.resize(xsize);
gVeg.resize(xsize);
for(int n=0; n<xsize; n++)
{
gTopo[n].resize(ysize);
gVeg[n].resize(ysize);
}
setNumPlayers(1);
reseed();
}
void afterStart()
{
infoBox("Hacked Map Editor","Play the Warren to change the map seed. Play the Graveyard when you are done editing. ");
statusMsg(nullPlayer,"Hello");
}
void beforeStart()
{
gPlayer=getHumanPlayer(0);
gPlayer.addToHand("Warren");
gPlayer.addToHand("Graveyard");
gPlayer.addToHand("Naturescaping");
gPlayer.addToHand("Silviculture");
gPlayer.addToHand("Inundation");
Entity grove = createEntity("Grove",0,0,gPlayer);
//Entity asg=createEntity("Astridian Geographic Society",0,1,gPlayer);
createEntity("Trade Routes",-1,-1,gPlayer);
createEntity("Light of Day",-1,-1,gPlayer);
enchantEntity(grove ,"Vines of Dellen",gPlayer);
enchantEntity(grove ,"Vines of Dellen",gPlayer);
enchantEntity(grove ,"Weather Vane",gPlayer);
gPlayer.addFlux(10);
int ds=gPlayer.deckSize();
for(int n=0; n<ds; n++) gPlayer.removeDeckCard(0);
}
void onPlayersTurn(Player player)
{
forEachEntity();
bool hasWarren=false;
bool hasGrave=false;
bool hasNature=false;
bool hasCulture=false;
bool hasInun=false;
int hs=gPlayer.handSize();
for(int n=0; n<hs; n++)
{
if(gPlayer.getHandCard(n).getName()=="Warren") hasWarren=true;
if(gPlayer.getHandCard(n).getName()=="Graveyard") hasGrave=true;
if(gPlayer.getHandCard(n).getName()=="Naturescaping") hasNature=true;
if(gPlayer.getHandCard(n).getName()=="Silviculture") hasCulture=true;
if(gPlayer.getHandCard(n).getName()=="Inundation") hasInun=true;
}
if(!hasNature)
{
gPlayer.addToHand("Naturescaping");
gPlayer.addFlux(2);
}
if(!hasCulture)
{
gPlayer.addToHand("Silviculture");
gPlayer.addFlux(2);
}
if(!hasInun)
{
gPlayer.addToHand("Inundation");
gPlayer.addFlux(2);
}
if(!hasWarren)
{
gPlayer.addToHand("Warren");
gPlayer.addFlux(7);
reseed();
}
if(!hasGrave)
{
gPlayer.addToHand("Graveyard");
gPlayer.addFlux(7);
dump();
}
}
bool entityCallback(Entity ent)
{
if(ent.getName()=="Warren")
{
ent.remove();
}else if(ent.getName()=="Graveyard")
{
ent.remove();
}else if(ent.getName()=="Construction Site")
{
ent.remove();
}
return(true);
}
void reseed()
{
gSeed=rand(32000);
setMapSeed(gSeed);
string msg="setMapSeed( ";
msg += gSeed;
msg += " );\n";
statusMsg(nullPlayer,msg);
for(int x=0; x<xsize; x++)
{
for(int y=0; y<ysize; y++)
{
Location loc=createLocation(x,y);
gTopo[x][y]=getTopo(loc);
gVeg[x][y]=getVeg(loc);
}
}
}
void dump()
{
string msg="setMapSeed( ";
msg += gSeed;
msg += " );\n";
for(int x=0; x<xsize; x++)
{
for(int y=0; y<ysize; y++)
{
Location loc=createLocation(x,y);
int t=getTopo(loc);
int v=getVeg(loc);
if(v == 0){v = 1;}
if( (gTopo[x][y]!=t) || (gVeg[x][y]!=v))
{
msg += "setTerrain(createLocation(";
msg += x;
msg += ",";
msg += y;
msg += "),";
msg += t;
msg += ",";
msg += v;
msg += ");\n";
}
}
}
statusMsg(nullPlayer,msg);
}
void onNewRound(){
createEntity("Light of Day",-1,-1,gPlayer);
}