NetMauMau
0.24.0
Client API
|
Utilities and helper functions and macros.
This are several utilities and helper functions and macros to ease the use of the NetMauMau client API
Classes | |
struct | CARDCONFIG |
Structure containing the configuration of initial cards and decks. More... | |
struct | NetMauMau::Common::cardGreaterThan< T > |
Functor to compare cards. More... | |
struct | NetMauMau::Common::cardLessThan< T > |
Functor to compare cards. More... | |
struct | NetMauMau::Common::equalTo< CardType, Tp > |
Generic equality functor. More... | |
Macros | |
#define | MAKE_VERSION(maj, min) |
#define | MAKE_VERSION_REL(maj, min, rel) |
#define | VERSION_MAJ(v) |
#define | VERSION_MIN(v) |
#define | VERSION_REL(v) |
Variables | |
const std::string | NetMauMau::Common::DefaultPlayerImage |
std::string containing the default player image in PNG format More... | |
Server query methods | |
static uint32_t | NetMauMau::Client::AbstractClientV05::getClientProtocolVersion () |
Returns the version of the client's implemented protocol. More... | |
static uint32_t | NetMauMau::Client::AbstractClientV05::getClientLibraryVersion () |
Returns the version of the client library. More... | |
static uint32_t | NetMauMau::Client::AbstractClientV05::parseProtocolVersion (const std::string &version) |
Parses a version string and returns the resulting protocol version. More... | |
static bool | NetMauMau::Client::AbstractClientV05::isPlayerImageUploadable (const unsigned char *pngData, std::size_t pngDataLen) |
Checks if an player image is uploadable to the server. More... | |
static uint16_t | NetMauMau::Client::AbstractClientV05::getDefaultPort () |
Gets the default port of the server. More... | |
static const char * | NetMauMau::Client::AbstractClientV05::getDefaultAIName () |
Gets the compiled in default AI player name. More... | |
CAPABILITIES | NetMauMau::Client::AbstractClientV05::capabilities (timeval *timeout=NULL) throw (NetMauMau::Common::Exception::SocketException) |
Returns the server capabilities. More... | |
PLAYERINFOS | NetMauMau::Client::AbstractClientV05::playerList (bool playerPNG, timeval *timeout=NULL) throw (NetMauMau::Common::Exception::SocketException) |
Returns the list of currently registered player names. More... | |
PLAYERLIST | NetMauMau::Client::AbstractClientV05::playerList (timeval *timeout=NULL) throw (NetMauMau::Common::Exception::SocketException) |
Returns the list of currently registered player names. More... | |
std::string | NetMauMau::Client::AbstractClientV05::getPlayerName () const |
Gets the player's name. More... | |
Server query methods | |
static bool | NetMauMau::Client::AbstractClientV11::isPlayerImageUploadable (const unsigned char *pngData, std::size_t pngDataLen, const IBase64 *base64) |
Checks if an player image is uploadable to the server. More... | |
Card SUIT helpers | |
const std::string * | NetMauMau::Common::getSuitSymbols () |
Get an array of the four SUIT symbols. More... | |
std::string | NetMauMau::Common::ansiSuit (const std::string &suit) |
Converts a SUIT symbol to a ANSI color representation. More... | |
NetMauMau::Common::ICard::SUIT | NetMauMau::Common::symbolToSuit (const std::string &symbol) |
Converts a symbol to a NetMauMau::Common::ICard::SUIT. More... | |
std::string | NetMauMau::Common::suitToSymbol (NetMauMau::Common::ICard::SUIT suit, bool ansi, bool endansi=false) |
Converts a NetMauMau::Common::ICard::SUIT to a symbol. More... | |
Card description | |
bool | NetMauMau::Common::parseCardDesc (const std::string &desc, NetMauMau::Common::ICard::SUIT *suit, NetMauMau::Common::ICard::RANK *rank) |
Parses a textual description. More... | |
std::string | NetMauMau::Common::createCardDesc (NetMauMau::Common::ICard::SUIT suite, NetMauMau::Common::ICard::RANK rank, bool ansi) |
Creates a card description. More... | |
Sorting cards | |
unsigned int | NetMauMau::Common::suitOrderPosition (NetMauMau::Common::ICard::SUIT suit) |
Gets an ordinal number for a SUIT . More... | |
unsigned int | NetMauMau::Common::rankOrderPosition (NetMauMau::Common::ICard::RANK rank) |
Gets an ordinal number for a RANK . More... | |
bool | NetMauMau::Common::cardEqual (const NetMauMau::Common::ICard *lhs, const NetMauMau::Common::ICard *rhs) |
Checks if two cards are equal. More... | |
bool | NetMauMau::Common::cardLess (const NetMauMau::Common::ICard *lhs, const NetMauMau::Common::ICard *rhs) |
Checks if a card comes before another. More... | |
bool | NetMauMau::Common::cardGreater (const NetMauMau::Common::ICard *lhs, const NetMauMau::Common::ICard *rhs) |
Checks if a card comes before another. More... | |
Identifying and finding cards | |
bool | NetMauMau::Common::isSuit (const NetMauMau::Common::ICard *card, NetMauMau::Common::ICard::SUIT suit) |
Checks if the a card is of SUIT . More... | |
bool | NetMauMau::Common::isRank (const NetMauMau::Common::ICard *card, NetMauMau::Common::ICard::RANK rank) |
Checks if the a card is of RANK . More... | |
template<typename Tp , typename Iterator > | |
std::iterator_traits< Iterator > ::value_type | NetMauMau::Common::find (Tp arg, Iterator first, Iterator last) |
Generic find function. More... | |
template<typename Iterator > | |
std::iterator_traits< Iterator > ::value_type | NetMauMau::Common::findSuit (NetMauMau::Common::ICard::SUIT suit, Iterator first, Iterator last) |
Finds the first card of a given SUIT . More... | |
template<typename Iterator > | |
std::iterator_traits< Iterator > ::value_type | NetMauMau::Common::findRank (NetMauMau::Common::ICard::RANK rank, Iterator first, Iterator last) |
Finds the first card of a given RANK . More... | |
template<typename Iterator > | |
std::iterator_traits< Iterator > ::value_type | NetMauMau::Common::findCard (typename Iterator::value_type card, Iterator first, Iterator last) |
Finds the first card equal to a given card. More... | |
Miscellaneous functions | |
NetMauMau::Common::ICard * | NetMauMau::Common::getIllegalCard () |
Gets an illegal card card to trigger special actions. More... | |
CARDCONFIG | NetMauMau::Common::getCardConfig (std::size_t players, std::size_t initialCardCount=5, std::size_t decks=1) |
Determines reasonable amounts of initial cards and card decks. More... | |
const char * | NetMauMau::Common::getServerExe () |
Gets the executable name of the server. More... | |
std::size_t | NetMauMau::Common::getCardPoints (NetMauMau::Common::ICard::RANK rank) |
Gets the points of a RANK . More... | |
#define MAKE_VERSION | ( | maj, | |
min | |||
) |
#include <iconnection.h>
Computes the corresponding version number integer to an usigned 32 bit integer
maj | the major of the version number |
min | the minor of the version number |
Referenced by NetMauMau::Client::AbstractClientV05::getClientProtocolVersion(), and NetMauMau::Client::AbstractClientV05::parseProtocolVersion().
#define MAKE_VERSION_REL | ( | maj, | |
min, | |||
rel | |||
) |
#include <iconnection.h>
Computes the corresponding version number integer to an usigned 32 bit integer
maj | the major of the version number |
min | the minor of the version number |
rel | the release of the version number |
Referenced by NetMauMau::Client::AbstractClientV05::getClientLibraryVersion(), and NetMauMau::Client::AbstractClientV05::parseProtocolVersion().
#define VERSION_MAJ | ( | v | ) |
#include <iconnection.h>
Gets the major number of the version as unsigned 16 bit integer
v | the version number |
#define VERSION_MIN | ( | v | ) |
#include <iconnection.h>
Gets the minor number of the version as unsigned 16 bit integer
v | the version number |
#define VERSION_REL | ( | v | ) |
#include <iconnection.h>
Gets the release number of the version as unsigned 16 bit integer
v | the version number |
std::string NetMauMau::Common::ansiSuit | ( | const std::string & | suit | ) |
#include <cardtools.h>
Converts a SUIT
symbol to a ANSI color representation.
suit | the SUIT symbol |
SUIT
symbol in ANSI color representation References NetMauMau::Common::suitToSymbol(), and NetMauMau::Common::symbolToSuit().
Connection::CAPABILITIES AbstractClientV05::capabilities | ( | timeval * | timeout = NULL | ) | |
throw | ( | NetMauMau::Common::Exception::SocketException | |||
) |
#include <abstractclient.h>
Returns the server capabilities.
timeout | the time to wait for a connection, if NULL there will be no timeout |
Common::Exception::SocketException | if the connection failed |
Client::Exception::CapabilitiesException | if the capabilities cannot get retrieved |
Client::Exception::TimeoutException | if the connection attempt timed out |
bool NetMauMau::Common::cardEqual | ( | const NetMauMau::Common::ICard * | lhs, |
const NetMauMau::Common::ICard * | rhs | ||
) |
#include <cardtools.h>
Checks if two cards are equal.
NetMauMau::Common::equalTo
insteadlhs | a card |
rhs | a card |
true
if the cards are equal, false
otherwise bool NetMauMau::Common::cardGreater | ( | const NetMauMau::Common::ICard * | lhs, |
const NetMauMau::Common::ICard * | rhs | ||
) |
#include <cardtools.h>
Checks if a card comes before another.
Useful for sorting with rank first than suit
lhs | a card |
rhs | a card |
true
if lhs
comes before rhs
, false
otherwisebool NetMauMau::Common::cardLess | ( | const NetMauMau::Common::ICard * | lhs, |
const NetMauMau::Common::ICard * | rhs | ||
) |
#include <cardtools.h>
Checks if a card comes before another.
Useful for sorting with suit first than rank
lhs | a card |
rhs | a card |
true
if lhs
comes before rhs
, false
otherwise std::string NetMauMau::Common::createCardDesc | ( | NetMauMau::Common::ICard::SUIT | suite, |
NetMauMau::Common::ICard::RANK | rank, | ||
bool | ansi | ||
) |
#include <cardtools.h>
Creates a card description.
suite | the SUIT |
rank | the RANK |
ansi | if true create a ANSI color representation |
References NetMauMau::Common::suitToSymbol().
std::iterator_traits<Iterator>::value_type NetMauMau::Common::find | ( | Tp | arg, |
Iterator | first, | ||
Iterator | last | ||
) |
#include <cardtools.h>
Generic find function.
Search for the first occurrence of a card
Tp | NetMauMau::Common::ICard::SUIT , NetMauMau::Common::ICard::RANK or pointer to NetMauMau::Common::ICard type |
Iterator | iterator type to a collection of NetMauMau::Common::ICard type pointers |
NetMauMau::Common::equalTo
instead arg | NetMauMau::Common::ICard::SUIT , NetMauMau::Common::ICard::RANK or pointer to NetMauMau::Common::ICard type |
first | iterator to begin of the range to search for |
last | iterator to end of the range to search for |
NetMauMau::Common::ICard
type pointer, or NULL
if nothing was foundReferenced by NetMauMau::Common::findCard(), NetMauMau::Common::findRank(), and NetMauMau::Common::findSuit().
|
inline |
#include <cardtools.h>
Finds the first card equal to a given card.
Iterator | an iterator |
NetMauMau::Common::find
insteadcard | the card to find |
first | iterator to the first card |
last | iterator to the last card |
0L
otherwise References NetMauMau::Common::find().
|
inline |
#include <cardtools.h>
Finds the first card of a given RANK
.
Iterator | an iterator |
NetMauMau::Common::find
insteadrank | the RANK to find |
first | iterator to the first card |
last | iterator to the last card |
0L
otherwise References NetMauMau::Common::find().
|
inline |
#include <cardtools.h>
Finds the first card of a given SUIT
.
Iterator | an iterator |
NetMauMau::Common::find
insteadsuit | the SUIT to find |
first | iterator to the first card |
last | iterator to the last card |
0L
otherwise References NetMauMau::Common::find().
NetMauMau::Common::CARDCONFIG NetMauMau::Common::getCardConfig | ( | std::size_t | players, |
std::size_t | initialCardCount = 5 , |
||
std::size_t | decks = 1 |
||
) |
#include <cardtools.h>
Determines reasonable amounts of initial cards and card decks.
This function calculates reasonable values based on the amount of players
, initialCardCount
and decks
.
This function can be used by clients to avoid the server adjusting the given parameters.
players | the amount of players |
initialCardCount | the desired amount of initial cards |
decks | the desired amount of card decks |
std::size_t NetMauMau::Common::getCardPoints | ( | NetMauMau::Common::ICard::RANK | rank | ) |
#include <cardtools.h>
Gets the points of a RANK
.
Rank | Points |
---|---|
Seven | 1 |
Eight | 2 |
Nine | 3 |
Ten | 4 |
Queen | 5 |
King | 6 |
Ace | 11 |
Jack | 20 |
rank | the RANK |
RANK
|
static |
#include <abstractclient.h>
Returns the version of the client library.
References MAKE_VERSION_REL.
|
static |
#include <abstractclient.h>
Returns the version of the client's implemented protocol.
You can retrieve major and minor version as following:
References MAKE_VERSION.
|
static |
#include <abstractclient.h>
Gets the compiled in default AI player name.
|
static |
#include <abstractclient.h>
Gets the default port of the server.
NetMauMau::Common::ICard * NetMauMau::Common::getIllegalCard | ( | ) |
#include <cardtools.h>
Gets an illegal card card to trigger special actions.
std::string AbstractClientV05::getPlayerName | ( | ) | const |
#include <abstractclient.h>
Gets the player's name.
const char * NetMauMau::Common::getServerExe | ( | ) |
#include <cardtools.h>
Gets the executable name of the server.
const std::string * NetMauMau::Common::getSuitSymbols | ( | ) |
#include <cardtools.h>
Get an array of the four SUIT
symbols.
SUIT
symbols
|
static |
#include <abstractclient.h>
Checks if an player image is uploadable to the server.
pngData | the image data |
pngDataLen | length of the image data |
true
if the file will most probably accepted by the server, false
otherwiseReferenced by NetMauMau::Client::AbstractClientV11::isPlayerImageUploadable().
|
static |
#include <abstractclient.h>
Checks if an player image is uploadable to the server.
pngData | the image data |
pngDataLen | length of the image data |
true
if the file will most probably accepted by the server, false
otherwisebase64 | interface to a custom implementation of IBase64 |
References NetMauMau::Client::AbstractClientV05::isPlayerImageUploadable().
bool NetMauMau::Common::isRank | ( | const NetMauMau::Common::ICard * | card, |
NetMauMau::Common::ICard::RANK | rank | ||
) |
#include <cardtools.h>
Checks if the a card is of RANK
.
card | the card to check |
rank | the RANK to check for |
NetMauMau::Common::equalTo
insteadtrue
if the card is of RANK
bool NetMauMau::Common::isSuit | ( | const NetMauMau::Common::ICard * | card, |
NetMauMau::Common::ICard::SUIT | suit | ||
) |
#include <cardtools.h>
Checks if the a card is of SUIT
.
card | the card to check |
suit | the SUIT to check for |
NetMauMau::Common::equalTo
insteadtrue
if the card is of SUIT
|
related |
Compares a card against a rank.
card | card to compare to |
rank | rank to compare to |
false
if equal, true
otherwiseReferences NetMauMau::Common::ICard::getRank().
|
related |
Compares a card against a suit.
card | card to compare to |
suit | suit to compare to |
false
if equal, true
otherwiseReferences NetMauMau::Common::ICard::getSuit().
|
related |
Compares cards.
lhs | left card |
rhs | right card |
false
if equal, true
otherwise
|
related |
Compares a card against a rank.
card | card to compare to |
rank | rank to compare to |
false
if equal, true
otherwise
|
related |
Compares a card against a suit.
card | card to compare to |
suit | suit to compare to |
false
if equal, true
otherwise
|
related |
Compares cards.
lhs | left card |
rhs | right card |
true
if lesser, false
otherwiseReferences NetMauMau::Common::ICard::getRank(), NetMauMau::Common::ICard::getSuit(), NetMauMau::Common::rankOrderPosition(), and NetMauMau::Common::suitOrderPosition().
|
related |
Compares a card against a rank.
card | card to compare to |
rank | rank to compare to |
true
if equal, false
otherwiseReferences NetMauMau::Common::ICard::getRank().
|
related |
Compares a card against a suit.
card | card to compare to |
suit | suit to compare to |
true
if equal, false
otherwiseReferences NetMauMau::Common::ICard::getSuit().
|
related |
Compares cards.
lhs | left card |
rhs | right card |
true
if equal, false
otherwiseReferences NetMauMau::Common::ICard::getRank(), and NetMauMau::Common::ICard::getSuit().
|
related |
Compares a card against a rank.
card | card to compare to |
rank | rank to compare to |
true
if equal, false
otherwise
|
related |
Compares a card against a suit.
card | card to compare to |
suit | suit to compare to |
true
if equal, false
otherwise
|
related |
Compares cards.
lhs | left card |
rhs | right card |
true
if greater, false
otherwiseReferences NetMauMau::Common::ICard::getRank(), NetMauMau::Common::ICard::getSuit(), NetMauMau::Common::rankOrderPosition(), and NetMauMau::Common::suitOrderPosition().
bool NetMauMau::Common::parseCardDesc | ( | const std::string & | desc, |
NetMauMau::Common::ICard::SUIT * | suit, | ||
NetMauMau::Common::ICard::RANK * | rank | ||
) |
#include <cardtools.h>
Parses a textual description.
Parses a textual description and stores the suit and the rank into the pointers, which cannot be null.
[in] | desc | the textual description of the card |
[out] | suit | pointer to store the resulting SUIT |
[out] | rank | pointer to store the resulting RANK |
true
if the parsing was successful, false
otherwise References NetMauMau::Common::symbolToSuit().
|
static |
#include <abstractclient.h>
Parses a version string and returns the resulting protocol version.
version | the protocol version as string |
References MAKE_VERSION, and MAKE_VERSION_REL.
Connection::PLAYERINFOS AbstractClientV05::playerList | ( | bool | playerPNG, |
timeval * | timeout = NULL |
||
) | |||
throw | ( | NetMauMau::Common::Exception::SocketException | |
) |
#include <abstractclient.h>
Returns the list of currently registered player names.
NetMauMau::Client::AbstractClient::PLAYERLIST
must be freed by the userplayerPNG | true if the player images should get retrieved |
timeout | the time to wait for a connection, if NULL there will be no timeout |
Common::Exception::SocketException | if the connection failed |
Client::Exception::PlayerlistException | if the player list cannot get retrieved |
Client::Exception::TimeoutException | if the connection attempt timed out |
Client::Exception::CapabilitiesException | if called within a running game |
Connection::PLAYERLIST AbstractClientV05::playerList | ( | timeval * | timeout = NULL | ) | |
throw | ( | NetMauMau::Common::Exception::SocketException | |||
) |
#include <abstractclient.h>
Returns the list of currently registered player names.
It does not retrieve the player images
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
unsigned int NetMauMau::Common::rankOrderPosition | ( | NetMauMau::Common::ICard::RANK | rank | ) |
#include <cardtools.h>
Gets an ordinal number for a RANK
.
rank | the RANK to get the ordinal for |
RANK
References NetMauMau::Common::ICard::ACE, NetMauMau::Common::ICard::EIGHT, NetMauMau::Common::ICard::JACK, NetMauMau::Common::ICard::KING, NetMauMau::Common::ICard::NINE, NetMauMau::Common::ICard::QUEEN, NetMauMau::Common::ICard::SEVEN, and NetMauMau::Common::ICard::TEN.
Referenced by NetMauMau::Common::ICard::operator<(), and NetMauMau::Common::ICard::operator>().
unsigned int NetMauMau::Common::suitOrderPosition | ( | NetMauMau::Common::ICard::SUIT | suit | ) |
#include <cardtools.h>
Gets an ordinal number for a SUIT
.
The ordinals follow the Skat and Doppelkopf order
See here: http://i-p-c-s.org/faq/suit-ranking.php
suit | the SUIT to get the ordinal for |
SUIT
Referenced by NetMauMau::Common::ICard::operator<(), and NetMauMau::Common::ICard::operator>().
std::string NetMauMau::Common::suitToSymbol | ( | NetMauMau::Common::ICard::SUIT | suit, |
bool | ansi, | ||
bool | endansi = false |
||
) |
#include <cardtools.h>
Converts a NetMauMau::Common::ICard::SUIT to a symbol.
suit | the SUIT to convert |
ansi | if true create a ANSI color representation |
endansi | if false (default) don't end the ANSI color codes |
SUIT
symbol Referenced by NetMauMau::Common::ansiSuit(), and NetMauMau::Common::createCardDesc().
NetMauMau::Common::ICard::SUIT NetMauMau::Common::symbolToSuit | ( | const std::string & | symbol | ) |
#include <cardtools.h>
Converts a symbol to a NetMauMau::Common::ICard::SUIT.
symbol | the symbol |
SUIT
Referenced by NetMauMau::Common::ansiSuit(), and NetMauMau::Common::parseCardDesc().
const std::string NetMauMau::Common::DefaultPlayerImage |
#include <defaultplayerimage.h>
std::string
containing the default player image in PNG format