implement sounds when blinds increases (ticket #83)

This commit is contained in:
doitux
2011-12-25 13:34:06 +00:00
parent 3aa998070f
commit f294834d00
9 changed files with 162 additions and 110 deletions
+39 -1
View File
@@ -1,8 +1,46 @@
#include "sdlplayer.h"
#include "configfile.h"
#include "gametableimpl.h"
#include "session.h"
#include "game.h"
#include "soundevents.h"
SoundEvents::SoundEvents(ConfigFile *c): myConfig(c)
SoundEvents::SoundEvents(ConfigFile *c, gameTableImpl *w): myConfig(c), myW(w)
{
mySDLPlayer = new SDLPlayer(myConfig);
}
SoundEvents::~SoundEvents()
{
mySDLPlayer->deleteLater();
}
void SoundEvents::blindsWereSet(int sB)
{
int currentGameId = myW->getSession()->getCurrentGame()->getMyGameID();
if(currentGameId != lastGameId)
{
lastSBLevel = 0;
lastSBValue = sB;
lastGameId = currentGameId;
}
if(sB > lastSBValue) {
lastSBValue = sB;
++lastSBLevel;
if(lastSBLevel == 1 || lastSBLevel == 2)
{
mySDLPlayer->playSound("blinds_raises_level1", 0);
}
if(lastSBLevel == 3 || lastSBLevel == 4)
{
mySDLPlayer->playSound("blinds_raises_level2", 0);
}
if(lastSBLevel >= 5)
{
mySDLPlayer->playSound("blinds_raises_level3", 0);
}
}
}
+11 -1
View File
@@ -3,14 +3,24 @@
class SDLPlayer;
class ConfigFile;
class gameTableImpl;
class SoundEvents
{
public:
SoundEvents(ConfigFile*);
SoundEvents(ConfigFile*, gameTableImpl*);
~SoundEvents();
void blindsWereSet(int sB);
private:
SDLPlayer *mySDLPlayer;
gameTableImpl *myW;
ConfigFile *myConfig;
unsigned int lastSBValue;
unsigned int lastSBLevel;
unsigned int lastGameId;
};