[CODE] Colorless Hybrid
Posted: Mon Sep 23, 2013 4:04 pm
There is an issue that has been reported with colorless hybrid card (Spectral Procession and the likes).
Basically, you can't pay the colorless "part" of the mana cost with coloured mana, you have to use real *colorless* mana.
It means you can't cast Spectral Procession for BBWW for instance.
Attached is my attempt at fixing this by updating ManaCost::tryToPayHybrids, which, in its current state, could not handle colorless hybrid.
Using this code, I've been able to cast Spectral Procession with the following manapools.
Edit: Sadly, my code doesn't work for Reaper King...
Basically, you can't pay the colorless "part" of the mana cost with coloured mana, you have to use real *colorless* mana.
It means you can't cast Spectral Procession for BBWW for instance.
Attached is my attempt at fixing this by updating ManaCost::tryToPayHybrids, which, in its current state, could not handle colorless hybrid.
Using this code, I've been able to cast Spectral Procession with the following manapools.
- 6 non-white mana
- 5 mana (including 1 white)
- 4 mana (including 2 white)
- 3 white
Code: Select all
/**
starting from the end of the array (diff)
*/
int ManaCost::tryToPayHybrids(std::vector<ManaCostHybrid>& _hybrids, int _nbhybrids, std::vector<int16_t>& diff)
{
if (!_nbhybrids)
return 1;
int result = 0;
ManaCostHybrid& h = _hybrids[_nbhybrids - 1];
if (diff[h.color1 * 2 + 1] >= h.value1)
{
diff[h.color1 * 2 + 1] -= h.value1;
result = tryToPayHybrids(_hybrids, _nbhybrids - 1, diff);
if (result)
return 1;
diff[h.color1 * 2 + 1] += h.value1;
}
if (diff[h.color2 * 2 + 1] >= h.value2)
{
diff[h.color2 * 2 + 1] -= h.value2;
result = tryToPayHybrids(_hybrids, _nbhybrids - 1, diff);
if (result)
return 1;
diff[h.color2 * 2 + 1] += h.value2;
}
if (h.color1 == Constants::MTG_COLOR_ARTIFACT && h.value1 > 0)
{
int colorlesscost = h.value1;
vector<int16_t> diffcopy;
diffcopy.resize((Constants::NB_Colors + 1) * 2);
diffcopy[Constants::NB_Colors * 2] = Constants::NB_Colors;
for (int i = 0; i < Constants::NB_Colors*2; i++)
{
diffcopy[i] = diff[i];
}
for (int i = 0 ; i <= Constants::MTG_COLOR_LAND ; i++)
{
if (colorlesscost <= diffcopy[i * 2 + 1]) {
diffcopy[i * 2 + 1] -= colorlesscost;
colorlesscost = 0;
}
else
{
//update what's left to pay & empty that mana pool's color
colorlesscost -= diffcopy[i * 2 + 1];
diffcopy[i * 2 + 1] = 0;
}
}
if (colorlesscost == 0) {
//we paid the whole cost, update the real mana cost and proceed
for (int i = 0; i < Constants::NB_Colors*2; i++)
{
diff[i] = diffcopy[i];
}
result = tryToPayHybrids(_hybrids, _nbhybrids - 1, diff);
if (result)
return 1;
}
}
return 0;
}