[CODE]Pass Phases Automation (no more draw phase mana waste)

All code submission.
almosthumane
Posts: 66
Joined: Wed Mar 31, 2010 3:52 am

[CODE]Pass Phases Automation (no more draw phase mana waste)

Post by almosthumane »

Last Update (Version 3):

Last compile files (Win32-build 2004r): http://www.megaupload.com/?d=WIE10KIM
Changed source files: http://www.megaupload.com/?d=7RKMFWAR

----------------------------------------------------------------

I've been messing with the code to see if I could make the game jump phases that you don't actually want to play unless there is some effect to be interrupted there.

I've found that that could be auto skip phases via in GameObserver.cpp::GameObserver::Update(float dt)
I've add this:

Code: Select all

if ((opponent()->isAI() && !(isInterrupting)) &&
	  (
	     currentGamePhase == Constants::MTG_PHASE_UNTAP
	  || currentGamePhase == Constants::MTG_PHASE_UPKEEP
	  || currentGamePhase == Constants::MTG_PHASE_DRAW
	  || currentGamePhase == Constants::MTG_PHASE_COMBATBEGIN
	  || currentGamePhase == Constants::MTG_PHASE_ENDOFTURN
	  || (currentGamePhase == Constants::MTG_PHASE_CLEANUP && currentPlayer->game->hand->nb_cards < 8)
	  ))
      userRequestNextGamePhase(); //ALMHUM
I've also automate End combat skip if no attaker addind to GameObserver::nextGamePhase() this

Code: Select all

  (...)

//Go directly to end of combat if no attackers
  if (cPhaseOld->id == Constants::MTG_PHASE_COMBATATTACKERS && !(currentPlayer->game->inPlay->getNextAttacker(NULL))){
    phaseRing->forward();
    phaseRing->forward();
	if (!(isInterrupting)) phaseRing->forward(); //Added this line
    }

(...)
in the end of the class and in the test all game functions seem to be ok and it looks like it only does "Left trigger" on the chosen phases if no interrupt is there.
Anyway I would like to know if this interferes in any other game functions that I'm not aware of, or if that is overrides any MTG rules that I'm not aware of.

The changed executable files are here to test are here (version 1 - with above code):
http://www.megaupload.com/?d=WFWLZ7YK

[EDIT ABRA - REnamed topic]
Last edited by almosthumane on Sun Apr 18, 2010 3:12 pm, edited 5 times in total.
almosthumane
Posts: 66
Joined: Wed Mar 31, 2010 3:52 am

Re: Automation Skip Phase Code (no more draw phase mana burn)

Post by almosthumane »

Nobody seems interested but here is the new version of this tweak.

EDIT: REMOVED- Old version - Check new version link on the main post

Now is an option enabled in advanced options.

None: Normal game;
Simples: Passes Untap, Draw, Combat begin and cleanup (only if <7 cards in hand);
Full: Passes above phases and Upkeep, Attackers (only if now creatures in play), Combat End (only if noone blocks) and End phase.

I believe this allow the same gameplay.
From the update rules:
-Untap and Cleanup: Can't play any spell except for interrupt (wish are never override by this in any phase);
-Upkeep and Draw: I don't know any strategy that demands play instants before main phase unless for interrupting;
-Combat Begins: Since in Wagic you can play spells in attacker phase (when you have priority), so it's useless;
-Combat End and End of Turn: As far as know it's only played by the opponent of the active player since it's when you say "your done...for now".
Last edited by almosthumane on Thu Apr 15, 2010 3:43 pm, edited 1 time in total.
flad_nag
Posts: 248
Joined: Mon Aug 31, 2009 7:56 am

Re: Automation Skip Phase Code (no more draw phase mana burn)

Post by flad_nag »

hi almosthumane! great job! will try this and will give you feedback! thanks!

btw, care to post the code changes you made on the affected files? I'd like to do it manually on my SVN.
abrasax
Posts: 976
Joined: Wed Oct 15, 2008 7:46 am
Location: Switzerland

Re: Automation Skip Phase Code (no more draw phase mana burn)

Post by abrasax »

Hi,

Great addition man, it has been requested for long time by a lot of users !

Could you post here a "patch" that we can apply directly to the code source ?

I'm not sure I will have the opportunity to test it before the WE, but if it works as expected I hope this will make it to an official release !

Thanks a lot for your effort, keep-up the good work !

Grüssi

Abra
We need your Help !!!
New to wagic ? Be sure to check the following :

Bug report: Bug reporting
Help us: Add cards & Compiling.
Customize: Themes FAQ, All images thread, Abra's Mediafire folder
almosthumane
Posts: 66
Joined: Wed Mar 31, 2010 3:52 am

Re: Pass Phases Automation Code (no more draw phase mana waste)

Post by almosthumane »

Thank you guys for the feedback! :)
I was beginning to think this was useless.

I've changed the post name because It might be confused with the ability (which is not the case)

The changed source files are here:

EDIT- REMOVED-Old version - Check new version link on the main post
I identify my changes with the comment "//almhum" so it's easy for me to track what I've done wrong.

I was trying to make the automation check as a GameObserver class but I don't understand yet how header files work. If someone could give me a guideline on that it would help a lot.

That and the constructive criticism and ideias about this you might have are obviously welcome.
Last edited by almosthumane on Thu Apr 15, 2010 3:44 pm, edited 1 time in total.
flad_nag
Posts: 248
Joined: Mon Aug 31, 2009 7:56 am

Re: Pass Phases Automation Code (no more draw phase mana waste)

Post by flad_nag »

hi, have you compiled your code for the PSP? I tried, but i get this error.

[The extension jpg has been deactivated and can no longer be displayed.]

almosthumane
Posts: 66
Joined: Wed Mar 31, 2010 3:52 am

Re: Pass Phases Automation Code (no more draw phase mana waste)

Post by almosthumane »

Hi flag_nad,

I have only compiled in debug mode and for in win32 release mode since I don't have a PSP to test the code.
But since I did't used any JGE features it shouldn't provide any incompatibility.

About the error on Winbase.h it can be negleted. You can comment or delete the line #include <Winbase.h> on the top of GameObserver.cpp.
It was there because I was trying to slow the passed phases via "::sleep(500)" but the effect is so "rough" that I've removed that code.

About the && inside of || part i don't get it because there are two logical tests with that feature and they are enclosed by parenthesis:

"|| (currentGamePhase == Constants::MTG_PHASE_CLEANUP && currentPlayer->game->hand->nb_cards < 8)"

"|| (currentGamePhase == Constants::MTG_PHASE_COMBATATTACKERS && (nrCreatures == 0))"

Check if those lines are in your code that way and there should be no problem.
If it doesn't solve disable the "treat warnings as errors" option in your compiler and see if it solves the problem.
almosthumane
Posts: 66
Joined: Wed Mar 31, 2010 3:52 am

Re: Pass Phases Automation Code (no more draw phase mana waste)

Post by almosthumane »

Since when you set "Interrupt my abilities" the game stopt in all need phases I made changes to the auto phase check and now the game stop only in 1st main phase, Attackers, Blockers and 2nd Main Phase unless the is any interrupt (i.e. Damage, Draw, upkeep effect, regeration effect, etc)

Also gatherered all the auto check to GameObserver::Update() so the only code needed to be add in this .cpp is the following:

Code: Select all

int skipLevel = options[Options::ASPHASES].number;
  int nrCreatures = currentPlayer->game->inPlay->countByType("Creature");
    
  if (skipLevel == Constants::ASKIP_COMMON || skipLevel == Constants::ASKIP_FULL) {
    if ((opponent()->isAI() && !(isInterrupting)) &&
	  (
	     currentGamePhase == Constants::MTG_PHASE_UNTAP
	  || currentGamePhase == Constants::MTG_PHASE_DRAW
	  || currentGamePhase == Constants::MTG_PHASE_COMBATBEGIN
	  || currentGamePhase == Constants::MTG_PHASE_COMBATDAMAGE
	  || (currentGamePhase == Constants::MTG_PHASE_CLEANUP && currentPlayer->game->hand->nb_cards < 8)
	  ))
	  userRequestNextGamePhase();
  }
  if (skipLevel == Constants::ASKIP_FULL) {
    if ((opponent()->isAI() && !(isInterrupting)) &&
         currentGamePhase == Constants::MTG_PHASE_UPKEEP
      || currentGamePhase == Constants::MTG_PHASE_ENDOFTURN
      || (currentGamePhase == Constants::MTG_PHASE_COMBATATTACKERS && (nrCreatures == 0)
	  || currentGamePhase == Constants::MTG_PHASE_COMBATEND)
	  )
	  userRequestNextGamePhase();
  }	//almhum
Source and excutable files in 1st post
Daddy32
Posts: 177
Joined: Thu Aug 20, 2009 8:20 am
Location: Slovakia

Re: Pass Phases Automation Code (no more draw phase mana waste)

Post by Daddy32 »

This is long requested feature and will surely be loved if it gets polished enough to be integrated to the official version.

Could you provide a .patch (diff) file of the changes? It would be much simpler to test. Tortoise SVN can generate it easily.
almosthumane
Posts: 66
Joined: Wed Mar 31, 2010 3:52 am

Re: Pass Phases Automation Code (no more draw phase mana waste)

Post by almosthumane »

Hello Daddy32,
Daddy32 wrote:it gets polished enough
At the moment I consider this as a final state. If anyone wants to adress issues I can make repair on that, but for my intention of use there is nothing else I need to change.

If you tell me what could be improved I might be able to adress it.
I would appreciate it, since I had no "after test" comments so far.
Daddy32 wrote:Could you provide a .patch (diff) file of the changes? It would be much simpler to test.
I didn't even new that Tortoise did that! Tortoise SVN is still a new thing to me, but I'll see if I can find that function ASAP and make the diff file.
Locked