7 #include "gb/declare.h" 11 #include "gb/GB_server.h" 12 #include "gb/buffers.h" 13 #include "gb/config.h" 15 #include "gb/files_shl.h" 17 #include "gb/shlmisc.h" 19 #include "gb/tweakables.h" 20 #include "gb/utils/rand.h" 26 void invite(
const command_t &argv, GameObj &g) {
27 const player_t Playernum = g.player;
28 const governor_t Governor = g.governor;
29 bool mode = argv[0] ==
"invite";
36 g.out <<
"Only leaders may invite.\n";
39 if (!(n = get_player(argv[1]))) {
40 g.out <<
"No such player.\n";
44 g.out <<
"Not needed, you are the leader.\n";
47 Race = races[Playernum - 1];
50 setbit(Blocks[Playernum - 1].invite, n);
51 sprintf(buf,
"%s [%d] has invited you to join %s\n", Race->name, Playernum,
52 Blocks[Playernum - 1].name);
54 sprintf(buf,
"%s [%d] has been invited to join %s [%d]\n", alien->name, n,
55 Blocks[Playernum - 1].name, Playernum);
56 warn_race(Playernum, buf);
58 clrbit(Blocks[Playernum - 1].invite, n);
59 sprintf(buf,
"You have been blackballed from %s [%d]\n",
60 Blocks[Playernum - 1].name, Playernum);
62 sprintf(buf,
"%s [%d] has been blackballed from %s [%d]\n", alien->name, n,
63 Blocks[Playernum - 1].name, Playernum);
64 warn_race(Playernum, buf);
72 void pledge(
const command_t &argv, GameObj &g) {
73 const player_t Playernum = g.player;
74 const governor_t Governor = g.governor;
75 bool mode = argv[0] ==
"pledge";
80 g.out <<
"Only leaders may pledge.\n";
83 if (!(n = get_player(argv[1]))) {
84 g.out <<
"No such player.\n";
88 g.out <<
"Not needed, you are the leader.\n";
91 Race = races[Playernum - 1];
93 setbit(Blocks[n - 1].pledge, Playernum);
94 sprintf(buf,
"%s [%d] has pledged %s.\n", Race->name, Playernum,
97 sprintf(buf,
"You have pledged allegiance to %s.\n", Blocks[n - 1].name);
98 warn_race(Playernum, buf);
100 switch (int_rand(1, 20)) {
104 "%s [%d] joins the band wagon and pledges allegiance to %s [%d]!\n",
105 Race->name, Playernum, Blocks[n - 1].name, n);
108 sprintf(buf,
"%s [%d] pledges allegiance to %s [%d].\n", Race->name,
109 Playernum, Blocks[n - 1].name, n);
113 clrbit(Blocks[n - 1].pledge, Playernum);
114 sprintf(buf,
"%s [%d] has quit %s [%d].\n", Race->name, Playernum,
115 Blocks[n - 1].name, n);
117 sprintf(buf,
"You have quit %s\n", Blocks[n - 1].name);
118 warn_race(Playernum, buf);
120 switch (int_rand(1, 20)) {
122 sprintf(buf,
"%s [%d] calls %s [%d] a bunch of geeks and QUITS!\n",
123 Race->name, Playernum, Blocks[n - 1].name, n);
126 sprintf(buf,
"%s [%d] has QUIT %s [%d]!\n", Race->name, Playernum,
127 Blocks[n - 1].name, n);
134 compute_power_blocks();
138 void declare(
const command_t &argv, GameObj &g) {
139 const player_t Playernum = g.player;
140 const governor_t Governor = g.governor;
141 const int APcount = 1;
148 g.out <<
"Only leaders may declare.\n";
152 if (!(n = get_player(argv[1]))) {
153 g.out <<
"No such player.\n";
159 if ((
int)Sdata.AP[Playernum - 1] >= APcount) {
162 }
else if ((g.level == ScopeLevel::LEVEL_STAR ||
163 g.level == ScopeLevel::LEVEL_PLAN) &&
164 enufAP(Playernum
, Governor
, Stars[g.snum]->AP[Playernum - 1]
, 168 sprintf(buf,
"You don't have enough AP's (%d)\n", APcount);
169 notify(Playernum, Governor, buf);
173 Race = races[Playernum - 1];
174 alien = races[n - 1];
176 switch (*argv[2].c_str()) {
181 sprintf(buf,
"But would you want your sister to marry one?\n");
182 notify(Playernum, Governor, buf);
184 sprintf(buf,
"Good for you.\n");
185 notify(Playernum, Governor, buf);
187 sprintf(buf,
" Player #%d (%s) has declared an alliance with you!\n",
188 Playernum, Race->name);
190 sprintf(buf,
"%s [%d] declares ALLIANCE with %s [%d].\n", Race->name,
191 Playernum, alien->name, n);
193 if (argv.size() > 3) d_mod = std::stoi(argv[3]);
194 d_mod = std::max(d_mod, 30);
199 sprintf(buf,
"Done.\n");
200 notify(Playernum, Governor, buf);
202 sprintf(buf,
" Player #%d (%s) has declared neutrality with you!\n",
203 Playernum, Race->name);
205 sprintf(buf,
"%s [%d] declares a state of neutrality with %s [%d].\n",
206 Race->name, Playernum, alien->name, n);
214 "Your enemies flaunt their secondary male reproductive " 215 "glands in your\ngeneral direction.\n");
216 notify(Playernum, Governor, buf);
218 sprintf(buf,
"Give 'em hell!\n");
219 notify(Playernum, Governor, buf);
221 sprintf(buf,
" Player #%d (%s) has declared war against you!\n",
222 Playernum, Race->name);
224 switch (int_rand(1, 5)) {
226 sprintf(buf,
"%s [%d] declares WAR on %s [%d].\n", Race->name,
227 Playernum, alien->name, n);
230 sprintf(buf,
"%s [%d] has had enough of %s [%d] and declares WAR!\n",
231 Race->name, Playernum, alien->name, n);
236 "%s [%d] decided that it is time to declare WAR on %s [%d]!\n",
237 Race->name, Playernum, alien->name, n);
241 "%s [%d] had no choice but to declare WAR against %s [%d]!\n",
242 Race->name, Playernum, alien->name, n);
246 "%s [%d] says 'screw it!' and declares WAR on %s [%d]!\n",
247 Race->name, Playernum, alien->name, n);
255 g.out <<
"I don't understand.\n";
260 warn_race(Playernum, buf);
263 alien->translate[Playernum - 1] =
264 MIN(alien->translate[Playernum - 1] + d_mod, 100);
271 void vote(
const command_t &argv, GameObj &g) {
272 const player_t Playernum = g.player;
273 const governor_t Governor = g.governor;
280 Race = races[Playernum - 1];
283 sprintf(buf,
"Your vote doesn't count, however, here is the count.\n");
284 notify(Playernum, Governor, buf);
289 sprintf(buf,
"You are not allowed to vote, but, here is the count.\n");
290 notify(Playernum, Governor, buf);
295 if (argv.size() > 2) {
297 if (argv[1] ==
"update") {
298 if (argv[2] ==
"go") {
301 }
else if (argv[2] ==
"wait")
304 sprintf(buf,
"No such update choice '%s'\n", argv[2].c_str());
305 notify(Playernum, Governor, buf);
309 sprintf(buf,
"No such vote '%s'\n", argv[1].c_str());
310 notify(Playernum, Governor, buf);
321 for (player_t pnum = 1; pnum <= Num_races; pnum++) {
322 Race = races[pnum - 1];
323 if (Race->God || Race->Guest)
continue;
331 if (nvotes > 0 && nvotes == yays && nays == 0) {
337 sprintf(buf,
"Your vote on updates is %s\n",
339 notify(Playernum, Governor, buf);
351 nays = yays = nvotes = 0;
352 for (pnum = 1; pnum <= Num_races; pnum++) {
353 Race = races[pnum - 1];
354 if (Race->God || Race->Guest)
continue;
358 sprintf(buf,
" %s voted go.\n", Race->name);
361 sprintf(buf,
" %s voted wait.\n", Race->name);
363 if (races[Playernum - 1]->God) notify(Playernum, Governor, buf);
365 sprintf(buf,
" Total votes = %d, Go = %d, Wait = %d.\n", nvotes, yays, nays);
366 notify(Playernum, Governor, buf);
void vote(const command_t &argv, GameObj &g)
void declare(const command_t &argv, GameObj &g)
void post(const char *origmsg, int type)
void deductAPs(const player_t Playernum, const governor_t Governor, unsigned int n, starnum_t snum, int sdata)
int enufAP(int Playernum, int Governor, unsigned short AP, int x)
static void show_votes(int, int)
void invite(const command_t &argv, GameObj &g)
void Putblock(struct block b[MAXPLAYERS])
void pledge(const command_t &argv, GameObj &g)