[Package Index | Mudlib Index | Effect Index]

File /obj/handlers/haggle_handler.c

This handler controls the npcs haggling the price of something with a player. Currently it only handles sell barganing.

Factors of relevance:

  1. merchants' guild rating
  2. race of customer vs. shopkeeper

Includes

This class includes the following files /include/money.h and /include/shops/bank.h

Method index

Public Functions

These are functions that everyone can access.

bargain_factor
int bargain_factor(object keeper,
                   object customer)

This method determines the barganing factor between the customer and the shop keeper.

Parameters:
keeper - the shop keeper
customer - the customer of the shop


insult_factor
int insult_factor(object keeper,
                  object customer)

This method determines the insult factor between the customer and the shop keeper.

Parameters:
keeper - the shop keeper
customer - the customer in the shop


sell_haggle
int * sell_haggle(int value,
                  int offer,
                  int asking,
                  int insults,
                  string place,
                  object keeper,
                  object customer)

This method does the actual haggle on a sell. The logic is as follows:
if offer > asking then
   give back a boggle response
else if offer == asking then
   sell the thing and give an accepted saying
else if offer * insult_factor > asking * 100 then
   adjustment = ( ( asking - offer ) * bargain_factor ) / 100
   asking -= adjustment
   return an adjustment message
else
   return an insulted message
endif
The return from this function is an array of three elements, the first is the a flag saying if the item was accepted or not, the second is the current asking price and the last is the current insult level.
({
   flag (0/1), // This is 0 if unable to sell, 1 if sold
   asking,     // the current asking price
   insults,    // the current insult level
})


Parameters:
value - the real value of the item
offer - the offered value for the item
asking - the current asking price
insults - the current insult level
place - the place for the money strings
keeper - the shop keeper
customer - the customer

Returns:
the array as described above

See also:
insult_factor() and bargain_factor()