mElite
1.0
An Elite clone based on TextElite by Jan-Philipp Kappmeier and Melanie Schmidt.
|
Provides an interface to communicate with the inner text elite object. More...
#include <Wrapper.h>
Construction | |
Wrapper (void(*userErrorFnc)(std::string), void(*progErrorFnc)(std::string)) | |
Constructor. | |
~Wrapper (void) | |
Destructor. | |
Get functions | |
The following functions provide a wide range of information about the status of the current game that is saved within the TextEliteGame object. | |
System | getSystemInfo (int number) |
Get system information. | |
int | getCurrentSystem () |
Get the current system. | |
std::vector< int > * | getLocalSystems () |
Get systems near to the current system. | |
std::vector< int > * | getSystemsInRectangle (int left, int right, int bottom, int top) |
Get systems in a special region. | |
bool | systemIsReachable (int number) |
Check if a system is reachable. | |
bool | systemIsInLocalRange (int number) |
Check if a system is generally reachable. | |
float | getMaxFuel () |
Get the maximal amount of fuel. | |
float | getFuelAmount () |
Get actual amount of fuel. | |
int | getNumberOfTradegoods () |
Get the number of tradegoods. | |
std::vector< Tradegood > * | getAllTradegoodDescriptions () |
Get descriptions for the tradegood. | |
Tradegood | getTradegoodDescription (int) |
Get the description to one tradegood. | |
bool | tradegoodIsInTons (int) |
Check if a tradegood is weighted in tonnes. | |
std::vector< MarketplaceItem > * | getCurrentMarketplace () |
Get information about the current marketplace. | |
float | getFuelCost () |
Gets the price for one LY fuel. | |
std::vector< int > * | getCurrentCargo () |
Gets information about the current cargo. | |
unsigned int | getFreeHoldspace () |
Gets the room in cargo. | |
float | getCurrentCash () |
Get the current cash. | |
unsigned int | getCargoBaySize () |
Get the size of the cargo bay. | |
Actions | |
The following functions implement the actions jump, buy and sell. | |
void | buyFuel (float amount) |
Buy fuel. | |
void | performJump (int number) |
Jump to another system. | |
std::string | performPurchase (int number, int amount) |
Buy a tradegood. | |
std::string | performSale (int number, int amount) |
Sell a tradegood. | |
Control functions (or cheating) | |
The following functions can set values directly without playing after the rules of the game. This can be used to provide additional features (as a cargo bay upgrade) or for cheating. | |
void | setCash (float amount) |
Sets the amount of cash that we have. | |
void | setFuel (float amount) |
Sets the amount of fuel that we have. | |
void | setCargoBay (unsigned int amount) |
Sets the size of the cargo bay that we have. | |
void | addCash (float amount) |
Adds 'amount' cash to the current amount of cash. | |
void | addFuel (float amount) |
Tries to add 'amount' fuel to the current amount of fuel. | |
void | addCargoSpace (unsigned int amount) |
Increases the size of the cargo bay by 'amount'. | |
Provides an interface to communicate with the inner text elite object.
Some functions transform the information because the text elite objects saves it in different ways; other functions simply call the corrisponding functions from the TextEliteGame-object.
Wrapper::Wrapper | ( | void(*)(std::string) | userErrorFnc, |
void(*)(std::string) | progErrorFnc | ||
) |
Constructor.
The constructor sets the names of the tradegoods and constructs a text elite object
Definition at line 22 of file Wrapper.cpp.
Wrapper::~Wrapper | ( | void | ) |
Destructor.
Definition at line 63 of file Wrapper.cpp.
void Wrapper::addCargoSpace | ( | unsigned int | amount | ) |
Increases the size of the cargo bay by 'amount'.
Definition at line 480 of file Wrapper.cpp.
void Wrapper::addCash | ( | float | amount | ) |
Adds 'amount' cash to the current amount of cash.
Negative values are allowed but not recommended.
Definition at line 473 of file Wrapper.cpp.
void Wrapper::addFuel | ( | float | amount | ) |
Tries to add 'amount' fuel to the current amount of fuel.
It failes if the tank would be too full.
Definition at line 455 of file Wrapper.cpp.
void Wrapper::buyFuel | ( | float | amount | ) |
Buy fuel.
Attempts to buy 'amount' fuel. This can fail because of the following errors:
If an error occures it is always bought as much as possible.
amount | The amount of fuel that should be bought. |
Definition at line 312 of file Wrapper.cpp.
std::vector< Tradegood > * Wrapper::getAllTradegoodDescriptions | ( | void | ) |
Get descriptions for the tradegood.
Returns a list with names and units of all known tradegoods. The structure 'Tradegood' from wrappDef.h is used. The information about tradegoods is stored in the wrapperclass and in the TextEliteGame class.
Definition at line 190 of file Wrapper.cpp.
unsigned int Wrapper::getCargoBaySize | ( | void | ) |
Get the size of the cargo bay.
Returns the size of the cargo bay. It can be changed using the cheat functions.
Definition at line 291 of file Wrapper.cpp.
std::vector< int > * Wrapper::getCurrentCargo | ( | void | ) |
Gets information about the current cargo.
Tells how much we have in our cargo for each of the 17 buyable items.
Definition at line 257 of file Wrapper.cpp.
float Wrapper::getCurrentCash | ( | void | ) |
Get the current cash.
Returns the amount of available cash
Definition at line 278 of file Wrapper.cpp.
std::vector< MarketplaceItem > * Wrapper::getCurrentMarketplace | ( | void | ) |
Get information about the current marketplace.
Gives a list of MarketplaceItems saying how much is available of each of the 17 items and how much it costs (both regarding the market in the current system). The structure 'MarketplaceItem' from wrappDef.h is used.
Definition at line 238 of file Wrapper.cpp.
int Wrapper::getCurrentSystem | ( | ) |
Get the current system.
Returns the number of the system we are currently in.
Definition at line 95 of file Wrapper.cpp.
unsigned int Wrapper::getFreeHoldspace | ( | void | ) |
Gets the room in cargo.
Tells how much space is free for storing additional items. Only items with unit 't' are taken into account, 'kg' and 'g' make no difference
Definition at line 268 of file Wrapper.cpp.
float Wrapper::getFuelAmount | ( | ) |
Get actual amount of fuel.
Returns the actual amount of fuel
Definition at line 167 of file Wrapper.cpp.
float Wrapper::getFuelCost | ( | ) |
Gets the price for one LY fuel.
Returns the price for one lightyear of fuel
Definition at line 248 of file Wrapper.cpp.
std::vector< int > * Wrapper::getLocalSystems | ( | ) |
Get systems near to the current system.
Returns an int-vector with the numbers of all systems that could be reached if we had the maximal amount of fuel (7.0 LY). We decided that the system info can only be seen for systems within this range; this is somehow analogous to textelite, where you can see the info for all systems if you know their names, but you can only see the names of systems in local range.
Definition at line 109 of file Wrapper.cpp.
float Wrapper::getMaxFuel | ( | ) |
Get the maximal amount of fuel.
Returns the amount of fuel that fits into the tank The player cannot buy more fuel. Systems that can be reaches with full tank are said to be in 'local range'
Definition at line 158 of file Wrapper.cpp.
int Wrapper::getNumberOfTradegoods | ( | void | ) |
Get the number of tradegoods.
Returns the number of known tradegoods the information about tradegoos is stored in the wrapperclass and in the TextEliteGame class
Definition at line 177 of file Wrapper.cpp.
System Wrapper::getSystemInfo | ( | int | number | ) |
Get system information.
Returns information about the system with the given number the structure 'system' from wrappDef.h is used
Definition at line 80 of file Wrapper.cpp.
std::vector< int > * Wrapper::getSystemsInRectangle | ( | int | left, |
int | right, | ||
int | bottom, | ||
int | top | ||
) |
Get systems in a special region.
this function returns an int-vector with the numbers of all systems within the given rectangle. Because we decided to divide y-coordinates by 2 for the use in our classes, we have to multiply them by 2 when we contact the textelite.
Definition at line 121 of file Wrapper.cpp.
Tradegood Wrapper::getTradegoodDescription | ( | int | number | ) |
Get the description to one tradegood.
Returns the name and unit of a certain tradegood. The structure 'Tradegood' from wrappDef.h is used. The information about tradegoods is stored in the wrapperclass and in the TextEliteGame class.
number | The number of the tradegood |
Definition at line 208 of file Wrapper.cpp.
void Wrapper::performJump | ( | int | number | ) |
Jump to another system.
Attempts to jump to the system with number 'number'. This can fail because of the following errors:
In this cases the player stays where he is.
number | The internal number of the destination system. |
Definition at line 332 of file Wrapper.cpp.
std::string Wrapper::performPurchase | ( | int | number, |
int | amount | ||
) |
Buy a tradegood.
Attempts to buy 'amount' items of type 'number'. This can fail because of one of the following errors:
In this cases it is always bought as much as possible.
number | The number of the tradegood |
amount | The quantity of items that should be bought |
Definition at line 352 of file Wrapper.cpp.
std::string Wrapper::performSale | ( | int | number, |
int | amount | ||
) |
Sell a tradegood.
Attempts to sell 'amount' items of type 'number'. This can fail because of the following errors:
It is sold as much as possible.
number | The number of the tradegood |
amount | The quantity of items that should be bought |
Definition at line 385 of file Wrapper.cpp.
void Wrapper::setCargoBay | ( | unsigned int | amount | ) |
Sets the size of the cargo bay that we have.
This can fail if the current cargo would not fit into the new cargo space In this case the cargo bay does not change.
Definition at line 447 of file Wrapper.cpp.
void Wrapper::setCash | ( | float | amount | ) |
Sets the amount of cash that we have.
Because the cash is saved differently inside textelite we have to multiply it with 10 before calling the appropriate function.
Definition at line 417 of file Wrapper.cpp.
void Wrapper::setFuel | ( | float | amount | ) |
Sets the amount of fuel that we have.
Because the fuel is saved differently inside textelite we have to multiply it with 10 before calling the appropriate function.
Definition at line 432 of file Wrapper.cpp.
bool Wrapper::systemIsInLocalRange | ( | int | number | ) |
Check if a system is generally reachable.
Returns whether the system 'number' is reachable from the current system if we have the maximal amount of fuel. The player can only see system information for systems in local range.
Definition at line 146 of file Wrapper.cpp.
bool Wrapper::systemIsReachable | ( | int | number | ) |
Check if a system is reachable.
Returns whether the system 'number' is reachable from the current system by hyperspace with the current amount of fuel
Definition at line 135 of file Wrapper.cpp.
bool Wrapper::tradegoodIsInTons | ( | int | number | ) |
Check if a tradegood is weighted in tonnes.
This function returns whether a certain tradegood has tonnes as unit. this is important because only items in tonnes count for the calculation of the free holdspace.
number | The number of the tradegood |
Definition at line 226 of file Wrapper.cpp.