7 #include "gb/commands/grant.h" 18 #include "gb/GB_server.h" 19 #include "gb/buffers.h" 21 #include "gb/files_shl.h" 25 #include "gb/shlmisc.h" 26 #include "gb/tweakables.h" 29 void grant(
const command_t &argv, GameObj &g) {
30 player_t Playernum = g.player;
31 governor_t Governor = g.governor;
39 Race = races[Playernum - 1];
40 if (argv.size() < 3) {
41 g.out <<
"Syntax: grant <governor> star\n";
42 g.out <<
" grant <governor> ship <shiplist>\n";
43 g.out <<
" grant <governor> money <amount>\n";
47 g.out <<
"Bad governor number.\n";
50 if (!Race->governor[gov].active) {
51 g.out <<
"That governor is not active.\n";
54 if (argv[2] ==
"star") {
56 if (g.level != ScopeLevel::LEVEL_STAR) {
57 g.out <<
"Please cs to the star system first.\n";
61 Stars[snum]->governor[Playernum - 1] = gov;
62 sprintf(buf,
"\"%s\" has granted you control of the /%s star system.\n",
63 Race->governor[Governor].name, Stars[snum]->name);
64 warn(Playernum, gov, buf);
66 }
else if (argv[2] ==
"ship") {
67 nextshipno = start_shiplist(g, argv[3]);
69 if (in_list(Playernum, argv[3], *ship, &nextshipno) &&
70 authorized(Governor, *ship)) {
72 sprintf(buf,
"\"%s\" granted you %s at %s\n",
73 Race->governor[Governor].name, ship_to_string(*ship).c_str(),
74 prin_ship_orbits(ship));
75 warn(Playernum, gov, buf);
77 sprintf(buf,
"%s granted to \"%s\"\n", ship_to_string(*ship).c_str(),
78 Race->governor[gov].name);
79 notify(Playernum, Governor, buf);
83 }
else if (argv[2] ==
"money") {
85 if (argv.size() < 4) {
86 g.out <<
"Indicate the amount of money.\n";
89 amount = std::stoi(argv[3]);
90 if (amount < 0 && Governor) {
91 g.out <<
"Only leaders may make take away money.\n";
94 if (amount > Race->governor[Governor].money)
95 amount = Race->governor[Governor].money;
96 else if (-amount > Race->governor[gov].money)
97 amount = -Race->governor[gov].money;
99 sprintf(buf,
"%ld money granted to \"%s\".\n", amount,
100 Race->governor[gov].name);
102 sprintf(buf,
"%ld money deducted from \"%s\".\n", -amount,
103 Race->governor[gov].name);
104 notify(Playernum, Governor, buf);
106 sprintf(buf,
"\"%s\" granted you %ld money.\n",
107 Race->governor[Governor].name, amount);
109 sprintf(buf,
"\"%s\" docked you %ld money.\n",
110 Race->governor[Governor].name, -amount);
111 warn(Playernum, gov, buf);
112 Race->governor[Governor].money -= amount;
113 Race->governor[gov].money += amount;
117 g.out <<
"You can't grant that.\n";
void putstar(startype *s, starnum_t snum)
shipnum_t do_shiplist(Ship **s, shipnum_t *nextshipno)
void grant(const command_t &argv, GameObj &g)