Sylv2

// to forest fot treeherts
#include 159

Entity gFlux;
Entity gTreeherd;
int gInfoIndex;

int NUM_BLERBS = 11;
bool[] gShown(NUM_BLERBS);
bool gotUnit;

void reset()
{
	gNextScript = 287;
	commonReset();
	setMapSeed(15849);
	setTerrain(createLocation(6, 6), 3, 3);
	setTerrain(createLocation(6, 7), 3, 3);
	setTerrain(createLocation(7, 5), 3, 3);
	setTerrain(createLocation(7, 6), 4, 3);
	setTerrain(createLocation(7, 7), 4, 3);
	setTerrain(createLocation(8, 6), 3, 3);
	setTerrain(createLocation(8, 7), 3, 3);

	gHumanPlayer.addToHand("Grove");
	gHumanPlayer.addToHand("Elven Scout");
	gHumanPlayer.addToHand("Bindweed Poultice");
	gHumanPlayer.addToHand("Treeherd");
	gHumanPlayer.addToHand("Sapling");
	gHumanPlayer.addToHand("Treeherd");
	gHumanPlayer.addToDeck("Emerald Spring", 1);
	gHumanPlayer.addToDeck("Treeherd", 2);
	gHumanPlayer.addToDeck("Sapling", 3);
	gHumanPlayer.addToDeck("Grove", 4);

	gAIPlayer.addToHand("Graveyard");
	gAIPlayer.addToHand("Hypnotic Banshee");
	gAIPlayer.addToHand("Crypt Doctor");
	gAIPlayer.addToHand("Lysis");
	gAIPlayer.addToHand("Hell Cat");
	gAIPlayer.addToDeck("Graveyard", 12);
	gAIPlayer.addToDeck("Hell Cat", 10);
	gAIPlayer.addToDeck("Zombie", 11);
	gAIPlayer.addToDeck("Hell Cat", 13);

	gotUnit = false;

	createEntity("Flux Well", createLocation(1, 1));
	gFlux = 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() + 10);
	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) < 2)
			saveData(gHumanPlayer, 0, 2);
		gFinished = true;

		DlgBox box = createDialog("Victory!", "Congratulations, you passed the second mission. Keep it up.");
		box.addOption("Play Again", "", 3);
		box.addOption("Next Scenario", "", 2);
		box.show(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 (gHumanPlayer.canSee(createLocation(6, 6)) && !gotUnit)
	{
		gTreeherd = createEntity("Treeherd", 6, 6, gHumanPlayer);
		gotUnit = true;
		showInfo();
	}
	if (player == gHumanPlayer)
		showInfo();

}

int getNextDialog()
{
	if (!gShown[0]) return (0);
	if (!gShown[1]) return (1);
	if (!gShown[2] && gHumanPlayer.canSee(createLocation(3, 2)))
		return (2);
	if (!gShown[3] && gHumanPlayer.canSee(createLocation(3, 2)))
		return (3);
	if (!gShown[4] && gHumanPlayer.canSee(createLocation(6, 6)))
		return (4);
	return (NUM_BLERBS - 1); // nothing
}

void showInfo()
{
	//statusMsg(nullPlayer,"showInfo");
	int index = getNextDialog();
	gShown[index] = true;
	switch (index)
	{
	case 0:
	{
		string msg = "Curbing the enemy gave you time to call {C,Treeherd}s to battle, this creature doesn't need a Base to be cast, but requires a forest." ;
		infoBox("Mission 2.", msg, true, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 1:
	{
		string msg = "In this mission you have 2 ways to achieve victory - either earn 6 Glory or destroy the enemy base.";
		infoBox("", msg, false, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 2:
	{
		string msg = "Looks like there are no forests nearby, however there is one in the northeast, send a Scout there.";
		infoBox("", msg, false, nullEntity, nullCard, createLocation(6, 6), nullPlayer, false, 0);
	}
	break;
	case 3:
	{
		string msg = "Somewhere in the northwest is the enemy base, be wary of running too far into uncharted land, you can pointlessly lose your creature.";
		infoBox("", msg, true, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 4:
	{
		string msg = "Here is the forest, now you can cast your {C,Sapling} and {C,Treeherd}.";
		infoBox("", msg, false, nullEntity, nullCard, createLocation(6, 6), nullPlayer, false, 0);
	}
	break;
	}

}