Page 4 of 6

Re: Mana Pool

PostPosted: 13 Jun 2009, 14:58
by Incantus
you guys are the ones working on this, but i strongly recommend not going down the path of doing these kinds of hacks to make things easier from a short term perspective. It may work now, but when you get to the point where the hack prevents a lot of other stuff it will be really difficult to fix. Just my 2 cents ( speaking from experience with Incantus)

Re: Mana Pool

PostPosted: 13 Jun 2009, 17:52
by Rob Cashwalker
Incantus wrote:you guys are the ones working on this, but i strongly recommend not going down the path of doing these kinds of hacks to make things easier from a short term perspective. It may work now, but when you get to the point where the hack prevents a lot of other stuff it will be really difficult to fix. Just my 2 cents ( speaking from experience with Incantus)
I'd normally agree, however I just don't think we have the architecture to deal with it properly. I can't figure out a better way to deal with the architecture. The architecture for paying costs only works with cards right now.
Theoretically, this hack will get us by until Rares is really ready with v2. No, it's not an ideal solution, but I don't see how it will prevent anything else from working.

Re: Mana Pool

PostPosted: 14 Jun 2009, 02:24
by Rob Cashwalker
So, it works!

Start off in GameAction.java around line 531:
Code: Select all
    for(int i = 0; i < 7; i++)
    {
      this.drawCard(Constant.Player.Computer);
      this.drawCard(Constant.Player.Human);
    }
    Card mp = new Card();
    mp.setName("Mana Pool");
    mp.addType("Land");
    mp.addIntrinsicKeyword("Indestructible");
    mp.addIntrinsicKeyword("Shroud");
    AllZone.Human_Play.add(mp);

    AllZone.Stack.reset();//this works, it clears the stack of Upkeep effects like Bitterblossom
    AllZone.InputControl.setInput(new Input_Mulligan());
  }//newGame()
Then move onto Input_PayManaCostUtil.java, around line 27:
Code: Select all
    if(manaCost.isNeeded(color))//this line changed
    {
      if (card.getName() == "Mana Pool")
         card.removeExtrinsicKeyword("ManaPool:" +getColor2(color));
      else
         card.tap();
     
      manaCost.subtractMana(color);
And around line 63:
Code: Select all
    for(int i = 0; i < check.size(); i++)
    {
      if(check.get(i).toString().startsWith(manaString) || check.get(i).toString().startsWith("ManaPool:"))
      {
        //gets G from "tap: add G"
        letter = check.get(i).toString().charAt(manaString.length());
And add this near the end:
Code: Select all
  public static String getColor2(String color)
  {
     Map<String, String> m = new HashMap<String, String>();
     m.put(Constant.Color.Green, "G");
     m.put(Constant.Color.Red, "R");
     m.put(Constant.Color.Blue, "U");
     m.put(Constant.Color.Black, "B");
     m.put(Constant.Color.White, "W");
     m.put(Constant.Color.Colorless, "1");
      
     Object o = m.get(color);
    
     return o.toString();
  }
And now presenting our very first mana spell, Seething Song (in CardFactory):
Code: Select all
    if (cardName.equals("Seething Song"))
    {
       final SpellAbility spell = new Spell(card)
       {
          private static final long serialVersionUID = 113811381138L;
          
          public void resolve()
          {
             CardList list = new CardList(AllZone.getZone(Constant.Zone.Play, Constant.Player.Human).getCards());
             list = list.getName("Mana Pool");
             Card mp = list.getCard(0);
             mp.addExtrinsicKeyword("ManaPool:R");
             mp.addExtrinsicKeyword("ManaPool:R");
             mp.addExtrinsicKeyword("ManaPool:R");
             mp.addExtrinsicKeyword("ManaPool:R");
             mp.addExtrinsicKeyword("ManaPool:R");
          }
          public boolean canPlayAI()
          {
             return false;
          }
       };
       
        spell.setStackDescription("Adds R R R R R to your mana pool");
       card.clearSpellAbility();
        card.addSpellAbility(spell);

        return card;
    }
Cards.txt:
Code: Select all
Seething Song
2 R
Instant
Add R R R R R to your mana pool.
Here's a card image for the Mana Pool:
mana_pool.jpg
mana_pool.jpg (4.85 KiB) Viewed 2878 times


Still to do:
Keyword handler for existing "tap: add _" keyworded cards.
Figure out how to put the card in its own panel. Any takers?

Re: Mana Pool

PostPosted: 14 Jun 2009, 02:34
by DennisBergkamp
Wow, awesome stuff Rob =D>
I'll merge this in and try it out for myself as soon as I get the chance :D

Re: Mana Pool

PostPosted: 15 Jun 2009, 19:30
by mtgrares
Incantus wrote:you guys are the ones working on this, but i strongly recommend not going down the path of doing these kinds of hacks to make things easier from a short term perspective.
Well with MTG Forge we have to hack more, lol. MTG Forge hasn't gone through a major rules rewrite like Incantus has.

Re: Mana Pool

PostPosted: 16 Jun 2009, 02:48
by DennisBergkamp
So Rob, I've added your code and it seems to be working just fine :)
For kicks, I added Dark Ritual and was able to play Hypnotic Specter on turn 1 =D>

Re: Mana Pool

PostPosted: 16 Jun 2009, 03:23
by Rob Cashwalker
that's great! when I was testing, I forgot that Seething Song cost 2 R... I had it at R. So I played some 5 mana burn spell on turn 1!

Re: Mana Pool

PostPosted: 16 Jun 2009, 05:33
by DennisBergkamp
Wow, that's like a Red Lotus :D

Not sure if I should add it, but I've also coded Sol Ring based on the same principle (this means the AI won't be able to use it, and you have to add the 2 mana to the manapool first, then cast a spell and draw the 2 mana from the manapool).

Anyway, very impressive stuff Rob :) Even though it's all pretty hacky when making the mana pool a card, I'd say this is the very best that can be done for now.

Re: Mana Pool

PostPosted: 16 Jun 2009, 06:09
by Mr.Chaos
Mana pool? Mana sources that give more than 1 mana?
...
YYYYYYYYYYYYYYYEEEEEEEEESSSSSS!!!!!!!
:D =D>

Now then, time for the 3 big bad mana makers:
Gaea's Cradle (any creature deck that needs lots of mana)
Tolarian Academy (Memnarch is smiling now)
Serra's Sanctum (Sigil of the Empty Throne is begging for this one)

Ok, that's me getting ahead of things again but Dark Ritual, Seething Song and Sol Ring got me all fired up!
Way to go guys!

Re: Mana Pool

PostPosted: 16 Jun 2009, 06:22
by DennisBergkamp
Those are all possible now (in fact, very easy :mrgreen: ).
But, I think the current main issues are:

1. Having to manually select the color of mana to use from a list that is currently in the manapool (Especially with cards like Gaea's Cradle, it would be awesome if it would just use as much mana as needed with a single click, definitely if there's mana of only one color in the manapool).
2. The AI doesn't have a manapool.
3. Can't seem to specify what color mana from a "multi-mana" source to add to the manapool (for instance Savannah will just add W to the manapool).

Re: Mana Pool

PostPosted: 16 Jun 2009, 07:47
by Mr.Chaos
DennisBergkamp wrote:Those are all possible now (in fact, very easy :mrgreen: ).
But, I think the current main issues are:

1. Having to manually select the color of mana to use from a list that is currently in the manapool (Especially with cards like Gaea's Cradle, it would be awesome if it would just use as much mana as needed with a single click, definitely if there's mana of only one color in the manapool).
2. The AI doesn't have a manapool.
3. Can't seem to specify what color mana from a "multi-mana" source to add to the manapool (for instance Savannah will just add W to the manapool).
Easy eh? Ok, bring em on then. :wink:
1 So, if I have a cradle and say, 20 creatures in play and tap the cradle, I have to manually select 20 green mana?
Not ideal but I will take it over not having the Cradle. :roll:
2 Well, that is not our problem is it. :lol: Compy has too many dirty advantages as it is anyway so just give us the mana pool, see how we like it and then go improve and/or make it work for compy.
3 If I understand this, it means that with a mana pool, we can no longer select the color for mana from dual mana sorces? That is a let down.

Still, if it is even half doable, implement them big bad mana making lands and let's see how quick we can crash the game using Mycoloth and Rhys the Redeemed. :mrgreen:
Seriously: would using Gaea's Cradle and the like mean the game would slow down quicker?
I mean, just add the cradle and the academy to my Master-Memnarch deck. You have heaps of artifacts and creatures so both give piles of mana which you use to create and control more artifacts.
Would the slow down be actually worse than with saproling tokens? Because there are 2 multi mana sources at work, both based on a total of items in play, just like Rhys does with tokens and we all know that slows things down something serious!

Re: Mana Pool

PostPosted: 16 Jun 2009, 11:07
by Hellfish
Awesomeness! Brings me *that* much closer to dusting off my old Shandalar UBControl deck for the forge =P~

Re: Mana Pool

PostPosted: 16 Jun 2009, 15:34
by DennisBergkamp
3 If I understand this, it means that with a mana pool, we can no longer select the color for mana from dual mana sorces? That is a let down.
I mean, you still can just pay for the spell regularly like it's always been done in MTGForge (i.e. just play the spell, and tap the dual land / BoP / Darksteel Ingot /... for whatever color of mana). However, you don't have this flexibility with the manapool, and currently that's probably not even an issue, plus it's probably an easy fix.

I don't think slowdowns would be an issue. In the case of Rhys the Redeemed, we add more tokens based on tokens, these tokens added are card objects and have to be kept track of.
In the case of adding mana, all we're doing is adding keywords to the manapool.

Then again, tapping a Gaea's Cradle might cause a bit of a slowdown if there's a lot of creatures in play, since we would have to calculate how much mana to add (kind of like using Rhys' ability when there's an Essence Warden in play, the Essence Warden does definitely slow things down).

Re: Mana Pool

PostPosted: 16 Jun 2009, 16:00
by Mr.Chaos
Ah, thanks for explaining that, Dennis.
I am looking forward to playtest those lands. 8)

Re: Mana Pool

PostPosted: 16 Jun 2009, 20:32
by Rob Cashwalker
I think what Dennis means about the single color from Savannah, is that if you tap the Savannah for mana before actually needing it, it will prompt you to select the color. That color is then added to the pool. You can't change it later. I sent Dennis my keyword handler to make "tap: add _" abilities work for BOTH adding to the pool and selection for mana cost payments. You don't HAVE to tap the land before playing the spell, but you can if you want.

As written so far, there is no mana burn... but of course it will empty. Maybe at some point an option can be added to play by old rules....

In the process of making this work Dennis actually fixed at least one of the "Pay Mana Cost: 0" bugs, where tap abilities with no cost would require clicking on a land even without being tapped for mana. In my first draft of the keyword handler, I tried to play the ability on my first turn land drop, and without any other land in play, I couldn't add the mana to the pool, since it wanted me to pay zero....

AI for the mana pool will probably be very selective.... Like Dark Ritual.. sure. But AI for single mana use, not likely. Ravnica bounce lands (producing WU for example) might be possible in the future, but would require some explicit coding, not in the generic keyword handler.

BTW, the code for adding 2 mana must include two instances of ManaPool:1 . No shortcuts.

Counting up creatures is quick, and looping through adding the keywords should be quick. Don't see any reason Gaea's Cradle would be a problem. Essence Warden is a problem because of state based effects.
AI for gaea's cradle is a possibility too. Basically any multi-mana generation can be decided based on if the computer has large spells that can be played.