grendel-1.0.0a7/backup/
grendel-1.0.0a7/bin/
grendel-1.0.0a7/boards/
grendel-1.0.0a7/clans/
grendel-1.0.0a7/documentation/todo/
grendel-1.0.0a7/help/
grendel-1.0.0a7/logs/
grendel-1.0.0a7/players/
grendel-1.0.0a7/progs/
grendel-1.0.0a7/races/
grendel-1.0.0a7/src/contrib/
grendel-1.0.0a7/src/modules/speller/
grendel-1.0.0a7/src/modules/status/
grendel-1.0.0a7/src/tests/
grendel-1.0.0a7/src/tests/dunit/
unit speller_main;

interface

implementation


uses
  SysUtils,
  chars,
  player,
  area,
  dtypes,
  modules,
  commands,
  mudspell;


type
  GSpellerModule = class(TInterfacedObject, IModuleInterface)
  	procedure registerModule();
  	procedure unregisterModule();
  end;
  
  
procedure do_spellcheck(ch : GCharacter; param : string);
var
	room : GRoom;
	area : GArea;
	iterator : GIterator;
begin
  if (GPlayer(ch).area_fname='') then
    begin
    ch.sendBuffer('You have not yet been assigned an area.'#13#10);
    exit;
    end;

  area := GPlayer(ch).area;
  if (area=nil) then
    begin
    ch.sendBuffer('Use LOADAREA first to loadup your assigned area.'#13#10);
    exit;
    end;

  ch.sendBuffer('Spellchecking area '+area.fname+'...'#13#10#13#10);

	iterator := room_list.iterator();

	while (iterator.hasNext()) do
		begin
		room := GRoom(iterator.next());

		if (room.area = area) then
			begin
			if (not checkWords(room.description)) then
				ch.sendBuffer('('+inttostr(room.vnum)+') possibly misspelled word(s), [' + trim(misspelled_words) + ']'#13#10);
			end;
		end;

	iterator.Free();
end;

procedure do_addcustom(ch : GCharacter; param : string);
begin
  if (length(param) = 0) then
    begin
    ch.sendBuffer('ADDCUSTOM <word to add to custom dictionary>'#13#10);
    exit;
    end;
    
  addToCustom(param);
  
  ch.sendBuffer('Ok.'#13#10);
end;

function returnModuleInterface() : IModuleInterface;
begin
	Result := GSpellerModule.Create();
end;

procedure GSpellerModule.registerModule();
begin
  registerCommand('do_spellcheck', do_spellcheck);
  registerCommand('do_addcustom', do_addcustom);
end;

procedure GSpellerModule.unregisterModule();
begin
  unregisterCommand('do_spellcheck');
  unregisterCommand('do_addcustom');
end;


exports
	returnModuleInterface;


end.