Rem Level 139 (level1)

SET_GENERATE_SPEED(400)

MAX_CREATURES(PLAYER0,7)

START_MONEY(PLAYER0,2500)

ADD_CREATURE_TO_POOL(FLY,3)
ADD_CREATURE_TO_POOL(BUG,12)

CREATURE_AVAILABLE(PLAYER0,FLY,1,1)

ROOM_AVAILABLE(PLAYER0,TREASURE,1,1)

MAGIC_AVAILABLE(PLAYER0,POWER_HAND,1,1)
MAGIC_AVAILABLE(PLAYER0,POWER_SLAP,1,1)

CREATURE_AVAILABLE(PLAYER_GOOD,TUNNELLER,1,1)
CREATURE_AVAILABLE(PLAYER_GOOD,THIEF,1,1)
CREATURE_AVAILABLE(PLAYER_GOOD,KNIGHT,1,1)

SET_CREATURE_FEAR(TUNNELLER,0)
SET_CREATURE_FEAR(THIEF,0)
SET_CREATURE_FEAR(KNIGHT,0)

CREATE_PARTY(KNIGHT)
ADD_TO_PARTY(KNIGHT,KNIGHT,1,1000,ATTACK_ENEMIES,0)

SET_CREATURE_MAX_LEVEL(PLAYER_GOOD,KNIGHT,1)
SET_CREATURE_MAX_LEVEL(PLAYER_GOOD,THIEF,1)
SET_CREATURE_MAX_LEVEL(PLAYER_GOOD,TUNNELLER,1)

SET_CREATURE_STRENGTH(KNIGHT,30)
SET_CREATURE_ARMOUR(KNIGHT,30)
SET_CREATURE_STRENGTH(TUNNELLER,20)
SET_CREATURE_ARMOUR(TUNNELLER,20)


REM		PLAYER0 FLAG0	=	1	Tresure room >= 9
REM		PLAYER1	FLAG0	=	1	gold mined   > 0
REM		PLAYER0	FLAG1	=	1	tresure room >9 & gold mined > 0 & gold mined > 1000 & gold mined > 5000
REM								gold mined > 90000
REM		PLAYER0	FLAG0	=	3	lair > 9
REM		PLAYER0 FLAG4	=	4



IF(PLAYER0, GAME_TURN > 20)
rem CREATE_TEXT(1, 2)
	DISPLAY_OBJECTIVE(2,PLAYER0)
	TUTORIAL_FLASH_BUTTON(6,-1)
	IF(PLAYER0,TREASURE>=1)
		IF(PLAYER0, GAME_TURN > 175)
rem			CREATE_TEXT(32, 3)
			DISPLAY_INFORMATION(3,PLAYER0)
		ENDIF
	ENDIF
ENDIF

IF(PLAYER0, GAME_TURN > 125)
rem CREATE_TEXT(26, 1)
	DISPLAY_INFORMATION(1,PLAYER0)
ENDIF

IF(PLAYER0,TREASURE >= 9)
	rem CREATE_TEXT(2, 4)
	DISPLAY_OBJECTIVE(4,PLAYER0)
	SET_FLAG(PLAYER0, FLAG0, 1)
ENDIF

IF(PLAYER0,TOTAL_GOLD_MINED>0)
	SET_FLAG(PLAYER1,FLAG0,1)
ENDIF

IF(PLAYER0,FLAG0==1)
	IF(PLAYER1,FLAG0==1)
		IF(PLAYER0,TOTAL_GOLD_MINED >= 1000)
rem			CREATE_TEXT(3, 5)
			DISPLAY_INFORMATION(5,PLAYER0)
 			IF(PLAYER0,TOTAL_GOLD_MINED >= 5000)
rem				CREATE_TEXT(20, 6)
				DISPLAY_INFORMATION(6,PLAYER0)
				IF(PLAYER0,TOTAL_GOLD_MINED >= 9000)
					SET_FLAG(PLAYER0,FLAG1,1)
rem					CREATE_TEXT(4, 7)
					DISPLAY_OBJECTIVE(7,PLAYER0)
					ROOM_AVAILABLE(PLAYER0,LAIR,1,1)
					TUTORIAL_FLASH_BUTTON(2,-1)
					TUTORIAL_FLASH_BUTTON(8,-1)
					IF(PLAYER0,LAIR >= 9)
rem						CREATE_TEXT(5, 8)
						DISPLAY_OBJECTIVE(8,PLAYER0)
						SET_FLAG(PLAYER0, FLAG0, 3)
					ENDIF
				ENDIF
			ENDIF
		ENDIF
	ENDIF
ENDIF


REM		PLAYER0	FLAG1	=	1	if tresure room not 9 & gold mined >0 & gold > 1000 & gold > 5000 & gold > 9000

IF(PLAYER0,FLAG0==0)
	IF(PLAYER1,FLAG0==1)
rem		CREATE_TEXT(16, 9)
		DISPLAY_OBJECTIVE(9,PLAYER0)
		IF(PLAYER0,TOTAL_GOLD_MINED >= 1000)
rem			CREATE_TEXT(20, 10)
			DISPLAY_INFORMATION(10,PLAYER0)
			IF(PLAYER0,TOTAL_GOLD_MINED >= 5000)
rem				CREATE_TEXT(3, 11)
				DISPLAY_INFORMATION(11,PLAYER0)
				IF(PLAYER0,TOTAL_GOLD_MINED >= 9000)
					SET_FLAG(PLAYER0,FLAG1,1)
rem					CREATE_TEXT(30, 12)
					DISPLAY_OBJECTIVE(12,PLAYER0)
				ENDIF
			ENDIF
		ENDIF
	ENDIF				
ENDIF

IF(PLAYER0,TOTAL_CREATURES >= 1)
	IF(PLAYER0,TREASURE >= 9)
		ROOM_AVAILABLE(PLAYER0,LAIR,1,1)
	ENDIF
ENDIF

REM *** BUILT LAIR ***
IF (PLAYER0, FLAG0 == 3)
	IF(PLAYER0,TOTAL_CREATURES >= 1)
rem		CREATE_TEXT(6, 13)
		DISPLAY_OBJECTIVE(13,PLAYER0)
		CREATURE_AVAILABLE(PLAYER0,FLY,1,0)
		CREATURE_AVAILABLE(PLAYER0,BUG,1,1)

		IF(PLAYER0,BUG >= 1)
rem			CREATE_TEXT(7, 14)
			DISPLAY_OBJECTIVE(14,PLAYER0)
			CREATURE_AVAILABLE(PLAYER0,FLY,1,1)
			ROOM_AVAILABLE(PLAYER0,GARDEN,1,1)
			TUTORIAL_FLASH_BUTTON(7,-1)
			IF(PLAYER0,GARDEN >= 9)
				
rem				CREATE_TEXT(8, 15)
				DISPLAY_OBJECTIVE(15,PLAYER0)
				MAGIC_AVAILABLE(PLAYER0,POWER_IMP,1,1)
				TUTORIAL_FLASH_BUTTON(3,-1)
				TUTORIAL_FLASH_BUTTON(21,-1)
				SET_TIMER(PLAYER0,TIMER1)
				SET_FLAG(PLAYER0, FLAG0, 4)
			ENDIF
		ENDIF
	ENDIF
ENDIF

REM *** BUILT GARDEN ***
IF (PLAYER0, FLAG0 == 4)
	IF(PLAYER0,TOTAL_CREATURES >= 7)
		SET_FLAG(PLAYER0, FLAG0, 5)
	ENDIF
ENDIF

REM *** HAS EIGHT OR MORE CREATURES ***
IF (PLAYER0, FLAG0 == 5)
	IF(PLAYER0,TIMER1 >= 600)
rem		CREATE_TEXT(30, 16)
		DISPLAY_INFORMATION(16,PLAYER0)
		TUTORIAL_FLASH_BUTTON(5,-1)
			IF(PLAYER0,TIMER1 >= 800)
			ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,1,DUNGEON,0,1,200)
			ADD_TUNNELLER_TO_LEVEL(PLAYER_GOOD,1,DUNGEON,0,1,200)
rem			CREATE_TEXT(12, 17)
			DISPLAY_OBJECTIVE(17,PLAYER0)
			TUTORIAL_FLASH_BUTTON(37,-1)
			IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
				TUTORIAL_FLASH_BUTTON(0,0)
rem				CREATE_TEXT(13, 18)
				DISPLAY_OBJECTIVE(18,PLAYER0)
				SET_TIMER(PLAYER0,TIMER2)
				SET_FLAG(PLAYER0, FLAG0, 6)
			ENDIF
		ENDIF
	ENDIF
ENDIF

REM *** HAS WON FIRST BATTLE ***
IF (PLAYER0, FLAG0 == 6)
	IF(PLAYER0,TIMER2 >= 500)
		IF(PLAYER0,TOTAL_CREATURES >= 7)
			ADD_PARTY_TO_LEVEL(PLAYER_GOOD,KNIGHT,1,1)
rem			CREATE_TEXT(14, 19)
			DISPLAY_OBJECTIVE(19,PLAYER)
			set_flag(player0, FLAG0, 7)
		ENDIF
	ENDIF							
ENDIF								

REM *** END LEVEL CHECK - DOESNT NEED A FLAG AS THIRD BATTLE IS ALWAYS KNIGHT ***
REM *** HOWEVER IT MAY BE BETTER TO USE THE FLAG AND THEN TEST FOR PLAYER_GOOD, TOTAL_CREATURES == 0 ***
IF(PLAYER0, FLAG0 == 7)
	IF(PLAYER_GOOD, TOTAL_CREATURES == 0)
rem		CREATE_TEXT(15, 20)
		DISPLAY_OBJECTIVE(20,PLAYER0)
		WIN_GAME
	endif
ENDIF


IF(PLAYER0,TOTAL_IMPS==0)
	rem CREATE_TEXT(25, 21)
	DISPLAY_INFORMATION(21,PLAYER0)
	MAGIC_AVAILABLE(PLAYER0,POWER_IMP,1,1)
	TUTORIAL_FLASH_BUTTON(3,-1)
	TUTORIAL_FLASH_BUTTON(21,-1)
ENDIF
