ManaPlus
Public Member Functions
TmwAthena::BuySellHandler Class Reference

#include <buysellhandler.h>

Inheritance diagram for TmwAthena::BuySellHandler:
Ea::BuySellHandler Net::BuySellHandler

Public Member Functions

 BuySellHandler ()
 
 ~BuySellHandler ()
 
void requestSellList (const std::string &nick) const
 
void requestBuyList (const std::string &nick) const
 
void sendBuyRequest (const std::string &nick, const ShopItem *const item, const int amount) const
 
void sendSellRequest (const std::string &nick, const ShopItem *const item, const int amount) const
 
void close () const
 
- Public Member Functions inherited from Ea::BuySellHandler
 BuySellHandler ()
 
void cleanDialogReference (const BuyDialog *const dialog) const
 
- Public Member Functions inherited from Net::BuySellHandler
 BuySellHandler ()
 

Detailed Description

Definition at line 32 of file buysellhandler.h.

Constructor & Destructor Documentation

◆ BuySellHandler()

TmwAthena::BuySellHandler::BuySellHandler ( )

Definition at line 44 of file buysellhandler.cpp.

44  :
46 {
47  buySellHandler = this;
49 }
Net::BuySellHandler * buySellHandler
Definition: net.cpp:100
BuyDialog * mBuyDialog
Definition: buysellrecv.cpp:53

References buySellHandler, and Ea::BuySellRecv::mBuyDialog.

◆ ~BuySellHandler()

TmwAthena::BuySellHandler::~BuySellHandler ( )
virtual

Reimplemented from Net::BuySellHandler.

Definition at line 51 of file buysellhandler.cpp.

52 {
53  buySellHandler = nullptr;
54 }

References buySellHandler.

Member Function Documentation

◆ close()

void TmwAthena::BuySellHandler::close ( ) const
virtual

Implements Net::BuySellHandler.

Definition at line 131 of file buysellhandler.cpp.

132 {
133 }

◆ requestBuyList()

void TmwAthena::BuySellHandler::requestBuyList ( const std::string &  nick) const
virtual

Implements Net::BuySellHandler.

Definition at line 75 of file buysellhandler.cpp.

76 {
77  if (nick.empty() || (shopWindow == nullptr))
78  return;
79 
80  const std::string data("!buylist " + toString(tick_time));
83  if (config.getBoolValue("hideShopMessages"))
84  {
86  }
87  else
88  {
89  if (chatWindow != nullptr)
91  }
92 }
Net::ChatHandler * chatHandler
Definition: net.cpp:86
ChatWindow * chatWindow
Definition: chatwindow.cpp:94
void addWhisper(const std::string &nick, const std::string &mes, const ChatMsgTypeT own)
bool getBoolValue(const std::string &key) const
virtual void privateMessage(const std::string &recipient, const std::string &text) const =0
void setAcceptPlayer(const std::string &name)
Definition: shopwindow.h:121
Configuration config
uint32_t data
volatile int tick_time
Definition: timer.cpp:53
std::string toString(T const &value)
converts any type to a string
Definition: catch.hpp:1774
std::string mShopRequestName
Definition: chatrecv.cpp:57
ShopWindow * shopWindow
Definition: shopwindow.cpp:101

References ChatWindow::addWhisper(), ChatMsgType::BY_PLAYER, chatHandler, chatWindow, config, data, Configuration::getBoolValue(), TmwAthena::ChatRecv::mShopRequestName, Net::ChatHandler::privateMessage(), ShopWindow::setAcceptPlayer(), shopWindow, tick_time, and Catch::toString().

◆ requestSellList()

void TmwAthena::BuySellHandler::requestSellList ( const std::string &  nick) const
virtual

Implements Net::BuySellHandler.

Definition at line 56 of file buysellhandler.cpp.

57 {
58  if (nick.empty() || shopWindow == nullptr)
59  return;
60 
61  const std::string data("!selllist " + toString(tick_time));
64  if (config.getBoolValue("hideShopMessages"))
65  {
67  }
68  else
69  {
70  if (chatWindow != nullptr)
72  }
73 }

References ChatWindow::addWhisper(), ChatMsgType::BY_PLAYER, chatHandler, chatWindow, config, data, Configuration::getBoolValue(), TmwAthena::ChatRecv::mShopRequestName, Net::ChatHandler::privateMessage(), ShopWindow::setAcceptPlayer(), shopWindow, tick_time, and Catch::toString().

◆ sendBuyRequest()

void TmwAthena::BuySellHandler::sendBuyRequest ( const std::string &  nick,
const ShopItem *const  item,
const int  amount 
) const
virtual

Implements Net::BuySellHandler.

Definition at line 94 of file buysellhandler.cpp.

97 {
98  if ((chatWindow == nullptr) || nick.empty() || (item == nullptr) ||
99  amount < 1 || amount > item->getQuantity())
100  {
101  return;
102  }
103  const std::string data = strprintf("!buyitem %d %d %d",
104  item->getId(), item->getPrice(), amount);
105 
106  if (config.getBoolValue("hideShopMessages"))
108  else
110 }
int getQuantity() const
Definition: item.h:105
int getId() const
Definition: item.h:81
int getPrice() const
Definition: shopitem.h:132
std::string strprintf(const char *const format,...)

References ChatWindow::addWhisper(), ChatMsgType::BY_PLAYER, chatHandler, chatWindow, config, data, Configuration::getBoolValue(), Item::getId(), ShopItem::getPrice(), Item::getQuantity(), Net::ChatHandler::privateMessage(), and strprintf().

◆ sendSellRequest()

void TmwAthena::BuySellHandler::sendSellRequest ( const std::string &  nick,
const ShopItem *const  item,
const int  amount 
) const
virtual

Implements Net::BuySellHandler.

Definition at line 112 of file buysellhandler.cpp.

115 {
116  if ((chatWindow == nullptr) || nick.empty() || (item == nullptr) ||
117  amount < 1 || amount > item->getQuantity())
118  {
119  return;
120  }
121 
122  const std::string data = strprintf("!sellitem %d %d %d",
123  item->getId(), item->getPrice(), amount);
124 
125  if (config.getBoolValue("hideShopMessages"))
127  else
129 }

References ChatWindow::addWhisper(), ChatMsgType::BY_PLAYER, chatHandler, chatWindow, config, data, Configuration::getBoolValue(), Item::getId(), ShopItem::getPrice(), Item::getQuantity(), Net::ChatHandler::privateMessage(), and strprintf().


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