Atrinik Server 2.5
Functions
server/shop.c File Reference
#include <global.h>

Go to the source code of this file.

Functions

static sint64 pay_from_container (object *op, object *pouch, sint64 to_pay)
sint64 query_cost (object *tmp, object *who, int flag)
static archetypefind_next_coin (sint64 c, int *cointype)
char * cost_string_from_value (sint64 cost)
char * query_cost_string (object *tmp, object *who, int flag)
sint64 query_money (object *op)
int pay_for_amount (sint64 to_pay, object *pl)
int pay_for_item (object *op, object *pl)
int get_payment (object *pl, object *op)
void sell_item (object *op, object *pl, sint64 value)
int get_money_from_string (const char *text, struct _money_block *money)
int query_money_type (object *op, int value)
sint64 remove_money_type (object *who, object *op, sint64 value, sint64 amount)
void insert_money_in_player (object *pl, object *money, uint32 nrof)
objectbank_get_info (object *op)
objectbank_create_info (object *op)
objectbank_get_create_info (object *op)
sint64 bank_get_balance (object *op)
int bank_deposit (object *op, const char *text, sint64 *value)
int bank_withdraw (object *op, const char *text, sint64 *value)
sint64 insert_coins (object *pl, sint64 value)

Detailed Description

Functions dealing with shop handling, bargaining, etc.

Definition in file shop.c.


Function Documentation

object* bank_create_info ( object op)

Create a new bank player info object and insert it to 'op'.

Parameters:
opPlayer.
Returns:
The created player info object.

Definition at line 944 of file shop.c.

int bank_deposit ( object op,
const char *  text,
sint64 *  value 
)

Deposit money to player's bank object.

Parameters:
opPlayer.
textWhat was said to trigger this.
[out]valueWill contain the deposited amount.
Returns:
One of Bank return values.

Definition at line 993 of file shop.c.

sint64 bank_get_balance ( object op)

Query how much money player has stored in bank.

Parameters:
opPlayer to query for.
Returns:
The money stored.

Definition at line 975 of file shop.c.

object* bank_get_create_info ( object op)

Convenience function to either find a bank player info object and if not found, create a new one.

Parameters:
opPlayer object.
Returns:
The bank player info object. Never NULL.

Definition at line 959 of file shop.c.

object* bank_get_info ( object op)

Find bank player info object in player's inventory.

Parameters:
opWhere to look for the player info object.
Returns:
The player info object if found, NULL otherwise.

Definition at line 925 of file shop.c.

int bank_withdraw ( object op,
const char *  text,
sint64 *  value 
)

Withdraw money player previously stored in bank object.

Parameters:
opPlayer.
bankBank object in player's inventory.
textWhat was said to trigger this.
[out]valueWill contain the withdrawn amount.
Returns:
One of Bank return values.

Definition at line 1084 of file shop.c.

char* cost_string_from_value ( sint64  cost)

Converts a price to number of coins.

Parameters:
costValue to transform to currency.
Returns:
Buffer containing the price.

Definition at line 207 of file shop.c.

static archetype* find_next_coin ( sint64  c,
int *  cointype 
) [static]

Find the coin type that is worth more than 'c'. Starts at the cointype placement.

Parameters:
cValue we're searching.
cointypeFirst coin type to search.
Returns:
Coin archetype, NULL if none found.

Definition at line 178 of file shop.c.

int get_money_from_string ( const char *  text,
struct _money_block money 
)

Get money from a string.

Parameters:
textText to get money from.
moneyMoney block structure.
Returns:
One of Money string modes.

Definition at line 728 of file shop.c.

int get_payment ( object pl,
object op 
)

Descends containers looking for unpaid items, and pays for them.

Parameters:
plPlayer buying the stuff.
opObject we are examining. If op has and inventory, we examine that. Ii there are objects below op, we descend down.
Return values:
0Player still has unpaid items.
1Player has paid for everything.

Definition at line 596 of file shop.c.

sint64 insert_coins ( object pl,
sint64  value 
)

Insert coins into a player.

Parameters:
plPlayer.
valueValue of coins to insert (for example, 120 for 1 silver and 20 copper).
Returns:
value.

Definition at line 1166 of file shop.c.

void insert_money_in_player ( object pl,
object money,
uint32  nrof 
)

Insert money inside player.

Parameters:
plPlayer.
moneyMoney object to insert.
nrofHow many money objects to insert to player.

Definition at line 910 of file shop.c.

int pay_for_amount ( sint64  to_pay,
object pl 
)

Takes the amount of money from the the player inventory and from it's various pouches using the pay_from_container() function.

Parameters:
to_payAmount to pay.
plPlayer paying.
Returns:
0 if not enough money, in which case nothing is removed, 1 if money was removed.

Definition at line 342 of file shop.c.

int pay_for_item ( object op,
object pl 
)

This is a wrapper for pay_from_container, which is called for the player, then for each active container that can hold money until op is paid for. Change will be left wherever the last of the price was paid from.

Parameters:
opObject to buy.
plPlayer buying.
Returns:
1 if object was bought, 0 otherwise.

Definition at line 385 of file shop.c.

static sint64 pay_from_container ( object op,
object pouch,
sint64  to_pay 
) [static]

This pays for the item, and takes the proper amount of money off the player.

Parameters:
opPlayer paying.
pouchContainer (pouch or player) to remove the coins from.
to_payRequired amount.
Returns:
Amount still not paid after using "pouch".

Definition at line 428 of file shop.c.

sint64 query_cost ( object tmp,
object who,
int  flag 
)

Return the price of an item for a character.

Parameters:
tmpObject we're querying the price of.
whoWho is inquiring. Can be NULL, only meaningful if player.
flagCombination of F_xxx flags.
Returns:
The price for the item.

Definition at line 40 of file shop.c.

char* query_cost_string ( object tmp,
object who,
int  flag 
)

Query the cost of an object.

This is really a wrapper for cost_string_from_value() and query_cost().

Parameters:
tmpObject we're querying the price of.
whoWho is inquiring. Can be NULL, only meaningful if player.
flagCombination of F_xxx flags.
Returns:
The cost string.

Definition at line 295 of file shop.c.

sint64 query_money ( object op)

Finds out how much money the player is carrying, including what is in containers and in bank.

Parameters:
opItem to get money for. Must be a player or a container.
Returns:
Total money the player is carrying.

Definition at line 305 of file shop.c.

int query_money_type ( object op,
int  value 
)

Query money by type.

Parameters:
opObject.
valueValue of the coin to query for.
Returns:
Total number of coins of the specified type.

Definition at line 809 of file shop.c.

sint64 remove_money_type ( object who,
object op,
sint64  value,
sint64  amount 
)

Remove money by type.

Parameters:
whoPlayer object who is getting the money removed.
opObject we're removing from.
valueValue of the coin type to remove.
amountAmount of money to remove.
Returns:
Removed amount.

Definition at line 841 of file shop.c.

void sell_item ( object op,
object pl,
sint64  value 
)

Player is selling an item. Give money, print appropriate messages.

Parameters:
opObject to sell.
plPlayer. Shouldn't be NULL or non player.
valueIf op is NULL, this value is used instead of using query_cost().

Definition at line 672 of file shop.c.