Erwan
- Moved the "putintoplay" rule as a standard MTGAbility - reverted bad encoding for MTGGuiPlay
This commit is contained in:
@@ -32,8 +32,9 @@ class GameObserver{
|
||||
int currentRound;
|
||||
|
||||
|
||||
int targetListIsSet(MTGCardInstance * card);
|
||||
|
||||
public:
|
||||
int targetListIsSet(MTGCardInstance * card);
|
||||
PhaseRing * phaseRing;
|
||||
int cancelCurrentAction();
|
||||
int currentGamePhase;
|
||||
|
||||
@@ -8,6 +8,16 @@
|
||||
#include "../include/Counters.h"
|
||||
|
||||
|
||||
class MTGPutInPlayRule:public MTGAbility{
|
||||
public:
|
||||
int isReactingToClick(MTGCardInstance * card);
|
||||
int reactToClick(MTGCardInstance * card);
|
||||
int testDestroy();
|
||||
MTGPutInPlayRule(int _id);
|
||||
const char * getMenuText(){return "Put into play";}
|
||||
|
||||
};
|
||||
|
||||
class MTGAttackRule:public MTGAbility{
|
||||
public:
|
||||
int isReactingToClick(MTGCardInstance * card);
|
||||
|
||||
@@ -152,7 +152,9 @@ int ActionLayer::reactToClick(MTGCardInstance * card){
|
||||
|
||||
for (int i=0;i<mCount;i++){
|
||||
ActionElement * currentAction = (ActionElement *)mObjects[i];
|
||||
OutputDebugString(currentAction->getMenuText());
|
||||
result += currentAction->reactToClick(card);
|
||||
if (result) return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ void DuelLayers::init(){
|
||||
MTGGamePhase * phaseManager = NEW MTGGamePhase(actionLayer->getMaxId());
|
||||
actionLayer->Add(phaseManager);
|
||||
//Add Magic Specific Rules
|
||||
actionLayer->Add(NEW MTGPutInPlayRule(-1));
|
||||
actionLayer->Add(NEW MTGAttackRule(-1));
|
||||
actionLayer->Add(NEW MTGBlockRule(-1));
|
||||
actionLayer->Add(NEW MTGLegendRule(-1));
|
||||
|
||||
@@ -307,26 +307,17 @@ void GameObserver::cardClick (MTGCardInstance * card, Targetable * object){
|
||||
|
||||
if (reaction != -1){
|
||||
if (!card) return;
|
||||
if (currentlyActing()->game->hand->hasCard(card)){
|
||||
//Current player's hand
|
||||
if (canPutInPlay(card)){
|
||||
putInPlay(card);
|
||||
if (card->hasType("land")){
|
||||
currentPlayer->canPutLandsIntoPlay--;
|
||||
}
|
||||
}else if (currentPlayer->game->hand->hasCard(card)){ //Current player's hand
|
||||
if (currentGamePhase == Constants::MTG_PHASE_CLEANUP && currentPlayer->game->hand->nb_cards > 7){
|
||||
currentPlayer->game->putInGraveyard(card);
|
||||
}
|
||||
}
|
||||
}else if (reaction){
|
||||
//Current player's hand
|
||||
if (currentPlayer->game->hand->hasCard(card) && currentGamePhase == Constants::MTG_PHASE_CLEANUP && currentPlayer->game->hand->nb_cards > 7){
|
||||
currentPlayer->game->putInGraveyard(card);
|
||||
}else if (reaction){
|
||||
if (reaction == 1){
|
||||
mLayers->actionLayer()->reactToClick(card);
|
||||
}else{
|
||||
mLayers->actionLayer()->setMenuObject(object);
|
||||
}
|
||||
}else if (card->isTapped() && card->controller() == currentPlayer){
|
||||
// int a = ConstraintResolver::untap(this, card);
|
||||
ConstraintResolver::untap(this, card);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1712,18 +1712,20 @@ int TargetAbility::reactToClick(MTGCardInstance * card){
|
||||
if (isReactingToClick(card)){
|
||||
waitingForAnswer = 1;
|
||||
tc->initTargets();
|
||||
return 1;
|
||||
}
|
||||
}else{
|
||||
if (card == source){
|
||||
if (tc->targetsReadyCheck() == TARGET_OK){
|
||||
waitingForAnswer = 0;
|
||||
ActivatedAbility::reactToClick(source);
|
||||
waitingForAnswer = 0;
|
||||
return ActivatedAbility::reactToClick(source);
|
||||
}
|
||||
}else{
|
||||
tc->toggleTarget(card);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void TargetAbility::Render(){
|
||||
|
||||
Binary file not shown.
@@ -1,6 +1,76 @@
|
||||
#include "../include/config.h"
|
||||
#include "../include/MTGRules.h"
|
||||
|
||||
MTGPutInPlayRule::MTGPutInPlayRule(int _id):MTGAbility(_id, NULL){
|
||||
|
||||
}
|
||||
|
||||
int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card){
|
||||
Player * player = game->currentlyActing();
|
||||
Player * currentPlayer = game->currentPlayer;
|
||||
LOG("CANPUTINPLAY- check if card belongs to current player\n");
|
||||
if (!player->game->hand->hasCard(card)) return 0;
|
||||
LOG("CANPUTINPLAY- check if card is land or can be played\n");
|
||||
if (card->hasType("land")){
|
||||
LOG("CANPUTINPLAY- card is land - check if can be played\n");
|
||||
if (player == currentPlayer && currentPlayer->canPutLandsIntoPlay && (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN)){
|
||||
LOG("CANPUTINPLAY- Land, ok\n");
|
||||
return 1;
|
||||
}
|
||||
}else if ((card->hasType("instant")) || card->has(Constants::FLASH) || (player == currentPlayer && (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN))){
|
||||
LOG("CANPUTINPLAY- correct time to play\n");
|
||||
ManaCost * playerMana = player->getManaPool();
|
||||
ManaCost * cost = card->getManaCost();
|
||||
if (playerMana->canAfford(cost)){
|
||||
LOG("CANPUTINPLAY- ManaCost ok\n");
|
||||
if (game->targetListIsSet(card)){
|
||||
#ifdef LOG
|
||||
LOG("CANPUTINPLAY- Targets chosen -> OK\n");
|
||||
#endif
|
||||
return 1;
|
||||
}else{
|
||||
#ifdef LOG
|
||||
LOG("CANPUTINPLAY- Targets not chosen yet\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MTGPutInPlayRule::reactToClick(MTGCardInstance * card){
|
||||
if (!isReactingToClick(card)) return 0;
|
||||
Player * player = game->currentlyActing();
|
||||
ManaCost * previousManaPool = NEW ManaCost(player->getManaPool());
|
||||
player->getManaPool()->pay(card->getManaCost());
|
||||
ManaCost * spellCost = previousManaPool->Diff(player->getManaPool());
|
||||
delete previousManaPool;
|
||||
if (card->hasType("land")){
|
||||
Spell * spell = NEW Spell(card);
|
||||
player->game->putInZone(card, player->game->hand, player->game->stack);
|
||||
spell->resolve();
|
||||
delete spellCost;
|
||||
delete spell;
|
||||
player->canPutLandsIntoPlay--;
|
||||
}else{
|
||||
if (game->targetChooser){
|
||||
game->mLayers->stackLayer()->addSpell(card,game->targetChooser->targets,game->targetChooser->cursor, spellCost);
|
||||
SAFE_DELETE(game->targetChooser);
|
||||
}else{
|
||||
game->mLayers->stackLayer()->addSpell(card,NULL,0, spellCost);
|
||||
}
|
||||
player->game->putInZone(card, player->game->hand, player->game->stack);
|
||||
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
//The Put into play rule is never destroyed
|
||||
int MTGPutInPlayRule::testDestroy(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
MTGAttackRule::MTGAttackRule(int _id):MTGAbility(_id,NULL){
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user