It is currently 09 Jul 2025, 03:38
   
Text Size

Mana Pool

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Re: Mana Pool

Postby Incantus » 13 Jun 2009, 14:58

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)
Incantus
DEVELOPER
 
Posts: 267
Joined: 29 May 2008, 15:53
Has thanked: 0 time
Been thanked: 3 times

Re: Mana Pool

Postby Rob Cashwalker » 13 Jun 2009, 17:52

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.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Mana Pool

Postby Rob Cashwalker » 14 Jun 2009, 02:24

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 6145 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?
Last edited by Rob Cashwalker on 14 Jun 2009, 02:42, edited 2 times in total.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Mana Pool

Postby DennisBergkamp » 14 Jun 2009, 02:34

Wow, awesome stuff Rob =D>
I'll merge this in and try it out for myself as soon as I get the chance :D
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby mtgrares » 15 Jun 2009, 19:30

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.
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times

Re: Mana Pool

Postby DennisBergkamp » 16 Jun 2009, 02:48

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>
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby Rob Cashwalker » 16 Jun 2009, 03:23

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!
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Mana Pool

Postby DennisBergkamp » 16 Jun 2009, 05:33

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.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby Mr.Chaos » 16 Jun 2009, 06:09

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!
](*,) = coder at work, according to a coder.It does explain some of the bugs. :wink:
Mr.Chaos
Tester
 
Posts: 625
Joined: 06 Sep 2008, 08:15
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby DennisBergkamp » 16 Jun 2009, 06:22

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).
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby Mr.Chaos » 16 Jun 2009, 07:47

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!
](*,) = coder at work, according to a coder.It does explain some of the bugs. :wink:
Mr.Chaos
Tester
 
Posts: 625
Joined: 06 Sep 2008, 08:15
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby Hellfish » 16 Jun 2009, 11:07

Awesomeness! Brings me *that* much closer to dusting off my old Shandalar UBControl deck for the forge =P~
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times

Re: Mana Pool

Postby DennisBergkamp » 16 Jun 2009, 15:34

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).
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby Mr.Chaos » 16 Jun 2009, 16:00

Ah, thanks for explaining that, Dennis.
I am looking forward to playtest those lands. 8)
](*,) = coder at work, according to a coder.It does explain some of the bugs. :wink:
Mr.Chaos
Tester
 
Posts: 625
Joined: 06 Sep 2008, 08:15
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby Rob Cashwalker » 16 Jun 2009, 20:32

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.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

PreviousNext

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 38 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 38 users online :: 0 registered, 0 hidden and 38 guests (based on users active over the past 10 minutes)
Most users ever online was 5050 on 26 Jun 2025, 06:02

Users browsing this forum: No registered users and 38 guests

Login Form