Planeshift
Exchange Class Referenceabstract

A basic exchange. More...

#include <exchangemanager.h>

Public Member Functions

virtual bool AddItem (Client *fromClient, INVENTORY_SLOT_NUMBER fromSlot, int stackCount, int toSlot)
 Add a new item to the exchange. More...
 
virtual bool AdjustMoney (Client *client, int moneyType, int newMoney)
 
virtual bool AdjustMoney (Client *client, const psMoney &money)
 
bool CheckRange (int clientNum, gemObject *ourActor, gemObject *otherActor)
 
 Exchange (Client *starter, bool automaticExchange, ExchangeManager *manager)
 
int GetID () const
 
virtual psMoney GetOfferedMoney (Client *client)
 
ClientGetStarterClient ()
 
psItemGetStarterOffer (int slot)
 
virtual psItemGetTargetOffer (int slot)
 
virtual bool HandleAccept (Client *client)=0
 One of the client has accepted the exchange. More...
 
virtual void HandleEnd (Client *client)=0
 One of the clients has ended this exchange. More...
 
virtual void MoveItem (Client *client, int fromSlot, int stackCount, int toSlot)
 Move an item from one slot to another in the exchange. More...
 
virtual bool RemoveItem (Client *fromClient, int slot, int stackCount)
 Removes an item from the exchange. More...
 
virtual ~Exchange ()
 
- Public Member Functions inherited from iDeleteObjectCallback
virtual void DeleteObjectCallback (iDeleteNotificationObject *object)=0
 
virtual ~iDeleteObjectCallback ()
 

Protected Member Functions

virtual void SendAddItemMessage (Client *fromClient, int slot, psCharacterInventory::psCharacterInventoryItem *item)
 
void SendEnd (int clientNum)
 
virtual void SendRemoveItemMessage (Client *fromClient, int slot)
 

Protected Attributes

bool automaticExchange
 the exchange is done entirely server side don't open windows on the client. This is used only with NPC! More...
 
bool exchangeEnded
 exchange ended and should be deleted More...
 
ExchangeManagerexchangeMgr
 
bool exchangeSuccess
 exchange was successful and items should not be returned to owners More...
 
int id
 unique exchange ID More...
 
uint32_t player
 
ExchangingCharacter starterChar
 Information about the player that initiated the exchange. More...
 
ClientstarterClient
 

Static Protected Attributes

static int next_id
 

Detailed Description

A basic exchange.

This shares the qualities of any exchange and stores the players involved as well as functionality to start/stop the exchange.

Definition at line 204 of file exchangemanager.h.

Constructor & Destructor Documentation

Exchange::Exchange ( Client starter,
bool  automaticExchange,
ExchangeManager manager 
)
virtual Exchange::~Exchange ( )
virtual

Member Function Documentation

virtual bool Exchange::AddItem ( Client fromClient,
INVENTORY_SLOT_NUMBER  fromSlot,
int  stackCount,
int  toSlot 
)
virtual

Add a new item to the exchange.

Will add to the offering slot of the person that offered it an the receiving slot of the other person. Sends out the relevant network messages.

Parameters
fromClientThe client that this item came from.
fromSlotThe originating slot in the exchange window for the item moved.
stackCountThe number of items being moved.
toSlotWhere in the exchange the item is to be placed.

Reimplemented in PlayerToPlayerExchange.

virtual bool Exchange::AdjustMoney ( Client client,
int  moneyType,
int  newMoney 
)
virtual

Reimplemented in PlayerToPlayerExchange.

virtual bool Exchange::AdjustMoney ( Client client,
const psMoney money 
)
virtual

Reimplemented in PlayerToPlayerExchange.

bool Exchange::CheckRange ( int  clientNum,
gemObject ourActor,
gemObject otherActor 
)
int Exchange::GetID ( ) const
inline

Definition at line 276 of file exchangemanager.h.

virtual psMoney Exchange::GetOfferedMoney ( Client client)
virtual

Reimplemented in PlayerToPlayerExchange.

Client* Exchange::GetStarterClient ( )
inline

Definition at line 282 of file exchangemanager.h.

psItem* Exchange::GetStarterOffer ( int  slot)
virtual psItem* Exchange::GetTargetOffer ( int  slot)
inlinevirtual

Reimplemented in PlayerToPlayerExchange.

Definition at line 288 of file exchangemanager.h.

virtual bool Exchange::HandleAccept ( Client client)
pure virtual

One of the client has accepted the exchange.

If both clients have accepted the exchange will end and the items will be exchanged.

Parameters
clientThe client that has accepted the exchange.
Returns
true If the exchange has ended.

Implemented in PlayerToNPCExchange, and PlayerToPlayerExchange.

virtual void Exchange::HandleEnd ( Client client)
pure virtual

One of the clients has ended this exchange.

This will close the exchange on both the clients without transfer of items.

Parameters
clientThe client that has ended the exchange.

Implemented in PlayerToNPCExchange, and PlayerToPlayerExchange.

virtual void Exchange::MoveItem ( Client client,
int  fromSlot,
int  stackCount,
int  toSlot 
)
virtual

Move an item from one slot to another in the exchange.

Will swap items if another item is already in the destination slot. Sends out the relevant network messages.

Parameters
clientThe client that this item came from.
fromSlotThe originating slot in the exchange window for the item moved.
stackCountThe number of items being moved.
toSlotWhere in the exchange the item is to be placed.
virtual bool Exchange::RemoveItem ( Client fromClient,
int  slot,
int  stackCount 
)
virtual

Removes an item from the exchange.

Sends out the network messages to update the clients' views.

Parameters
fromClientThe client that has removed an item.
slotThe slot that the items were removed from.
stackCountThe amount to remove from that slot.
Returns
A new psItem for the items removed.

Reimplemented in PlayerToPlayerExchange.

virtual void Exchange::SendAddItemMessage ( Client fromClient,
int  slot,
psCharacterInventory::psCharacterInventoryItem item 
)
protectedvirtual

Reimplemented in PlayerToPlayerExchange.

void Exchange::SendEnd ( int  clientNum)
protected
virtual void Exchange::SendRemoveItemMessage ( Client fromClient,
int  slot 
)
protectedvirtual

Reimplemented in PlayerToPlayerExchange.

Member Data Documentation

bool Exchange::automaticExchange
protected

the exchange is done entirely server side don't open windows on the client. This is used only with NPC!

Definition at line 311 of file exchangemanager.h.

bool Exchange::exchangeEnded
protected

exchange ended and should be deleted

Definition at line 308 of file exchangemanager.h.

ExchangeManager* Exchange::exchangeMgr
protected

Definition at line 313 of file exchangemanager.h.

bool Exchange::exchangeSuccess
protected

exchange was successful and items should not be returned to owners

Definition at line 309 of file exchangemanager.h.

int Exchange::id
protected

unique exchange ID

Definition at line 301 of file exchangemanager.h.

int Exchange::next_id
staticprotected

Definition at line 298 of file exchangemanager.h.

uint32_t Exchange::player
protected

Definition at line 306 of file exchangemanager.h.

ExchangingCharacter Exchange::starterChar
protected

Information about the player that initiated the exchange.

Definition at line 304 of file exchangemanager.h.

Client* Exchange::starterClient
protected

Definition at line 305 of file exchangemanager.h.


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