It is currently 23 Apr 2024, 23:38
   
Text Size

Mana Pool

Post MTG Forge Related Programming Questions Here

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

Mana Pool

Postby zerker2000 » 28 May 2009, 14:19

This whole post might be just me being lazy about searching the forums 8-[ , but everywhere I look there's people complaining about forge not supporting multi-mana abilities(e.g. {T}: "Add {G} {G} {G} to your mana pool"-- Elvish Abberation :-s how do you autocard?). To this, the developers are replying that forge doesn't support a mana pool. On that topic, I have a question and a roundabout solution:

First of all, can someone please tell me (and/or link to a previous post) why you can't just have the mana subtracted from the pool if it can be, and leave the ability alone if it can't, making the amount part of the script that ckecks whether the mana produced by a source can be used to (help) cast a spell?

Second of all, can't you just make a new token type "mana", and have multi-mana generators make those:
Code: Select all
    "{R}"
    R
    Mana Red
    "{R}" is indestructible
    Sacrifice "{R}": add R
    At end of turn, sacrifice "{R}". It deals 1 damage to you.
... make up a better name, and make the same for other colors. So, for i.e.
Code: Select all
Dormant Volcano
Land
Dormant Volcano comes into play tapped.
When Dormant Volcano comes into play, return an untapped Mountain you control to its owner's hand.
tap: add 1. Put a red "{R}" mana token into play.
EDIT: hmm, so autocarding works where I don't want it, and doesn't where I do, is that it? :(
Though I am sure not everything I've described is possible to put in without tweaking some code, I do not see major problems with anything. In fact, you could go a step further and replace all previous mana abilites with something like "addtoken R", move the "mana tokens" into a third row below your lands, give them {W} {U} {B} {R} {G} {1} for pictures, and you'll basically have a mana pool on which you can click to pay abilities. Of course, in that case there would have to be an option to turn this off for people used to playing with...

I am getting way ahead of myself. However, this is a huge essay of a first post(comments don't count), and I am expecting it to stir activity due to its topic. So, <clears throat>

Questions? Comments? Things I have overlooked? Tout le monde répondez s'il vous plaît! <french moustache smiley>
Last edited by zerker2000 on 28 May 2009, 16:50, edited 3 times in total.
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.


--Eladamri, the Seed of Freyalise
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby Arcanis222 » 28 May 2009, 14:44

Hmm well. Let's take another look at a similar engine. Let's look at wagic.
Instead of you trying to cast a spell, and then the engine checking the mana, You tap lands at your own pace, and it's added to a visible mana pool on the side of the screen, symbolised by colours, E.G you tap a Plateau, It asks You White Or Red, Then a White Mana Symbol, Or a red mana symbol, Based on your decision is added to your pool. Personally this would be the best thing to do, Why? Because we could implement X cost Spells, Kicker Cost, And other Casting Shenanigans.
Arcanis222
 
Posts: 61
Joined: 26 May 2009, 20:48
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby zerker2000 » 28 May 2009, 14:55

That might be best, however the developers(for their reasons) don't have that as of yet. What I am suggesting is a workaround that won't require a lot of coding to work but is functionally the same. As for X costs, even without interface changes that could be implemented by just tapping enough lands to pay X and then clicking OK.
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.


--Eladamri, the Seed of Freyalise
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby GandoTheBard » 28 May 2009, 16:17

AFAIK the program does not REALLY support sacrifice yet. Which makes this idea somewhat moot. Also it seems a heinous hack but innovative so props on that. If Sacrifice were to be implemented there are a lot of cards that could be implemented even without the hack.
visit my personal homepage here: http://outofthebrokensky.com

Listen to my podcast with famed AJ_Impy "Freed from the Real" on http://puremtgo.com
User avatar
GandoTheBard
Tester
 
Posts: 1043
Joined: 06 Sep 2008, 18:43
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby zerker2000 » 28 May 2009, 16:57

That's fixable:
Code: Select all
        "{R}"
        R
        Mana Red
        "{R}" is indestructible
        Tap: add R
        At end of turn, if "{R}" is untapped, It deals 1 damage to you.
        At end of turn, sacrifice "{R}".
or
Code: Select all
        "{R}"
        R
        Mana Red
        "{R}" is indestructible
        Tap: add R. "{R}" Becomes a 0/0 Dying Wisp Creature until end of turn
        At end of turn, sacrifice "{R}". It deals 1 damage to you.
:P

...I have seen "at end of turn, sacrifice <card's name>" in cards.txt
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.


--Eladamri, the Seed of Freyalise
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby DennisBergkamp » 29 May 2009, 00:20

Zerker,

I think it's an interesting idea to simulate a mana pool like this (by floating tokens around that represent mana in the pool). I'll have to look into the possibility to see if it's possible (I'm not sure how to do the sacrifice and add mana as a result of the sacrifice). We could even have the tokens appear in some hidden zone, and you could access them by clicking on some button... or they could appear in the land panel, whatever.

Ideally we would implement a real mana pool though, and manaburn would occur after each phase. But to tell you the truth, I still don't really fully understand the way mana works in forge. I'll have to look into it some more.
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 zerker2000 » 29 May 2009, 00:52

Thank you for insight!

I also have no idea how forge mana works, I don't even know (yet) how any part of forge works, but I have looked about cards.txt and tokens.txt a bunch. As far as I could see from them, only " tap: add <color>" is implemented as a keyword :(

As for manaburn, I am sure that having the token deal 1 damage to you and then sacrifice itself would be functionally equivalent. Hmm, speaking, is "manaburn" a valid "source" for damage prevention (e.g. Cho-Arrim :P)
Last edited by zerker2000 on 29 May 2009, 03:37, edited 1 time in total.
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.


--Eladamri, the Seed of Freyalise
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby Rob Cashwalker » 29 May 2009, 02:21

I've suggested a mana pool of sorts in past threads.

Basically, we define a string in the Player object. Then we define a keyworded ability (similar in theory to PTPump) which taps the card with the keyword, and concatenates the mana character to the end of the string.

After much looking around, I think the only place we could make use of this is at the beginning of Input_PayManaCost.tapCard. Basically, it should pop (read and remove) characters off from the Player's mana pool string, and use manaCost.subtractMana(color); for each mana character found until the string is either empty or ManaCost.isPaid becomes true. If still not paid, THEN it continues with the existing first line in the routine, tapping lands or other cards as usual.

Then again, mtgrares has a mana pool for v2, so I'm curious how compatible it might be.... If it were that compatible, I hope he would have already provided it to us....
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 zerker2000 » 29 May 2009, 06:32

Starting from your end, I do not think the v2 one is compatible with the current version in any respect, since it seems like the sort of "Basic building block" that would be a founding principle of the program, which is way different for the current forge. And I am quit sure that if mtgrares' pool was usable(for forge 1), he'd take the 5 minutes needed to post it on this forum.

As for how to code your ideas, please don't flood me with details since all I've seen of forge are the card&token files( I scanned through a couple manaCost methods in source.rar, but I couldn't make heads or tails of them :()

As for the spells automatically taking mana from the pool, that could be problematic... here, let me make up a story:

Your main phase begins, you only have one life left, {B} {B} in your mana pool, and only one (an untapped Rakdos Carnarium thankfully) land. Though without it you would have surely been toast (when the computer swung out that 57/57 Mycoloth, and later started making tons of 1/1 s with Nemata, Grove Guardian while having a Mycologist out ... who knew a saproling deck could be so powerful in the computer's hands?), your Altar of Shadows has simply been a nuisance lately, bringing you down from 4 to 3 and last turn 1 since that computer Armageddon -ed your 14 lands. However, you did kill off all the serious threats, and now you just need a blocker... you have a Fiery Temper and an Avatar of Discord in hand, so you tap the land, play the avatar, discard your remaining two hards... and notice that forge just played your Avatar for {R} {B} {B}, so you
a) can't deal the 3 damage to stop his Elspeth, Knight-Errant from making his permanents indestructible,
about which you don't care since
b) you're going to die of mana burn. So there you are, dead of a leech-ridden {B} because of a mana pool usability problem.

How was the final chapter of "The Autobiography of Rob Planeswaker"? :P
Last edited by zerker2000 on 29 May 2009, 13:22, edited 1 time in total.
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.


--Eladamri, the Seed of Freyalise
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby Incantus » 29 May 2009, 12:28

In Incantus, mana costs are convertable between strings and an array of 5 integers (WUBRGC). I've implemented a simple manapool object that handles adding and subtracting mana, and also handles making sure you have enough mana in your pool, and also an algorithm to determine how to distribute the current mana in the pool for a particular cost (for example, say have WR in your pool, and the spell costs 1R, the distribution algorithm will automatically figure out how to do this). Ive attached it below. This code is pretty much only called by the player class (for add mana), and by the ManaCost class (for everything else). The UI code also uses some of the helper functions (in particular, when the distribute algorithm fails and you have multiple choices for paying a colorless cost - say you have WRG and the spell costs 1R.

Here is my compute and pay functions for the ManaCost class (these are called in the beginning steps of playing spells/abilities):

Code: Select all
    def compute(self, source, player):
        # XXX This is where I should check if the player has enough mana and the player should
be
        # able to generate more mana
        mp = player.manapool
        cost = self.final_cost
        for i, val in enumerate(cost):
            if val < 0: cost[i] = 0
        while True:
            required = mp.enoughInPool(cost)
            if required == '0': return True
            if not player.getMoreMana(required): return False
    def pay(self, source, player):
        mp = player.manapool
        # Now I have enough mana - how do I distribute it?
        payment = mp.distribute(self.final_cost)
        if not payment:
            # Ask the player to distribute
            payment = Mana.convert_mana_string(player.getManaChoice(str(player.manapool), Mana.
convert_to_mana_string(self.final_cost)))
        mp.spend(payment)
        self.payment = Mana.convert_to_mana_string(payment)
It should be pretty self-explanatory. From outside the manapool perspective, all groups of mana are passed around as strings.

Don't know if this is useful, but you might be able to use it as a basis for Forge's pool. The distribute algorithm in particular took me a bit of time.

edit: I forgot to attach the file, and it seems the board doesn't let me attach text files. Here it is zipped up.
Mana.zip
(2.04 KiB) Downloaded 406 times
Last edited by Incantus on 30 May 2009, 04:14, edited 1 time in total.
Incantus
DEVELOPER
 
Posts: 267
Joined: 29 May 2008, 15:53
Has thanked: 0 time
Been thanked: 3 times

Re: Mana Pool

Postby zerker2000 » 29 May 2009, 13:26

Hmm... I don't understand any of the code, but I just found a ManaPool.java in the source, does anyone know what that is used for?

Code: Select all
public class ManaPool extends MyObservable
{
  private int mana[];

  public ManaPool()
  {
    reset();
  }
  public void reset()
  {
    mana = new int[6];
    this.updateObservers();
  }
  private int getIndex(String color)
  {
    if(color.equals(Constant.Color.Black))
      return 0;
    else if(color.equals(Constant.Color.Blue))
      return 1;
    else if(color.equals(Constant.Color.Colorless))
      return 2;
    else if(color.equals(Constant.Color.Green))
      return 3;
    else if(color.equals(Constant.Color.Red))
      return 4;
    else if(color.equals(Constant.Color.White))
      return 5;

    throw new RuntimeException("ManaPool:getIndex() invalid color argument " +color);
  }
  public int getColor(String color)
  {
    return mana[getIndex(color)];
  }
  public void subtractColor(String color)
  {
    mana[getIndex(color)]--;
    updateObservers();
  }
  public void subtractColor(String color, int n)
  {
    mana[getIndex(color)] = mana[getIndex(color)] - n;
    updateObservers();
  }
  public void addColor(String color)
  {
    mana[getIndex(color)]++;
    updateObservers();
  }
  public void addColor(String color, int n)
  {
    mana[getIndex(color)] = mana[getIndex(color)] + n;
    updateObservers();
  }
}
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.


--Eladamri, the Seed of Freyalise
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby mtgrares » 29 May 2009, 17:30

I'll chime in, it is used by Input_PayManaCost which is what you, the human player, use to pay the mana cost on the cost. Input_PayManaCost handles the mouse input like clicking on a card and uses the mana pool to subtract mana. (I think since I did the hybrid mana update that ManaPool.java isn't used at all.) When I was programming MTG Forge I sort of forgot about the mana pool, so that is the "official" reason why. I didn't realize it until I was trying to program Dark Ritual. I said, "Arg, big problem" and then went on because everything else was working and I had 50 or so cards.
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times

Re: Mana Pool

Postby zerker2000 » 29 May 2009, 21:44

Ah: so it is( or was) the program part of the paying of mana costs, while ManaPayCost is the interface part? Also, just how hard is it to make my "mana token" workaround?
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.


--Eladamri, the Seed of Freyalise
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time

Re: Mana Pool

Postby Rob Cashwalker » 30 May 2009, 12:37

zerker2000 wrote:Your main phase begins, you only have one life left, {B} {B} in your mana pool,
How do you begin the main phase with {B}{B} in your mana pool? If had been put there by some effect during "upkeep" (which isn't precisely supported yet either) then it would have burned you before moving to the next phase. And if it were an effect that automatically put mana in your pool, then it usually also carries a clause about this mana doesn't cause burn and/or doesn't empty until end of turn....

I think my solution is the only simple way to hack a pool into the existing source. And I'm not responding directly to you with the technical details, I'm simply re-iterating my idea for the 4th time, only with a few more ideas hashed out with code backup. I may try to hack it in myself, or maybe Dennis or Rares would read it and finally go "A-HA!"
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 zerker2000 » 30 May 2009, 14:57

You get your {B} {B} from your altar of Shadows, which has two charge counters from destroying the computer's Mycoloth and Nemata, so it gives you mana at the beggining of your main phase:
Gatherer card reference: <http://gatherer.wizrads.com> wrote:Card Name: Altar of Shadows
Mana Cost: {7}
Converted Mana Cost: 7

Types: Artifact
Card Text:
At the beginning of your precombat main phase, add {B} to your mana pool for each charge counter on Altar of Shadows.
{7}, {T}: Destroy target creature. Then put a charge counter on Altar of Shadows.
Expansion:Image Mirrodin
Rarity: Rare
Card #: 143
Artist: Sam Wood
Sorry, I do tend to get all official on people doubting my MTG knowledge :P

EDIT: Oh, and the Altar seems to be autocarded as well, I should have just pointed you to that #-o
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.


--Eladamri, the Seed of Freyalise
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time

Next

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 38 guests


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 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 38 guests

Login Form