cyphesis/client/ObserverClient.cpp
Al Riddoch dee412c0a0 * client/CharacterClient.cpp: Removed commented out code.
* client/CreatorClient.cpp: Fixed processing the response
	  to a create operation, and cleaned up debugging output.

	* client/ObjserverClient.cpp, client/ObserverClient.h,
	  client/client.cpp: Added setup method, which which handles
	  connecting, negotiation, logging in and creating character.

	* client/Py_CreatorClient.cpp: Added check if make() failed.

	* rulesets/Python_API.cpp: Fixed setting the import hooks
	  list properlly to include the ruleset list in use, instead
	  of hardcoding it.

	* rulesets/acorn/define_world.py: Copied define_world.py script
	  from client directory for Acorn.

	* rulesets/basic/editor.py: Modified to be used from C++ core.

	* rulesets/basic/mind/goals/__init__.py,
	  rulesets/basic/mind/goals/humanoid/werewolf.py:
	  Added in goals file to contain goals related to werewolf.

	* rulesets/basic/mind/panlingua/interlinguish.py:
	  Added in vote and execute verbs for werewolf.

	* rulesets/werewolf: Added in new ruleset for werewolf.

Al Riddoch  <alriddoch@zepler.org>
2001-08-19 18:37:38 +00:00

129 lines
3.5 KiB
C++

// This file may be redistributed and modified only under the terms of
// the GNU General Public License (See COPYING for details).
// Copyright (C) 2000,2001 Alistair Riddoch
#include "ObserverClient.h"
#include "define_world.h"
#include <common/accountbase.h>
#include <unistd.h>
using Atlas::Message::Object;
ObserverClient::ObserverClient()
{
}
bool ObserverClient::setup()
{
if (!connect()) {
return false;
}
Object::MapType adminAccount;
if (!AccountBase::instance()->getAccount("admin", adminAccount)) {
std::cerr << "Unable to read admin account from database"
<< std::endl << std::flush;
return false;
}
Object::MapType::const_iterator I = adminAccount.find("password");
if (I == adminAccount.end()) {
std::cerr << "Unable to read admin account from database"
<< std::endl << std::flush;
return false;
}
const std::string & password = I->second.AsString();
player = createPlayer("admin",password);
if (player.empty()) {
return false;
}
character = createCharacter("creator");
if (character == NULL) {
return false;
}
return true;
}
void ObserverClient::loadDefault()
{
DefineWorld::define(character);
}
void ObserverClient::idle()
{
usleep(100);
// This is where we will put diagnostics, and maybe in future the AI code.
#if 0
// time.sleep(0.1);
if (not ObserverClient::display) {
return;
}
ObserverClient::map=ObserverClient::character.map;
wait=0.0;
xmin=-300.0;
xmax=-xmin;
ymin=-150.0;
ymax=-ymin;
sizex=49;
sizey=20;
goal_width=30;
screen = [None]*sizex;
for (/*i in range(sizex)*/) {
screen[i] = ['.'] * sizey;
}
house_list=[];
mind_list=[];
fire_list=[];
for (/*t in ObserverClient::map.things.values()*/) {
if (len(t.type)>=1) {
typething = string.split(t.type[0], ".");
if (string.find(typething[-1], "house")>=0) {
house_list.append(t);
}
else if (string.find(typething[-1], "farmer")>=0 or string.find(typething[-1], "smith")>=0 or string.find(typething[-1], "character")>=0 or string.find(typething[-1], "creator")>=0) {
mind_list.append(t);
}
else if (string.find(typething[-1], "fire")) {
fire_list.append(t);
}
}
else {
print "CHEAT!: somewhere is entity without type!:",t;
}
}
ObserverClient::time=str(ObserverClient::character.time);
status_str=ObserverClient::time+" Count of minds: "+`len(mind_list)`;
print chr(27)+"[H",status_str+" "*(sizex-len(status_str)-1);
for (/*t in house_list*/) {
(x,y,z)=t.get_xyz();
screen[scx(x)][scy(y)]=t.name[0];
}
yind=1;
goal_txt={};
for (/*m in mind_list*/) {
(x,y,z)=m.get_xyz();
x,y=scx(x),scy(y);
screen[x][y]=m.name[0];
screen[x+1][y]=m.name[-1];
if (hasattr(m,"goal")) {
goal_txt[yind]=(`m`+":"+m.goal+" "*goal_width)[:goal_width];
yind=yind+1;
}
}
for (/*t in fire_list*/) {
(x,y,z)=t.get_xyz();
screen[scx(x)][scy(y)]='F';
wait=0.2;
}
out=[];
for (/*y in range(sizey)*/) {
for (/*x in range(sizex)*/) {
out.append(screen[x][y]);
}
out.append(goal_txt.get(y," "*goal_width));
out.append('\n');
}
print string.join(out,'');
#endif
}