changed some of the ability names as requested, autoformatted ability.cpp as it was getting pretty messy. added @attackedalone( trigger. added "removefromcombat" mtgability. im going on vacation, whoosh :P
This commit is contained in:
+263
-208
File diff suppressed because it is too large
Load Diff
@@ -145,6 +145,7 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
|
|||||||
void attemptUntap();
|
void attemptUntap();
|
||||||
|
|
||||||
void eventattacked();
|
void eventattacked();
|
||||||
|
void eventattackedAlone();
|
||||||
void eventattackednotblocked();
|
void eventattackednotblocked();
|
||||||
void eventattackedblocked();
|
void eventattackedblocked();
|
||||||
void eventblocked();
|
void eventblocked();
|
||||||
|
|||||||
@@ -108,6 +108,12 @@ struct WEventCardAttacked : public WEventCardUpdate {
|
|||||||
virtual Targetable * getTarget(int target);
|
virtual Targetable * getTarget(int target);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//event when card attacks alone.
|
||||||
|
struct WEventCardAttackedAlone : public WEventCardUpdate {
|
||||||
|
WEventCardAttackedAlone(MTGCardInstance * card);
|
||||||
|
virtual Targetable * getTarget(int target);
|
||||||
|
};
|
||||||
|
|
||||||
//event when card attacks but is not blocked.
|
//event when card attacks but is not blocked.
|
||||||
struct WEventCardAttackedNotBlocked : public WEventCardUpdate {
|
struct WEventCardAttackedNotBlocked : public WEventCardUpdate {
|
||||||
WEventCardAttackedNotBlocked(MTGCardInstance * card);
|
WEventCardAttackedNotBlocked(MTGCardInstance * card);
|
||||||
@@ -147,6 +153,11 @@ struct WEventCreatureBlocker : public WEventCardUpdate {
|
|||||||
WEventCreatureBlocker(MTGCardInstance * card,MTGCardInstance * from,MTGCardInstance * to);
|
WEventCreatureBlocker(MTGCardInstance * card,MTGCardInstance * from,MTGCardInstance * to);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Event sent when attackers have been chosen and they
|
||||||
|
//cannot be changed any more.
|
||||||
|
struct WEventAttackersChosen : public WEvent {
|
||||||
|
};
|
||||||
|
|
||||||
//Event sent when blockers have been chosen and they
|
//Event sent when blockers have been chosen and they
|
||||||
//cannot be changed any more.
|
//cannot be changed any more.
|
||||||
struct WEventBlockersChosen : public WEvent {
|
struct WEventBlockersChosen : public WEvent {
|
||||||
|
|||||||
@@ -138,6 +138,9 @@ void GameObserver::nextGamePhase(){
|
|||||||
case Constants::MTG_PHASE_DRAW:
|
case Constants::MTG_PHASE_DRAW:
|
||||||
//mLayers->stackLayer()->addDraw(currentPlayer,1);
|
//mLayers->stackLayer()->addDraw(currentPlayer,1);
|
||||||
break;
|
break;
|
||||||
|
case Constants::MTG_PHASE_COMBATBLOCKERS:
|
||||||
|
receiveEvent(NEW WEventAttackersChosen());
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
+101
-82
@@ -144,6 +144,18 @@ TriggeredAbility * AbilityFactory::parseTrigger(string magicText, int id, Spell
|
|||||||
return NEW TrCardAddedToZone(id,card,(TargetZoneChooser *)toTc, toTcCard,(TargetZoneChooser *)fromTc,fromTcCard);
|
return NEW TrCardAddedToZone(id,card,(TargetZoneChooser *)toTc, toTcCard,(TargetZoneChooser *)fromTc,fromTcCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Card unTapped
|
||||||
|
found = s.find("untapped(");
|
||||||
|
if (found != string::npos){
|
||||||
|
size_t end = s.find (")");
|
||||||
|
string starget = s.substr(found+9,end - found - 9);
|
||||||
|
TargetChooserFactory tcf;
|
||||||
|
TargetChooser *tc = tcf.createTargetChooser(starget,card);
|
||||||
|
tc->targetter = NULL;
|
||||||
|
|
||||||
|
return NEW TrCardTapped(id,card,tc,false);
|
||||||
|
}
|
||||||
|
|
||||||
//Card Tapped
|
//Card Tapped
|
||||||
found = s.find("tapped(");
|
found = s.find("tapped(");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
@@ -156,18 +168,6 @@ TriggeredAbility * AbilityFactory::parseTrigger(string magicText, int id, Spell
|
|||||||
return NEW TrCardTapped(id,card,tc,true);
|
return NEW TrCardTapped(id,card,tc,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Card unTapped
|
|
||||||
found = s.find("untapping(");
|
|
||||||
if (found != string::npos){
|
|
||||||
size_t end = s.find (")");
|
|
||||||
string starget = s.substr(found+10,end - found - 10);
|
|
||||||
TargetChooserFactory tcf;
|
|
||||||
TargetChooser *tc = tcf.createTargetChooser(starget,card);
|
|
||||||
tc->targetter = NULL;
|
|
||||||
|
|
||||||
return NEW TrCardTapped(id,card,tc,false);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Card Tapped for mana
|
//Card Tapped for mana
|
||||||
found = s.find("tappedformana(");
|
found = s.find("tappedformana(");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
@@ -191,6 +191,17 @@ TriggeredAbility * AbilityFactory::parseTrigger(string magicText, int id, Spell
|
|||||||
|
|
||||||
return NEW TrCardAttacked(id,card,tc);
|
return NEW TrCardAttacked(id,card,tc);
|
||||||
}
|
}
|
||||||
|
//Card is attacking alone
|
||||||
|
found = s.find("attackedalone(");
|
||||||
|
if (found != string::npos){
|
||||||
|
size_t end = s.find (")");
|
||||||
|
string starget = s.substr(found+14,end - found - 14);
|
||||||
|
TargetChooserFactory tcf;
|
||||||
|
TargetChooser *tc = tcf.createTargetChooser(starget,card);
|
||||||
|
tc->targetter = NULL;
|
||||||
|
|
||||||
|
return NEW TrCardAttackedAlone(id,card,tc);
|
||||||
|
}
|
||||||
|
|
||||||
//Card card attacked and is not blocked
|
//Card card attacked and is not blocked
|
||||||
found = s.find("notblocked(");
|
found = s.find("notblocked(");
|
||||||
@@ -282,6 +293,47 @@ TriggeredAbility * AbilityFactory::parseTrigger(string magicText, int id, Spell
|
|||||||
return NEW TrCardDiscarded(id,card,tc);
|
return NEW TrCardDiscarded(id,card,tc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Card Damaging non combat
|
||||||
|
found = s.find("noncombatdamaged(");
|
||||||
|
if (found != string::npos){
|
||||||
|
size_t end = s.find (")");
|
||||||
|
string starget = s.substr(found+17,end - found - 17);
|
||||||
|
TargetChooserFactory tcf;
|
||||||
|
TargetChooser *tc = tcf.createTargetChooser(starget,card);
|
||||||
|
tc->targetter = NULL;
|
||||||
|
found = s.find("from(");
|
||||||
|
|
||||||
|
TargetChooser *fromTc = NULL;
|
||||||
|
if (found != string::npos){
|
||||||
|
end = s.find (")", found);
|
||||||
|
starget = s.substr(found+5,end - found - 5);
|
||||||
|
fromTc = tcf.createTargetChooser(starget,card);
|
||||||
|
fromTc->targetter = NULL;
|
||||||
|
}
|
||||||
|
return NEW TrDamaged(id,card,tc,fromTc, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Card Damaging combat
|
||||||
|
found = s.find("combatdamaged(");
|
||||||
|
if (found != string::npos){
|
||||||
|
size_t end = s.find (")");
|
||||||
|
string starget = s.substr(found+14,end - found - 14);
|
||||||
|
TargetChooserFactory tcf;
|
||||||
|
TargetChooser *tc = tcf.createTargetChooser(starget,card);
|
||||||
|
tc->targetter = NULL;
|
||||||
|
found = s.find("from(");
|
||||||
|
|
||||||
|
TargetChooser *fromTc = NULL;
|
||||||
|
if (found != string::npos){
|
||||||
|
end = s.find (")", found);
|
||||||
|
starget = s.substr(found+5,end - found - 5);
|
||||||
|
fromTc = tcf.createTargetChooser(starget,card);
|
||||||
|
fromTc->targetter = NULL;
|
||||||
|
}
|
||||||
|
return NEW TrDamaged(id,card,tc,fromTc, 1);
|
||||||
|
}
|
||||||
|
|
||||||
//Card Damaging
|
//Card Damaging
|
||||||
found = s.find("damaged(");
|
found = s.find("damaged(");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
@@ -302,46 +354,6 @@ TriggeredAbility * AbilityFactory::parseTrigger(string magicText, int id, Spell
|
|||||||
return NEW TrDamaged(id,card,tc,fromTc, 0);
|
return NEW TrDamaged(id,card,tc,fromTc, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Card Damaging combat
|
|
||||||
found = s.find("combatdamage(");
|
|
||||||
if (found != string::npos){
|
|
||||||
size_t end = s.find (")");
|
|
||||||
string starget = s.substr(found+13,end - found - 13);
|
|
||||||
TargetChooserFactory tcf;
|
|
||||||
TargetChooser *tc = tcf.createTargetChooser(starget,card);
|
|
||||||
tc->targetter = NULL;
|
|
||||||
found = s.find("from(");
|
|
||||||
|
|
||||||
TargetChooser *fromTc = NULL;
|
|
||||||
if (found != string::npos){
|
|
||||||
end = s.find (")", found);
|
|
||||||
starget = s.substr(found+5,end - found - 5);
|
|
||||||
fromTc = tcf.createTargetChooser(starget,card);
|
|
||||||
fromTc->targetter = NULL;
|
|
||||||
}
|
|
||||||
return NEW TrDamaged(id,card,tc,fromTc, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Card Damaging non combat
|
|
||||||
found = s.find("damagenoncombat(");
|
|
||||||
if (found != string::npos){
|
|
||||||
size_t end = s.find (")");
|
|
||||||
string starget = s.substr(found+16,end - found - 16);
|
|
||||||
TargetChooserFactory tcf;
|
|
||||||
TargetChooser *tc = tcf.createTargetChooser(starget,card);
|
|
||||||
tc->targetter = NULL;
|
|
||||||
found = s.find("from(");
|
|
||||||
|
|
||||||
TargetChooser *fromTc = NULL;
|
|
||||||
if (found != string::npos){
|
|
||||||
end = s.find (")", found);
|
|
||||||
starget = s.substr(found+5,end - found - 5);
|
|
||||||
fromTc = tcf.createTargetChooser(starget,card);
|
|
||||||
fromTc->targetter = NULL;
|
|
||||||
}
|
|
||||||
return NEW TrDamaged(id,card,tc,fromTc, 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
int who = 0;
|
int who = 0;
|
||||||
if (s.find("my") != string::npos) who = 1;
|
if (s.find("my") != string::npos) who = 1;
|
||||||
if (s.find("opponent") != string::npos) who = -1;
|
if (s.find("opponent") != string::npos) who = -1;
|
||||||
@@ -804,6 +816,14 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//combat removel
|
||||||
|
found = s.find("removefromcombat");
|
||||||
|
if (found != string::npos){
|
||||||
|
MTGAbility * a = NEW ACombatRemovel(id,card,target);
|
||||||
|
a->oneShot = 1;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
//Fizzle (counterspell...)
|
//Fizzle (counterspell...)
|
||||||
found = s.find("fizzle");
|
found = s.find("fizzle");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
@@ -1010,13 +1030,36 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
|
|
||||||
MTGAbility * ab;
|
MTGAbility * ab;
|
||||||
if (forceUEOT){
|
if (forceUEOT){
|
||||||
ab = NEW APreventAllCombatDamageUEOT(id,card,to,from);
|
ab = NEW APreventDamageTypesUEOT(id,card,to,from);
|
||||||
}else{
|
}else{
|
||||||
ab = NEW APreventAllCombatDamage(id,card,to,from);
|
ab = NEW APreventDamageTypes(id,card,to,from);
|
||||||
}
|
}
|
||||||
return ab;
|
return ab;
|
||||||
}
|
}
|
||||||
//PreventCombat Damage
|
//Prevent all non combat damage Damage
|
||||||
|
found = s.find("preventallnoncombatdamage");
|
||||||
|
if (found != string::npos){
|
||||||
|
string to = "";
|
||||||
|
string from = "";
|
||||||
|
found = s.find("to(");
|
||||||
|
if (found != string::npos){
|
||||||
|
size_t end = s.find (")", found);
|
||||||
|
to = s.substr(found+3,end - found - 3);
|
||||||
|
}
|
||||||
|
found = s.find("from(");
|
||||||
|
if (found != string::npos){
|
||||||
|
size_t end = s.find (")", found);
|
||||||
|
from = s.substr(found+5,end - found - 5);
|
||||||
|
}
|
||||||
|
MTGAbility * ab;
|
||||||
|
if (forceUEOT){
|
||||||
|
ab = NEW APreventDamageTypesUEOT(id,card,to,from,2);
|
||||||
|
}else{
|
||||||
|
ab = NEW APreventDamageTypes(id,card,to,from,2);
|
||||||
|
}
|
||||||
|
return ab;
|
||||||
|
}
|
||||||
|
//Prevent all damage
|
||||||
found = s.find("preventalldamage");
|
found = s.find("preventalldamage");
|
||||||
if (found != string::npos){
|
if (found != string::npos){
|
||||||
string to = "";
|
string to = "";
|
||||||
@@ -1033,33 +1076,9 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
}
|
}
|
||||||
MTGAbility * ab;
|
MTGAbility * ab;
|
||||||
if (forceUEOT){
|
if (forceUEOT){
|
||||||
ab = NEW APreventAllCombatDamageUEOT(id,card,to,from,1);
|
ab = NEW APreventDamageTypesUEOT(id,card,to,from,1);
|
||||||
}else{
|
}else{
|
||||||
ab = NEW APreventAllCombatDamage(id,card,to,from,1);
|
ab = NEW APreventDamageTypes(id,card,to,from,1);
|
||||||
}
|
|
||||||
return ab;
|
|
||||||
}
|
|
||||||
|
|
||||||
//PreventCombat Damage
|
|
||||||
found = s.find("preventallnoncombat");
|
|
||||||
if (found != string::npos){
|
|
||||||
string to = "";
|
|
||||||
string from = "";
|
|
||||||
found = s.find("to(");
|
|
||||||
if (found != string::npos){
|
|
||||||
size_t end = s.find (")", found);
|
|
||||||
to = s.substr(found+3,end - found - 3);
|
|
||||||
}
|
|
||||||
found = s.find("from(");
|
|
||||||
if (found != string::npos){
|
|
||||||
size_t end = s.find (")", found);
|
|
||||||
from = s.substr(found+5,end - found - 5);
|
|
||||||
}
|
|
||||||
MTGAbility * ab;
|
|
||||||
if (forceUEOT){
|
|
||||||
ab = NEW APreventAllCombatDamageUEOT(id,card,to,from,2);
|
|
||||||
}else{
|
|
||||||
ab = NEW APreventAllCombatDamage(id,card,to,from,2);
|
|
||||||
}
|
}
|
||||||
return ab;
|
return ab;
|
||||||
}
|
}
|
||||||
@@ -1079,7 +1098,7 @@ MTGAbility * AbilityFactory::parseMagicLine(string s, int id, Spell * spell, MTG
|
|||||||
size_t end = s.find (")", found);
|
size_t end = s.find (")", found);
|
||||||
from = s.substr(found+5,end - found - 5);
|
from = s.substr(found+5,end - found - 5);
|
||||||
}
|
}
|
||||||
MTGAbility * a = NEW APreventAllCombatDamageUEOT(id,card,to,from);
|
MTGAbility * a = NEW APreventDamageTypesUEOT(id,card,to,from);
|
||||||
a->oneShot = 1;
|
a->oneShot = 1;
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,6 +223,13 @@ void MTGCardInstance::eventattacked(){
|
|||||||
game->receiveEvent(e);
|
game->receiveEvent(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//sets card as attacked alone and sends events
|
||||||
|
void MTGCardInstance::eventattackedAlone(){
|
||||||
|
WEvent * e = NEW WEventCardAttackedAlone(this);
|
||||||
|
GameObserver * game = GameObserver::GetInstance();
|
||||||
|
game->receiveEvent(e);
|
||||||
|
}
|
||||||
|
|
||||||
//sets card as attacked and sends events
|
//sets card as attacked and sends events
|
||||||
void MTGCardInstance::eventattackednotblocked(){
|
void MTGCardInstance::eventattackednotblocked(){
|
||||||
didattacked = 1;
|
didattacked = 1;
|
||||||
|
|||||||
@@ -784,6 +784,26 @@ int MTGCombatTriggersRule::receiveEvent(WEvent *e){
|
|||||||
}
|
}
|
||||||
//---------------
|
//---------------
|
||||||
}
|
}
|
||||||
|
if (WEventAttackersChosen * event = dynamic_cast<WEventAttackersChosen*>(e))
|
||||||
|
{
|
||||||
|
MTGCardInstance * lonelyAttacker;
|
||||||
|
int nbattackers = 0;
|
||||||
|
Player * p = game->currentPlayer;
|
||||||
|
MTGGameZone * z = p->game->inPlay;
|
||||||
|
int nbcards = z->nb_cards;
|
||||||
|
for (int i = 0; i < nbcards; ++i){
|
||||||
|
MTGCardInstance * c = z->cards[i];
|
||||||
|
if (c->attacker){
|
||||||
|
nbattackers++;
|
||||||
|
lonelyAttacker = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (nbattackers == 1)
|
||||||
|
{
|
||||||
|
lonelyAttacker->eventattackedAlone();
|
||||||
|
}
|
||||||
|
else lonelyAttacker = NULL;
|
||||||
|
}
|
||||||
if (WEventBlockersChosen * event = dynamic_cast<WEventBlockersChosen*>(e))
|
if (WEventBlockersChosen * event = dynamic_cast<WEventBlockersChosen*>(e))
|
||||||
{
|
{
|
||||||
Player * p = game->currentPlayer;
|
Player * p = game->currentPlayer;
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ WEventCardTappedForMana::WEventCardTappedForMana(MTGCardInstance * card, bool be
|
|||||||
|
|
||||||
WEventCardAttacked::WEventCardAttacked(MTGCardInstance * card) : WEventCardUpdate(card){}
|
WEventCardAttacked::WEventCardAttacked(MTGCardInstance * card) : WEventCardUpdate(card){}
|
||||||
|
|
||||||
|
WEventCardAttackedAlone::WEventCardAttackedAlone(MTGCardInstance * card) : WEventCardUpdate(card){}
|
||||||
|
|
||||||
WEventCardAttackedNotBlocked::WEventCardAttackedNotBlocked(MTGCardInstance * card) : WEventCardUpdate(card){}
|
WEventCardAttackedNotBlocked::WEventCardAttackedNotBlocked(MTGCardInstance * card) : WEventCardUpdate(card){}
|
||||||
|
|
||||||
WEventCardAttackedBlocked::WEventCardAttackedBlocked(MTGCardInstance * card) : WEventCardUpdate(card){}
|
WEventCardAttackedBlocked::WEventCardAttackedBlocked(MTGCardInstance * card) : WEventCardUpdate(card){}
|
||||||
@@ -72,6 +74,11 @@ Targetable * WEventCardAttacked::getTarget(int target) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Targetable * WEventCardAttackedAlone::getTarget(int target) {
|
||||||
|
if (target) return card;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
Targetable * WEventCardSacrifice::getTarget(int target) {
|
Targetable * WEventCardSacrifice::getTarget(int target) {
|
||||||
if (target) return card;
|
if (target) return card;
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user