Map Editor

NOT A GAME. Tool for Script Editors.

int gSeed;
Player nullPlayer;
Player gPlayer;
int[][] gTopo;
int[][] gVeg;

void configGame()
{
	gTopo.resize(12);
	gVeg.resize(12);
	for(int n=0; n<12; n++)
	{
		gTopo[n].resize(13);
		gVeg[n].resize(13);
	}

	setNumPlayers(1);
	reseed();
	dontNeedDecks();
}

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");
	for(int n=0; n<4; n++) gPlayer.addToHand("Naturescaping");
	createEntity("Grove",0,0,gPlayer);
	Entity asg=createEntity("Astridian Geographic Society",0,1,gPlayer);
	createEntity("Trade Routes",-1,-1,gPlayer);
	enchantEntity(asg,"Vines of Dellen",gPlayer);
	gPlayer.addFlux(300);

	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;
	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(hs<5) 
		gPlayer.addToHand("Naturescaping");
	if(!hasWarren)
	{
		gPlayer.addToHand("Warren");
		reseed();
	}
	if(!hasGrave)
	{
		gPlayer.addToHand("Graveyard");
		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<12; x++)
	{
		for(int y=0; y<13; 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<12; x++)
	{
		for(int y=0; y<13; y++)
		{
			Location loc=createLocation(x,y);
			int t=getTopo(loc);
			int v=getVeg(loc);
			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);
}