• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdegames API Reference
  • KDE Home
  • Contact Us
 

libkdegames

Public Slots | Signals | Public Member Functions | Properties | List of all members
KgDifficulty Class Reference

#include <KgDifficulty>

Inheritance diagram for KgDifficulty:
Inheritance graph
[legend]

Public Slots

void select (const KgDifficultyLevel *level)
 

Signals

void currentLevelChanged (const KgDifficultyLevel *level)
 
void editableChanged (bool editable)
 
void gameRunningChanged (bool gameRunning)
 
void selectedLevelChanged (const KgDifficultyLevel *level)
 

Public Member Functions

 KgDifficulty (QObject *parent=0)
 
virtual ~KgDifficulty ()
 
void addLevel (KgDifficultyLevel *level)
 
void addStandardLevel (KgDifficultyLevel::StandardLevel level, bool isDefault=false)
 
void addStandardLevelRange (KgDifficultyLevel::StandardLevel from, KgDifficultyLevel::StandardLevel to)
 
void addStandardLevelRange (KgDifficultyLevel::StandardLevel from, KgDifficultyLevel::StandardLevel to, KgDifficultyLevel::StandardLevel defaultLevel)
 
const KgDifficultyLevel * currentLevel () const
 
bool isEditable () const
 
bool isGameRunning () const
 
QList< const KgDifficultyLevel * > levels () const
 
void setEditable (bool editable)
 
void setGameRunning (bool running)
 

Properties

const KgDifficultyLevel currentLevel
 
bool editable
 
bool gameRunning
 
const KgDifficultyLevel selectedLevel
 

Detailed Description

KgDifficulty manages difficulty levels of a game in a standard way.

The difficulty can be a type of game (like in KMines: small or big field) or the AI skills (like in Bovo: how deep should the computer search to find the best move) or a combination of both of them. On the user point of view, it's not really different: either is the game easy or hard to play.

KgDifficulty contains a list of KgDifficultyLevel instances. One of these levels is selected; this selection will be recorded when the application is closed. A set of standard difficulty levels is provided by KgDifficultyLevel, but custom levels can be defined at the same time.

Definition at line 96 of file kgdifficulty.h.

Constructor & Destructor Documentation

KgDifficulty::KgDifficulty ( QObject *  parent = 0)
explicit

Definition at line 153 of file kgdifficulty.cpp.

KgDifficulty::~KgDifficulty ( )
virtual

Destroys this instance and all DifficultyLevel instances in it.

Definition at line 160 of file kgdifficulty.cpp.

Member Function Documentation

void KgDifficulty::addLevel ( KgDifficultyLevel *  level)

Adds a difficulty level to this instance.

This will not affect the currentLevel() if there is one.

Definition at line 178 of file kgdifficulty.cpp.

void KgDifficulty::addStandardLevel ( KgDifficultyLevel::StandardLevel  level,
bool  isDefault = false 
)

A shortcut for addLevel(new KgDifficultyLevel(level)).

Definition at line 200 of file kgdifficulty.cpp.

void KgDifficulty::addStandardLevelRange ( KgDifficultyLevel::StandardLevel  from,
KgDifficultyLevel::StandardLevel  to 
)

This convenience method adds a range of standard levels to this instance (including the boundaries).

For example:

difficulty.addStandardLevelRange(
KgDifficultyLevel::Easy,
KgDifficultyLevel::VeryHard
);

This adds the levels "Easy", "Medium", "Hard" and "Very hard".

Definition at line 205 of file kgdifficulty.cpp.

void KgDifficulty::addStandardLevelRange ( KgDifficultyLevel::StandardLevel  from,
KgDifficultyLevel::StandardLevel  to,
KgDifficultyLevel::StandardLevel  defaultLevel 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This overload allows to specify a defaultLevel.

Definition at line 211 of file kgdifficulty.cpp.

const KgDifficultyLevel* KgDifficulty::currentLevel ( ) const
Returns
the current difficulty level

After the KgDifficulty object has been created, the current difficulty level will not be determined until this method is called for the first time. This allows the application developer to set up the difficulty levels before KgDifficulty retrieves the last selected level from the configuration file.

void KgDifficulty::currentLevelChanged ( const KgDifficultyLevel *  level)
signal

Emitted when a new difficulty level has been selected.

void KgDifficulty::editableChanged ( bool  editable)
signal

Emitted when the editability changes.

See also
setEditable
void KgDifficulty::gameRunningChanged ( bool  gameRunning)
signal

Emitted when a running game has been marked or unmarked.

See also
setGameRunning
bool KgDifficulty::isEditable ( ) const
Returns
whether the difficulty level selection may be edited

Definition at line 270 of file kgdifficulty.cpp.

bool KgDifficulty::isGameRunning ( ) const
Returns
whether a running game has been marked
See also
setGameRunning

Definition at line 285 of file kgdifficulty.cpp.

QList< const KgDifficultyLevel * > KgDifficulty::levels ( ) const
Returns
a list of all difficulty levels, sorted by hardness

Definition at line 236 of file kgdifficulty.cpp.

void KgDifficulty::select ( const KgDifficultyLevel *  level)
slot

Select a new difficulty level.

The given level must already have been added to this instance.

Note
This does nothing if isEditable() is false. If a game is running (according to setGameRunning()), the user will be asked for confirmation before the new difficulty level is selected.

Definition at line 300 of file kgdifficulty.cpp.

void KgDifficulty::selectedLevelChanged ( const KgDifficultyLevel *  level)
signal

Emitted after every call to select(), even when the user has rejected the change.

This is useful to reset a difficulty level selection UI after a rejected change.

void KgDifficulty::setEditable ( bool  editable)

Set whether the difficulty level selection may be edited.

The default value is true.

Definition at line 275 of file kgdifficulty.cpp.

void KgDifficulty::setGameRunning ( bool  running)

KgDifficulty has optional protection against changing the difficulty level while a game is running.

If setGameRunning(true) has been called, and select() is called to select a new difficulty level, the user will be asked for confirmation.

Definition at line 290 of file kgdifficulty.cpp.

Property Documentation

const KgDifficultyLevel * KgDifficulty::currentLevel
readwrite

Definition at line 101 of file kgdifficulty.h.

bool KgDifficulty::editable
readwrite

Definition at line 103 of file kgdifficulty.h.

bool KgDifficulty::gameRunning
readwrite

Definition at line 104 of file kgdifficulty.h.

const KgDifficultyLevel KgDifficulty::selectedLevel
readwrite

Definition at line 102 of file kgdifficulty.h.


The documentation for this class was generated from the following files:
  • kgdifficulty.h
  • kgdifficulty.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:44:35 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

libkdegames

Skip menu "libkdegames"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdegames API Reference

Skip menu "kdegames API Reference"
  • granatier
  • kapman
  • kblackbox
  • kgoldrunner
  • kigo
  • kmahjongg
  • KShisen
  • ksquares
  • libkdegames
  •   highscore
  •   libkdegamesprivate
  •     kgame
  • libkmahjongg
  • palapeli
  •   libpala

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal