RPG Money Manager #245
Aliases: RPG Money Manager, MM
8 verbs · 9 properties · 0 children
Verbs
| Verb | Spec | Flags | Definer | Lines |
|---|---|---|---|---|
coin_assets | this none this | | #245 | 11 |
@worth | any none none | rxd | #245 | 57 |
find_money | this none this | | #245 | 22 |
money_list | this none this | | #245 | 16 |
give_coin | this none this | | #245 | 66 |
ask_cont | this none this | | #245 | 10 |
@give @pay | any to any | rxd | #245 | 34 |
s_i_n | this none this | | #245 | 9 |
Properties
| Property | Definer | Flags | Owner | Value |
|---|---|---|---|---|
usage | #245 | | — | not readable (E_PERM) |
users | #245 | | — | value (2321 chars){#22630, #24436, #29209, #46102, #49397, #50290, #50367, #55090, #56054, #58091, #58421, #58793, #58806, #59324, #59513, #74428, #76231, #76404, #78047, #81861, #72264, #67439, #59560, #63546, #37972, #87929, #87750, #63625, #87485, #78610, #53702, #90685, #90731, #85431, #94616, #38341, #94456, #80422, #63635, #94368, #89337, #58420, #91345, #89391, #97851, #98048, #98232, #59424, #58026, #94304, #86232, #96662, #92475, #89480, #53410, #56568, #81133, #97613, #99949, #98263, #101185, #100289, #80578, #91352, #101547, #100314, #88395, #94965, #102021, #99063, #103703, #91812, #104467, #101651, #101504, #89208, #47818, #104202, #90441, #105290, #99130, #96788, #86275, #105770, #103911, #85077, #90323, #108054, #107682, #100337, #81934, #103615, #108850, #9833, #107629, #103523, #97170, #71111, #108140, #107509, #64729, #97902, #108214, #106587, #97084, #96899, #108294, #106037, #110400, #112066, #110660, #110280, #112369, #107850, #110565, #112743, #90473, #112968, #108147, #112823, #108108, #100173, #87721, #59254, #48498, #87951, #106854, #109506, #114382, #103689, #112837, #110586, #114019, #114639, #114702, #114518, #100674, #113418, #112478, #105408, #98705, #87010, #115197, #114928, #115397, #105539, #114241, #87340, #107413, #113956, #110077, #115432, #37544, #116031, #64985, #114652, #113391, #116339, #116385, #87593, #113235, #116358, #107759, #116342, #116405, #58377, #107985, #116729, #116473, #113285, #106189, #91798, #115937, #116886, #116995, #115200, #117048, #38441, #69513, #114233, #108263, #115922, #116305, #117275, #117283, #109546, #112886, #116569, #116369, #98580, #116376, #114430, #12399, #118143, #109263, #92476, #90723, #97612, #88076, #30788, #112527, #101594, #117236, #103685, #116852, #118248, #35076, #118487, #118890, #107704, #118654, #118740, #86050, #119424, #109615, #119469, #110787, #115124, #119554, #119116, #111890, #119701, #86471, #107618, #114174, #119594, #120144, #120227, #120260, #120239, #120283, #114206, #117100, #120420, #118824, #120376, #120546, #120070, #120749, #57402, #121000, #121077, #121095, #121149, #121104, #120201, #121241, #119957, #121358, #121648, #121651, #117139, #121188, #121895, #121918, #121965, #121976, #121070, #115805, #114072, #110582, #122423, #118977, #119530, #122453, #122460, #122491, #122525, #122601, #122600} |
users_last_updated | #245 | | — | 915757365 |
help_msg | #245 | | — | "RPG Money Manager helps you keep track of the RPG money you're carrying around and eases access to transfering it to someone else." |
feature_verbs | #245 | | — | {"@worth", "@give"} |
key | #245 | | — | not readable (E_PERM) |
aliases | #245 | | — | {"RPG Money Manager", "MM"} |
description | #245 | | — | "RPG Money Manager helps you keep track of the RPG money you're carrying around and eases access to transfering it to someone else." |
object_size | #245 | | — | {11775, 1141287172} |
Ancestry
Ancestors (nearest first): none
Children: none
Call graph
Source
coin_assets
Referenced by
- #245:@worth line 22:
this:coin_assets - #245:@give line 30:
this:coin_assets
Source
1":coin_assets(who) => returns the new worth in coinage of this."; 2if (caller != this) 3 return E_PERM; 4endif 5who = args[1]; 6worth = 0; 7coin_list = this:money_list(who); 8for x in [1..length(coin_list)] 9 worth = worth + (coin_list[x].quantity * coin_list[x].unit_worth); 10endfor 11return worth;
@worth
Referenced by
none
Source
1"@worth [all|coin|me]"; 2" Examples:"; 3" @worth [me] => returns the total value (in copper)"; 4" of all coins you carry."; 5" (no argument defaults to 'me')"; 6" @worth silver => returns the total value (in copper)"; 7" of silver coins you carry."; 8" @worth all => returns a list of the values (in copper)"; 9" of all coins carried by you."; 10this:update_usage(verb, player); 11who = player; 12if (!(caller in {who, this})) 13 who:tell("Bugger off. You can't do that!"); 14 if (caller in connected_players()) 15 who:tell(caller:titlec(), " just tried to find your worth in coins."); 16 endif 17 return; 18endif 19types = $list_utils:map_prop(children(#57000), "denomination"); 20su = $string_utils; 21if ((!dobjstr) || (dobjstr == "me")) 22 worth = this:coin_assets(who); 23 who:tell(">>Total net worth (in copper): ", worth); 24 return; 25elseif (dobjstr == "all") 26 coin_list = this:money_list(who); 27 if (coin_list) 28 cum = 0; 29 who:tell("You are carrying:"); 30 for x in [1..length(coin_list)] 31 q = coin_list[x].quantity; 32 den = coin_list[x].denomination; 33 unit = coin_list[x].unit_worth; 34 worth = q * unit; 35 cum = cum + worth; 36 who:tell(su:right(q, 8), " ", su:capitalize(den), " coins (value = ", unit, ") => ", worth, " (in copper)."); 37 endfor 38 who:tell(">>Total net worth => ", cum, " (in copper)."); 39 else 40 who:tell(">You are not carrying any coin."); 41 endif 42 return; 43else 44 type = ""; 45 (i = $string_utils:find_prefix(dobjstr, types)) ? type = types[i] | 0; 46 if (!type) 47 who:tell("I don't understand that."); 48 return; 49 elseif (!valid(coin = this:find_money(who, type))) 50 who:tell("You don't seem to be carrying any ", dobjstr, " coins"); 51 else 52 worth = coin.quantity * coin.unit_worth; 53 who:tell(">Net worth of ", coin.quantity, " ", su:capitalize(type), " coins => ", worth, " (in copper)."); 54 endif 55 return; 56endif 57who:tell("I don't understand that.");
find_money
Referenced by
- #245:@worth line 49:
this:find_money - #245:money_list line 10:
this:find_money
Source
1":find_money(OBJ who, STR denomination) => OBJ money_object else if not found.. returns #-1"; 2if (caller != this) 3 return E_PERM; 4endif 5who = args[1]; 6coin_list = children(#57000); 7for i in [1..length(coin_list)] 8 if (coin_list[i].denomination == args[2]) 9 object = coin_list[i]; 10 endif 11endfor 12if (!valid(object)) 13 return E_INVARG; 14else 15 for x in (who.contents) 16 if ($object_utils:isa(x, object)) 17 it = x; 18 return it; 19 endif 20 endfor 21endif 22return $nothing;
money_list
Referenced by
- #245:coin_assets line 7:
this:money_list - #245:@worth line 26:
this:money_list - #245:give_coin line 10:
this:money_list
Source
1":money_list(who) => returns LIST of money objs in person's contents."; 2"..list is in ascending worth order."; 3if (caller != this) 4 return E_PERM; 5endif 6who = args[1]; 7temp_list = ret_list = coin_list = {}; 8temp_list = children(#57000); 9for x in [1..length(temp_list)] 10 if (valid(monobj = this:find_money(who, temp_list[x].denomination))) 11 coin_list = listappend(coin_list, {monobj.unit_worth, monobj}); 12 endif 13endfor 14coin_list = $list_utils:sort_alist(coin_list); 15ret_list = $list_utils:slice(coin_list, 2); 16return ret_list;
give_coin
Referenced by
- #245:@give line 33:
this:give_coin
Source
1":give_coin(OBJ from, OBJ to, NUM amount) =>"; 2"0 if not done, 1 if done.. it checks if amount necessary"; 3"is there.. then gives the amount in smallest change units."; 4if (caller != this) 5 return E_PERM; 6endif 7{from, to, tender} = args; 8len = length(children(#57000)); 9coin_list = pay_list = {}; 10coin_list = this:money_list(from); 11extra = 0; 12for x in [1..length(coin_list)] 13 coin = coin_list[x]; 14 q = coin.quantity; 15 unit = coin.unit_worth; 16 worth = unit * q; 17 div = unit * 10; 18 give = 0; 19 if ((!(tender > 0)) && (!pay_list)) 20 "...if there is nothing to give..."; 21 return; 22 elseif ((need = tender % unit) > 0) 23 "...if needing to go up to the next coin (ie, no copper and give = 33)..."; 24 if (!(ok = this:ask_cont(from, unit - need))) 25 callers = callers(); 26 caller = callers[1][2]; 27 from:tell(">Aborted '", caller, "' Command."); 28 return; 29 else 30 give = 1; 31 endif 32 endif 33 if ((y = tender + (give * unit)) && (y <= worth)) 34 "...if the smallest coin will do.. give that..."; 35 give = y / unit; 36 pay_list = listappend(pay_list, {coin, give}); 37 tender = tender - (give * unit); 38 elseif ((tender > 0) && (q > 0)) 39 "...going into the regular routine..."; 40 "...was there a shortage in a prev coinage amount?.."; 41 "..Do while len is 1-3, there is money needed and an amount to give.."; 42 while (((len > 0) && (tender > 0)) && (q > 0)) 43 "..r is in copper.. this is the amount needed for this level coin.."; 44 r = tender % div; 45 "..if there is enough there.. skips if not.. all the rest.. goes to"; 46 "..extra question above in next higher coin level.."; 47 if (worth >= r) 48 give = give + (r / unit); 49 tender = tender - r; 50 endif 51 len = len - 1; 52 div = div * 10; 53 unit = unit * 10; 54 endwhile 55 "...adds to pay_list.."; 56 if (give) 57 pay_list = listappend(pay_list, {coin, give}); 58 endif 59 endif 60endfor 61for index in [1..length(pay_list)] 62 this:s_i_n(); 63 coin = pay_list[index][1]; 64 amount = pay_list[index][2]; 65 c = coin:messaged_dist(to, from, amount); 66endfor
ask_cont
Referenced by
- #245:give_coin line 24:
this:ask_cont
Source
1":ask_cont(OBJ who, NUM over) => asks the who if they wanna continue."; 2"..cause the amount will given will be over by amount."; 3if (caller != this) 4 return E_PERM; 5endif 6{who, over} = args; 7who:tell("You do not have the correct change for this transaction."); 8who:tell("If you continue, the amount given will be over by ", over, " (value in copper)."); 9ans = $command_utils:yes_or_no("Continue?"); 10return ans;
@give @pay
Referenced by
none
Source
1"@give|@pay <NUM amount> to <OBJ|STR what>."; 2" (make sure the amount is in listed as 'worth of copper')"; 3" Gives amount TO what in the MOST number of coins possible."; 4" (this is to aid you in keeping your encumbrance as low as possible.)"; 5" Example:"; 6" You have: 1 gold, 20 silver and 110 copper."; 7" You type: @pay 302 to XYZ"; 8" 102 copper, and 20 silver coins will be paid to XYZ"; 9" leaving you with 1 gold coin and 8 copper coins."; 10this:update_usage(verb, player); 11usage = "USEAGE: @give|@pay <NUM amount> to <OBJ|STR what>."; 12who = player; 13if ((!(caller in {who, this})) && (!$local.rpg:trust())) 14 who:tell("You attempt to sneak some ", this.denomination, ", but fail miserably."); 15elseif ($command_utils:object_match_failed(to = who.location:match_object(iobjstr), iobjstr)) 16elseif (to.location != who.location) 17 who:tell("I see no \"", iobjstr, "\" here."); 18elseif (who == to) 19 who:tell("You want to give it to yourself?"); 20elseif (!to:accept(this)) 21 who:tell(to:titlec(), " ", $gender_utils:get_conj("does/do", to), " not want that item."); 22elseif (!dobjstr) 23 who:tell(useage); 24elseif (!(amt = toint(dobjstr))) 25 who:tell(usage); 26elseif (amt < 0) 27 who:tell("You can't give a negative amount!"); 28elseif (amt == 0) 29 who:tell("You want to give nothing?"); 30elseif (amt > (worth = this:coin_assets(who))) 31 who:tell("You don't have enough money for that."); 32else 33 this:give_coin(who, to, amt); 34endif
s_i_n
Referenced by
- #245:give_coin line 62:
this:s_i_n
Source
1"suspends if ticks left is under 7000 or if secs left is under 3"; 2if (caller != this) 3 raise(E_PERM); 4endif 5ticks = ticks_left(); 6secs = seconds_left(); 7if ((ticks < 7000) || (secs < 3)) 8 suspend(0); 9endif