/*
Imp_Office.m Class definition.
Copyright (C) 1995 David Flater.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include "cheezmud.h"
@implementation Imp_Office
+ str: (char *) whose_office
{
self=[super new];
if (whose_office[2] == 'q')
[[Queen str: whose_office] setlocation: self];
else
[[King str: whose_office] setlocation: self];
beatcount = random() % 10800;
return self;
}
- (void) heartbeat
{
int i,m,count=0;
if (++beatcount == 10800) {
beatcount = 0;
for(i=0,m=[contents size];i<m;i++) {
id whatever = [contents at:i];
if ([whatever isKindOf: [Queen class]] ||
[whatever isKindOf: [King class]]) count++;
}
if (!count) {
if (mudname[2] == 'q') {
[[Queen str: mudname] setlocation: self];
[self echo: "Lo! The queen approacheth!"];
}
else {
[[King str: mudname] setlocation: self];
[self echo: "Lo! The king approacheth!"];
}
}
}
}
@end