/* MegaZeux
 *
 * robo_ops.h - Primitive Robotic operations.
 *
 * Copyright (C) 2004 Gilead Kutnick <exophase@adelphia.net>
 * Copyright (c) 2008 Patrick Walton <pcwalton@uchicago.edu>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

#ifndef ROBO_OPS_H
#define ROBO_OPS_H

#include "compat.h"

__M_BEGIN_DECLS

#include "world.h"
#include "board.h"
#include "robot.h"
#include "data.h"
#include "idarray.h"
#include "idops.h"

typedef struct
{
  World *world;
  Board *board;
  Robot *robot;
  int id;
  int *x;
  int *y;
  int *blocked;
} RoboOpContext;

typedef struct
{
  World *mzx_world;
  Board *src_board;

  int check_color;
  mzx_thing check_id;
  int check_param;
  int put_color;
  mzx_thing put_id;
  int put_param;
} RoboOpChangeDescriptor;

void calculate_blocked(World * mzx_world, int x, int y, int id, int bl[4]);
void split_colors(int color, int *fg, int *bg);
void magic_load_mod(World * mzx_world, char *filename);
int place_at_xy(World *mzx_world, mzx_thing id, int color, int param,
 int x, int y);
int place_dir_xy(World *mzx_world, mzx_thing id, int color, int param,
 int x, int y, mzx_dir direction, Robot *cur_robot, int *_bl);
int place_under_xy(Board *src_board, mzx_thing id, int color, int param,
 int x, int y);
void robo_op_recalculate_blocked(RoboOpContext * ctx);
void send_at_xy(World *mzx_world, int id, int x, int y, char *label);

void robo_op_avalanche(World * mzx_world, Board * src_board);
int robo_op_become(RoboOpContext * ctx, int color, mzx_thing new_id,
 int param);
void robo_op_change(RoboOpChangeDescriptor * desc);
int robo_op_char_id(int id_char, int id_value);
int robo_op_copy_block(RoboOpContext *ctx, Layer src_layer,
 Point src_pt, Size size, Layer dest_layer, Point dest_pt);
int robo_op_fetch(RoboOpContext *ctx, Layer layer, Point pt,
 Ctp *ctp);
int robo_op_gotoxy(RoboOpContext *ctx, Point pt);
void robo_op_lock_scroll(RoboOpContext *ctx);
void robo_op_shootseeker(RoboOpContext * ctx, mzx_dir direction);
void robo_op_spitfire(RoboOpContext * ctx, mzx_dir direction);
int robo_op_teleport_player(RoboOpContext *ctx, const char *board_dest_buffer,
 int teleport_x, int teleport_y);

#endif
