MF1

// MF begin
#include 159

Entity gGrove;
Entity gHall;
Entity gScout;
int gInfoIndex;

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


void reset()
{
	gNextScript = 419;
	commonReset();
	setMapSeed(22343);
	setTerrain(createLocation(2, 2), 5, 2);
	setTerrain(createLocation(2, 3), 5, 3);
	setTerrain(createLocation(4, 0), 5, 1);
	setTerrain(createLocation(4, 2), 3, 2);
	setTerrain(createLocation(5, 1), 3, 2);
	setTerrain(createLocation(7, 2), 5, 2);

	gGrove = createEntity("Grove", 7, 1, gAIPlayer);
	gHall = createEntity("Dwarven Hall", 0, 1, gHumanPlayer);

	gHumanPlayer.addToHand("Dwarven Hall");
	gHumanPlayer.addToHand("Dwarven Warrior");
	gHumanPlayer.addToHand("Craig Scout");
	gHumanPlayer.addToHand("Dwarven Warrior");
	gHumanPlayer.addToHand("Craig Scout");
	gHumanPlayer.addToDeck("Dwarven Warrior", 1);
	gHumanPlayer.addToDeck("Dwarven Hall", 2);
	gHumanPlayer.addToDeck("Craig Scout", 3);
	gHumanPlayer.addToDeck("Craig Scout", 4);
	gHumanPlayer.addToDeck("Dwarven Warrior", 5);

	gAIPlayer.addToHand("Grove");
	gAIPlayer.addToHand("Treeherd");
	gAIPlayer.addToHand("Elven Scout");
	gAIPlayer.addToHand("Sapling");
	gAIPlayer.addToHand("Sapling");
	gAIPlayer.addToDeck("Grove", 1);
	gAIPlayer.addToDeck("Elven Scout", 2);
	gAIPlayer.addToDeck("Treeherd", 3);
	gAIPlayer.addToDeck("Elven Scout", 4);

	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() + 1);
	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 || !gGrove.doesExist())
	{
		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)
	{
		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 (!gotUnit)
	{
		gScout = createEntity("Craig Scout", 0, 3, gHumanPlayer);
		gotUnit = true;
	}
	if (player == gHumanPlayer)
		showInfo();
}

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

	return (NUM_BLERBS - 1); // nothing
}

void showInfo()
{
	//statusMsg(nullPlayer,"showInfo");
	int index = getNextDialog();
	gShown[index] = true;
	switch (index)
	{
	case 0:
	{
		Card card = gHumanPlayer.getHandCard(1);
		string msg =  "{C,Dwarven Warrior} is Mountain Folk creature with 1 flux cost and 1 damage and health.";
		infoBox("Mission 1.", msg, true, nullEntity, card, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 1:
	{
		string msg =  "{C, Craig Scout} cost 2 flux, but he is faster, have 4 vision and {A,Mountainstride}. Advantage of vision and speed may help you to attack enemy dimmed creature, so your Craig Scout will not take any damage.";
		infoBox("", msg  , true, nullEntity, nullCard, gScout.getLoc(), nullPlayer, false, 0);
	}
	break;
	case 2:
	{
		string msg =  "Your main task is to find and destroy the enemy base, but you should destroy the enemy forces first.";
		infoBox("", msg  , false, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 3:
	{
		string msg = "This is a enemy base, destroy it to win.";
		infoBox("", msg , false, nullEntity, nullCard, createLocation(7, 1), nullPlayer, false, 0);
	}
	break;
	}

}