Sylv5

//evil bunderbuss
#include 159

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

void reset()
{
	gNextScript = 291;
	commonReset();
	setMapSeed(30448);
	setTerrain(createLocation(0, 3), 1, 0);
	setTerrain(createLocation(1, 3), 1, 0);
	setTerrain(createLocation(2, 4), 1, 0);
	setTerrain(createLocation(3, 2), 2, 3);
	setTerrain(createLocation(3, 3), 1, 0);
	setTerrain(createLocation(4, 3), 1, 0);
	setTerrain(createLocation(8, 1), 2, 3);
	setTerrain(createLocation(8, 2), 1, 0);
	setTerrain(createLocation(8, 3), 1, 0);
	setTerrain(createLocation(9, 1), 2, 2);
	setTerrain(createLocation(10, 4), 5, 2);
	setTerrain(createLocation(10, 1), 2, 2);
	setTerrain(createLocation(11, 1), 2, 2);
	setTerrain(createLocation(11, 2), 2, 2);
	setTerrain(createLocation(12, 4), 1, 0);

	gHall = createEntity("Dwarven Hall", 10, 2, gAIPlayer);
	gSquad = createEntity("Blunderbuss Squad", 10, 1, gAIPlayer);

	gHumanPlayer.addToHand("Grove");
	gHumanPlayer.addToHand("Thistle Falcon");
	gHumanPlayer.addToHand("Tangler");
	gHumanPlayer.addToHand("Woodland Spies");
	gHumanPlayer.addToHand("Emerald Spring");
	gHumanPlayer.addToHand("Ascent");
	gHumanPlayer.addToHand("Entangle");
	gHumanPlayer.addToDeck("Thistle Falcon", 1);
	gHumanPlayer.addToDeck("Grove", 2);
	gHumanPlayer.addToDeck("Treeherd", 3);
	gHumanPlayer.addToDeck("Emerald Spring", 4);
	gHumanPlayer.addToDeck("Ascent", 5);

	gAIPlayer.addToHand("Dwarven Hall");
	gAIPlayer.addToHand("Craig Scout");
	gAIPlayer.addToHand("Home Guard");
	gAIPlayer.addToHand("Dwarven Warrior");
	gAIPlayer.addToHand("Manipulation");
	gAIPlayer.addToDeck("Dire Cave Cricket", 1);
	gAIPlayer.addToDeck("Craig Scout", 2);
	gAIPlayer.addToDeck("Dire Cave Cricket", 3);
	gAIPlayer.addToDeck("Dwarven Hall", 4);

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

		DlgBox box = createDialog("Victory!", "Congratulations, you passed the fifth 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] && !gShown[4] && gHumanPlayer.canSee(createLocation(8, 1)))
		return (2);
	if (gShown[2] && !gShown[3]) return (3);
	if (!gShown[4] && !gShown[2] && gHumanPlayer.canSee(createLocation(10, 4)))
		return (4);
	if (gShown[4] && !gShown[5]) return (5);
	if (!gShown[6] && gHumanPlayer.canSee(createLocation(8, 1)) && gHumanPlayer.canSee(createLocation(10, 4)))
		return (6);
	return (NUM_BLERBS - 1); // nothing
}

void showInfo()
{
	//statusMsg(nullPlayer,"showInfo");
	int index = getNextDialog();
	gShown[index] = true;
	switch (index)
	{
	case 0:
	{
		string msg = "These lands are controlled by Mountain Folk forces, one of our scouts saw a {C,Blunderbuss Squad} near their base.";
		infoBox("Mission 5.", msg , true, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 1:
	{
		string msg = "Use {C,Woodland Spies} enchantment to look at the enemy base.";
		infoBox("", msg, false, nullEntity, nullCard, createLocation(10, 1), nullPlayer, false, 0);
	}
	break;
	case 2:
	{
		string msg = "The {C,Blunderbuss Squad} will not be able to pass through this swamp - to enter this location creatures needs a minimum speed of 3, and his speed is only 2.";
		infoBox("", msg , true, nullEntity, nullCard, createLocation(8, 1), nullPlayer, false, 0);
	}
	break;
	case 3:
	{
		string msg = "It seems the Blunderbuss Squad might not be a danger to you, unless you find yourself near the enemy base. Try to view the area adjacent to the enemy base area to make sure. Do not forget to keep out of range of the enemy.";
		infoBox("", msg , false, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 4:
	{
		string msg = "Blunderbuss Squad will not be able to pass this mountain - to enter this location creatures needs a minimum speed of 3, and his speed is only 2.";
		infoBox("", msg, true, nullEntity, nullCard, createLocation(10, 4), nullPlayer, false, 0);
	}
	break;
	case 5:
	{
		string msg = "It seems the Blunderbuss Squad might not be a danger to you, unless you find yourself near the enemy base. Try to view the area adjacent to the enemy base area to make sure. Do not forget to keep out of range of the enemy.";
		infoBox("", msg , false, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	case 6:
	{
		string msg = "As expected, the Blunderbuss Squad poses no danger, now you can easily build by one of the Flux Well that are difficult for the enemy to reach. Do not forget to prevent attempts to destroy your construction site.";
		infoBox("", msg , false, nullEntity, nullCard, nullLocation, nullPlayer, false, 0);
	}
	break;
	}
}