musicmud-2.1.6/data/
musicmud-2.1.6/data/help/
musicmud-2.1.6/data/policy/
musicmud-2.1.6/data/wild/
musicmud-2.1.6/data/world/
musicmud-2.1.6/doc/
musicmud-2.1.6/src/ident/
musicmud-2.1.6/src/lua/
musicmud-2.1.6/src/lua/include/
musicmud-2.1.6/src/lua/src/lib/
musicmud-2.1.6/src/lua/src/lua/
musicmud-2.1.6/src/lua/src/luac/
#ifndef MATCH_H
#define MATCH_H

#include <vector>

#include "teleob.h"

typedef bool (*tfn_t)(const TeleObject &t);

//! does the string /a/ end with the string /b/ ?
bool endswith(const char *a, const char *b);

//! obtain a list of objects that match given criteria
NewWorld match(MudObject *forwho, int argc, const char **argv,
	       tfn_t fn, int flags, int *i=0, World<MudObject> *special=0, const char *prep=0);
//! obtain a list of objects that match given criteria
NewWorld match(MudObject *forwho, int argc, const char **argv,
	       tfn_t fn, int flags, const char *prep);

//! whether /what/ matches the given category
bool category_match(MudObject *what, const char *str, MudObject *me=0);

//! wether /o_name/ matches /sought/ as a name
bool names_match(const char *o_name, const char *sought);

//! is /o/ a valid preposition?
bool prep(const char *o);

//! a collection of TeleObjects.
class TeleWorld {
  vector<TeleObject> v;
public:

  const char *prep;
  int all_nothing;
  int siz;
  string txt;

  TeleWorld() {
    prep = NULL;
    all_nothing = 0;
    siz = 0;
  }
  void add(MudObject &what, MudObject *where);
  void add(MudObject &what, MudObject *where, int n);  
  void add(TeleObject ob);

  bool has(const TeleObject &ob) const;

  const TeleObject &get(int n) const;

  int getsize() const;
  MudObject *get_nth(int a) const;
  int get_nthnth(int a) const;

  operator NewWorld() const {
    NewWorld w;
    iforeach(o, v) {
      w.add(o->what);
    }
    return w;
  }
};

//! obtain a list of matching objects
TeleWorld multi_match(MudObject *forwho, int argc, const char **argv,
		   tfn_t fn, int flags, int *nexto=0, World<MudObject> *special=0, const char *prepf=0);

//! flags for the match and multi_match functions
enum {
  LOOK_ROOM      = 1,
  LOOK_INV       = 2,
  LOOK_BOTH      = 3,
  IGNORE_EXITS   = 4,
  LOOK_SPECIAL   = 8,
  ALLOW_ME       = 16,
  LOOK_MWIELD    = 32,
  IGNORE_MISSION = 64,
  FIND_EXITS     = 0,
  LOOK_LINKED    = 128,
  IGNORE_CATEGORIES = 256,
  DEFAULT_ALL    = 512,
  PERSON_ONLY    = 1024,
};

//! convert a string to a cardinal number. return -1 for failure.
int decardinator(const char *a);

//! find player that matches string from pov of who
MudObject *get_player(MudObject *, const char*);

MudObject *find_object(MudObject *context, const char *name, bool shortcut=true);

MudObject *find_exit(MudObject *room, const char *name);

void set_prons(MudObject *player, TeleObject what);
void set_prons(MudObject *player, const MudObjectWorld &things);

#endif