freg  0.3
Free-Roaming Elementary Game
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Signals | Public Member Functions | Static Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
Player Class Referencefinal

This class contains information specific to player and interface for manipulating him. More...

#include <Player.h>

Inheritance diagram for Player:
Inheritance graph
[legend]
Collaboration diagram for Player:
Collaboration graph
[legend]

Signals

void Moved (long x, long y, int z) const
 
void Notify (QString) const
 This is emitted when a notification is needed to be displayed. More...
 
void OverstepBorder (int)
 This is emitted when player walks over shred border. More...
 
void Updated ()
 This is emitted when some player property is updated. More...
 
void GetString (QString &)
 
void Destroyed ()
 
void ShowFile (QString path)
 
void GetFocus (int *x, int *y, int *z) const
 

Public Member Functions

 Player ()
 Constructor creates or loads player. More...
 
 ~Player ()
 
long GlobalX () const
 
long GlobalY () const
 
int X () const
 
int Y () const
 
dirs GetDir () const
 This returns current player direction (see enum dirs in header.h) More...
 
int HP () const
 This returns player hitpoints, also known as durability. More...
 
int BreathPercent () const
 This returns player breath reserve. On error returns -100. More...
 
int SatiationPercent () const
 Can be > 100 if player is gorged. On error returns -100. More...
 
const BlockGetBlock () const
 
bool Visible (int x, int y, int z) const
 This returns true if block at (x, y, z) is visible to player. More...
 
int UsingType () const
 This returns how player is using something now. More...
 
int GetUsingInInventory () const
 
void SetUsingTypeNo ()
 
int UsingSelfType () const
 This returns how player is using himself. More...
 
InventoryPlayerInventory () const
 Returns nullptr if there is no inventory, otherwise returns inventory. More...
 
long GetLongitude () const
 
long GetLatitude () const
 
bool GetCreativeMode () const
 
void SetCreativeMode (bool turn)
 
void SetDir (dirs)
 
void Move (dirs)
 
void Jump ()
 
void StopUseAll ()
 Closes backpack, chests, etc. More...
 
void Backpack ()
 Tries to switch usingSelfType from NO to OPEN. More...
 
void Inscribe () const
 
void Examine ()
 
void Examine (int x, int y, int z)
 
bool Damage () const
 Returns true if xyz are in world bounds. More...
 
void Use ()
 
void Throw (int src, int dest=0, int num=1)
 Tries to throw (drop out) block number num from inventory. More...
 
usage_types Use (int num)
 Tries to use block number num in inventory. More...
 
bool Obtain (int src, int dest=0, int num=1)
 Tries to get block number num from outer inventory. More...
 
void Inscribe (int num)
 
void Craft (int num)
 
void Build (int num)
 
void Wield (int num)
 
void MoveInsideInventory (int num_from, int num_to, int num=1)
 Can also wield appropriate things. More...
 
void ProcessCommand (QString command)
 

Static Public Member Functions

static constexpr quint64 UniqueIntFromString (const char *const chars)
 

Private Slots

void CheckOverstep (int dir)
 Checks if player walked over the shred border. More...
 
void BlockDestroy ()
 This is called when player block is destroyed. More...
 
void SetPlayer (int set_x, int set_y, int set_z)
 
void UpdateXYZ ()
 Dir is not used, for slot signature compatibility only. More...
 

Private Member Functions

Playeroperator= (const Player &)=delete
 
 Player (const Player &)=delete
 
AnimalNewPlayer () const
 
BlockValidBlock (int num) const
 Checks player/inventory/block existence, size limits. More...
 
ShredGetShred () const
 
WorldGetWorld () const
 
bool ForbiddenAdminCommands () const
 
- Private Member Functions inherited from Xyz
 Xyz (short x, short y, short z)
 
 Xyz ()
 
short Z () const
 
void SetXyz (short x, short y, short z)
 
- Private Member Functions inherited from Xy
 Xy (short x, short y)
 
 Xy ()
 
short X () const
 
short Y () const
 

Private Attributes

QSettings settings
 
long homeLongi
 
long homeLati
 
int homeX
 
int homeY
 
int homeZ
 
Animalplayer
 
Animalcreator
 
int usingType
 
int usingSelfType
 
int usingInInventory
 
bool creativeMode
 
bool cleaned = false
 
- Private Attributes inherited from Xyz
short z_self
 
- Private Attributes inherited from Xy
short x_self
 
short y_self
 

Detailed Description

This class contains information specific to player and interface for manipulating him.

It receives input from screen, processes it, and dispatches actions to world.

It loads player from file and saves him to it.

Note: player block with its inventory is stored it shred file with all other blocks. player_save contains only coordinates where player is, his home coordinates and world player belongs to.

Also it does checks for player walking over the shred border.

Definition at line 34 of file Player.h.

Constructor & Destructor Documentation

Player::Player ( )

Constructor creates or loads player.

It puts player block to the world if there is no player block, and makes necessary connections.

Definition at line 497 of file Player.cpp.

Player::~Player ( )

Definition at line 531 of file Player.cpp.

Player::Player ( const Player )
privatedelete

Member Function Documentation

void Player::Backpack ( )

Tries to switch usingSelfType from NO to OPEN.

Definition at line 155 of file Player.cpp.

void Player::BlockDestroy ( )
privateslot

This is called when player block is destroyed.

Definition at line 439 of file Player.cpp.

int Player::BreathPercent ( ) const

This returns player breath reserve. On error returns -100.

Definition at line 72 of file Player.cpp.

void Player::Build ( int  num)

Definition at line 298 of file Player.cpp.

void Player::CheckOverstep ( int  dir)
privateslot

Checks if player walked over the shred border.

This is connected to player's block signal Moved(int). It emits OverstepBorder(int) signal when player walks over the shred border.

Definition at line 427 of file Player.cpp.

void Player::Craft ( int  num)

Definition at line 312 of file Player.cpp.

bool Player::Damage ( ) const

Returns true if xyz are in world bounds.

Definition at line 414 of file Player.cpp.

void Player::Destroyed ( )
signal
void Player::Examine ( )

Definition at line 95 of file Player.cpp.

void Player::Examine ( int  x,
int  y,
int  z 
)

Definition at line 102 of file Player.cpp.

bool Player::ForbiddenAdminCommands ( ) const
private

Definition at line 320 of file Player.cpp.

const Block * Player::GetBlock ( ) const

Definition at line 58 of file Player.cpp.

bool Player::GetCreativeMode ( ) const

Definition at line 57 of file Player.cpp.

dirs Player::GetDir ( ) const

This returns current player direction (see enum dirs in header.h)

Definition at line 49 of file Player.cpp.

void Player::GetFocus ( int *  x,
int *  y,
int *  z 
) const
signal
long Player::GetLatitude ( ) const

Definition at line 56 of file Player.cpp.

long Player::GetLongitude ( ) const

Definition at line 55 of file Player.cpp.

Shred * Player::GetShred ( ) const
private

Definition at line 46 of file Player.cpp.

void Player::GetString ( QString &  )
signal
int Player::GetUsingInInventory ( ) const

Definition at line 54 of file Player.cpp.

World * Player::GetWorld ( ) const
private

Definition at line 47 of file Player.cpp.

long Player::GlobalX ( ) const

Definition at line 44 of file Player.cpp.

long Player::GlobalY ( ) const

Definition at line 45 of file Player.cpp.

int Player::HP ( ) const

This returns player hitpoints, also known as durability.

void Player::Inscribe ( ) const

Definition at line 180 of file Player.cpp.

void Player::Inscribe ( int  num)

Definition at line 289 of file Player.cpp.

void Player::Jump ( )

Definition at line 133 of file Player.cpp.

void Player::Move ( dirs  direction)

Definition at line 145 of file Player.cpp.

void Player::Moved ( long  x,
long  y,
int  z 
) const
signal
void Player::MoveInsideInventory ( int  num_from,
int  num_to,
int  num = 1 
)

Can also wield appropriate things.

Definition at line 281 of file Player.cpp.

Animal * Player::NewPlayer ( ) const
private

Definition at line 449 of file Player.cpp.

void Player::Notify ( QString  ) const
signal

This is emitted when a notification is needed to be displayed.

It should be connected to screen::Notify(QString).

bool Player::Obtain ( int  src,
int  dest = 0,
int  num = 1 
)

Tries to get block number num from outer inventory.

Definition at line 257 of file Player.cpp.

Player& Player::operator= ( const Player )
privatedelete
void Player::OverstepBorder ( int  )
signal

This is emitted when player walks over shred border.

It should be connected to World::ReloadShreds(int) signal.

Inventory * Player::PlayerInventory ( ) const

Returns nullptr if there is no inventory, otherwise returns inventory.

Definition at line 80 of file Player.cpp.

void Player::ProcessCommand ( QString  command)

Definition at line 329 of file Player.cpp.

int Player::SatiationPercent ( ) const

Can be > 100 if player is gorged. On error returns -100.

Definition at line 74 of file Player.cpp.

void Player::SetCreativeMode ( bool  turn)

Definition at line 60 of file Player.cpp.

void Player::SetDir ( dirs  direction)

Definition at line 408 of file Player.cpp.

void Player::SetPlayer ( int  set_x,
int  set_y,
int  set_z 
)
privateslot

Definition at line 454 of file Player.cpp.

void Player::SetUsingTypeNo ( )

Definition at line 53 of file Player.cpp.

void Player::ShowFile ( QString  path)
signal
void Player::StopUseAll ( )

Closes backpack, chests, etc.

Definition at line 51 of file Player.cpp.

void Player::Throw ( int  src,
int  dest = 0,
int  num = 1 
)

Tries to throw (drop out) block number num from inventory.

Definition at line 249 of file Player.cpp.

static constexpr quint64 Player::UniqueIntFromString ( const char *const  chars)
inlinestatic

Turns low-case ASCII chars array (length <= 12) into unique quint64. Can be used as switch statement for switch on strings.

Definition at line 131 of file Player.h.

void Player::Updated ( )
signal

This is emitted when some player property is updated.

It shoul be connected to screen::UpdatePlayer() signal.

void Player::UpdateXYZ ( )
privateslot

Dir is not used, for slot signature compatibility only.

Definition at line 90 of file Player.cpp.

void Player::Use ( )

Definition at line 163 of file Player.cpp.

usage_types Player::Use ( int  num)

Tries to use block number num in inventory.

Definition at line 210 of file Player.cpp.

int Player::UsingSelfType ( ) const

This returns how player is using himself.

For example, OPEN means he is looking in his backpack. See enum usage_types in header.h.

Definition at line 52 of file Player.cpp.

int Player::UsingType ( ) const

This returns how player is using something now.

See enum usage_types in header.h.

Definition at line 50 of file Player.cpp.

Block * Player::ValidBlock ( int  num) const
private

Checks player/inventory/block existence, size limits.

Definition at line 192 of file Player.cpp.

bool Player::Visible ( int  x,
int  y,
int  z 
) const

This returns true if block at (x, y, z) is visible to player.

Definition at line 402 of file Player.cpp.

void Player::Wield ( int  num)

Definition at line 270 of file Player.cpp.

int Player::X ( ) const

Definition at line 36 of file Player.cpp.

int Player::Y ( ) const

Definition at line 40 of file Player.cpp.

Member Data Documentation

bool Player::cleaned = false
private

Definition at line 189 of file Player.h.

bool Player::creativeMode
private

Definition at line 188 of file Player.h.

Animal* Player::creator
private

Definition at line 184 of file Player.h.

long Player::homeLati
private

Definition at line 181 of file Player.h.

long Player::homeLongi
private

Definition at line 181 of file Player.h.

int Player::homeX
private

Definition at line 182 of file Player.h.

int Player::homeY
private

Definition at line 182 of file Player.h.

int Player::homeZ
private

Definition at line 182 of file Player.h.

Animal* Player::player
private

Definition at line 183 of file Player.h.

QSettings Player::settings
private

Definition at line 180 of file Player.h.

int Player::usingInInventory
private

Definition at line 187 of file Player.h.

int Player::usingSelfType
private

Definition at line 186 of file Player.h.

int Player::usingType
private

Definition at line 185 of file Player.h.


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