roulette-payout/PlayerAreaModel.cpp

67 lines
1.4 KiB
C++
Raw Normal View History

#include "PlayerAreaModel.h"
PlayerAreaModel::PlayerAreaModel(QObject *parent)
{
Player defaultValues;
2024-06-01 13:19:32 +01:00
for(int i = 0; i < 7; i++){
players.append(defaultValues);
2024-06-01 13:19:32 +01:00
}
}
uint PlayerAreaModel::focusedPlayer()
{
return focusedPlayer_;
}
void PlayerAreaModel::setFocusedPlayer(int n)
{
focusedPlayer_ = n;
Player player = players.at(n);
BetType b1 = player.bet1.betType;
BetType b2 = player.bet2.betType;
uint n1 = player.bet1.betSpot;
uint n2 = player.bet2.betSpot;
emit focusedPlayerChanged(b1, n1, b2, n2);
}
2024-06-01 13:19:32 +01:00
QString PlayerAreaModel::getPlayerName(int n)
{
return players.at(n).playerName;
}
2024-05-31 12:34:47 +01:00
void PlayerAreaModel::setPlayerName(QString s, int n)
{
this->players[n].playerName = s;
}
void PlayerAreaModel::bet(BetType b, int n, int bet)
2024-06-01 13:19:32 +01:00
{
Player *player = &players[focusedPlayer_];
if (player->bet1.betType == NONE) {
player->bet1.betType = b;
player->bet1.betValue = bet;
player->bet1.betSpot = n;
} else if (player->bet2.betType == NONE) {
player->bet2.betType = b;
player->bet2.betValue = bet;
player->bet2.betSpot = n;
}
2024-06-01 13:19:32 +01:00
}
void PlayerAreaModel::removeBet(BetType b, int n)
{
Player *player = &players[focusedPlayer_];
if (player->bet1.betType != NONE) {
player->bet1.betType = NONE;
} else {
player->bet2.betType = NONE;
}
}
void PlayerAreaModel::cancelBet(BetType b, int n) {
emit betCanceled(b, n);
}