Page 1 of 1

[CODE] Updated Mulligan

Posted: Mon Nov 26, 2012 5:20 am
by zhdarkstar
I tweaked the mulligan code developed by almosthumane to accommodate some issues I was having with the process. You can now take a mulligan during either turn 1 first main or turn 2 upkeep. It also uses the Duel of the Planeswalkers practice of first mulligan free.

GameObserver.cpp

Code: Select all

#include "Player.h"
GameStateDuel.cpp

Code: Select all

#include "Player.h"

ResetMullPen(); //Inserted right after game->startGame

if ((cardsinhand != 0) && ((game->turn < 2 && game->currentGamePhase == MTG_PHASE_FIRSTMAIN) || (game->turn < 2 && game->currentGamePhase == MTG_PHASE_UPKEEP)) && game->currentPlayer->game->inPlay->nb_cards == 0 && game->currentPlayer->game->graveyard->nb_cards == 0	&& game->currentPlayer->game->exile->nb_cards == 0 && game->currentlyActing() == (Player*)game->currentPlayer) //Modified 1st Play Check
Player.cpp

Code: Select all

int MullPen = 0;

void ResetMullPen()
{
	for (int n = 7; n != 7 - MullPen; MullPen--); //Simple loop to bring MullPen back to 0
}

Changes to takeMulligan after Shuffle
for (int i = 0; i < (7 - MullPen); i++)
        game->drawFromLibrary();
         //Draw hand with less cards according to number of mulligans //almhum
MullPen++; //Increase Mulligan Penalty counter
Player.h

Code: Select all

extern int MullPen;
void ResetMullPen();
Here are the files I edited: http://www.mediafire.com/?o5i3q3g6vj1dr26

I know that coding classes is better practice than global extern variables but I was going more for proof of concept than efficiency, having not coded for a decade. I've played through multiple games in a row taking various degrees of mulligans in each game and I haven't had an issue yet.

Ideally I'd like to change the mulligan process to a prompt before turn 1 regardless of who goes first, but my coding skills are rusty and I haven't figured out what functions you use for popups yet. I'll give the code another look tomorrow but I'm glad for what I accomplished today.

Re: [CODE] Updated Mulligan

Posted: Mon Nov 26, 2012 7:26 pm
by carslove54
How can i use it?

Re: [CODE] Updated Mulligan

Posted: Tue Nov 27, 2012 4:50 am
by zhdarkstar
carslove54 wrote:How can i use it?
1) Download the latest version of the source from the SVN.
2) Insert the code into the files listed in the OP
3) Compile for your platform http://code.google.com/p/wagic/wiki/Compiling
4) ????
5) Profit!

Re: [CODE] Updated Mulligan

Posted: Thu Nov 29, 2012 10:44 pm
by KF1
zhdarkstar,

I'll give this a try and report any problems I run into.

Thank you for doing this.

Re: [CODE] Updated Mulligan

Posted: Thu Nov 29, 2012 11:26 pm
by Zethfox
im working on adding a pregame phase, which would make mulligan more legal than in current.
and teaching ai when it should mulligan. so that it is not left with a hand full of spells and no lands. or vice versa.

Re: [CODE] Updated Mulligan

Posted: Fri Nov 30, 2012 7:32 pm
by zhdarkstar
I look forward to the updated phases when you finish your work. I looked at my code as a temporary fix until a better and more robust solution is presented.

If no one has encountered any problems with this so far, would it be possible to add it to the SVN for the time being? I've put it through hundreds of games over the past few days without a single issue.

Re: [CODE] Updated Mulligan

Posted: Fri Dec 28, 2012 6:38 pm
by jwilkes99999
If we're modifying mulligans before the next release I'd love to see friendly mulligans implemented. Either period or as an option in the menu.

Re: [CODE] Updated Mulligan

Posted: Sun Aug 25, 2013 10:15 am
by wagicmagic28
I don't know nothing about SVN and all that Geeky Programming MIT bs. Can someone please compile this Alien like stuff to me and the community and upload it as it were a Wagic Update. I don't like tampering around with this. Can someone please upload it already Recompiled where all it has to be done from there is putting it in the Main Directory of Wagic? Or how about incorporating it into a new update of Wagic + M14 as I have already made a request in a Thread about that!

Re: [CODE] Updated Mulligan

Posted: Thu Oct 31, 2013 4:27 pm
by Tacoghandi
For those of you looking to use this the GameStateDuel.cpp has old parameters. Here is the updated ones so that you can still compile correctly.

Code: Select all

if ((cardsinhand != 0) && ((game->turn < 2 && game->getCurrentGamePhase() == MTG_PHASE_FIRSTMAIN) || (game->turn < 2 && game->getCurrentGamePhase() == MTG_PHASE_UPKEEP))
     && game->currentPlayer->game->inPlay->nb_cards == 0 && game->currentPlayer->game->graveyard->nb_cards == 0
     && game->currentPlayer->game->exile->nb_cards == 0 && game->currentlyActing() == (Player*)game->currentPlayer) //Modified 1st Play Check

Re: [CODE] Updated Mulligan

Posted: Fri Oct 17, 2014 1:07 pm
by Darth Agnon
This looks interesting... Wagic 0.2?