2024-05-31 12:10:00 +01:00
|
|
|
#include "PlayerAreaModel.h"
|
|
|
|
|
|
|
|
PlayerAreaModel::PlayerAreaModel(QObject *parent)
|
|
|
|
{
|
2024-06-02 21:13:43 +01:00
|
|
|
Player defaultValues;
|
|
|
|
|
2024-06-01 13:19:32 +01:00
|
|
|
for(int i = 0; i < 7; i++){
|
2024-06-02 21:13:43 +01:00
|
|
|
players.append(defaultValues);
|
2024-06-01 13:19:32 +01:00
|
|
|
}
|
2024-05-31 12:10:00 +01:00
|
|
|
}
|
|
|
|
|
2024-06-02 21:13:43 +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)
|
2024-05-31 12:10:00 +01:00
|
|
|
{
|
2024-06-02 21:13:43 +01:00
|
|
|
return players.at(n).playerName;
|
2024-05-31 12:10:00 +01:00
|
|
|
}
|
|
|
|
|
2024-05-31 12:34:47 +01:00
|
|
|
void PlayerAreaModel::setPlayerName(QString s, int n)
|
2024-05-31 12:10:00 +01:00
|
|
|
{
|
2024-06-02 21:13:43 +01:00
|
|
|
this->players[n].playerName = s;
|
2024-05-31 12:10:00 +01:00
|
|
|
}
|
2024-06-01 07:11:29 +01:00
|
|
|
|
2024-06-02 21:13:43 +01:00
|
|
|
void PlayerAreaModel::bet(BetType b, int n, int bet)
|
2024-06-01 13:19:32 +01:00
|
|
|
{
|
2024-06-02 21:13:43 +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
|
|
|
}
|
|
|
|
|
2024-06-02 21:13:43 +01:00
|
|
|
void PlayerAreaModel::removeBet(BetType b, int n)
|
2024-06-01 07:11:29 +01:00
|
|
|
{
|
2024-06-02 21:13:43 +01:00
|
|
|
Player *player = &players[focusedPlayer_];
|
|
|
|
if (player->bet1.betType != NONE) {
|
|
|
|
player->bet1.betType = NONE;
|
|
|
|
} else {
|
|
|
|
player->bet2.betType = NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-04 21:10:39 +01:00
|
|
|
void PlayerAreaModel::cancelBet(BetType b, int n) {
|
|
|
|
emit betCanceled(b, n);
|
2024-06-01 07:11:29 +01:00
|
|
|
}
|
2024-06-02 21:13:43 +01:00
|
|
|
|