-fix issue 297
- also removed the "untapBlockers" system. The idea was nice but incorrectly implemented, and only 2 cards were using it so far.
This commit is contained in:
wagic.the.homebrew@gmail.com
2010-01-17 12:05:40 +00:00
parent 6830d850f2
commit ffbcd3f2d0
16 changed files with 74 additions and 306 deletions

View File

@@ -1,4 +1,4 @@
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/Blocker.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardPrimitive.o objs/CardSelector.o objs/ConstraintResolver.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DeckDataWrapper.o objs/DeckMetaData.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateAwards.o objs/GameStateDeckViewer.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PriceList.o objs/ReplacementEffects.o objs/Rules.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/SimplePad.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/Token.o objs/Translate.o objs/Trash.o objs/utils.o objs/WEvent.o objs/WResourceManager.o objs/WCachedResource.o objs/Tasks.o
OBJS = objs/ActionElement.o objs/ActionLayer.o objs/ActionStack.o objs/AIMomirPlayer.o objs/AIPlayer.o objs/AIStats.o objs/CardGui.o objs/CardDescriptor.o objs/CardDisplay.o objs/CardEffect.o objs/CardPrimitive.o objs/CardSelector.o objs/Counters.o objs/Credits.o objs/Damage.o objs/DamagerDamaged.o objs/DeckDataWrapper.o objs/DeckMetaData.o objs/DeckStats.o objs/DuelLayers.o objs/Effects.o objs/ExtraCost.o objs/GameApp.o objs/GameLauncher.o objs/GameObserver.o objs/GameOptions.o objs/GameState.o objs/GameStateAwards.o objs/GameStateDeckViewer.o objs/GameStateDuel.o objs/GameStateMenu.o objs/GameStateOptions.o objs/GameStateShop.o objs/GuiAvatars.o objs/GuiBackground.o objs/GuiCardsController.o objs/GuiCombat.o objs/GuiFrame.o objs/GuiHand.o objs/GuiLayers.o objs/GuiMana.o objs/GuiPhaseBar.o objs/GuiPlay.o objs/GuiStatic.o objs/Logger.o objs/ManaCost.o objs/ManaCostHybrid.o objs/MenuItem.o objs/MTGAbility.o objs/MTGCardInstance.o objs/MTGCard.o objs/MTGDeck.o objs/MTGDefinitions.o objs/MTGGamePhase.o objs/MTGGameZones.o objs/MTGRules.o objs/OptionItem.o objs/PhaseRing.o objs/Player.o objs/PlayerData.o objs/PlayGuiObjectController.o objs/PlayGuiObject.o objs/Pos.o objs/PriceList.o objs/ReplacementEffects.o objs/Rules.o objs/ShopItem.o objs/SimpleMenu.o objs/SimpleMenuItem.o objs/SimplePad.o objs/Subtypes.o objs/TargetChooser.o objs/TargetsList.o objs/TextScroller.o objs/Token.o objs/Translate.o objs/Trash.o objs/utils.o objs/WEvent.o objs/WResourceManager.o objs/WCachedResource.o objs/Tasks.o
DEPS = $(patsubst objs/%.o, deps/%.d, $(OBJS))
RESULT = $(shell psp-config --psp-prefix 2> Makefile.cache)

View File

@@ -1408,6 +1408,8 @@ type=Instant
text=Mana Vault doesn't untap during your untap step. At the beginning of your upkeep, you may pay {4}. If you do, untap Mana Vault. At the beginning of your draw step, if Mana Vault is tapped, it deals 1 damage to you. {T}: Add {3} to your mana pool.
id=1124
name=Mana Vault
auto=doesnotuntap
auto={4}:untap myUpkeepOnly
rarity=R
mana={1}
type=Artifact
@@ -1581,6 +1583,9 @@ text=Enchant creature When Paralyze enters the battlefield, tap enchanted crea
target=creature
id=1171
name=Paralyze
auto=tap
auto=doesnotuntap
auto={4}:untap upkeepOlny
rarity=C
mana={B}
type=Enchantment

View File

@@ -1405,27 +1405,6 @@ class GenericInstantAbility: public InstantAbility{
};
//Untap Blockers with simple Mana Mechanism
class AUntapManaBlocker: public UntapBlocker{
public:
AUntapManaBlocker(int id, MTGCardInstance * card, ManaCost * _cost):UntapBlocker(id, card, _cost){
}
AUntapManaBlocker(int id, MTGCardInstance * card, MTGCardInstance * _target, ManaCost * _cost):UntapBlocker(id, card,_target, _cost){
}
virtual ostream& toString(ostream& out) const
{
out << "AUntapManaBlocker ::: (";
return UntapBlocker::toString(out) << ")";
}
AUntapManaBlocker * clone() const{
AUntapManaBlocker * a = NEW AUntapManaBlocker(*this);
a->isClone = 1;
return a;
}
};
//Circle of Protections
class ACircleOfProtection: public TargetAbility{
protected:

View File

@@ -1,55 +0,0 @@
#ifndef _BLOCKER_H_
#define _BLOCKER_H_
#define MAX_BLOCKERS 64 // Currently needs to be equal to MAX_GUI_OBJECTS in JGE/JGui.h.
#include "MTGAbility.h"
class ManaCost;
class GameObserver;
class MTGAbility;
class UntapBlocker : public MTGAbility {
protected:
ManaCost * manaCost;
int currentPhase;
void init(ManaCost * _cost);
public:
virtual ManaCost * untapManaCost(){return manaCost;};
virtual int unblock(){return 1;};
UntapBlocker(int id, MTGCardInstance * card, ManaCost * _cost);
UntapBlocker(int id, MTGCardInstance * card);
UntapBlocker(int id, MTGCardInstance * card, MTGCardInstance *_target);
UntapBlocker(int id, MTGCardInstance * card, MTGCardInstance *_target, ManaCost * _cost);
~UntapBlocker();
virtual void Update(float dt);
virtual int destroy();
virtual UntapBlocker * clone() const;
};
class UntapBlockers {
protected:
int cursor;
int blockers[MAX_BLOCKERS];
GameObserver * game;
public:
UntapBlockers();
~UntapBlockers();
int Add (UntapBlocker * ability);
int Remove (UntapBlocker * ability);
int init();
UntapBlocker * next();
int rewind();
int isEmpty();
};
#include "ManaCost.h"
#include "GameObserver.h"
#endif

View File

@@ -1,14 +0,0 @@
#ifndef _CONSTRAINTRESOLVER_H_
#define _CONSTRAINTRESOLVER_H_
#include "GameObserver.h"
#include "MTGCardInstance.h"
class ConstraintResolver {
protected:
public:
static int untap(GameObserver * game, MTGCardInstance * card);
};
#endif

View File

@@ -31,6 +31,7 @@ class GameObserver{
int nbPlayers;
int currentPlayerId;
int untap(MTGCardInstance * card);
public:
CombatStep combatStep;

View File

@@ -119,6 +119,38 @@ class ActivatedAbility:public MTGAbility{
MY_EOT = 15,
MY_CLEANUP = 16,
MY_AFTER_EOT = 17,
OPPONENT_BEFORE_BEGIN = 23,
OPPONENT_UNTAP = 24,
OPPONENT_UPKEEP = 25,
OPPONENT_DRAW = 26,
OPPONENT_FIRSTMAIN = 27,
OPPONENT_COMBATBEGIN = 28,
OPPONENT_COMBATATTACKERS = 29,
OPPONENT_COMBATBLOCKERS = 30,
OPPONENT_COMBATDAMAGE = 31,
OPPONENT_COMBATEND = 32,
OPPONENT_SECONDMAIN = 33,
OPPONENT_ENDOFTURN = 34,
OPPONENT_EOT = 35,
OPPONENT_CLEANUP = 36,
OPPONENT_AFTER_EOT = 37,
BEFORE_BEGIN = 43,
UNTAP = 44,
UPKEEP = 45,
DRAW = 46,
FIRSTMAIN = 47,
COMBATBEGIN = 48,
COMBATATTACKERS = 49,
COMBATBLOCKERS = 50,
COMBATDAMAGE = 51,
COMBATEND = 52,
SECONDMAIN = 53,
ENDOFTURN = 54,
EOT = 55,
CLEANUP = 56,
AFTER_EOT = 57,
};
int restrictions;
int needsTapping;

View File

@@ -33,7 +33,6 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
int tapped;
int lifeOrig;
UntapBlockers * untapBlockers;
MTGPlayerCards * belongs_to;
MTGAbility * untapBlockerAbilities[10];
MTGCardInstance * getNextPartner();
@@ -105,7 +104,6 @@ class MTGCardInstance: public CardPrimitive, public MTGCard, public Damageable {
MTGCard * model;
MTGCardInstance();
MTGCardInstance(MTGCard * card, MTGPlayerCards * _belongs_to);
UntapBlockers * getUntapBlockers();
int regenerate();
int triggerRegenerate();
Player * controller();

View File

@@ -1,125 +0,0 @@
#include "../include/config.h"
#include "../include/Blocker.h"
UntapBlocker::UntapBlocker(int id, MTGCardInstance * card):MTGAbility(id, card){
init ( NEW ManaCost());
}
UntapBlocker::UntapBlocker(int id, MTGCardInstance * card, ManaCost * _cost):MTGAbility(id, card){
init(_cost);
}
UntapBlocker::UntapBlocker(int id, MTGCardInstance * card, MTGCardInstance *_target):MTGAbility(id, card,_target){
init ( NEW ManaCost());
}
UntapBlocker::UntapBlocker(int id, MTGCardInstance * card, MTGCardInstance *_target, ManaCost * _cost):MTGAbility(id, card,_target){
init(_cost);
}
UntapBlocker::~UntapBlocker(){
SAFE_DELETE(manaCost);
}
void UntapBlocker::init(ManaCost * _cost){
currentPhase = -1;
manaCost = _cost;
}
UntapBlocker * UntapBlocker::clone() const{
UntapBlocker * a = NEW UntapBlocker(*this);
a->isClone = 1;
return a;
}
//Default behaviour for blockers : they block the card they're attached to
void UntapBlocker::Update(float dt){
game = GameObserver::GetInstance();
int newPhase = game->getCurrentGamePhase();
if (newPhase != currentPhase){
MTGCardInstance * _target;
if (target){
_target = (MTGCardInstance *) target;
}else{
_target = source;
}
_target->getUntapBlockers()->Add(this);
#if defined (WIN32) || defined (LINUX)
char buf[4096];
sprintf(buf, "Adding Blocker to %s \n", _target->getName().c_str());
OutputDebugString(buf);
#endif
}
currentPhase = newPhase;
}
int UntapBlocker::destroy(){
MTGCardInstance * _target;
if (target){
_target = (MTGCardInstance *) target;
}else{
_target = source;
}
_target->getUntapBlockers()->Remove(this);
return 1;
}
UntapBlockers::UntapBlockers(){
init();
}
int UntapBlockers::init(){
cursor = -1;
for (int i=0; i< MAX_BLOCKERS ; i++){
blockers[i] = 0;
}
return 1;
}
int UntapBlockers::Add (UntapBlocker * ability){
game = GameObserver::GetInstance();
int index = game->mLayers->actionLayer()->getIndexOf(ability);
blockers[index] = 1;
return index;
}
int UntapBlockers::Remove (UntapBlocker * ability){
game = GameObserver::GetInstance();
int index = game->mLayers->actionLayer()->getIndexOf(ability);
blockers[index] = 0;
return index;
}
int UntapBlockers::rewind(){
cursor = -1;
return 1;
}
UntapBlocker * UntapBlockers::next(){
cursor++;
game = GameObserver::GetInstance();
while (blockers[cursor] == 0){
cursor ++;
if (cursor == MAX_BLOCKERS){
cursor = -1;
return NULL;
}
}
return (UntapBlocker *) (game->mLayers->actionLayer()->getByIndex(cursor));
}
int UntapBlockers::isEmpty(){
for (int i=0; i< MAX_BLOCKERS ; i++){
if (blockers[i])
return 0;
}
return 1;
}
UntapBlockers::~UntapBlockers(){
}

View File

@@ -19,7 +19,6 @@ int CardDescriptor::init(){
defenser = NULL;
banding = NULL;
//Remove unnecessary pointers
SAFE_DELETE(untapBlockers);
SAFE_DELETE(counters);
SAFE_DELETE(previous);
return result;

View File

@@ -1,42 +0,0 @@
#include "../include/config.h"
#include "../include/ConstraintResolver.h"
int ConstraintResolver::untap(GameObserver * game, MTGCardInstance * card){
if (!card->isUntapping()){
return 0;
}
if (card->has(Constants::DOESNOTUNTAP)) return 0;
int ok = 1;
ManaCost * untapManaCost = NEW ManaCost();
UntapBlockers * blockers = card->getUntapBlockers();
UntapBlocker * blocker;
blockers->rewind();
Player * player = game->currentPlayer;
while ((blocker = blockers->next())){
#if defined (WIN32) || defined (LINUX)
char buf[4096];
sprintf(buf, "next\n");
OutputDebugString(buf);
#endif
untapManaCost->add(blocker->untapManaCost());
}
if (player->getManaPool()->canAfford(untapManaCost)){
blockers->rewind();
while ((blocker = blockers->next())){
if (!blocker->unblock()){
ok = 0;
break;
}
}
}else{
ok = 0;
}
if (ok) {
player->getManaPool()->pay(untapManaCost);
card->attemptUntap();
}
delete untapManaCost;
return ok;
}

View File

@@ -435,7 +435,7 @@ void GameObserver::cardClick (MTGCardInstance * card, Targetable * object){
mLayers->actionLayer()->setMenuObject(object);
}
}else if (card->isTapped() && card->controller() == currentPlayer){
ConstraintResolver::untap(this, card);
untap(card);
}
@@ -443,6 +443,17 @@ void GameObserver::cardClick (MTGCardInstance * card, Targetable * object){
}
int GameObserver::untap(MTGCardInstance * card) {
if (!card->isUntapping()){
return 0;
}
if (card->has(Constants::DOESNOTUNTAP)) return 0;
card->attemptUntap();
return 1;
}
TargetChooser * GameObserver::getCurrentTargetChooser(){
TargetChooser * _tc = mLayers->actionLayer()->getCurrentTargetChooser();
if (_tc) return _tc;

View File

@@ -147,14 +147,18 @@ int AbilityFactory::parseRestriction(string s){
if (s.find("myturnonly") != string::npos) return ActivatedAbility::PLAYER_TURN_ONLY;
if (s.find("assorcery") != string::npos) return ActivatedAbility::AS_SORCERY;
size_t found = s.find("my");
if (found !=string::npos){
for (int i = 0; i < Constants::NB_MTG_PHASES; i++){
string toFind = "my";
toFind.append(Constants::MTGPhaseCodeNames[i]).append("only");
found = s.find(toFind);
if (found != string::npos){
return ActivatedAbility::MY_BEFORE_BEGIN + i;
string types[] = {"my","opponent", ""};
int starts[] = {ActivatedAbility::MY_BEFORE_BEGIN,ActivatedAbility::OPPONENT_BEFORE_BEGIN,ActivatedAbility::BEFORE_BEGIN};
for (int j = 0; j < 3; ++j){
size_t found = s.find(types[j]);
if (found !=string::npos){
for (int i = 0; i < Constants::NB_MTG_PHASES; i++){
string toFind = types[j];
toFind.append(Constants::MTGPhaseCodeNames[i]).append("only");
found = s.find(toFind);
if (found != string::npos){
return starts[j] + i;
}
}
}
}
@@ -1206,12 +1210,8 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
game->addObserver(NEW AConvertLandToCreatures(id, card, "forest"));
break;
}
case 1124: //Mana Vault
case 1124: //Mana Vault (the rest is softcoded!)
{
int output[] = {Constants::MTG_COLOR_ARTIFACT, 3};
game->addObserver(NEW AManaProducer(_id,card,card,NEW ManaCost(output,1)));
int cost[] = {Constants::MTG_COLOR_ARTIFACT, 4};
game->addObserver(NEW AUntapManaBlocker(_id+1, card, NEW ManaCost(cost,1)));
game->addObserver(NEW ARegularLifeModifierAura(_id+2, card, card, Constants::MTG_PHASE_DRAW, -1, 1));
break;
}
@@ -1336,13 +1336,6 @@ void AbilityFactory::addAbilities(int _id, Spell * spell){
}
break;
}
case 1171: //Paralyze
{
int cost[] = {Constants::MTG_COLOR_ARTIFACT, 4};
game->addObserver(NEW AUntapManaBlocker(_id, card,card->target, NEW ManaCost(cost,1)));
card->target->tap();
break;
}
case 1172: //Pestilence
{
game->addObserver(NEW APestilence(_id, card));
@@ -1736,6 +1729,15 @@ int ActivatedAbility::isReactingToClick(MTGCardInstance * card, ManaCost * mana)
if (cPhase != restrictions - MY_BEFORE_BEGIN + Constants::MTG_PHASE_BEFORE_BEGIN) return 0;
}
if (restrictions>= OPPONENT_BEFORE_BEGIN && restrictions <= OPPONENT_AFTER_EOT){
if (player == game->currentPlayer) return 0;
if (cPhase != restrictions - OPPONENT_BEFORE_BEGIN + Constants::MTG_PHASE_BEFORE_BEGIN) return 0;
}
if (restrictions>= BEFORE_BEGIN && restrictions <= AFTER_EOT){
if (cPhase != restrictions - BEFORE_BEGIN + Constants::MTG_PHASE_BEFORE_BEGIN) return 0;
}
if (card == source && source->controller()==player && (!needsTapping || (!source->isTapped() && !source->hasSummoningSickness()))){
if (!cost) return 1;
if (!mana) mana = player->getManaPool();

View File

@@ -81,7 +81,6 @@ void MTGCardInstance::copy(MTGCardInstance * card){
MTGCardInstance::~MTGCardInstance(){
LOG("==Deleting MTGCardInstance==");
SAFE_DELETE(untapBlockers);
SAFE_DELETE(counters);
SAFE_DELETE(previous);
LOG("==Deleting MTGCardInstance Succesfull==");
@@ -102,7 +101,6 @@ void MTGCardInstance::initMTGCI(){
doDamageTest = 1;
belongs_to=NULL;
tapped = 0;
untapBlockers = NULL;
untapping = 0;
summoningSickness = 1;
target = NULL;
@@ -159,11 +157,6 @@ int MTGCardInstance::removeType(int id, int removeAll){
return result;
}
UntapBlockers * MTGCardInstance::getUntapBlockers(){
if (!untapBlockers) untapBlockers = NEW UntapBlockers();
return untapBlockers;
}
int MTGCardInstance::isInPlay(){
GameObserver * game = GameObserver::GetInstance();
for (int i = 0 ; i < 2 ; i++){

View File

@@ -338,7 +338,7 @@ void MTGInPlay::untapAll(){
for (i = 0; i < nb_cards; i ++){
MTGCardInstance * card = cards[i];
card->setUntapping();
if (!card->basicAbilities[Constants::DOESNOTUNTAP] && card->getUntapBlockers()->isEmpty()){
if (!card->basicAbilities[Constants::DOESNOTUNTAP]){
card->attemptUntap();
}
}

View File

@@ -338,10 +338,6 @@
RelativePath=".\src\AIStats.cpp"
>
</File>
<File
RelativePath=".\src\Blocker.cpp"
>
</File>
<File
RelativePath=".\src\CardDescriptor.cpp"
>
@@ -362,10 +358,6 @@
RelativePath=".\src\CardSelector.cpp"
>
</File>
<File
RelativePath=".\src\ConstraintResolver.cpp"
>
</File>
<File
RelativePath=".\src\Counters.cpp"
>
@@ -749,10 +741,6 @@
RelativePath=".\include\AllAbilities.h"
>
</File>
<File
RelativePath=".\include\Blocker.h"
>
</File>
<File
RelativePath=".\include\CardDescriptor.h"
>
@@ -781,10 +769,6 @@
RelativePath=".\include\config.h"
>
</File>
<File
RelativePath=".\include\ConstraintResolver.h"
>
</File>
<File
RelativePath=".\include\Counters.h"
>