Sylv3

//seedburst + graft
#include 159

Entity gSapling;
Entity gFlux;
Entity gCat1;
Entity gCat2;
int gInfoIndex;

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

void reset()
{
	gNextScript = 288;
	commonReset();
	setMapSeed(20839);

	gotUnit = false;
	gHumanPlayer.addToHand("Grove");
	gHumanPlayer.addToHand("Elven Scout");
	gHumanPlayer.addToHand("Graft");
	gHumanPlayer.addToHand("Seedburst");
	gHumanPlayer.addToDeck("Tenderfoot Archer", 1);

	gAIPlayer.addToHand("Graveyard");
	gAIPlayer.addToHand("Zombie");
	gAIPlayer.addToHand("Bloodling");
	gAIPlayer.addToHand("Hypnotic Banshee");

	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) < 3)
			saveData(gHumanPlayer, 0, 3);
		gFinished = true;

		DlgBox box = createDialog("Victory!", "Congratulations, you passed the third 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(3, 2)) && !gotUnit)
	{
		gSapling = createEntity("Sapling", 3, 2, gHumanPlayer);
		gCat1 = createEntity("Hell Cat", 3, 3, gAIPlayer);
		gCat2 = createEntity("Hell Cat", 3, 1, gAIPlayer);
		gotUnit = true;
		gAIPlayer.addFlux(-gAIPlayer.getFlux());
		showInfo();
	}
	if (player == gHumanPlayer)
		showInfo();
}

int getNextDialog()
{
	if (!gShown[0]) return (0);
	if (!gShown[1]) return (1);
	if (!gShown[2] && gotUnit)
		return (2);
	if (!gShown[3] && gSapling.getCurHealth() < 1 && gotUnit)
		return (3);

	return (NUM_BLERBS - 1); // nothing
}

void showInfo()
{
	//statusMsg(nullPlayer,"showInfo");
	int index = getNextDialog();
	gShown[index] = true;
	switch (index)
	{
	case 0:
	{
		string msg = "Your army has suffered heavy losses, but the army of the enemy is also significantly thinned.";
		infoBox("Mission 3.", msg , true, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 1:
	{
		string msg = "You have only a couple of cards, but they may be sufficient to break the remnants of the enemy, you just need to find a {C,Sapling} or {C,Seedling}";
		infoBox("", msg, false, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 2:
	{
		string msg = "See, this {C,Sapling} still fighting heroically, but he could not stand against superior enemy forces.";
		infoBox("", msg, false, nullEntity, nullCard, gSapling.getLoc(), nullPlayer, false, 0);
	}
	break;
	case 3:
	{
		string msg = "Your {C,Sapling} cannot be rescued, you have to cast a {C,Seedburst} on it.";
		infoBox("", msg , false, nullEntity, nullCard, gSapling.getLoc(), nullPlayer, false, 0);
	}
	break;
	}

}