Sylv1

// spring building
#include 159

Entity gGrove;
Entity gGraveyard;
Entity gFlux;
Entity gZombie;
int gInfoIndex;

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


void reset()
{
	gNextScript = 286;
	commonReset();
	setMapSeed(29095);
	setTerrain(createLocation(1, 0), 5, 2);
	setTerrain(createLocation(2, 7), 5, 2);
	setTerrain(createLocation(6, 3), 2, 2);

	gGrove = createEntity("Grove", 0, 1, gHumanPlayer);
	gGraveyard = createEntity("Graveyard", 8, 1, gAIPlayer);
	gZombie = createEntity("Zombie", 7, 1, gAIPlayer);

	gHumanPlayer.addToHand("Grove");
	gHumanPlayer.addToHand("Elven Scout");
	gHumanPlayer.addToHand("Tenderfoot Archer");
	gHumanPlayer.addToHand("Emerald Spring");
	gHumanPlayer.addToDeck("Elven Scout", 1);
	gHumanPlayer.addToDeck("Tenderfoot Archer", 2);
	gHumanPlayer.addToDeck("Elven Scout", 3);
	gHumanPlayer.addToDeck("Tenderfoot Archer", 4);

	gAIPlayer.addToHand("Graveyard");
	gAIPlayer.addToHand("Zombie");
	gAIPlayer.addToHand("Lysis");
	gAIPlayer.addToHand("Bloodling");
	gAIPlayer.addToDeck("Graveyard", 12);
	gAIPlayer.addToDeck("Bloodling", 10);
	gAIPlayer.addToDeck("Hell Cat", 11);
	gAIPlayer.addToDeck("Medium of the 3rd Circle", 13);

	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() + 3);
	gHumanPlayer.addFlux(-gHumanPlayer.getFlux() + 3);
	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) < 1)
			saveData(gHumanPlayer, 0, 1);
		gFinished = true;

		DlgBox box = createDialog("Victory!", "Congratulations, you passed the first mission. Keep it up.");
		box.addOption("Play Again", "", 3);
		box.addOption("Next Scenario", "", 2);
		box.show(gHumanPlayer);
	}
	else if (gAIPlayer.getGlory() > 2 || !gGrove.doesExist())
	{
		gFinished = true;
		DlgBox box = createDialog("", "You lost. Your enemy reached 4 Glory. That's ok, you can just try again. Remember you must capture that right Flux Well.");
		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(gFlux.getLoc()))
		return (2);
	if (!gShown[3] && gHumanPlayer.canSee(gZombie.getLoc()) && gZombie.isDim())
		return (3);
	if (!gShown[4] && gShown[3])
		return (4);
	return (NUM_BLERBS - 1); // nothing
}

void showInfo()
{
	//statusMsg(nullPlayer,"showInfo");
	int index = getNextDialog();
	gShown[index] = true;
	switch (index)
	{
	case 0:
	{
		string msg = "Often sylvan have at their disposal a large number of low-cost and mobile creatures, allowing them to control most of the map at the beginning of the game.";
		infoBox("Mission 1.", msg, true, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 1:
	{
		string msg = "Try to explore the right part of the map, maybe there will be a good place to build {C,Emerald Spring}.";
		infoBox("", msg  , false, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 2:
	{
		string msg = "This place looks good, build {C,Emerald Spring} near this {C,Flux Well}.";
		infoBox("", msg , false, nullEntity, nullCard, createLocation(1, 7), nullPlayer, false, 0);
	}
	break;
	case 3:
	{
		string msg = "{C,Zombie} is stronger that your {C,Elven Scout} or {C,Tenderfoot Archer}, but you can try to attack him when zombie dimmed and not get a retaliatory strike at this turn.";
		infoBox("", msg , false, nullEntity, nullCard, gZombie.getLoc(), nullPlayer, false, 0);

	}
	break;
	case 4:
	{
		string msg = "Try to opt for more impassable locations when moving your creatures, there the enemy will be harder to reach and attack you.";
		infoBox("", msg , false, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	}

}