REM KDK Level 1

SET_GENERATE_SPEED(400)

MAX_CREATURES(PLAYER0,27)

START_MONEY(PLAYER0,535000)

ADD_CREATURE_TO_POOL(FLY,18)
ADD_CREATURE_TO_POOL(TROLL,4)
ADD_CREATURE_TO_POOL(BUG,7)

CREATURE_AVAILABLE(PLAYER0,TROLL,1,1)
CREATURE_AVAILABLE(PLAYER0,BUG,1,1)
CREATURE_AVAILABLE(PLAYER0,FLY,1,1)

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

ROOM_AVAILABLE(PLAYER0,LAIR,1,1)
ROOM_AVAILABLE(PLAYER0,TRAINING,1,1)
ROOM_AVAILABLE(PLAYER0,TREASURE,1,1)
ROOM_AVAILABLE(PLAYER0,WORKSHOP,1,1)
ROOM_AVAILABLE(PLAYER0,GARDEN,1,1)

TRAP_AVAILABLE(PLAYER0,LIGHTNING,1,0)
TRAP_AVAILABLE(PLAYER0,POISON_GAS,1,0)
DOOR_AVAILABLE(PLAYER0,WOOD,1,0)

SET_CREATURE_FEAR(TUNNELLER,0)
SET_CREATURE_FEAR(THIEF,0)
SET_CREATURE_FEAR(KNIGHT,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)

CREATE_PARTY(LORD_OF_LAND)
    ADD_TO_PARTY(LORD_OF_LAND,KNIGHT,1,1000,ATTACK_ENEMIES,0)
CREATE_PARTY(STRIKE1)
    ADD_TO_PARTY(STRIKE1,WIZARD,1,400,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(STRIKE1,DWARFA,2,200,ATTACK_DUNGEON_HEART,0)
    ADD_TO_PARTY(STRIKE1,WITCH,1,800,ATTACK_ENEMIES,0)
CREATE_PARTY(STRIKE2)
    ADD_TO_PARTY(STRIKE2,WIZARD,1,700,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(STRIKE2,MONK,2,1000,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(STRIKE2,TUNNELLER,3,250,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(STRIKE2,WITCH,1,1100,ATTACK_ENEMIES,0)
CREATE_PARTY(DABOMB)
    ADD_TO_PARTY(DABOMB,WIZARD,2,660,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DABOMB,MONK,2,300,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DABOMB,DWARFA,5,3500,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DABOMB,WITCH,2,900,ATTACK_ENEMIES,0)
    ADD_TO_PARTY(DABOMB,TUNNELLER,4,800,ATTACK_ENEMIES,0)

REM PLAYER0 FLAG0	=	1	Tresure room >= 9
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)
    DISPLAY_OBJECTIVE(2,PLAYER0)
    TUTORIAL_FLASH_BUTTON(6,-1)
    IF(PLAYER0,TREASURE >= 1)
        IF(PLAYER0,GAME_TURN > 175)
            DISPLAY_INFORMATION(3,PLAYER0)
        ENDIF
    ENDIF
ENDIF

IF(PLAYER0,GAME_TURN > 125)
    DISPLAY_INFORMATION(1,PLAYER0)
ENDIF

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

IF(PLAYER0,FLAG0 == 1)
    IF(PLAYER0,TOTAL_GOLD_MINED >= 1000)
        REM CREATE_TEXT(3, 5)
        DISPLAY_INFORMATION(5,PLAYER0)
        IF(PLAYER0,TOTAL_GOLD_MINED >= 5000)
            DISPLAY_INFORMATION(6,PLAYER0)
            IF_ACTION_POINT(2,PLAYER0)
                ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,STRIKE1,-1,DUNGEON_HEART,0,2,400)
            ENDIF
            IF(PLAYER0,TOTAL_GOLD_MINED >= 9000)
                SET_FLAG(PLAYER0,FLAG1,1)
                REM CREATE_TEXT(4, 7)
                DISPLAY_OBJECTIVE(7,PLAYER0)
                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


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

IF(PLAYER0,FLAG0 == 0)
    DISPLAY_OBJECTIVE(9,PLAYER0)
    IF(PLAYER0,TOTAL_GOLD_MINED >= 1000)
        DISPLAY_INFORMATION(10,PLAYER0)
        IF(PLAYER0,TOTAL_GOLD_MINED >= 5000)
            DISPLAY_INFORMATION(11,PLAYER0)
            IF(PLAYER0,TOTAL_GOLD_MINED >= 9000)
                SET_FLAG(PLAYER0,FLAG1,1)
                DISPLAY_OBJECTIVE(12,PLAYER0)
            ENDIF
        ENDIF
    ENDIF
ENDIF

REM *** BUILT LAIR ***
IF(PLAYER0,FLAG0 == 3)
    IF(PLAYER0,TOTAL_CREATURES >= 1)
        REM CREATE_TEXT(6, 13)
        DISPLAY_OBJECTIVE(13,PLAYER0)

        IF(PLAYER0,BUG >= 1)
            REM CREATE_TEXT(7, 14)
            DISPLAY_OBJECTIVE(14,PLAYER0)
            TUTORIAL_FLASH_BUTTON(7,-1)
            IF(PLAYER0,GARDEN >= 9)

                REM CREATE_TEXT(8, 15)
                DISPLAY_OBJECTIVE(15,PLAYER0)
                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,-2,DUNGEON,0,1,200)
            ADD_TUNNELLER_PARTY_TO_LEVEL(PLAYER_GOOD,STRIKE2,-2,DUNGEON,0,5,400)
            DISPLAY_OBJECTIVE(17,PLAYER0)
            TUTORIAL_FLASH_BUTTON(37,-1)
            IF(PLAYER_GOOD,TOTAL_CREATURES == 0)
                TUTORIAL_FLASH_BUTTON(0,0)
                DISPLAY_OBJECTIVE(18,PLAYER0)
                ADD_PARTY_TO_LEVEL(PLAYER_GOOD,DABOMB,-2,1)
                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 >= 900)
        IF(PLAYER0,TOTAL_CREATURES >= 7)
            ADD_PARTY_TO_LEVEL(PLAYER_GOOD,LORD_OF_LAND,1,1)
            DISPLAY_OBJECTIVE(19,PLAYER0)
            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)
        DISPLAY_OBJECTIVE(20,PLAYER0)
        WIN_GAME
    ENDIF
ENDIF

IF(PLAYER0,TOTAL_IMPS == 0)
    DISPLAY_INFORMATION(21,PLAYER0)
    TUTORIAL_FLASH_BUTTON(3,-1)
    TUTORIAL_FLASH_BUTTON(21,-1)
ENDIF
