- almosthumane's code for Mulligan
- added better wording for menu of "move" abilities (with help from Zthfox)
- updated Zethfox's card addon
This commit is contained in:
wagic.the.homebrew@gmail.com
2010-07-30 12:14:10 +00:00
parent d92643f5d6
commit b0d81dc8c1
3 changed files with 7214 additions and 6766 deletions
File diff suppressed because it is too large Load Diff
+87 -50
View File
@@ -475,6 +475,59 @@ class AACopier:public ActivatedAbility{
}
};
class AAMover:public ActivatedAbility{
public:
string destination;
AAMover(int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest, ManaCost * _cost=NULL, int doTap=0):ActivatedAbility(_id,_source,_cost,0,doTap),destination(dest){
if (_target) target = _target;
}
MTGGameZone * destinationZone(){
MTGCardInstance * _target = (MTGCardInstance *) target;
return MTGGameZone::stringToZone(destination, source,_target);
}
int resolve(){
MTGCardInstance * _target = (MTGCardInstance *) target;
if(target){
Player* p = _target->controller();
if (p){
GameObserver * g = GameObserver::GetInstance();
MTGGameZone * fromZone = _target->getCurrentZone();
MTGGameZone * destZone = destinationZone();
//inplay is a special zone !
for (int i=0; i < 2; i++){
if (destZone == g->players[i]->game->inPlay && fromZone != g->players[i]->game->inPlay && fromZone != g->players[i]->opponent()->game->inPlay){
MTGCardInstance * copy = g->players[i]->game->putInZone(_target, fromZone, g->players[i]->game->temp);
Spell * spell = NEW Spell(copy);
spell->resolve();
delete spell;
return 1;
}
}
p->game->putInZone(_target,fromZone,destZone);
return 1;
}
}
return 0;
}
const char * getMenuText(){
string result = "Move to ";
result.append(destination);
return (result.c_str());
}
AAMover * clone() const{
AAMover * a = NEW AAMover(*this);
a->isClone = 1;
return a;
}
};
/* Generic TargetAbility */
class GenericTargetAbility:public TargetAbility{
@@ -490,6 +543,40 @@ public:
counters = 0;
}
const char * getMenuText(){
if (!ability) return "Error";
MTGAbility * core = AbilityFactory::getCoreAbility(ability);
if (AAMover * move = dynamic_cast<AAMover *>(core)) {
MTGGameZone * dest = move->destinationZone();
GameObserver * g = GameObserver::GetInstance();
for (int i=0; i < 2; i++){
if (dest == g->players[i]->game->hand && tc->targetsZone(g->players[i]->game->inPlay)){
return "Bounce";
}else if (dest == g->players[i]->game->hand && tc->targetsZone(g->players[i]->game->graveyard)){
return "Reclaim";
}else if (dest == g->players[i]->game->graveyard && tc->targetsZone(g->players[i]->game->inPlay)){
return "Sacrifice";
}else if (dest == g->players[i]->game->library && tc->targetsZone(g->players[i]->game->graveyard)){
return "Recycle";
}else if (dest == g->players[i]->game->library){
return "Put in Library";
}else if (dest == g->players[i]->game->graveyard && tc->targetsZone(g->players[i]->game->hand)){
return "Discard";
}else if (dest == g->players[i]->game->exile){
return "Exile";
}else if (tc->targetsZone(g->players[i]->game->library)){
return "Fetch";
}
}
}
return ability->getMenuText();
}
~GenericTargetAbility(){
SAFE_DELETE(ability);
}
@@ -775,56 +862,6 @@ public:
};
class AAMover:public ActivatedAbility{
public:
string destination;
AAMover(int _id, MTGCardInstance * _source, MTGCardInstance * _target, string dest, ManaCost * _cost=NULL, int doTap=0):ActivatedAbility(_id,_source,_cost,0,doTap),destination(dest){
if (_target) target = _target;
}
MTGGameZone * destinationZone(){
MTGCardInstance * _target = (MTGCardInstance *) target;
return MTGGameZone::stringToZone(destination, source,_target);
}
int resolve(){
MTGCardInstance * _target = (MTGCardInstance *) target;
if(target){
Player* p = _target->controller();
if (p){
GameObserver * g = GameObserver::GetInstance();
MTGGameZone * fromZone = _target->getCurrentZone();
MTGGameZone * destZone = destinationZone();
//inplay is a special zone !
for (int i=0; i < 2; i++){
if (destZone == g->players[i]->game->inPlay && fromZone != g->players[i]->game->inPlay && fromZone != g->players[i]->opponent()->game->inPlay){
MTGCardInstance * copy = g->players[i]->game->putInZone(_target, fromZone, g->players[i]->game->temp);
Spell * spell = NEW Spell(copy);
spell->resolve();
delete spell;
return 1;
}
}
p->game->putInZone(_target,fromZone,destZone);
return 1;
}
}
return 0;
}
const char * getMenuText(){
return "Move";
}
AAMover * clone() const{
AAMover * a = NEW AAMover(*this);
a->isClone = 1;
return a;
}
};
class AADestroyer:public ActivatedAbility{
public:
+48 -14
View File
@@ -80,9 +80,7 @@ void GameStateDuel::Start()
mGamePhase = DUEL_STATE_CHOOSE_DECK1;
credits = NEW Credits();
menu = NEW SimpleMenu(DUEL_MENU_GAME_MENU, this, Constants::MENU_FONT, SCREEN_WIDTH/2-100, 25);
menu->Add(12,"Back to main menu");
menu->Add(13, "Cancel");
menu = NULL;
int decksneeded = 0;
@@ -340,16 +338,37 @@ void GameStateDuel::Update(float dt)
Start();
}
}
if (mEngine->GetButtonClick(JGE_BTN_MENU))
if (mEngine->GetButtonClick(JGE_BTN_MENU)) {
if (!menu) {
menu = NEW SimpleMenu(DUEL_MENU_GAME_MENU, this, Constants::MENU_FONT, SCREEN_WIDTH/2-100, 25);
int cardsinhand = game->players[0]->game->hand->nb_cards;
//almosthumane - mulligan
if ((game->turn < 1) && (cardsinhand != 0)
&& game->currentGamePhase == Constants::MTG_PHASE_FIRSTMAIN
&& game->players[0]->game->inPlay->nb_cards == 0
&& game->players[0]->game->graveyard->nb_cards == 0
&& game->players[0]->game->exile->nb_cards == 0) //1st Play Check
//IF there was no play at the moment automatically mulligan
{
menu->Add(14,"Mulligan");
}
//END almosthumane - mulligan
menu->Add(12,"Back to main menu");
menu->Add(13, "Cancel");
}
mGamePhase = DUEL_STATE_MENU;
}
break;
case DUEL_STATE_MENU:
menu->Update(dt);
break;
case DUEL_STATE_CANCEL:
menu->Update(dt);
if (menu->closed)
mGamePhase = DUEL_STATE_PLAY;
if (menu->closed) {
mGamePhase = DUEL_STATE_PLAY;
SAFE_DELETE(menu);
}
break;
case DUEL_STATE_BACK_TO_MAIN_MENU:
if(menu){
@@ -450,8 +469,7 @@ void GameStateDuel::Render()
}
}
void GameStateDuel::ButtonPressed(int controllerId, int controlId)
{
void GameStateDuel::ButtonPressed(int controllerId, int controlId) {
switch (controllerId){
case DUEL_MENU_CHOOSE_OPPONENT:
{
@@ -463,11 +481,10 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
break;
default:
loadPlayer(1,controlId,1);
OpponentsDeckid=controlId;
OpponentsDeckid=controlId;
opponentMenu->Close();
mGamePhase = DUEL_STATE_CHOOSE_DECK2_TO_PLAY;
break;
}
break;
}
@@ -494,14 +511,31 @@ void GameStateDuel::ButtonPressed(int controllerId, int controlId)
{
case 12:
menu->Close();
mGamePhase = DUEL_STATE_BACK_TO_MAIN_MENU;
menu->Close();
mGamePhase = DUEL_STATE_BACK_TO_MAIN_MENU;
break;
case 13:
menu->Close();
menu->Close();
mGamePhase = DUEL_STATE_CANCEL;
break;
}
case 14:
//almosthumane - mulligan
{
int cardsinhand = game->players[0]->game->hand->nb_cards;
for (int i = 0 ; i < cardsinhand; i ++) //Discard hand
game->currentPlayer->game->putInZone(game->currentPlayer->game->hand->cards[0],game->currentPlayer->game->hand ,game->currentPlayer->game->library);
game->currentPlayer->game->library->shuffle(); //Shuffle
for (int i = 0; i < (cardsinhand-1); i ++) game->draw(); //Draw hand with 1 less card penalty //almhum
menu->Close();
mGamePhase = DUEL_STATE_CANCEL;
break;
}
//END almosthumane - mulligan
}
}
}
}