[CODE] Updated Mulligan

All code submission.
Post Reply
zhdarkstar
Posts: 16
Joined: Mon Jun 29, 2009 7:13 pm

[CODE] Updated Mulligan

Post 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.
carslove54
Posts: 279
Joined: Thu Mar 18, 2010 8:58 pm

Re: [CODE] Updated Mulligan

Post by carslove54 »

How can i use it?
zhdarkstar
Posts: 16
Joined: Mon Jun 29, 2009 7:13 pm

Re: [CODE] Updated Mulligan

Post 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!
KF1
Posts: 1952
Joined: Tue Apr 06, 2010 7:04 pm

Re: [CODE] Updated Mulligan

Post by KF1 »

zhdarkstar,

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

Thank you for doing this.
Zethfox
Posts: 3029
Joined: Thu Jun 10, 2010 11:28 pm

Re: [CODE] Updated Mulligan

Post 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.
zhdarkstar
Posts: 16
Joined: Mon Jun 29, 2009 7:13 pm

Re: [CODE] Updated Mulligan

Post 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.
jwilkes99999
Posts: 151
Joined: Sun Jan 16, 2011 8:58 pm

Re: [CODE] Updated Mulligan

Post 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.
wagicmagic28
Posts: 275
Joined: Mon Aug 19, 2013 3:51 pm

Re: [CODE] Updated Mulligan

Post 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!
Tacoghandi
Posts: 1197
Joined: Thu Apr 28, 2011 11:34 pm

Re: [CODE] Updated Mulligan

Post 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
!!Check out My Created Sets and other Stuff!!

viewtopic.php?f=22&t=3380
Darth Agnon
Posts: 124
Joined: Mon Sep 22, 2014 8:00 pm
Location: United Kingdom
Contact:

Re: [CODE] Updated Mulligan

Post by Darth Agnon »

This looks interesting... Wagic 0.2?
Image
Like Wagic? Check out my custom themes, etc. at viewtopic.php?f=9&t=66181
Wololo's article: http://wololo.net/2016/07/14/new-wagic- ... rth-agnon/
Post Reply