Skip to content

Commit

Permalink
Drawing some snapshots #7
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonid committed Apr 16, 2022
1 parent 743f18d commit 9725bc7
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 259 deletions.
3 changes: 2 additions & 1 deletion Cards/Cards.pri
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ SOURCES += \
}

HEADERS += \
$$PWD/view.h
$$PWD/view.h \
$$PWD/enums.h

SOURCES += \
$$PWD/view.cpp
38 changes: 19 additions & 19 deletions Cards/archieve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void DeithwenArbalest::onEnter(Field &ally, Field &enemy)

void DeithwenArbalest::onTargetChoosen(Card *target, Field &ally, Field &enemy)
{
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, target));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, target));
damage(target, target->isSpy ? 6 : 3, ally, enemy);
}

Expand Down Expand Up @@ -308,7 +308,7 @@ void DimunDracar::onTurnEnd(Field &ally, Field &enemy)
if (!rowAndPos(this, ally, row, pos))
return;
if (Card *right = cardAtRowAndPos(row, pos + 1, ally)) {
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, right));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, right));
damage(right, 1, ally, enemy);
boost(this, 2, ally, enemy);
}
Expand Down Expand Up @@ -427,7 +427,7 @@ void KaedweniCavalry::onEnter(Field &ally, Field &enemy)
void KaedweniCavalry::onTargetChoosen(Card *target, Field &ally, Field &enemy)
{
const int armorTarget = target->armor;
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, target));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, target));
damage(target, armorTarget, ally, enemy);
boost(this, armorTarget, ally, enemy);
}
Expand All @@ -450,7 +450,7 @@ void AlzursThunder::onPlaySpecial(Field &ally, Field &enemy)

void AlzursThunder::onTargetChoosen(Card *target, Field &ally, Field &enemy)
{
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, target));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, target));
damage(target, 9, ally, enemy);
}

Expand Down Expand Up @@ -529,14 +529,14 @@ void ArachasVenom::onTargetChoosen(Card *target, Field &ally, Field &enemy)
Card *left = cardNextTo(target, ally, enemy, -1);
Card *right = cardNextTo(target, ally, enemy, 1);

// ally.animations.push_back(new Animation("", Animation::LineDamage, this, target));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, target));
damage(target, 4, ally, enemy);
if (left != nullptr) {
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, left));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, left));
damage(left, 4, ally, enemy);
}
if (right != nullptr) {
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, right));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, right));
damage(right, 4, ally, enemy);
}
}
Expand Down Expand Up @@ -586,7 +586,7 @@ void DolBlathannaArcher::onEnter(Field &ally, Field &enemy)

void DolBlathannaArcher::onTargetChoosen(Card *target, Field &ally, Field &enemy)
{
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, target));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, target));
damage(target, ++_nShots == 1 ? 3 : 1, ally, enemy);
}

Expand Down Expand Up @@ -652,7 +652,7 @@ Assassin::Assassin()
void Assassin::onEnter(Field &ally, Field &enemy)
{
if (Card *left = cardNextTo(this, ally, enemy, -1)) {
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, left));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, left));
damage(left, 10, ally, enemy);
}
}
Expand All @@ -674,7 +674,7 @@ void TuirseachArcher::onEnter(Field &ally, Field &enemy)

void TuirseachArcher::onTargetChoosen(Card *target, Field &ally, Field &enemy)
{
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, target));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, target));
damage(target, 1, ally, enemy);
}

Expand Down Expand Up @@ -829,7 +829,7 @@ void ManticoreVenom::onPlaySpecial(Field &ally, Field &enemy)

void ManticoreVenom::onTargetChoosen(Card *target, Field &ally, Field &enemy)
{
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, target));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, target));
damage(target, 13, ally, enemy);
}

Expand Down Expand Up @@ -967,7 +967,7 @@ void Cleaver::onEnter(Field &ally, Field &enemy)

void Cleaver::onTargetChoosen(Card *target, Field &ally, Field &enemy)
{
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, target));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, target));
damage(target, int(ally.hand.size()), ally, enemy);
}

Expand Down Expand Up @@ -1120,7 +1120,7 @@ void HeymaeySpearmaiden::onEnter(Field &ally, Field &enemy)

void HeymaeySpearmaiden::onTargetChoosen(Card *target, Field &ally, Field &enemy)
{
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, target));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, target));
damage(target, 1, ally, enemy);
if (Card *copy = findCopy(target, ally.deck))
playCard(copy, ally, enemy);
Expand Down Expand Up @@ -1506,7 +1506,7 @@ void ShupeHunter::onTargetChoosen(Card *target, Field &ally, Field &enemy)
if (dynamic_cast<ShupeHunter::Barrage *>(_choosen)) {
for (int n = 0; n < 8; ++n)
if (Card *card = random(cardsFiltered(ally, enemy, {}, Enemy))) {
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, card));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, card));
damage(card, 2, ally, enemy);
}
delete _choosen;
Expand All @@ -1525,7 +1525,7 @@ void ShupeHunter::onTargetChoosen(Card *target, Field &ally, Field &enemy)
}

if (dynamic_cast<ShupeHunter::Shot *>(_choosen)) {
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, target));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, target));
damage(target, 15, ally, enemy);
delete _choosen;
_choosen = nullptr;
Expand Down Expand Up @@ -1633,14 +1633,14 @@ void ShupeMage::onTargetChoosen(Card *target, Field &ally, Field &enemy)
Card *left = cardNextTo(target, ally, enemy, -1);
Card *right = cardNextTo(target, ally, enemy, 1);

// ally.animations.push_back(new Animation("", Animation::LineDamage, this, target));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, target));
damage(target, 10, ally, enemy);
if (left != nullptr) {
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, left));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, left));
damage(left, 5, ally, enemy);
}
if (right != nullptr) {
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, right));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, right));
damage(right, 5, ally, enemy);
}

Expand Down Expand Up @@ -2009,7 +2009,7 @@ void HaraldTheCripple::onEnter(Field &ally, Field &enemy)
return;
for (int n = 0; n < 9; ++n)
if (Card *card = random(enemy.row(row))) {
// ally.animations.push_back(new Animation("", Animation::LineDamage, this, card));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, this, card));
damage(card, 1, ally, enemy);
}
}
Expand Down
33 changes: 23 additions & 10 deletions Cards/card.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ Card *random(const std::vector<Card *> &cards)

void playAsSpecial(Card *card, Field &ally, Field &enemy)
{
// ally.animations.push_back(new Animation(randomSound(card), Animation::PlaySpecial, card));
saveFieldsSnapshot(ally, enemy, randomSound(card));

card->onPlaySpecial(ally, enemy);

Expand Down Expand Up @@ -324,7 +324,7 @@ void putOnField(Card *card, const Row row, const Pos pos, Field &ally, Field &en
if (takenFrom == Meele || takenFrom == Range || takenFrom == Seige)
return card->onMoveFromRowToRow(ally, enemy);

// ally.animations.push_back(new Animation(randomSound(card), Animation::PutOnField, card));
saveFieldsSnapshot(ally, enemy, randomSound(card));

if (card->isLoyal) {
if (takenFrom == Deck)
Expand Down Expand Up @@ -842,7 +842,7 @@ void banish(Card *card, Field &ally, Field &enemy)
void duel(Card *first, Card *second, Field &ally, Field &enemy)
{
while (true) {
// ally.animations.push_back(new Animation("", Animation::LineDamage, first, second));
// ally.snapshots.push_back(new Animation("", Animation::LineDamage, first, second));
if (damage(second, first->power, ally, enemy))
break;
std::swap(first, second);
Expand All @@ -863,7 +863,7 @@ bool damage(Card *card, const int x, Field &ally, Field &enemy)
/// if armor broken, but will survive
if ((card->armor == 0) && (card->power > dmgInPower)){
card->onArmorLost(ally, enemy);
// ally.animations.push_back(new Animation("", Animation::ArmorAllLost, card));
// ally.snapshots.push_back(new Animation("", Animation::ArmorAllLost, card));
}

if (dmgInPower == 0)
Expand All @@ -873,7 +873,8 @@ bool damage(Card *card, const int x, Field &ally, Field &enemy)

if (card->power > 0) {
card->onDamaged(dmgInPower, ally, enemy);
// ally.animations.push_back(new Animation("", Animation::DamageText, card));
saveFieldsSnapshot(ally, enemy);
// ally.snapshots.push_back(new Animation("", Animation::DamageText, card));
// TODO: trigger other on damaged
return false;
}
Expand All @@ -899,7 +900,7 @@ void boost(Card *card, const int x, Field &ally, Field &enemy)

card->power += x;

// ally.animations.push_back(new Animation("", Animation::BoostText, card));
// ally.snapshots.push_back(new Animation("", Animation::BoostText, card));

// TODO: others trigger on boosted
}
Expand All @@ -911,7 +912,7 @@ void strengthen(Card *card, const int x, Field &ally, Field &enemy)
card->power += x;
card->powerBase += x;

// ally.animations.push_back(new Animation("", Animation::StrengthenText, card));
// ally.snapshots.push_back(new Animation("", Animation::StrengthenText, card));

// TODO: others trigger on strengthen
}
Expand All @@ -923,7 +924,7 @@ void weaken(Card *card, const int x, Field &ally, Field &enemy)
card->power -= x;
card->powerBase -= x;

// ally.animations.push_back(new Animation("", Animation::WeakenText, card));
// ally.snapshots.push_back(new Animation("", Animation::WeakenText, card));

if (card->powerBase < 0)
return banish(card, ally, enemy);
Expand All @@ -937,7 +938,7 @@ void gainArmor(Card *card, const int x, Field &ally, Field &enemy)

card->armor += x;

// ally.animations.push_back(new Animation("", Animation::ArmorGainText, card));
// ally.snapshots.push_back(new Animation("", Animation::ArmorGainText, card));
}

std::string stringChoices(const std::vector<Choice> &cardStack)
Expand Down Expand Up @@ -1059,7 +1060,7 @@ void spawn(Card *card, Field &ally, Field &enemy)
assert(card != nullptr);

ally.cardsAdded.push_back(card);
// ally.animations.push_back(new Animation("", Animation::Spawn, card));
// ally.snapshots.push_back(new Animation("", Animation::Spawn, card));

if (card->isSpecial) {
playAsSpecial(card, ally, enemy);
Expand Down Expand Up @@ -1184,3 +1185,15 @@ void clearAllHazards(Field &field, std::vector<Card *> *damagedUnitsUnderHazards
rowEffect = NoRowEffect;
}
}

void saveFieldsSnapshot(Field &ally, Field &enemy, const std::string &sound)
{
FieldView viewAlly = fieldView(ally, enemy);
viewAlly.sound = sound;
ally.snapshots.push_back(viewAlly);


FieldView viewEnemy = fieldView(enemy, ally);
viewAlly.sound = sound;
enemy.snapshots.push_back(viewEnemy);
}
Loading

0 comments on commit 9725bc7

Please sign in to comment.