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 currentRound;
|
||||||
|
|
||||||
|
|
||||||
int targetListIsSet(MTGCardInstance * card);
|
|
||||||
public:
|
public:
|
||||||
|
int targetListIsSet(MTGCardInstance * card);
|
||||||
PhaseRing * phaseRing;
|
PhaseRing * phaseRing;
|
||||||
int cancelCurrentAction();
|
int cancelCurrentAction();
|
||||||
int currentGamePhase;
|
int currentGamePhase;
|
||||||
|
|||||||
@@ -8,6 +8,16 @@
|
|||||||
#include "../include/Counters.h"
|
#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{
|
class MTGAttackRule:public MTGAbility{
|
||||||
public:
|
public:
|
||||||
int isReactingToClick(MTGCardInstance * card);
|
int isReactingToClick(MTGCardInstance * card);
|
||||||
|
|||||||
@@ -152,7 +152,9 @@ int ActionLayer::reactToClick(MTGCardInstance * card){
|
|||||||
|
|
||||||
for (int i=0;i<mCount;i++){
|
for (int i=0;i<mCount;i++){
|
||||||
ActionElement * currentAction = (ActionElement *)mObjects[i];
|
ActionElement * currentAction = (ActionElement *)mObjects[i];
|
||||||
|
OutputDebugString(currentAction->getMenuText());
|
||||||
result += currentAction->reactToClick(card);
|
result += currentAction->reactToClick(card);
|
||||||
|
if (result) return result;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ void DuelLayers::init(){
|
|||||||
MTGGamePhase * phaseManager = NEW MTGGamePhase(actionLayer->getMaxId());
|
MTGGamePhase * phaseManager = NEW MTGGamePhase(actionLayer->getMaxId());
|
||||||
actionLayer->Add(phaseManager);
|
actionLayer->Add(phaseManager);
|
||||||
//Add Magic Specific Rules
|
//Add Magic Specific Rules
|
||||||
|
actionLayer->Add(NEW MTGPutInPlayRule(-1));
|
||||||
actionLayer->Add(NEW MTGAttackRule(-1));
|
actionLayer->Add(NEW MTGAttackRule(-1));
|
||||||
actionLayer->Add(NEW MTGBlockRule(-1));
|
actionLayer->Add(NEW MTGBlockRule(-1));
|
||||||
actionLayer->Add(NEW MTGLegendRule(-1));
|
actionLayer->Add(NEW MTGLegendRule(-1));
|
||||||
|
|||||||
@@ -307,18 +307,9 @@ void GameObserver::cardClick (MTGCardInstance * card, Targetable * object){
|
|||||||
|
|
||||||
if (reaction != -1){
|
if (reaction != -1){
|
||||||
if (!card) return;
|
if (!card) return;
|
||||||
if (currentlyActing()->game->hand->hasCard(card)){
|
|
||||||
//Current player's hand
|
//Current player's hand
|
||||||
if (canPutInPlay(card)){
|
if (currentPlayer->game->hand->hasCard(card) && currentGamePhase == Constants::MTG_PHASE_CLEANUP && currentPlayer->game->hand->nb_cards > 7){
|
||||||
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);
|
currentPlayer->game->putInGraveyard(card);
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if (reaction){
|
}else if (reaction){
|
||||||
if (reaction == 1){
|
if (reaction == 1){
|
||||||
mLayers->actionLayer()->reactToClick(card);
|
mLayers->actionLayer()->reactToClick(card);
|
||||||
@@ -326,7 +317,7 @@ void GameObserver::cardClick (MTGCardInstance * card, Targetable * object){
|
|||||||
mLayers->actionLayer()->setMenuObject(object);
|
mLayers->actionLayer()->setMenuObject(object);
|
||||||
}
|
}
|
||||||
}else if (card->isTapped() && card->controller() == currentPlayer){
|
}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)){
|
if (isReactingToClick(card)){
|
||||||
waitingForAnswer = 1;
|
waitingForAnswer = 1;
|
||||||
tc->initTargets();
|
tc->initTargets();
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if (card == source){
|
if (card == source){
|
||||||
if (tc->targetsReadyCheck() == TARGET_OK){
|
if (tc->targetsReadyCheck() == TARGET_OK){
|
||||||
waitingForAnswer = 0;
|
waitingForAnswer = 0;
|
||||||
ActivatedAbility::reactToClick(source);
|
return ActivatedAbility::reactToClick(source);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
tc->toggleTarget(card);
|
tc->toggleTarget(card);
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TargetAbility::Render(){
|
void TargetAbility::Render(){
|
||||||
|
|||||||
Binary file not shown.
@@ -1,6 +1,76 @@
|
|||||||
#include "../include/config.h"
|
#include "../include/config.h"
|
||||||
#include "../include/MTGRules.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){
|
MTGAttackRule::MTGAttackRule(int _id):MTGAbility(_id,NULL){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user