Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2 connection pp #8

Merged
merged 36 commits into from
Apr 20, 2022
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9c4b5e8
Added Tcp server #7
P1nkL1on Apr 10, 2022
21b34fa
Messages client<->server #7
P1nkL1on Apr 10, 2022
470712e
Buttons for messages #7
P1nkL1on Apr 10, 2022
e86f416
Renamed client stuff #7
P1nkL1on Apr 10, 2022
bcc4d22
Getting crashes on disconnect n close #7
P1nkL1on Apr 10, 2022
bd1be50
Copy mechanics #1
P1nkL1on Apr 10, 2022
9588ad2
Ambush vrihedd #1
P1nkL1on Apr 10, 2022
bdb659b
2 players but bad mulligan phase #1
P1nkL1on Apr 11, 2022
61c03ff
Moved all the field moved to rect #3
P1nkL1on Apr 12, 2022
028588b
Deck nums #3
P1nkL1on Apr 12, 2022
91ab545
Fixed hidden cards #3
P1nkL1on Apr 12, 2022
c1ca281
Looking to destroy/banish #1
P1nkL1on Apr 12, 2022
f6d472f
Select random from deck, showing stack #1, #3
P1nkL1on Apr 13, 2022
d5744cb
Arrowing from source to target #3
P1nkL1on Apr 13, 2022
ec869b4
Sounds from url added #1
P1nkL1on Apr 14, 2022
0d757d2
Animation tryied and failed, added more sounds sources #3
P1nkL1on Apr 14, 2022
5eca737
Added resilience and painting statuses #1
P1nkL1on Apr 14, 2022
ce7a8df
Decoy and shupes #1
P1nkL1on Apr 14, 2022
831eb98
Texts #1
P1nkL1on Apr 14, 2022
ed22b68
Working weather (mostly) #1
P1nkL1on Apr 15, 2022
110ebb7
Added moonlight, bad animations #3
P1nkL1on Apr 15, 2022
783e6ea
Several renames #1
P1nkL1on Apr 16, 2022
a68c197
View header added #1
P1nkL1on Apr 16, 2022
5b374f4
View of field done #1
P1nkL1on Apr 16, 2022
4614136
Slow moving onto repainting by view #3
P1nkL1on Apr 16, 2022
c5caabf
United view for both fields #1
P1nkL1on Apr 16, 2022
743f18d
Global powers #3
P1nkL1on Apr 16, 2022
9725bc7
Drawing some snapshots #7
P1nkL1on Apr 16, 2022
1d47aaf
Ressurect stuff #1
P1nkL1on Apr 18, 2022
475d0de
Better discards/resurrects/destroy #1
P1nkL1on Apr 19, 2022
fd1dde1
Filters refactoring #1
P1nkL1on Apr 19, 2022
c8e7b2e
No anim, but sounds #3
P1nkL1on Apr 19, 2022
2e36e4c
Some fixes, decks #3
P1nkL1on Apr 19, 2022
7ae8c52
Finished Regis and drain #1
P1nkL1on Apr 19, 2022
c4f725a
Refactored weather a bit #1
P1nkL1on Apr 20, 2022
33e82ce
Discard deck, default copy staggered #1
P1nkL1on Apr 20, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Global powers #3
P1nkL1on committed Apr 16, 2022
commit 743f18d8ecd2aa86f9bbcf489fede4a70f96b379
60 changes: 60 additions & 0 deletions Cards/archieve.cpp
Original file line number Diff line number Diff line change
@@ -1403,6 +1403,7 @@ void AdrenalineRush::onTargetChoosen(Card *target, Field &, Field &)
ShupesDayOff::ShupesDayOff()
{
name = "Shupe's Day Off";
text = "If your starting deck has no duplicates, Spawn a Shupe: Knight, Shupe: Hunter or Supe: Mage";
url = "https://gwent.one/image/card/low/cid/png/201627.png";
sounds = {
"https://gwent.one/audio/card/ob/en/SAY.Battlecries_part4.168.mp3",
@@ -2012,3 +2013,62 @@ void HaraldTheCripple::onEnter(Field &ally, Field &enemy)
damage(card, 1, ally, enemy);
}
}

Emissary::Emissary()
{
name = "Emissary";
text = "Look at 2 random Bronze units from your deck, then play 1.";
url = "https://gwent.one/image/card/low/cid/png/162314.png";
sounds = {
"https://gwent.one/audio/card/ob/en/NIS1_VSET_00526372.mp3",
"https://gwent.one/audio/card/ob/en/NIS1_Q002_01048548.mp3",
"https://gwent.one/audio/card/ob/en/NIS1_VSET_00526356.mp3",
};
isLoyal = false;
power = powerBase = 2;
rarity = Bronze;
faction = Nilfgaard;
tags = { };
}

bool Emissary::isBronzeUnit(Card *card)
{
return (card->rarity == Bronze) && !card->isSpecial;
}

void Emissary::onEnter(Field &ally, Field &enemy)
{
ally.cardStack.push_back(Choice(Target, this, randoms(cardsFiltered(ally, enemy, {isBronzeUnit}, AllyDeckShuffled), 2), 1, true));
}

void Emissary::onTargetChoosen(Card *target, Field &ally, Field &enemy)
{
playCard(target, ally, enemy);
}

CeallachDyffryn::CeallachDyffryn()
{
name = "Ceallach Dyffryn";
text = "Spawn an Ambassador, Assassin or Emissary.";
url = "https://gwent.one/image/card/low/cid/png/162213.png";
sounds = {
"https://gwent.one/audio/card/ob/en/SAY.Battlecries_part3.109.mp3",
"https://gwent.one/audio/card/ob/en/SAY.Battlecries_part3.110.mp3",
"https://gwent.one/audio/card/ob/en/SAY.Battlecries_part3.111.mp3",
};
power = powerBase = 2;
rarity = Silver;
faction = Nilfgaard;
tags = { Officer };
}

void CeallachDyffryn::onEnter(Field &ally, Field &)
{
startChoiceToSelectOption(ally, this, {new Ambassador, new Assassin, new Emissary});
}

void CeallachDyffryn::onTargetChoosen(Card *target, Field &ally, Field &enemy)
{
acceptOptionAndDeleteOthers(this, target);
spawn(target, ally, enemy);
}
21 changes: 17 additions & 4 deletions Cards/archieve.h
Original file line number Diff line number Diff line change
@@ -222,6 +222,23 @@ struct Assassin : Card
};


struct Emissary : Card
{
Emissary();
static bool isBronzeUnit(Card *card);
void onEnter(Field &ally, Field &enemy) override;
void onTargetChoosen(Card *target, Field &ally, Field &enemy) override;
};


struct CeallachDyffryn : Card
{
CeallachDyffryn();
void onEnter(Field &ally, Field &enemy) override;
void onTargetChoosen(Card *target, Field &ally, Field &enemy) override;
};


struct TuirseachArcher : Card
{
TuirseachArcher();
@@ -312,10 +329,6 @@ struct Vaedermakar : Card
Vaedermakar();
void onEnter(Field &ally, Field &) override;
void onTargetChoosen(Card *target, Field &ally, Field &enemy) override;
private:
Card *_c1 = nullptr;
Card *_c2 = nullptr;
Card *_c3 = nullptr;
};


73 changes: 64 additions & 9 deletions Cards/view.cpp
Original file line number Diff line number Diff line change
@@ -103,6 +103,12 @@ FieldView fieldView(const Field &ally, const Field &enemy)
res.enemyRowEffectMeele = enemy.rowEffectMeele;
res.enemyRowEffectRange = enemy.rowEffectRange;
res.enemyRowEffectSeige = enemy.rowEffectSeige;
res.nPowerRowAllyMeele = powerRow(ally.rowMeele);
res.nPowerRowAllyRange = powerRow(ally.rowRange);
res.nPowerRowAllySeige = powerRow(ally.rowSeige);
res.nPowerRowEnemyMeele = powerRow(enemy.rowMeele);
res.nPowerRowEnemyRange = powerRow(enemy.rowRange);
res.nPowerRowEnemySeige = powerRow(enemy.rowSeige);
res.nTurns = ally.nTurns;
res.nRounds = ally.nRounds;
res.nAllyWins = ally.nWins;
@@ -147,8 +153,8 @@ const CardView &FieldView::cardView(const int id) const

bool FieldView::idAtRowAndPos(const Row screenRow, const Pos screenPos, int *id, int *n) const
{
assert((0 <= screenRow) && (screenRow <= 6));
assert((0 <= screenPos) && (screenPos <= 9));
assert((0 <= screenRow) && (screenRow < 6));
assert((0 <= screenPos) && (screenPos < 9));

const std::vector<int> *rowIds = nullptr;
switch (screenRow) {
@@ -181,42 +187,42 @@ bool FieldView::rowAndPos(const int id, Row *row, Pos *pos, bool *isAlly) const
for (size_t i = 0; i < allyRowMeeleIds.size(); ++i)
if (id == allyRowMeeleIds[i]) {
_row = Meele;
_pos = i;
_pos = Pos(i);
_isAlly = true;
goto found;
}
for (size_t i = 0; i < allyRowRangeIds.size(); ++i)
if (id == allyRowRangeIds[i]) {
_row = Range;
_pos = i;
_pos = Pos(i);
_isAlly = true;
goto found;
}
for (size_t i = 0; i < allyRowSeigeIds.size(); ++i)
if (id == allyRowSeigeIds[i]) {
_row = Seige;
_pos = i;
_pos = Pos(i);
_isAlly = true;
goto found;
}
for (size_t i = 0; i < enemyRowMeeleIds.size(); ++i)
if (id == enemyRowMeeleIds[i]) {
_row = Meele;
_pos = i;
_pos = Pos(i);
_isAlly = false;
goto found;
}
for (size_t i = 0; i < enemyRowRangeIds.size(); ++i)
if (id == enemyRowRangeIds[i]) {
_row = Range;
_pos = i;
_pos = Pos(i);
_isAlly = false;
goto found;
}
for (size_t i = 0; i < enemyRowSeigeIds.size(); ++i)
if (id == enemyRowSeigeIds[i]) {
_row = Seige;
_pos = i;
_pos = Pos(i);
_isAlly = false;
goto found;
}
@@ -234,7 +240,7 @@ bool FieldView::rowAndPos(const int id, Row *row, Pos *pos, bool *isAlly) const

RowEffect FieldView::rowEffect(const Row screenRow) const
{
assert((0 <= screenRow) && (screenRow <= 6));
assert((0 <= screenRow) && (screenRow < 6));
switch (screenRow) {
case 0: return enemyRowEffectSeige;
case 1: return enemyRowEffectRange;
@@ -246,3 +252,52 @@ RowEffect FieldView::rowEffect(const Row screenRow) const
}
return NoRowEffect;
}

int FieldView::rowPower(const Row screenRow) const
{
assert((0 <= screenRow) && (screenRow < 6));
switch (screenRow) {
case 0: return nPowerRowEnemySeige;
case 1: return nPowerRowEnemyRange;
case 2: return nPowerRowEnemyMeele;
case 3: return nPowerRowAllyMeele;
case 4: return nPowerRowAllyRange;
case 5: return nPowerRowAllySeige;
default: assert(false);
}
return 0;
}

std::string ChoiceView::toString() const
{
switch (choiceType) {
case RoundStartPlay:
return "Choose a card to play";
case SelectAllyRowAndPos:
return "Choose an allied row and pos";
case SelectEnemyRowAndPos:
return "Choose an enemy row and pos";
case SelectAllyRow:
return "Choose an allied row";
case SelectEnemyRow:
return "Choose an enemy row";
case Target: {
std::string res = "Choose an ability option";
if ((nTargets > 1) || isOptional) {
res += " [";
if (isOptional)
res += "optional";
if (nTargets > 1) {
if (isOptional)
res += " ";
res += std::to_string(cardOptionIdsSelected.size()) + "/" + std::to_string(nTargets);
}
res += "]";
}
return res;
}
case RoundStartSwap:
return "Choose a card to swap [" + std::to_string(nTargets) + " left]";
}
assert(false);
}
15 changes: 12 additions & 3 deletions Cards/view.h
Original file line number Diff line number Diff line change
@@ -38,6 +38,8 @@ struct ChoiceView
std::vector<int> cardOptionIdsSelected;
int nTargets = 1;
bool isOptional = false;

std::string toString() const;
};


@@ -75,18 +77,24 @@ struct FieldView
std::vector<int> allyHandIds;
std::vector<int> allyDeckIds;
std::vector<int> allyDiscardIds;
RowEffect allyRowEffectMeele = NoRowEffect;
RowEffect allyRowEffectRange = NoRowEffect;
RowEffect allyRowEffectSeige = NoRowEffect;
std::vector<int> enemyRowMeeleIds;
std::vector<int> enemyRowRangeIds;
std::vector<int> enemyRowSeigeIds;
std::vector<int> enemyHandIds;
std::vector<int> enemyDeckIds;
std::vector<int> enemyDiscardIds;
RowEffect allyRowEffectMeele = NoRowEffect;
RowEffect allyRowEffectRange = NoRowEffect;
RowEffect allyRowEffectSeige = NoRowEffect;
RowEffect enemyRowEffectMeele = NoRowEffect;
RowEffect enemyRowEffectRange = NoRowEffect;
RowEffect enemyRowEffectSeige = NoRowEffect;
int nPowerRowAllyMeele = 0;
int nPowerRowAllyRange = 0;
int nPowerRowAllySeige = 0;
int nPowerRowEnemyMeele = 0;
int nPowerRowEnemyRange = 0;
int nPowerRowEnemySeige = 0;
int nTurns = 0;
int nRounds = 0;
int nAllyWins = 0;
@@ -99,6 +107,7 @@ struct FieldView
bool idAtRowAndPos(const Row screenRow, const Pos screenPos, int *id = nullptr, int *n = nullptr) const;
bool rowAndPos(const int id, Row *row = nullptr, Pos *pos = nullptr, bool *isAlly = nullptr) const;
RowEffect rowEffect(const Row screenRow) const;
int rowPower(const Row screenRow) const;
};

bool isIn(const int id, const std::vector<int> &vector);
129 changes: 67 additions & 62 deletions Client/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -19,6 +19,11 @@ MainWindow::MainWindow(QWidget *parent)


const std::vector<Card *> deckStarting = {
new CeallachDyffryn, new CeallachDyffryn,
new Reconnaissance, new Reconnaissance,
new Ambassador, new Ambassador,
new Assassin, new Assassin,
new Emissary, new Emissary,
new Vaedermakar, new CiriNova, new CiriNova, new HaraldTheCripple, new DolBlathannaArcher, new DolBlathannaArcher,
new HaraldTheCripple, new HaraldTheCripple, new FirstLight, new FirstLight,
// new GeraltIgni, new DolBlathannaArcher, new DolBlathannaArcher, new DolBlathannaArcher,
@@ -348,15 +353,14 @@ void MainWindow::mouseClick(const QRect &rect, const QPoint &point, Field &ally,
Q_ASSERT(false);
}

void MainWindow::paintInRect(const QRect rect, Field &___ally, Field &___enemy)
void MainWindow::paintInRect(const QRect rect, const FieldView &view)
{
if (rect.width() < _layout.spacingPx * 2)
return;

if (rect.height() < _layout.spacingPx * 2)
return;

const FieldView view = fieldView(___ally, ___enemy);
const ChoiceView *currentChoiceView = view.choices.size() ? &view.choices.back() : nullptr;

const QFontMetricsF metrics(QFont{});
@@ -482,7 +486,7 @@ void MainWindow::paintInRect(const QRect rect, Field &___ally, Field &___enemy)

/// draw armor
if (cardView.armor) {
width += paintTextInPoint("A" + QString::number(cardView.armor), QPointF(topLeft.x() + width, topLeft.y()), Qt::yellow, Qt::black);
width += paintTextInPoint("ARMOR " + QString::number(cardView.armor), QPointF(topLeft.x() + width, topLeft.y()), Qt::yellow, Qt::black);
width += _layout.borderTextPx;
}

@@ -492,7 +496,7 @@ void MainWindow::paintInRect(const QRect rect, Field &___ally, Field &___enemy)
}

if (cardView.timer) {
width += paintTextInPoint("T" + QString::number(cardView.timer), QPointF(topLeft.x() + width, topLeft.y()), Qt::cyan, Qt::black);
width += paintTextInPoint("TIMER " + QString::number(cardView.timer), QPointF(topLeft.x() + width, topLeft.y()), Qt::cyan, Qt::black);
width += _layout.borderTextPx;
}

@@ -523,47 +527,41 @@ void MainWindow::paintInRect(const QRect rect, Field &___ally, Field &___enemy)

// ___________________
// TODO: tmp copypaste
// const auto cardAt = [=](const QPoint &point) -> Card * {
// for (int j = 0; j < 6; ++j) {
// const Field *field = j < 3 ? &___enemy : &___ally;
// const Row row = Row(j < 3 ? (2 - j) : (j - 3));
// const std::vector<Card *> &cards = field->row(row);
// const size_t count = cards.size();
// if (count == 0)
// continue;
// for (size_t i = 0; i < 9; ++i) {
// if (i >= count)
// continue;
// const QRectF cardRect = QRectF(i * posWidth, _layout.spacingPx + (j + 1) * posHeight, posWidth, posHeight).translated(rect.topLeft());
// if (cardRect.contains(point))
// return cards[i];
// }
// }
// if (___ally.cardStack.size() > 0) {
// for (size_t i = 0; i < ___ally.choice().cardOptions.size(); ++i) {
// const QRectF cardRect = QRectF(i * posWidth, 2 * _layout.spacingPx + 7 * posHeight, posWidth, posHeight).translated(rect.topLeft());
// if (cardRect.contains(point))
// return ___ally.choice().cardOptions[i];
// }
// }
// return nullptr;
// };
// if (Card *card = cardAt(_pos)) {
// const QPointF topLeft = QPointF(posWidth * 9 + _layout.spacingPx, posHeight * 1 + _layout.spacingPx) + rect.topLeft();
// paintCard(card, topLeft);
// paintTextInPoint(QString("Power = %1").arg(card->power), topLeft + QPointF(0, posHeight + 0 * metrics.height()), Qt::white, Qt::black);
// paintTextInPoint(QString("Power Base = %1").arg(card->powerBase), topLeft + QPointF(0, posHeight + 1 * metrics.height()), Qt::white, Qt::black);
// paintTextInPoint(QString("Armor = %1").arg(card->armor), topLeft + QPointF(0, posHeight + 2 * metrics.height()), Qt::white, Qt::black);
// paintTextInPoint(QString("Special? %1").arg(card->isSpecial), topLeft + QPointF(0, posHeight + 3 * metrics.height()), Qt::white, Qt::black);
// paintTextInPoint(QString("Locked? %1").arg(card->isLocked), topLeft + QPointF(0, posHeight + 4 * metrics.height()), Qt::white, Qt::black);
// paintTextInPoint(QString("Resilient? %1").arg(card->isResilient), topLeft + QPointF(0, posHeight + 5 * metrics.height()), Qt::white, Qt::black);
// paintTextInPoint(QString("Spying? %1").arg(card->isSpy), topLeft + QPointF(0, posHeight + 6 * metrics.height()), Qt::white, Qt::black);
// paintTextInPoint(QString("Immune? %1").arg(card->isImmune), topLeft + QPointF(0, posHeight + 7 * metrics.height()), Qt::white, Qt::black);
// paintTextInPoint(QString("Doomed? %1").arg(card->isDoomed), topLeft + QPointF(0, posHeight + 8 * metrics.height()), Qt::white, Qt::black);
// paintTextInPoint(QString("Name: %1").arg(QString::fromStdString(card->name)), topLeft + QPointF(0, posHeight + 9 * metrics.height()), Qt::white, Qt::black);
// paintTextInPoint(QString("Text: %1").arg(QString::fromStdString(card->text)), topLeft + QPointF(0, posHeight + 10 * metrics.height()), Qt::white, Qt::black);

// }
const auto cardIdAt = [=](const QPoint &point) -> int {
for (int j = 0; j < 6; ++j) {
for (size_t i = 0; i < 9; ++i) {
int id;
if (!view.idAtRowAndPos(Row(j), Pos(i), &id))
continue;
const QRectF cardRect = QRectF(i * posWidth, _layout.spacingPx + (j + 1) * posHeight, posWidth, posHeight).translated(rect.topLeft());
if (cardRect.contains(point))
return id;
}
}
if (currentChoiceView)
for (size_t i = 0; i < currentChoiceView->cardOptionIds.size(); ++i) {
const QRectF cardRect = QRectF(i * posWidth, 2 * _layout.spacingPx + 7 * posHeight, posWidth, posHeight).translated(rect.topLeft());
if (cardRect.contains(point))
return currentChoiceView->cardOptionIds[i];
}
return -1;
};
const int cardIdSelected = cardIdAt(_pos);
if (cardIdSelected >= 0) {
const CardView &cardView = view.cardView(cardIdSelected);
const QPointF topLeft = QPointF(posWidth * 9 + _layout.spacingPx, posHeight * 1 + _layout.spacingPx) + rect.topLeft();
paintCard(cardView, topLeft);
paintTextInPoint(QString("Power = %1").arg(cardView.power), topLeft + QPointF(0, posHeight + 0 * metrics.height()), Qt::white, Qt::black);
paintTextInPoint(QString("Power Base = %1").arg(cardView.powerBase), topLeft + QPointF(0, posHeight + 1 * metrics.height()), Qt::white, Qt::black);
paintTextInPoint(QString("Armor = %1").arg(cardView.armor), topLeft + QPointF(0, posHeight + 2 * metrics.height()), Qt::white, Qt::black);
paintTextInPoint(QString("Locked? %1").arg(cardView.isLocked), topLeft + QPointF(0, posHeight + 4 * metrics.height()), Qt::white, Qt::black);
paintTextInPoint(QString("Resilient? %1").arg(cardView.isResilient), topLeft + QPointF(0, posHeight + 5 * metrics.height()), Qt::white, Qt::black);
paintTextInPoint(QString("Spying? %1").arg(cardView.isSpy), topLeft + QPointF(0, posHeight + 6 * metrics.height()), Qt::white, Qt::black);
paintTextInPoint(QString("Immune? %1").arg(cardView.isImmune), topLeft + QPointF(0, posHeight + 7 * metrics.height()), Qt::white, Qt::black);
paintTextInPoint(QString("Doomed? %1").arg(cardView.isDoomed), topLeft + QPointF(0, posHeight + 8 * metrics.height()), Qt::white, Qt::black);
paintTextInPoint(QString("Name: %1").arg(QString::fromStdString(cardView.name)), topLeft + QPointF(0, posHeight + 9 * metrics.height()), Qt::white, Qt::black);
paintTextInPoint(QString("Text: %1").arg(QString::fromStdString(cardView.text)), topLeft + QPointF(0, posHeight + 10 * metrics.height()), Qt::white, Qt::black);
}
// TODO: tmp remove all above
// __________________________

@@ -586,8 +584,7 @@ void MainWindow::paintInRect(const QRect rect, Field &___ally, Field &___enemy)
}

// TODO: return showing a power
// const int power = powerRow(cards);
// paintTextInPoint(QString::number(power), rect.topLeft() + QPointF(9 * posWidth, _layout.spacingPx + (j + 1) * posHeight));
paintTextInPoint(QString::number(view.rowPower(Row(j))), rect.topLeft() + QPointF(9 * posWidth, _layout.spacingPx + (j + 1) * posHeight));

/// draw a row back
const QRectF rowRect = QRectF(0, _layout.spacingPx + (j + 1) * posHeight + metrics.height(), posWidth * 9, posHeight - 2 * metrics.height()).translated(rect.topLeft());
@@ -632,7 +629,7 @@ void MainWindow::paintInRect(const QRect rect, Field &___ally, Field &___enemy)
}

if (_view == ViewStack) {
const QString stringStatus = QString::fromStdString(stringChoices(___ally.cardStack));
const QString stringStatus = QString::fromStdString(currentChoiceView->toString());
const QString stringTurn = QString::number(1 + view.nTurns);
double statusWidth = 0;
if (currentChoiceView){
@@ -690,14 +687,16 @@ void MainWindow::paintInRect(const QRect rect, Field &___ally, Field &___enemy)
} else {
Q_ASSERT(false);
}

paintTextInPoint(QString("Ally: %1%2").arg(powerField(___ally)).arg(___ally.passed ? " PASS" : ""), QPointF(0, 0), Qt::black, Qt::cyan);
paintTextInPoint(QString("Enemy: %1%2").arg(powerField(___enemy)).arg(___enemy.passed ? " PASS" : ""), QPointF(0, 15), Qt::black, Qt::red);

// _______________
// TODO: remove animation block
painter.setPen(QPen(_animationColor, 2));
painter.drawLine(_animationPosDst, _animationPosSrc);
const QString stringStatusAlly = QString("ALLY: Power = %1, Pass = %2, Wins = %3")
.arg(view.nPowerRowAllyMeele + view.nPowerRowAllyRange + view.nPowerRowAllySeige)
.arg(view.allyPassed)
.arg(view.nAllyWins);
const QString stringStatusEnemy = QString("ENEMY: Power = %1, Pass = %2, Wins = %3")
.arg(view.nPowerRowEnemyMeele + view.nPowerRowEnemyRange + view.nPowerRowEnemySeige)
.arg(view.enemyPassed)
.arg(view.nEnemyWins);
paintTextInPoint(stringStatusAlly, QPointF(0, 0), Qt::black, Qt::cyan);
paintTextInPoint(stringStatusEnemy, QPointF(0, 15), Qt::black, Qt::red);
}


@@ -723,7 +722,7 @@ void MainWindow::onImageRequestFinished(QNetworkReply *reply)

bool MainWindow::eventFilter(QObject *o, QEvent *e)
{
const QRect rect = this->rect().marginsRemoved(QMargins(10, 10, 100, 10));
const QRect rect = this->rect().marginsRemoved(QMargins(10, 10, 200, 150));

if (e->type() == QEvent::MouseButtonPress) {
auto *em = static_cast<QMouseEvent *>(e);
@@ -770,10 +769,16 @@ bool MainWindow::eventFilter(QObject *o, QEvent *e)

void MainWindow::paintEvent(QPaintEvent *e)
{
const QRect rect = e->rect().marginsRemoved(QMargins(10, 10, 100, 10));
const QRect rect = e->rect().marginsRemoved(QMargins(10, 10, 200, 150));

const FieldView view = fieldView(_ally, _enemy);

if (_ally.cardStack.size())
paintInRect(rect, _ally, _enemy);
else if (_enemy.cardStack.size())
paintInRect(rect, _enemy, _ally);
if (_ally.cardStack.size()) {
const FieldView view = fieldView(_ally, _enemy);
paintInRect(rect, view);

} else if (_enemy.cardStack.size()) {
const FieldView view = fieldView(_enemy, _ally);
paintInRect(rect, view);
}
}
7 changes: 1 addition & 6 deletions Client/mainwindow.h
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@ private slots:
bool eventFilter(QObject*, QEvent* e) override;
void paintEvent(QPaintEvent *e) override;
void mouseClick(const QRect &rect, const QPoint &point, Field &ally, Field &enemy);
void paintInRect(const QRect rect, Field &ally, Field &enemy);
void paintInRect(const QRect rect, const FieldView &view);

Layout _layout;
int _sound = 20;
@@ -52,11 +52,6 @@ private slots:
QSet<QString> _pixMapsRequested;
QMap<QString, QImage> _pixMapsLoaded;
QMap<QString, QMediaPlayer *> _sounds;

QPointF _animationPosSrc;
QPointF _animationPosDst;
Qt::GlobalColor _animationColor;
// QVariantAnimation *_variantAnimation = nullptr;
};

#endif // MAINWINDOW_H