MF2

// Earthworks
#include 159

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

void reset()
{
	gNextScript = 420;
	commonReset();
	setMapSeed(2422);

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

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

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

		DlgBox box = createDialog("Victory!", "Congratulations, you passed the second 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(3);
		string msg = "Now you have got {C,Earthworks}, building that can attack enemies with 2 spaces." ;
		infoBox("Mission 2.", msg, true, nullEntity, card, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 1:
	{
		string msg = "With two {C,Craig Scout}s in your hand you can try to capture another flux well with {C,Earthworks}.";
		infoBox("", msg, true, nullEntity, nullCard, createLocation(1, 6), nullPlayer, false, 0);
	}
	break;
	case 2:
	{
		string msg = "{C,Manipulation} and {C,Iron Gate} will help you to finish your constricting building.";
		infoBox("", msg, false, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	}

}