MF6

//ancient Indian graveyard
#include 159

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

void reset()
{
	gNextScript = 425;
	commonReset();
	setMapSeed(4238);
	setTerrain(createLocation(3, 4), 5, 3);
	setTerrain(createLocation(4, 4), 5, 3);
	setTerrain(createLocation(4, 3), 4, 3);
	setTerrain(createLocation(2, 5), 4, 3);

	gotUnit = false;

	gHumanPlayer.addToHand("Dwarven Hall");
	gHumanPlayer.addToHand("Ord Stone");
	gHumanPlayer.addToHand("Dwarven Warrior");
	gHumanPlayer.addToHand("Ord Stone");
	gHumanPlayer.addToHand("Volcano");
	gHumanPlayer.addToHand("Shield Warrior");

	gHumanPlayer.addToDeck("Dwarven Hall", 1);
	gHumanPlayer.addToDeck("Volcano", 2);
	gHumanPlayer.addToDeck("Craig Scout", 3);
	gHumanPlayer.addToDeck("Stone Mauler", 4);
	gHumanPlayer.addToDeck("Disenchant", 5);
	gHumanPlayer.addToDeck("Dwarven Hall", 6);
	gHumanPlayer.addToDeck("Axe Captain", 7);
	gHumanPlayer.addToDeck("Stone Mauler", 8);
	gHumanPlayer.addToDeck("Shield Warrior", 9);
	gHumanPlayer.addToDeck("Craig Scout", 10);
	gHumanPlayer.addToDeck("Earthworks", 11);

	gAIPlayer.addToHand("Graveyard");
	gAIPlayer.addToHand("Red Imp");
	gAIPlayer.addToHand("Gather Spirits");
	gAIPlayer.addToHand("Demonic Surge");
	gAIPlayer.addToHand("Dank Pit");
	gAIPlayer.addToHand("Hell Cat");
	gAIPlayer.addToDeck("Graveyard", 1);
	gAIPlayer.addToDeck("Soul Broker", 2);
	gAIPlayer.addToDeck("Demonic Surge", 3);
	gAIPlayer.addToDeck("Medium of the 3rd Circle", 4);
	gAIPlayer.addToDeck("Lysis", 5);
	gAIPlayer.addToDeck("Graveyard", 6);
	gAIPlayer.addToDeck("Hell Cat", 7);
	gAIPlayer.addToDeck("Demonic Surge", 8);
	gAIPlayer.addToDeck("Possession", 9);
	gAIPlayer.addToDeck("Medium of the 3rd Circle", 10);

	createEntity("Flux Well", createLocation(2, 2));
	createEntity("Flux Well", createLocation(2, 10));
	createEntity("Flux Well", createLocation(6, 6));
	createEntity("Flux Well", createLocation(10, 2));
	createEntity("Flux Well", createLocation(10, 10));

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

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

	fogMap();
	lightFog(gHumanPlayer, 0, 0, 2, 5);
	lightFog(gAIPlayer, 7, 0, 12, 11);

	wipeEffect();
	showInfo();

}

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

		DlgBox box = createDialog("Victory!", "Congratulations, you passed the sixth 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, 7)) && !gotUnit)
	{
		gGraveyard = createEntity("Graveyard", 6, 7, gAIPlayer);
		createEntity("Zombie", 5, 6, gAIPlayer);
		createEntity("Zombie", 6, 6, gAIPlayer);
		createEntity("Zombie", 6, 8, gAIPlayer);
		createEntity("Zombie", 5, 7, gAIPlayer);
		createEntity("Zombie", 7, 6, gAIPlayer);
		createEntity("Zombie", 7, 7, gAIPlayer);
		gotUnit = true;
		showInfo();
	}

	if (player == gHumanPlayer)
		showInfo();
}

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

	return (NUM_BLERBS - 1); // nothing
}

void showInfo()
{
	//statusMsg(nullPlayer,"showInfo");
	int index = getNextDialog();
	gShown[index] = true;
	switch (index)
	{
	case 0:
	{
		string msg = "Legends told about ancient Indean graveyard somewhere in this lands. Take care.";
		infoBox("Mission 6.", msg , true, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 1:
	{
		string msg = "Oh! Here is it. Try to get two domain levels and use {C,Volcano} to destroy this {C,Zombie}s.";
		infoBox("", msg, false, nullEntity, nullCard, gGraveyard.getLoc(), nullPlayer, false, 0);
	}
	break;
	case 2:
	{
		string msg = "Also keep in mind, that you should destroy this {C,Graveyard} before enemy get 4 glory.";
		infoBox("", msg, false, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	}
}