/*
	This file is part of The Adventures of Stickman by Matt Trobaugh, which is dedicated to the public domain under a CC0 Public Domain Dedication. To view a copy of this dedication, visit http://creativecommons.org/publicdomain/zero/1.0/.

	The Adventures of Stickman is built on the Turpidge Game Engine version 1.1 by Matt Trobaugh.
*/

try{



battles = new Battles();


playerPositions = new Array("10-6", "13-5", "7-5", "8-4", "12-4", "11-3", "9-3");
spoils = new Array("Green Potion");

//									(name, playerPositions, spoils)
bunnyBattle = battles.addBattle("Bunny Battle", playerPositions, spoils);
bunnyBattle.recurring = true;

//						(name, x, y)
bunnyBattle.addEnemy("Bunny", 7, 11);
bunnyBattle.addEnemy("Bunny", 10, 12);
bunnyBattle.addEnemy("Bunny", 13, 11);
bunnyBattle.addEnemy("Bunny", 12, 13);
bunnyBattle.addEnemy("Bunny", 8, 13);


playerPositions = new Array("4-5", "4-3", "4-7", "3-4", "3-6", "2-3", "2-6");
spoils = new Array();

//									(name, playerPositions, spoils)
spiderBattle = battles.addBattle("Spider Battle", playerPositions, spoils);

//						(name, x, y)
spiderBattle.addEnemy("Spider", 6, 4);
spiderBattle.addEnemy("Spider", 7, 3);
spiderBattle.addEnemy("Spider", 7, 6);
spiderBattle.addEnemy("Spider", 8, 4);
spiderBattle.addEnemy("Spider", 9, 5);
spiderBattle.addEnemy("Spider", 10, 2);
spiderBattle.addEnemy("Spider", 10, 6);
spiderBattle.addEnemy("Spider", 11, 7);


playerPositions = new Array("10-19", "8-19", "12-19", "9-20", "11-20", "7-20", "13-20");
spoils = new Array("Staff");

//									(name, playerPositions, spoils)
woodsBattle = battles.addBattle("Woods Battle", playerPositions, spoils);

//						(name, x, y)
woodsBattle.addEnemy("Bat", 5, 13);
woodsBattle.addEnemy("Bat", 5, 14);
woodsBattle.addEnemy("Bat", 6, 13);

woodsBattle.addEnemy("Bat", 13, 12);
woodsBattle.addEnemy("Bat", 14, 12);
woodsBattle.addEnemy("Bat", 15, 12);

woodsBattle.addEnemy("Bat", 5, 9);
woodsBattle.addEnemy("Bat", 4, 10);

woodsBattle.addEnemy("Bat", 16, 8);
woodsBattle.addEnemy("Bat", 17, 8);

woodsBattle.addEnemy("Bat", 12, 7);
woodsBattle.addEnemy("Bat", 13, 7);

woodsBattle.addEnemy("Bat", 8, 6);
woodsBattle.addEnemy("Bat", 9, 6);

woodsBattle.addEnemy("Bat", 6, 5);
woodsBattle.addEnemy("Bat", 7, 5);

woodsBattle.addEnemy("Bat", 13, 4);

//						(name, x, y)
woodsBattle.addEnemy("Spider", 16, 14);
woodsBattle.addEnemy("Spider", 8, 15);
woodsBattle.addEnemy("Spider", 11, 13);
woodsBattle.addEnemy("Spider", 8, 11);
woodsBattle.addEnemy("Spider", 9, 9);
woodsBattle.addEnemy("Spider", 13, 10);
woodsBattle.addEnemy("Spider", 4, 7);
woodsBattle.addEnemy("Spider", 10, 4);
woodsBattle.addEnemy("Spider", 16, 6);


playerPositions = new Array("6-12", "6-10", "6-14", "5-11", "5-13", "5-9", "5-15");
spoils = new Array("Battle Axe");

//									(name, playerPositions, spoils)
bridgeBattle = battles.addBattle("Bridge Battle", playerPositions, spoils);

//						(name, x, y)
bridgeBattle.addEnemy("Goblin", 34, 11);
bridgeBattle.addEnemy("Goblin", 33, 12);
bridgeBattle.addEnemy("Goblin", 34, 13);

bridgeBattle.addEnemy("Goblin", 22, 11);
bridgeBattle.addEnemy("Goblin", 22, 12);
bridgeBattle.addEnemy("Goblin", 22, 13);

bridgeBattle.addEnemy("Goblin", 28, 8);
bridgeBattle.addEnemy("Goblin", 28, 9);
bridgeBattle.addEnemy("Goblin", 29, 9);

bridgeBattle.addEnemy("Goblin", 28, 15);
bridgeBattle.addEnemy("Goblin", 28, 16);
bridgeBattle.addEnemy("Goblin", 29, 15);

//						(name, x, y)
bridgeBattle.addEnemy("Bat", 22, 6);
bridgeBattle.addEnemy("Bat", 23, 6);

bridgeBattle.addEnemy("Bat", 11, 19);
bridgeBattle.addEnemy("Bat", 12, 19);

bridgeBattle.onWin = function()
{
	currentLocation.setSpace(35, 12, "#a37547", "", 1);
}


playerPositions = new Array("8-6", "8-8", "8-10", "7-7", "7-9", "9-7", "9-9");
spoils = new Array("Boots of Mobility");

//									(name, playerPositions, spoils)
mansionBattle = battles.addBattle("Mansion Battle", playerPositions, spoils);

//						(name, x, y)
mansionBattle.addEnemy("Voodoo Doll", 4, 3);
mansionBattle.addEnemy("Voodoo Doll", 7, 3);
mansionBattle.addEnemy("Voodoo Doll", 9, 3);
mansionBattle.addEnemy("Voodoo Doll", 12, 3);
mansionBattle.addEnemy("Voodoo Doll", 13, 4);
mansionBattle.addEnemy("Voodoo Doll", 13, 6);
mansionBattle.addEnemy("Voodoo Doll", 13, 8);
mansionBattle.addEnemy("Voodoo Doll", 13, 10);
mansionBattle.addEnemy("Voodoo Doll", 13, 12);
mansionBattle.addEnemy("Voodoo Doll", 12, 13);
mansionBattle.addEnemy("Voodoo Doll", 10, 13);
mansionBattle.addEnemy("Voodoo Doll", 6, 13);
mansionBattle.addEnemy("Voodoo Doll", 4, 13);
mansionBattle.addEnemy("Voodoo Doll", 3, 12);
mansionBattle.addEnemy("Voodoo Doll", 3, 10);
mansionBattle.addEnemy("Voodoo Doll", 3, 8);
mansionBattle.addEnemy("Voodoo Doll", 3, 6);
mansionBattle.addEnemy("Voodoo Doll", 3, 4);


playerPositions = new Array("11-34", "13-34", "15-34", "10-35", "12-35", "14-35", "16-35");
spoils = new Array("Iron Shield");

//									(name, playerPositions, spoils)
castleBattle = battles.addBattle("Castle Battle", playerPositions, spoils);

//						(name, x, y)
castleBattle.addEnemy("Fighter", 10, 24);
castleBattle.addEnemy("Fighter", 11, 24);
castleBattle.addEnemy("Fighter", 12, 24);
castleBattle.addEnemy("Fighter", 13, 24);
castleBattle.addEnemy("Fighter", 14, 24);
castleBattle.addEnemy("Fighter", 15, 24);
castleBattle.addEnemy("Fighter", 16, 24);
castleBattle.addEnemy("Devil", 13, 22);

//						(name, x, y)
castleBattle.addEnemy("Fighter", 8, 14);
castleBattle.addEnemy("Fighter", 9, 14);
castleBattle.addEnemy("Fighter", 10, 14);
castleBattle.addEnemy("Fighter", 11, 14);
castleBattle.addEnemy("Fighter", 12, 14);
castleBattle.addEnemy("Devil", 10, 12);

//						(name, x, y)
castleBattle.addEnemy("Fighter", 14, 14);
castleBattle.addEnemy("Fighter", 15, 14);
castleBattle.addEnemy("Fighter", 16, 14);
castleBattle.addEnemy("Fighter", 17, 14);
castleBattle.addEnemy("Fighter", 18, 14);
castleBattle.addEnemy("Devil", 16, 12);

castleBattle.onWin = function()
{
	center(13, 4);
	
	// I need a bit of a pause here so the player can see what is happening
	var d1 = new Date();
	var time1 = d1.getTime();
	var d2 = new Date();
	var time2 = d2.getTime();
	
	while(time1 + 500 > time2)
	{
		d2 = new Date();
		time2 = d2.getTime();
	}
	
	// re-set where the drawbridge was up
	currentLocation.setArea(13, 1, 14, 3, "#a37547", "", 1);
	
	// drawbridge down
	currentLocation.setSpace(13, 4, "#009900", "drawbridgeDown1.png", 1);
	currentLocation.setSpace(14, 4, "#009900", "drawbridgeDown2.png", 1);
	currentLocation.setSpace(13, 5, "#0066ff", "drawbridgeDown3.png", 1);
	currentLocation.setSpace(14, 5, "#0066ff", "drawbridgeDown4.png", 1);
	currentLocation.setSpace(13, 6, "#a37547", "drawbridgeDown5.png", 1);
	currentLocation.setSpace(14, 6, "#a37547", "drawbridgeDown6.png", 1);
	
	// reset html
	document.getElementById("13-1").style.backgroundImage = "";
	document.getElementById("14-1").style.backgroundImage = "";
	document.getElementById("13-2").style.backgroundImage = "";
	document.getElementById("14-2").style.backgroundImage = "";
	document.getElementById("13-3").style.backgroundImage = "";
	document.getElementById("14-3").style.backgroundImage = "";
	
	document.getElementById("13-4").style.backgroundImage = "url('images/drawbridgeDown1.png')";
	document.getElementById("14-4").style.backgroundImage = "url('images/drawbridgeDown2.png')";
	document.getElementById("13-5").style.backgroundImage = "url('images/drawbridgeDown3.png')";
	document.getElementById("14-5").style.backgroundImage = "url('images/drawbridgeDown4.png')";
	document.getElementById("13-6").style.backgroundImage = "url('images/drawbridgeDown5.png')";
	document.getElementById("14-6").style.backgroundImage = "url('images/drawbridgeDown6.png')";
	
	// and another brief pause
	d1 = new Date();
	time1 = d1.getTime();
	d2 = new Date();
	time2 = d2.getTime();
	
	while(time1 + 1100 > time2)
	{
		d2 = new Date();
		time2 = d2.getTime();
	}
}


playerPositions = new Array("22-3", "21-4", "23-4", "22-5", "21-6", "23-6", "22-7");
spoils = new Array("Ancient Trident");

//									(name, playerPositions, spoils)
cellarBattle = battles.addBattle("Cellar Battle", playerPositions, spoils);

//						(name, x, y)
cellarBattle.addEnemy("Devil", 12, 9);
cellarBattle.addEnemy("Devil", 8, 5);
cellarBattle.addEnemy("Devil", 16, 5);
cellarBattle.addEnemy("Devil", 8, 13);
cellarBattle.addEnemy("Devil", 16, 13);

//						(name, x, y)
cellarBattle.addEnemy("Imp", 6, 3);
cellarBattle.addEnemy("Imp", 10, 3);
cellarBattle.addEnemy("Imp", 6, 7);
cellarBattle.addEnemy("Imp", 10, 7);

//						(name, x, y)
cellarBattle.addEnemy("Imp", 14, 3);
cellarBattle.addEnemy("Imp", 18, 3);
cellarBattle.addEnemy("Imp", 14, 7);
cellarBattle.addEnemy("Imp", 18, 7);

//						(name, x, y)
cellarBattle.addEnemy("Imp", 6, 11);
cellarBattle.addEnemy("Imp", 10, 11);
cellarBattle.addEnemy("Imp", 6, 15);
cellarBattle.addEnemy("Imp", 10, 15);

//						(name, x, y)
cellarBattle.addEnemy("Imp", 14, 11);
cellarBattle.addEnemy("Imp", 18, 11);
cellarBattle.addEnemy("Imp", 14, 15);
cellarBattle.addEnemy("Imp", 18, 15);


playerPositions = new Array("7-6", "6-7", "8-7", "5-8", "7-8", "6-9", "8-9");
spoils = new Array("Ancient Axe");

//									(name, playerPositions, spoils)
witchBattle = battles.addBattle("Witch Battle", playerPositions, spoils);

//						(name, x, y)
witchBattle.addEnemy("Fighter", 16, 6);
witchBattle.addEnemy("Fighter", 16, 7);
witchBattle.addEnemy("Fighter", 16, 8);
witchBattle.addEnemy("Fighter", 16, 9);
witchBattle.addEnemy("Fighter", 16, 10);

witchBattle.addEnemy("Devil", 19, 8);

//						(name, x, y)
witchBattle.addEnemy("Imp", 19, 6);
witchBattle.addEnemy("Imp", 21, 8);
witchBattle.addEnemy("Imp", 19, 10);

//						(name, x, y)
witchBattle.addEnemy("Fighter", 5, 16);
witchBattle.addEnemy("Fighter", 6, 16);
witchBattle.addEnemy("Fighter", 7, 16);
witchBattle.addEnemy("Fighter", 8, 16);
witchBattle.addEnemy("Fighter", 9, 16);

witchBattle.addEnemy("Devil", 7, 19);

//						(name, x, y)
witchBattle.addEnemy("Imp", 5, 19);
witchBattle.addEnemy("Imp", 9, 19);
witchBattle.addEnemy("Imp", 7, 21);

//						(name, x, y)
witchBattle.addEnemy("Fighter", 23, 20);
witchBattle.addEnemy("Fighter", 24, 19);
witchBattle.addEnemy("Fighter", 25, 18);
witchBattle.addEnemy("Fighter", 26, 17);
witchBattle.addEnemy("Fighter", 27, 16);
witchBattle.addEnemy("Fighter", 28, 15);
witchBattle.addEnemy("Fighter", 29, 14);

witchBattle.addEnemy("Witch", 29, 19);

//						(name, x, y)
witchBattle.addEnemy("Devil", 27, 21);
witchBattle.addEnemy("Devil", 31, 17);

witchBattle.addEnemy("Imp", 29, 17);
witchBattle.addEnemy("Imp", 27, 19);
witchBattle.addEnemy("Imp", 31, 19);
witchBattle.addEnemy("Imp", 29, 21);


playerPositions = new Array("14-44", "16-44", "13-45", "15-45", "17-45", "14-46", "16-46");
spoils = new Array();

//									(name, playerPositions, spoils)
hellBattle = battles.addBattle("Hell Battle", playerPositions, spoils);

hellBattle.addEnemy("The Beast", 15, 1);

//						(name, x, y)
hellBattle.addEnemy("Demon", 11, 7);
hellBattle.addEnemy("Demon", 19, 7);
hellBattle.addEnemy("Demon", 12, 17);
hellBattle.addEnemy("Demon", 18, 17);
hellBattle.addEnemy("Demon", 10, 26);
hellBattle.addEnemy("Demon", 20, 26);
hellBattle.addEnemy("Demon", 13, 34);
hellBattle.addEnemy("Demon", 17, 34);

//						(name, x, y)
hellBattle.addEnemy("Devil", 5, 9);
hellBattle.addEnemy("Devil", 9, 9);
hellBattle.addEnemy("Devil", 5, 13);
hellBattle.addEnemy("Devil", 9, 13);
hellBattle.addEnemy("Imp", 4, 8);
hellBattle.addEnemy("Imp", 6, 8);
hellBattle.addEnemy("Imp", 8, 8);
hellBattle.addEnemy("Imp", 10, 8);
hellBattle.addEnemy("Imp", 4, 10);
hellBattle.addEnemy("Imp", 6, 10);
hellBattle.addEnemy("Imp", 8, 10);
hellBattle.addEnemy("Imp", 10, 10);
hellBattle.addEnemy("Imp", 4, 12);
hellBattle.addEnemy("Imp", 6, 12);
hellBattle.addEnemy("Imp", 8, 12);
hellBattle.addEnemy("Imp", 10, 12);
hellBattle.addEnemy("Imp", 4, 14);
hellBattle.addEnemy("Imp", 6, 14);
hellBattle.addEnemy("Imp", 8, 14);
hellBattle.addEnemy("Imp", 10, 14);

//						(name, x, y)
hellBattle.addEnemy("Devil", 22, 2);
hellBattle.addEnemy("Devil", 26, 2);
hellBattle.addEnemy("Devil", 22, 6);
hellBattle.addEnemy("Devil", 26, 6);
hellBattle.addEnemy("Imp", 21, 1);
hellBattle.addEnemy("Imp", 23, 1);
hellBattle.addEnemy("Imp", 25, 1);
hellBattle.addEnemy("Imp", 27, 1);
hellBattle.addEnemy("Imp", 21, 3);
hellBattle.addEnemy("Imp", 23, 3);
hellBattle.addEnemy("Imp", 25, 3);
hellBattle.addEnemy("Imp", 27, 3);
hellBattle.addEnemy("Imp", 21, 5);
hellBattle.addEnemy("Imp", 23, 5);
hellBattle.addEnemy("Imp", 25, 5);
hellBattle.addEnemy("Imp", 27, 5);
hellBattle.addEnemy("Imp", 21, 7);
hellBattle.addEnemy("Imp", 23, 7);
hellBattle.addEnemy("Imp", 25, 7);
hellBattle.addEnemy("Imp", 27, 7);

//						(name, x, y)
hellBattle.addEnemy("Devil", 5, 37);
hellBattle.addEnemy("Devil", 9, 37);
hellBattle.addEnemy("Imp", 5, 33);
hellBattle.addEnemy("Imp", 9, 33);
hellBattle.addEnemy("Imp", 3, 35);
hellBattle.addEnemy("Imp", 7, 35);
hellBattle.addEnemy("Imp", 11, 35);
hellBattle.addEnemy("Imp", 1, 37);
hellBattle.addEnemy("Imp", 13, 37);
hellBattle.addEnemy("Imp", 3, 39);
hellBattle.addEnemy("Imp", 7, 39);
hellBattle.addEnemy("Imp", 11, 39);
hellBattle.addEnemy("Imp", 5, 41);
hellBattle.addEnemy("Imp", 9, 41);

//						(name, x, y)
hellBattle.addEnemy("Devil", 21, 40);
hellBattle.addEnemy("Devil", 25, 40);
hellBattle.addEnemy("Imp", 21, 36);
hellBattle.addEnemy("Imp", 25, 36);
hellBattle.addEnemy("Imp", 19, 38);
hellBattle.addEnemy("Imp", 23, 38);
hellBattle.addEnemy("Imp", 27, 38);
hellBattle.addEnemy("Imp", 17, 40);
hellBattle.addEnemy("Imp", 29, 40);
hellBattle.addEnemy("Imp", 19, 42);
hellBattle.addEnemy("Imp", 23, 42);
hellBattle.addEnemy("Imp", 27, 42);
hellBattle.addEnemy("Imp", 21, 44);
hellBattle.addEnemy("Imp", 25, 44);

hellBattle.onWin = function(){endGame();};











}
catch(e)
{
	alert("An error has occurred in battles.js\n\n" + e);
}
