1 /* -*- Mode: C++ -*- */
2 #ifndef __TWCPLAYERCLIENT_H
3 #define __TWCPLAYERCLIENT_H
9 #include <wvstreamclone.h>
10 #include <wvstringlist.h>
13 DeclareWvTable2(IntTable
, int);
15 int find_next_unused(const UniConf
&cfg
);
17 class TWCGameController
;
21 typedef WvCallback
<WvString
, WvStringParm
> TWCQnACallback
;
22 typedef WvCallback
<void> TWCEndConvCallback
;
28 WvString default_answer
;
29 TWCQnACallback check_answer
;
31 TWCQnA(WvStringParm _question
, WvStringParm _default_answer
,
32 TWCQnACallback _check_answer
)
33 : question(_question
), default_answer(_default_answer
),
34 check_answer(_check_answer
) {}
36 DeclareWvList2(TWCConversation
, TWCQnA
);
46 TWCGameController
&game
;
49 TWCPlayerClient(TWCGameController
&_game
, TWCPlayer
&_player
);
50 virtual ~TWCPlayerClient();
54 // For mostly cosmetic messages.
55 virtual void msg(WvStringParm s
) = 0;
56 virtual void msg(WVSTRING_FORMAT_DECL
) = 0;
58 virtual void set_location(TWCObject
*_location
);
60 virtual bool areyousure() { return true; }
62 // For events that take place in a particular sector
63 // i.e. ships docking, warping, fighting, etc.
64 virtual void event(TWCEventType type
, int actor
, int target
,
65 WvStringParm eventmsg
) = 0;
66 virtual void weapon_recharged() = 0;
68 virtual WvString
try_passwd() = 0;
76 void starbar_eavesdrop();
78 void starbar_underground();
79 void sell_ship(int ship
);
84 class TWCHumanPlayerClient
: public WvStreamClone
, public TWCPlayerClient
87 TWCObjectIf
*interface
;
90 TWCHumanPlayerClient(WvTCPConn
*tcp
, TWCGameController
&_game
,
92 virtual ~TWCHumanPlayerClient();
96 virtual void msg(WvStringParm s
) { print(s
); }
97 virtual void msg(WVSTRING_FORMAT_DECL
)
98 { print(WvString(WVSTRING_FORMAT_CALL
)); }
100 virtual void set_location(TWCObject
*_location
);
102 char *continue_getline();
103 int get_int(bool &abort
, int dflt
= 0);
106 int menu(const IntTable
&items
, WvStringParm prompt
);
108 virtual bool areyousure();
109 virtual void weapon_recharged()
110 { print("\nYour ship's weapon has recharged.\n"); }
112 virtual void event(TWCEventType type
, int actor
, int target
,
113 WvStringParm eventmsg
);
114 bool new_ship(bool first_ship
);
116 void print_ships_menu(const TWCShipList
&ships
, WvStringParm prompt
);
117 TWCShip
*ship_menu(const TWCShipList
&ships
, WvStringParm prompt
);
118 TWCShip
*acquire_target(WvStringParm prompt
, WvStringParm docked
);
120 virtual WvString
try_passwd();
122 void display_inventory(TWCShip
*ship
, bool menu
= false);
124 void do_conversation(TWCConversation
&_conv
, TWCEndConvCallback _endconv
);
125 void do_conversation_callback(WvStream
&, void *);
128 bool create_new_interface
;
129 TWCConversation conv
;
130 TWCEndConvCallback endconv
;
132 virtual void execute();
133 void send_question();
136 DeclareWvList(TWCPlayerClient
);
137 DeclareWvDict(TWCPlayerClient
, int, player
.id
);
138 DeclareWvDict(TWCHumanPlayerClient
, int, player
.id
);
140 #endif // __TWCPLAYERCLIENT_H