Erwan
- Added Momir Basic mode :)
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#include "../include/MTGRules.h"
|
||||
|
||||
MTGPutInPlayRule::MTGPutInPlayRule(int _id):MTGAbility(_id, NULL){
|
||||
|
||||
aType=MTGAbility::PUT_INTO_PLAY;
|
||||
}
|
||||
|
||||
int MTGPutInPlayRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){
|
||||
@@ -78,6 +78,7 @@ int MTGPutInPlayRule::testDestroy(){
|
||||
}
|
||||
|
||||
MTGAttackRule::MTGAttackRule(int _id):MTGAbility(_id,NULL){
|
||||
aType=MTGAbility::MTG_ATTACK_RULE;
|
||||
}
|
||||
|
||||
int MTGAttackRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){
|
||||
@@ -102,6 +103,7 @@ int MTGAttackRule::testDestroy(){
|
||||
|
||||
|
||||
MTGBlockRule::MTGBlockRule(int _id):MTGAbility(_id,NULL){
|
||||
aType=MTGAbility::MTG_BLOCK_RULE;
|
||||
}
|
||||
|
||||
int MTGBlockRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){
|
||||
@@ -134,3 +136,74 @@ int MTGBlockRule::reactToClick(MTGCardInstance * card){
|
||||
int MTGBlockRule::testDestroy(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// * Momir
|
||||
//
|
||||
|
||||
MTGMomirRule::MTGMomirRule(int _id, MTGAllCards * _collection):MTGAbility(_id, NULL){
|
||||
collection = _collection;
|
||||
alreadyplayed = 0;
|
||||
aType=MTGAbility::MOMIR;
|
||||
}
|
||||
|
||||
int MTGMomirRule::isReactingToClick(MTGCardInstance * card, ManaCost * mana){
|
||||
if (alreadyplayed) return 0;
|
||||
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 (player == currentPlayer && !game->isInterrupting && (game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN || game->currentGamePhase == Constants::MTG_PHASE_SECONDMAIN)){
|
||||
LOG("CANPUTINPLAY- correct time to play\n");
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int MTGMomirRule::reactToClick(MTGCardInstance * card_to_discard){
|
||||
if (!isReactingToClick(card_to_discard)) return 0;
|
||||
Player * player = game->currentlyActing();
|
||||
ManaCost * cost = player->getManaPool();
|
||||
int converted = cost->getConvertedCost();
|
||||
player->getManaPool()->pay(cost);
|
||||
player->game->putInZone(card_to_discard, player->game->hand, player->game->graveyard);
|
||||
MTGCardInstance * card = genRandomCreature(converted); //TODO code this function
|
||||
player->game->stack->addCard(card);
|
||||
Spell * spell = NEW Spell(card);
|
||||
spell->resolve();
|
||||
spell->source->isToken = 1;
|
||||
delete spell;
|
||||
alreadyplayed = 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
MTGCardInstance * MTGMomirRule::genRandomCreature(int convertedCost){
|
||||
Player * p = game->currentlyActing();
|
||||
int total_cards = collection->totalCards();
|
||||
int start = (rand() % total_cards);
|
||||
int id2 = start;
|
||||
while (id2 < total_cards){
|
||||
MTGCard * card = collection->collection[id2];
|
||||
if (card->isACreature() && card->getManaCost()->getConvertedCost() == convertedCost){
|
||||
return NEW MTGCardInstance(card,p->game);
|
||||
}
|
||||
id2++;
|
||||
if (id2 == start) return NULL;
|
||||
if (id2 == total_cards) id2 = 0;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//The Momir rule is never destroyed
|
||||
int MTGMomirRule::testDestroy(){
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MTGMomirRule::Update(float dt){
|
||||
if (newPhase != currentPhase && newPhase == Constants::MTG_PHASE_UNTAP){
|
||||
alreadyplayed = 0;
|
||||
}
|
||||
MTGAbility::Update(dt);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user