#include <sys/types.h>
#include <sys/time.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "merc.h"
#include "interp.h"
#include "recycle.h"
#include "tables.h"
#include "lookup.h"
Include dependency graph for tithe.c:

Go to the source code of this file.
Functions | |
| void | check_tithe (CHAR_DATA *ch, int silver, int gold) |
| void | do_tithe (CHAR_DATA *ch, char *argument) |
| void | get_tithe (CHAR_DATA *ch, char *argument) |
| void | kingdom_check_tithe (CHAR_DATA *ch, char *argument) |
|
||||||||||||||||
|
Definition at line 98 of file tithe.c. References MAX_STRING_LENGTH. Referenced by get_obj(). 00099 {
00100 int to_keep;
00101 int tithe;
00102 int tithe_gold, tithe_silver;
00103 char buf[MAX_STRING_LENGTH];
00104
00105 /* If you don't get 1 gold from your kill, then you are not tithed. */
00106 if ((silver <= 100 && gold <= 0) || kingdom_data[ch->king].tithe == 0)
00107 {
00108 ch->silver += silver;
00109 ch->gold += gold;
00110 return;
00111 }
00112
00113
00114 /* Calculate the tithe from both gold and silver. In my orginal plans, I had
00115 * it converting the gold to silver, then tithing from that..but that proved
00116 * to have more problems since when you kill something, you can get upwars to
00117 * over a thousand silver. So we'll thithe from both and get better, accurate
00118 * results. */
00119 tithe_silver = silver * (kingdom_data[ch->king].tithe / 100);
00120 tithe_gold = (gold * 100) * (kingdom_data[ch->king].tithe / 100);
00121
00122 tithe = tithe_gold + tithe_silver;
00123
00124 /* tithe_account is the bank account that we'll put this in. Since DSL's accounts
00125 * deal only in eggs, this one will have to be differnt so it can deal in silver/
00126 * gold. TODO: Add code here to check the current account number, and convert to
00127 * eggs/blues. Or, you can just have it do it manually in the command to show
00128 * how much has been tithed. */
00129
00130 kingdom_data[ch->king].tithe_account += tithe;
00131
00132 sprintf(buf, "Your tithe at %d percent was %d silver and %d gold.\n\r",(int)kingdom_data[ch->king].tithe,
00133 tithe_silver + (tithe_gold % 100), tithe_gold / 100);
00134 send_to_char(buf,ch);
00135
00136 /* Need to convert it back to usuable money so we can give it to the citizen. This
00137 * math is pretty accurate I believe and should give what is needed, no more, and no
00138 * less. */
00139
00140 silver = silver - (tithe_silver + (tithe_gold % 100));
00141 gold = gold - (tithe_gold / 100);
00142 ch->silver += silver;
00143 ch->gold += gold;
00144 save_kingdom_data();
00145
00146 return;
00147
00148 }
|
|
||||||||||||
|
Definition at line 37 of file tithe.c. References IS_IMMORTAL, is_number(), IS_SET, KING_LEADER, kingdom_data, MAX_STRING_LENGTH, save_kingdom_data(), send_to_char(), and kingdom_data_1::tithe. 00038 {
00039 char buf[MAX_STRING_LENGTH];
00040
00041 if (ch->king == 0 && !IS_IMMORTAL(ch))
00042 {
00043 send_to_char("Huh?\n\r",ch);
00044 return;
00045 }
00046
00047 if (!IS_SET(ch->kking, KING_LEADER) && !IS_IMMORTAL(ch))
00048 {
00049 send_to_char("You must be a kingdomer leader to set the tithe status of your kingdom.\n\r",ch);
00050 return;
00051 }
00052
00053 /* kingdom_data is the structures that I have for my kingdom system which are loaded and saved to
00054 * disk when needed. They are not hardcoded. I have simply added a 'int tithe' part to the struct
00055 * and updated my save_kingdom_data/load_kingdom_data code to load and save the tithe. */
00056
00057 if (argument[0] == '\0')
00058 {
00059
00060 send_to_char("Current tithe status: ",ch);
00061 if (kingdom_data[ch->king].tithe == 0)
00062 send_to_char("None.\n\r",ch);
00063 else
00064 {
00065 sprintf(buf, "%d percent.\n\r", (int)kingdom_data[ch->king].tithe);
00066 send_to_char(buf,ch);
00067 }
00068
00069 return;
00070 }
00071
00072 if (!is_number(argument))
00073 {
00074 send_to_char("Value must be numerical and must be between 0 and 15. No percent sign should be used.\n\r",ch);
00075 return;
00076 }
00077
00078 if (atoi(argument) > 20 || atoi (argument) < 0)
00079 {
00080 send_to_char("Value must be between 0 and 15. No percent sign should be used.\n\r",ch);
00081 return;
00082 }
00083
00084 if (atoi(argument) == 0)
00085 sprintf(buf, "You will no longer tithe your citizens.\n\r");
00086 else
00087 sprintf(buf, "You will now tithe your citizens at %d percent.\n\r", atoi(argument));
00088
00089 send_to_char(buf,ch);
00090 kingdom_data[ch->king].tithe = atoi(argument);
00091 save_kingdom_data();
00092 return;
00093 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 192 of file tithe.c. References do_function(), get_tithe(), IS_IMMORTAL, is_number(), IS_SET, KING_LEADER, kingdom_check_tithe(), kingdom_data, MAX_STRING_LENGTH, one_argument(), send_to_char(), str_prefix(), and kingdom_data_1::tithe_account. Referenced by get_tithe(). 00193 {
00194 char buf[MAX_STRING_LENGTH];
00195 int total;
00196 char arg[MAX_STRING_LENGTH];
00197
00198
00199
00200 if (ch->king == 0 && !IS_IMMORTAL(ch))
00201 {
00202 send_to_char("Huh?\n\r",ch);
00203 return;
00204 }
00205 if (!IS_SET(ch->kking, KING_LEADER) && !IS_IMMORTAL(ch))
00206 {
00207 send_to_char("Huh?\n\r",ch);
00208 return;
00209 }
00210
00211 argument = one_argument(argument,arg);
00212
00213 if (arg[0] == '\0')
00214 {
00215 do_function(ch, &kingdom_check_tithe, "");
00216 return;
00217 }
00218
00219 if (argument[0] == '\0')
00220 {
00221 send_to_char("Syntax: GetTithe <amount> <type> (type can be gold or silver)\n\r",ch);
00222 return;
00223 }
00224
00225 if (!is_number(arg))
00226 {
00227 send_to_char("Syntax: GetTithe <amount> <type> (type can be gold or silver)\n\r",ch);
00228 return;
00229 }
00230
00231 if (!str_prefix(argument, "gold"))
00232 {
00233 total = kingdom_data[ch->king].tithe_account;
00234 if ((atoi(arg) * 100) > total)
00235 {
00236 send_to_char("Insufficent funds.\n\r",ch);
00237 do_function(ch, &kingdom_check_tithe,"");
00238 return;
00239 }
00240
00241 ch->gold += atoi(arg);
00242 kingdom_data[ch->king].tithe_account -= (atoi(arg) * 100);
00243 sprintf(buf, "%s gold has been deducted from your tithe account.\n\r", arg);
00244 send_to_char(buf,ch);
00245 return;
00246 }
00247
00248 if (!str_prefix(argument, "silver"))
00249 {
00250 total = kingdom_data[ch->king].tithe_account;
00251 if (atoi(arg) > total)
00252 {
00253 send_to_char("Insufficent funds.\n\r",ch);
00254 do_function(ch,&kingdom_check_tithe,"");
00255 return;
00256 }
00257
00258 ch->silver += atoi(arg);
00259 kingdom_data[ch->king].tithe_account -= atoi(arg);
00260 sprintf(buf, "%s silver has been deducted from your tithe account.\n\r",arg);
00261 send_to_char(buf,ch);
00262 return;
00263 }
00264
00265 do_function(ch, &get_tithe, "");
00266 return;
00267 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 150 of file tithe.c. References IS_IMMORTAL, IS_SET, KING_LEADER, kingdom_data, MAX_STRING_LENGTH, send_to_char(), and kingdom_data_1::tithe_account. Referenced by get_tithe(). 00151 {
00152 char buf[MAX_STRING_LENGTH];
00153 int gold,silver; /*,blue, eggs*/ /* for you DSL folks to determine */
00154 long int total;
00155
00156
00157
00158 if (ch->king == 0 && !IS_IMMORTAL(ch))
00159 {
00160 send_to_char("Huh?\n\r",ch);
00161 return;
00162 }
00163
00164 if (!IS_SET(ch->kking, KING_LEADER) && !IS_IMMORTAL(ch))
00165 {
00166 send_to_char("Huh?\n\r",ch);
00167 return;
00168 }
00169
00170 total = kingdom_data[ch->king].tithe_account;
00171
00172 send_to_char("Current Tithe Account Status:\n\r",ch);
00173 send_to_char("-----------------------------\n\r",ch);
00174 send_to_char("In bank: ",ch);
00175 if (kingdom_data[ch->king].tithe_account <= 0)
00176 sprintf(buf, "Empty.\n\r");
00177 else
00178 {
00179 if (total > 100)
00180 {
00181 gold = total / 100;
00182 silver = total - (gold * 100);
00183 sprintf(buf, "%d {YGold{x, %d {WSilver{x\n\r", gold, silver);
00184 }
00185 else
00186 sprintf(buf, "%ld Silver.\n\r",total);
00187 }
00188 send_to_char(buf,ch);
00189
00190 }
|
Here is the call graph for this function:

1.4.0