#include <allegro.h>
#include <string.h>
#include <math.h>
#include "aldumb.h"
#include "standards.h"
#include "rotk2.h"
#include "sounds.h"

#include "CLevel.h"
#include "CLevels.h"


/*int CLevels::count_fries_collected(void)
{
    int ret=0;
    for(int n=0 ; n<next_level ; n++)
        {
        ret += level[n].total_fries - level[n].fries_left;
        }
    return ret;
}

int CLevels::count_total_fries(void)
{
    int ret=0;
    for(int n=0 ; n<next_level ; n++)
        {
        ret += level[n].total_fries;
        }
    return ret;
}
     */
/*void CLevels::load_level_states(FILE *fp)
{
    for(int n=0 ; n<next_level ; n++)
        {
        level[n].load_level_state(fp);
        }
}

void CLevels::save_level_states(FILE *fp)
{
    for(int n=0 ; n<next_level ; n++)
        {
        level[n].save_level_state(fp);
        }
} */

void CLevels::count_items(CMapObjects *obs)
{
    for(int n=0 ; n<next_level ; n++)
        level[n].count_items(obs);
}

char* CLevels::ret_name(int level_num)
{
   return level[level_num].level_name;
}

void CLevels::splash_level(BITMAP *bmp, int level_num,FONT *f, int y)
{
    if(level_num<next_level)
        level[level_num].splash_level(bmp, f,y);
}

void CLevels::set_up_level(int level_num,CMap *map, CMapObjects *obs ,CObjectSet *os, CTileSet *ts, DATAFILE *d, CTile *blank, CEnims *enims, CCinematic *_ingameCin )
{
    if(level_num<next_level)
    {
        level[level_num].set_up_level(map,obs,os,ts,d,blank,enims,_ingameCin);
    }
}

void CLevels::set_up_all_levels(CMap *map, CMapObjects *obs ,CObjectSet *os, CTileSet *ts, DATAFILE *d, CTile *blank, CEnims *enims, CCinematic *ingameCin)
{
    for(int n=0 ; n<next_level ; n++)
    {
        level[n].set_up_level(map,obs,os,ts,d,blank,enims,ingameCin);
    }
}

void CLevels::create_level(char *map_name, char *level_name, char *tileset_name, char *objectset_name, char *song_name, int world_num, int iFriesNeeded, int iCheeseNeeded, int map_pos_x, int map_pos_y)
{
    level[next_level].create_level(map_name,level_name,tileset_name,objectset_name,song_name,world_num,iFriesNeeded,iCheeseNeeded, map_pos_x, map_pos_y);
    next_level++;

    if(next_level >= max_levels-1)
        next_level=max_levels-1;
}

char* CLevels::ret_song_filename(int n)
{
    return level[n].ret_song_filename();   
}    

void CLevels::init_all(void)
{
    for(int n=0 ; n<max_levels ; n++)
        level[n].init();
    next_level=0;

}
