Planeshift
ExchangingCharacter Class Reference

ExchangingCharacter holds relevant information about character that is participating in exchange of items with another character. More...

#include <exchangemanager.h>

Public Member Functions

void AdjustMoney (int coin, int delta)
 Change the amount of money this character is offering in the exchange. More...
 
void AdjustMoney (const psMoney &amount)
 
 ExchangingCharacter (int client, psCharacterInventory &inv)
 
bool GetExchangedItems (csString &text)
 
psItemGetOfferedItem (int slot)
 
psMoney GetOfferedMoney ()
 
void GetOffering (csString &buff)
 Constructs an XML list of the items that are being offered. More...
 
void GetOfferingCSV (csString &buff)
 
void GetSimpleOffering (csString &buff, psCharacter *chr, bool exact=true)
 Constructs a simple XML list of the items that are being offered. More...
 
float GetSumSize ()
 Gets the total size of all the items that are offered. More...
 
float GetSumWeight ()
 Gets the total weight of all the items that are offered. More...
 
bool IsOfferingSane ()
 Make sure all offered items still have legal stack counts. More...
 
bool MoveOfferedItem (int fromSlot, int stackcount, int toSlot)
 
bool OfferItem (int exchSlotNum, INVENTORY_SLOT_NUMBER invSlot, int stackcount, bool test)
 Inserts item to position 'itemNum'. More...
 
bool RemoveItemFromOffer (int itemNum, int count, int &remain)
 Removes items from position 'itemNum'. More...
 
void TransferMoney (int targetClientNum)
 Transfers the trias from this exchanging player to a different player. More...
 
void TransferMoney (psCharacter *target)
 Transfers the trias from this exchanging player to another character. More...
 
void TransferOffer (int targetClientNum)
 Transfers offered items and money to character 'target'. More...
 
void TransferOffer (psCharacter *npc)
 Transfers offered items and money to an NPC 'npc'. More...
 
void UpdateOfferingMoney ()
 Update the money box for money that is being offered by this character. More...
 
void UpdateReceivingMoney (psMoney &money)
 Update the money box for money that will be received by this character. More...
 

Public Attributes

psMoney offeringMoney
 

Protected Member Functions

psCharacterGetClientCharacter (int clientNum)
 

Protected Attributes

psCharacterInventorychrinv
 
int client
 Stuff that was removed from character inventory and offered to the other character. More...
 

Detailed Description

ExchangingCharacter holds relevant information about character that is participating in exchange of items with another character.

Definition at line 54 of file exchangemanager.h.

Constructor & Destructor Documentation

ExchangingCharacter::ExchangingCharacter ( int  client,
psCharacterInventory inv 
)

Member Function Documentation

void ExchangingCharacter::AdjustMoney ( int  coin,
int  delta 
)

Change the amount of money this character is offering in the exchange.

Parameters
coinIs one of the 4 coin types. Defined in common/rpgrules/psmoney.h
deltaThe amount to change by. Can be +/-
void ExchangingCharacter::AdjustMoney ( const psMoney amount)
psCharacter* ExchangingCharacter::GetClientCharacter ( int  clientNum)
protected
bool ExchangingCharacter::GetExchangedItems ( csString &  text)
psItem* ExchangingCharacter::GetOfferedItem ( int  slot)
psMoney ExchangingCharacter::GetOfferedMoney ( )
inline

Definition at line 113 of file exchangemanager.h.

void ExchangingCharacter::GetOffering ( csString &  buff)

Constructs an XML list of the items that are being offered.

The format of the xml is: <L MONEY=psMoney.ToString> <ITEM N=name SLT_POS=slotposition C=count WT=weight IMG=icon image> ... </L>

Parameters
buff[CHANGES] Is where the resulting xml message is built.
void ExchangingCharacter::GetOfferingCSV ( csString &  buff)
void ExchangingCharacter::GetSimpleOffering ( csString &  buff,
psCharacter chr,
bool  exact = true 
)

Constructs a simple XML list of the items that are being offered.

The format of the xml is when exact: <L MONEY="psMoney.ToString"><ITEM N=name C=count Q=quality />...</L> else: <L MONEY="0,0,0,psMoney.GetTotal"><ITEM N=name C=count Q=quality />...</L>

Parameters
buff[CHANGES] Is where the resulting xml message is built.
chrThe character
exactShould the offer be exactly
float ExchangingCharacter::GetSumSize ( )

Gets the total size of all the items that are offered.

float ExchangingCharacter::GetSumWeight ( )

Gets the total weight of all the items that are offered.

bool ExchangingCharacter::IsOfferingSane ( )

Make sure all offered items still have legal stack counts.

bool ExchangingCharacter::MoveOfferedItem ( int  fromSlot,
int  stackcount,
int  toSlot 
)
bool ExchangingCharacter::OfferItem ( int  exchSlotNum,
INVENTORY_SLOT_NUMBER  invSlot,
int  stackcount,
bool  test 
)

Inserts item to position 'itemNum'.

If there is another item at this position already, it tries to stack them.

Returns
-1 on failure otherwise the number of remaining items
bool ExchangingCharacter::RemoveItemFromOffer ( int  itemNum,
int  count,
int remain 
)

Removes items from position 'itemNum'.

Can return NULL if there is no item. Returned item instance now belongs to caller.

Parameters
itemNumThe position to remove from.
countCount=-1 means take everything.
remain[CHANGES] The number of items left in the slot ( if any )
void ExchangingCharacter::TransferMoney ( int  targetClientNum)

Transfers the trias from this exchanging player to a different player.

Parameters
targetClientNumThe client id of the client that should be receiving this characters offering money.
void ExchangingCharacter::TransferMoney ( psCharacter target)

Transfers the trias from this exchanging player to another character.

void ExchangingCharacter::TransferOffer ( int  targetClientNum)

Transfers offered items and money to character 'target'.

Target can be 0 - in this case everything is just destroyed.

void ExchangingCharacter::TransferOffer ( psCharacter npc)

Transfers offered items and money to an NPC 'npc'.

void ExchangingCharacter::UpdateOfferingMoney ( )

Update the money box for money that is being offered by this character.

void ExchangingCharacter::UpdateReceivingMoney ( psMoney money)

Update the money box for money that will be received by this character.

Member Data Documentation

psCharacterInventory* ExchangingCharacter::chrinv
protected

Definition at line 193 of file exchangemanager.h.

int ExchangingCharacter::client
protected

Stuff that was removed from character inventory and offered to the other character.

Definition at line 192 of file exchangemanager.h.

psMoney ExchangingCharacter::offeringMoney

Definition at line 168 of file exchangemanager.h.


The documentation for this class was generated from the following file: