MF3

//alternative flux
#include 159

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

void reset()
{
	gNextScript = 421;
	commonReset();

	setMapSeed(21524);
	setTerrain(createLocation(3, 2), 1, 1);
	setTerrain(createLocation(3, 3), 1, 1);
	setTerrain(createLocation(4, 0), 1, 1);
	setTerrain(createLocation(4, 1), 1, 1);
	setTerrain(createLocation(5, 0), 4, 2);
	setTerrain(createLocation(5, 1), 4, 2);


	gHumanPlayer.addToHand("Dwarven Hall");
	gHumanPlayer.addToHand("Manipulation");
	gHumanPlayer.addToHand("Ord Stone");
	gHumanPlayer.addToHand("Apprentice Timesap");
	gHumanPlayer.addToHand("Rune of Shielding");
	gHumanPlayer.addToHand("Iron Gate");
	gHumanPlayer.addToDeck("Craig Scout", 1);
	gHumanPlayer.addToDeck("Dwarven Hall", 2);
	gHumanPlayer.addToDeck("Earthworks", 3);
	gHumanPlayer.addToDeck("Apprentice Timesap", 4);
	gHumanPlayer.addToDeck("Dwarven Warrior", 5);
	gHumanPlayer.addToDeck("Dwarven Hall", 6);
	gHumanPlayer.addToDeck("Apprentice Timesap", 7);

	gAIPlayer.addToHand("Grove");
	gAIPlayer.addToHand("Elven Scout");
	gAIPlayer.addToHand("Tenderfoot Archer");
	gAIPlayer.addToHand("Treeherd");
	gAIPlayer.addToHand("Thistle Falcon");
	gAIPlayer.addToHand("Elven Scout");
	gAIPlayer.addToHand("Emerald Spring");
	gAIPlayer.addToDeck("Elven Scout", 1);
	gAIPlayer.addToDeck("Grove", 2);
	gAIPlayer.addToDeck("Dellenari Beastmaster", 3);
	gAIPlayer.addToDeck("Bindweed Poultice", 4);
	gAIPlayer.addToDeck("Dellenari Beastmaster", 5);
	gAIPlayer.addToDeck("Bindweed Poultice", 6);
	gAIPlayer.addToDeck("Dellenari Beastmaster", 7);


	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 (player == gHumanPlayer)
		showInfo();
}

int getNextDialog()
{
	if (!gShown[0]) return (0);
	if (!gShown[1]) return (1);
	if (!gShown[2]) return (2);
	return (NUM_BLERBS - 1); // nothing
}

void showInfo()
{
	//statusMsg(nullPlayer,"showInfo");
	int index = getNextDialog();
	gShown[index] = true;
	switch (index)
	{
	case 0:
	{
		Card card = gHumanPlayer.getHandCard(2);
		string msg = "This time you don't have any cheap creatures in your starting hand. But you can get advantage with {C,Ord Stone}";
		infoBox("Mission 3.", msg , true, nullEntity, card, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 1:
	{
		Card card = gHumanPlayer.getHandCard(4);
		string msg = "Also you have {C,Rune of Shielding} that can protect your creatures from weak sylvan forces.";
		infoBox("", msg, true, nullEntity, card, nullLocation, nullPlayer, false, 0);
	}
	break;

	case 2:
	{
		Card card = gHumanPlayer.getHandCard(3);
		string msg = "Casting {C,Rune of Shielding} on {C,Apprentice Timesap} looks like good idea.";
		infoBox("", msg, false, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	}

}