Sylv4

//cricket attack
#include 159

int gInfoIndex;
Entity gHall;
int NUM_BLERBS = 11;
bool[] gShown(NUM_BLERBS);

void reset()
{
	commonReset();
	setMapSeed(25483);
	setTerrain(createLocation(7, 4), 3, 1);
	setTerrain(createLocation(7, 5), 4, 1);
	setTerrain(createLocation(4, 5), 2, 3);

	gHall = createEntity("Dwarven Hall", 7, 6, gAIPlayer);

	gHumanPlayer.addToHand("Grove");
	gHumanPlayer.addToHand("Elven Scout");
	gHumanPlayer.addToHand("Tangler");
	gHumanPlayer.addToHand("Entangle");
	gHumanPlayer.addToHand("Treeherd");
	gHumanPlayer.addToHand("Grove");
	gHumanPlayer.addToDeck("Mis-Scribed Circle", 1);
	gHumanPlayer.addToDeck("Entangle", 2);
	gHumanPlayer.addToDeck("Tenderfoot Archer", 3);
	gHumanPlayer.addToDeck("Emerald Spring", 4);


	gAIPlayer.addToHand("Dwarven Hall");
	gAIPlayer.addToHand("Craig Scout");
	gAIPlayer.addToHand("Ord Stone");
	gAIPlayer.addToHand("Dire Cave Cricket");
	gAIPlayer.addToHand("Manipulation");
	gAIPlayer.addToDeck("Dire Cave Cricket", 3);
	gAIPlayer.addToDeck("Craig Scout", 2);
	gAIPlayer.addToDeck("Dire Cave Cricket", 1);

	createEntity("Flux Well", createLocation(1, 1));
	createEntity("Flux Well", createLocation(1, 6));
	createEntity("Flux Well", createLocation(7, 1));
	createEntity("Flux Well", createLocation(7, 6));

	for (int n = 0; n < NUM_BLERBS; n++) gShown[n] = false;

	gAIPlayer.addFlux(-gAIPlayer.getFlux() + 3);
	gHumanPlayer.addFlux(-gHumanPlayer.getFlux() + 10);
	gAIPlayer.addGlory(-gAIPlayer.getGlory());
	gHumanPlayer.addGlory(-gHumanPlayer.getGlory());

	fogMap();
	lightFog(gHumanPlayer, 0, 0, 1, 5);
	lightFog(gAIPlayer, 4, 0, 8, 7);

	wipeEffect();
	showInfo();

}

void onNewRound()
{
	if (gHumanPlayer.getGlory() >= 4)
	{
		if (loadData(gHumanPlayer, 0) < 4)
			saveData(gHumanPlayer, 0, 4);
		gFinished = true;

		DlgBox box = createDialog("Victory!", "Congratulations, you passed the fourth mission. Now you can start the second part of the campaign.");
		box.addOption("Play Again", "", 3);
		box.addOption("Finish", "", 4);
		box.show(gHumanPlayer);
		endGame(gHumanPlayer);
	}
	else if (gAIPlayer.getGlory() > 2)
	{
		gFinished = true;
		DlgBox box = createDialog("", "You lost. Your enemy reached 4 Glory. That's ok you can just try again.");
		box.addOption("Try Again", "", 3);
		box.show(gHumanPlayer);
	}
}
void onPlayersTurn(Player player)
{
	if (player == gHumanPlayer)
		showInfo();
}

int getNextDialog()
{
	if (!gShown[0]) return (0);
	if (!gShown[1]) return (1);
	if (!gShown[2] && gHumanPlayer.canSee(createLocation(4, 5)))
		return (2);

	return (NUM_BLERBS - 1); // nothing
}

void showInfo()
{
	//statusMsg(nullPlayer,"showInfo");
	int index = getNextDialog();
	gShown[index] = true;
	switch (index)
	{
	case 0:
	{
		string msg = "While you was fighting with the Dark Legion forces one of the Dwarf clans released some {C,Dire Cave Cricket}s near your base. They do not look friendly.";
		infoBox("Mission 4.", msg , true, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 1:
	{
		string msg = "In this mission we have the restraining {C,Entangle} enchantment, also in your disposal is a {C,Tangler}. Good luck.";
		infoBox("", msg, false, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 2:
	{
		string msg = "This place looks good for the {C,Tangler}. Try to put it there when a dimmed enemy creature is adjacent.";
		infoBox("", msg , false, nullEntity, nullCard, createLocation(4, 5), nullPlayer, false, 0);
	}
	break;
	}

}