/**************************************************************
 * FFTacticsMUD : area.cpp                                    *
 **************************************************************
 * (c) 2002 Damien Dailidenas (Trenton). All rights reserved. *
 **************************************************************/

#include "main.h"
#include "mysql/mysql.h"
#include <strstream>

const struct areas area_table[] = {
  {},
  { "Orbonne Monastery",
"You are in an elevated section of the church, standing before an alter, \
surrounded by stained glass windows. The floor is covered by a long, ornately \
woven red carpet with gold trim. Light streaks in through the stained glass windows.",
battle_orbonne_monastery },
  {}
};

long BATTLE_AREA::size() {
  return width * height;
}
 
void BATTLE_AREA::set_coordinates() {
  unsigned int x = 1, y = 1;
  long size = this->size(), id;
 
  for(id = 1; id <= size; ++id) {
    this->room[id]->x = x;
    this->room[id]->y = y;
 
    if(++x > this->width) {
      ++y;
      x = 1;
    }
  }
 
  return;
}

string BATTLE_AREA::str_weather() {
  return (string)weather_table[weather].condition;
}

AREA *get_area(const short id) {
  for(AREA *area = area_list; area; area = area->next)
    if(area->id == id)
      return area;
      
  return NULL;
}

BATTLE_AREA *get_battle_area(const short id) {
  for(BATTLE_AREA *area = battle_area_list; area; area = area->next) {
    if(area->id == id) {
      ostrstream ost;
      ost << area->name << " " << area->width << " " << area->height << ends;
      log_string(ost.str());
      return area;
    }
  }

  return NULL;
}

string AREA::name() {
  return (string)area_table[id].name;
}

BATTLE_FUN *AREA::battle() {
  return area_table[id].battle;
}