It is currently 24 Apr 2024, 06:53
   
Text Size

Cards with counters.

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

Re: Cards with counters.

Postby DennisBergkamp » 12 Jan 2009, 19:41

As far as I know, keyword checks are done all over the place right now. A bunch of them are done in CardFactory.java, I put some of the checks for Exalted in GameActionUtil.java, but I realize I should probably move them over to CombatUtil.java.

Unfortunately, I have no solution for your problem... I know there is an isMana() method in CardUtil.java, which checks for the mana abilities keywords.
But in terms of code, how they're used exactly, I'm not sure. I've always found the mana abilities a bit elusive in MTGForge. Cards like Sol Ring are currently tricky to do, because there's no mana pool.

Anyway, in this case you might not necessarily have to use keywords, but if you don't you will have to add 5 separate abilities (one for each color) just to this card.
Might still be easier though, but of course less reusable.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Cards with counters.

Postby DennisBergkamp » 12 Jan 2009, 20:15

Another tricky thing with keywords is that they will show up on the card's text. I'm having trouble with this right now, since I used "Remove three spore counters from this card: Put a 1/1 green Saproling creature token into play." as a keyword. Whenever I find a card with this keyword, I create an Ability containing the code to remove three spore counters from this card, and to put a 1/1 Saproling token into play.
Now, I also put "Remove three spore counters from this card: Put a 1/1 green Saproling creature token into play." as the description for the ability (ability.setDescription()), the same as the keyword. Now, everything works fine for my test subject Elvish Farmer, but, his text looks like this now:

Remove three spore counters from this card: Put a 1/1 green Saproling creature token into play.
At the beginning of your upkeep, put a spore counter on Elvish Farmer.
Remove three spore counters from this card: Put a 1/1 green Saproling creature token into play.
Sacrifice a Saproling: You gain 2 life.

Does anyone know, is there an easy way to remove duplication like this when using keywords? Or a way to hide them altogether?

Anyway Orpheu, in your case if you use keywords it looks like you will also see:

remctr: add W
remctr: add U
remctr: add B
remctr: add R
remctr: add G

On the text of the card, which looks a little bit ugly.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Cards with counters.

Postby Rob Cashwalker » 13 Jan 2009, 04:29

@Dennis:
After parsing the keyword to generate the ability, remove your keyword from the card's keyword array. The shouldPump function in CardFactory does this for example. Primarily this allows two pump abilities on one creature, but the side benefit is that after parsing these keywords, the text becomes only what you set in code. You can then shorten your keyword to the bare minimum of syllables.....

@Orpheu:
You have two choices - keyword it, or give the card regular "tap: add _" keywords, handling the special case internally.

For the special handling method, look at the pain land code in InputPayManaCost:
Code: Select all
//pain lands
      ArrayList pain = new ArrayList();
      pain.add("Battlefield Forge");
      pain.add("Caves of Koilos");
      pain.add("Llanowar Wastes");
      pain.add("Shivan Reef");
      pain.add("Yavimaya Coast");
      pain.add("Adarkar Wastes");
      pain.add("Brushland");
      pain.add("Karplusan Forest");
      pain.add("Underground River");
      pain.add("Sulfurous Springs");
      if(pain.contains(card.getName()) && coloredMana)
        AllZone.GameAction.getPlayerLife(card.getController()).subtractLife(1);

      if(card.getName() == "Mirrodin's Core" && colored Mana)
        card.removeCounter("Charge Counter");
To add a mana keyword, start here in CardUtil:
Code: Select all
  //checks to see if the card can produce mana
  //presumes mana abilities start with "tap: add"
  public static boolean isMana(Card c)
  {
    Object[] keyword = c.getKeyword().toArray();

    for(int i = 0; i < keyword.length; i++)
      if (keyword[i].toString().startsWith("tap: add") ||
           keyword[i].toString().startsWith("remctrtap: add"))     // Modify/add this line
         return true;

    return false;
  }
then modify the following in InputPayManaCost:
Code: Select all
  private static final String manaString = "tap: add ";
  private static final String MCmanaString = "remctrtap: add";   // Add this
.........
  public static ArrayList getManaAbilities(Card card)
  {
    ArrayList check = card.getKeyword();
    ArrayList mana  = new ArrayList();

    char letter;

    for(int i = 0; i < check.size(); i++)
    {
      if(check.get(i).toString().startsWith(manaString))
      {
        //gets G from "tap: add G"
        letter = check.get(i).toString().charAt(manaString.length());
        mana.add(getColor(letter +""));
      }
      if (check.get(i).toString().startsWith(MCmanaString))      // Add this block
      {
         //gets g from "remctrtap: add G"
         letter = check.get(i).toString().charAt(manaString.length());
         mana.add(getColor(letter + ""));
         card.removeCounter("Charge Counter");
       }
    }

    return mana;
  }
If you made it this far, you now have to decide if the computer is going to be able to play the ability correctly.... Oh, and make sure that you can't tap for colored mana if there aren't any counters on it.

But if you can make this work, this opens up Tendo Ice Bridge, Gemstone Mine and the Vivid lands.

And yes, we'd be stuck with all the "remctr: add _" keywords in the card text... it can't be removed from the array like the keyword translations - pump and RegenerateMe. Unless you made some serious modification to the card object and gave it a secret ability array..... hmm.... a secret array.... anyway.... If you use the card pictures, it shouldn't be too bad, as long as it functions... it wouldn't bother me.
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: Cards with counters.

Postby Orpheu » 13 Jan 2009, 10:45

DennisBergkamp wrote:As far as I know, keyword checks are done all over the place right now. A bunch of them are done in CardFactory.java, I put some of the checks for Exalted in GameActionUtil.java, but I realize I should probably move them over to CombatUtil.java.

Unfortunately, I have no solution for your problem... I know there is an isMana() method in CardUtil.java, which checks for the mana abilities keywords.
But in terms of code, how they're used exactly, I'm not sure. I've always found the mana abilities a bit elusive in MTGForge. Cards like Sol Ring are currently tricky to do, because there's no mana pool.

Anyway, in this case you might not necessarily have to use keywords, but if you don't you will have to add 5 separate abilities (one for each color) just to this card.
Might still be easier though, but of course less reusable.
Why this keyword check is not done just where you read the cards file input?? Why it's distributed for a bunch of classes?

This code seems to be full of small patches... :S This work in the short term, but it seems to be harder and harder to expand to make other things and specially to garante that this abilities will actually work, once small patches and individual cases leads to almost untraceable number of execution paths. Shouldn't we just "clean" up the code before we move forward?

For instance, why the manapool is not a object that could be handle? The are some creatures that have the ability to add Mana to mana pool if you sacrifice it. How can you do just that if we can't access the manapool?
Orpheu
 
Posts: 25
Joined: 13 Dec 2008, 09:43
Has thanked: 0 time
Been thanked: 0 time

Re: Cards with counters.

Postby jpb » 13 Jan 2009, 11:55

Forge implemented mtgforge in a very short time and in doing so the design was quickly done. Everyone, including forge, agrees that much of this design was highly flawed. He is working on Version 2 now, with the plan to incorporate all that he learned from doing version 1. Hopefully version 2 will be an improvement over version 1. One improvement he has talked about is the addition of a mana pool =)

For version 1 their is no mana pool because mtgforge uses the simplest possible solution for mana. That is, when you wish to pay for something you tap a card to help pay for it. If you wish to add the mana pool and get mtgforge to use it I am sure it will get into the soonest release possible.

My plan for version 1 is to improve it to add as much fun as possible while we wait for version 2 to be released.
jpb
 
Posts: 132
Joined: 05 Sep 2008, 13:12
Has thanked: 0 time
Been thanked: 0 time

Re: Cards with counters.

Postby Orpheu » 13 Jan 2009, 12:40

jpb wrote: One improvement he has talked about is the addition of a mana pool =)
So maybe the best solution for my current problem will be to just wait for a new update to forge and then add the mana to the pool. :?:

Is there some release date to the next version of run forge?

By the way... The previous remarks about the current version is not a critique to forge, I'm sure he do the best possible to make it work, but we could help him out in the process if he let us. Maybe we could make some kind of project to the overall program struct and then divide the programming work between us all. In this way the final "product" will result in a better and a more easly extensible one. What do you guys think?
Orpheu
 
Posts: 25
Joined: 13 Dec 2008, 09:43
Has thanked: 0 time
Been thanked: 0 time

Re: Cards with counters.

Postby DennisBergkamp » 13 Jan 2009, 17:16

@Dennis:
After parsing the keyword to generate the ability, remove your keyword from the card's keyword array. The shouldPump function in CardFactory does this for example. Primarily this allows two pump abilities on one creature, but the side benefit is that after parsing these keywords, the text becomes only what you set in code. You can then shorten your keyword to the bare minimum of syllables.....
Thank you!!! I knew I was missing something. I'll check out shouldPump().

So maybe the best solution for my current problem will be to just wait for a new update to forge and then add the mana to the pool. :?:

Is there some release date to the next version of run forge?

By the way... The previous remarks about the current version is not a critique to forge, I'm sure he do the best possible to make it work, but we could help him out in the process if he let us. Maybe we could make some kind of project to the overall program struct and then divide the programming work between us all. In this way the final "product" will result in a better and a more easly extensible one. What do you guys think?
Release date of V2 could be years away, unfortunately.
I think your suggestion is good, we should ask forge what he thinks of it. Either we could rewrite parts of V1, or maybe we could directly help him with V2?

For the last few months, much like jpb, I've just been trying to make the best of V1, adding new cards / features, fixing things.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Cards with counters.

Postby mtgrares » 13 Jan 2009, 19:46

Alot of good discussion, I'll be honest and say that I didn't follow 100% of all of it but I think I got at least 70%.

Does anyone know, is there an easy way to remove duplication like this when using keywords? Or a way to hide them altogether?

Anyway Orpheu, in your case if you use keywords it looks like you will also see:

remctr: add W
remctr: add U
remctr: add B
remctr: add R
remctr: add G
You could change Card.getText() which returns a String. This method is called by the "card detail" methods which show the card's text on the right of the screen. The code would look for a colon : in the interal list of all keywords and wouldn't add it to the String that was outputted. The code below has not been checked or compiled, but something like it would work.

Code: Select all
//Card.getText()
//this is from the middle of the method

String s = "";
ArrayList keyword = getKeyword();
for(int i = 0; i < keyword.size(); i++)
{
  if(! keyword.get(i).contains(":"))
  {
    if(i != 0)
      s += ", ";
    s += keyword.get(i).toString();
  }
}
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times

Re: Cards with counters.

Postby mtgrares » 13 Jan 2009, 19:54

Release date of V2 could be years away, unfortunately.
I think your suggestion is good, we should ask forge what he thinks of it. Either we could rewrite parts of V1, or maybe we could directly help him with V2?
I don't know when version 2 will be playable, real life is confusing right now. Feel free to rewrite parts of version 1, the problem of adding something is that you have to change to much of the other parts of the program. For example, just adding a mana pool means that you have to update Input_NoCost_TapAbility, Input_PayManaCost, Input_PayManaCost_Ability, Input_PayManaCostUtil.java, which isn't impossible but it does seem hard enough. And MTG Forge doesn't have any automated testing which WOULD help out.

I'll tell you everything I know about MTG Forge but sometimes that isn't too much ;)
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times

Re: Cards with counters.

Postby Rob Cashwalker » 13 Jan 2009, 23:32

rares - go you think my suggestions for adding alternative mana abilities is workable or am I missing something major?
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: Cards with counters.

Postby mtgrares » 15 Jan 2009, 19:57

The truth is I don't know how hard it is to add a mana pool can be added to version 1. The answer is I know it is not easy. It may be very hard or it may not be.

Basically paying for mana involves the classes Input_NoCost_TapAbility, Input_PayManaCost, Input_PayManaCost_Ability, Input_PayManaCostUtil.java. (There should really be only one class but the others are "mutatations".) The idea is that you, the player, click on lands, and the Input class just taps those lands. These classes look for any of the "mana keywords" like tap: add 1, tap: add B, if a card has one of those it is tapped and the mana cost is reduced. Each Spell or Ability has a mana cost, SpellAbility.getManaCost() which returns a String.
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times

Re: Cards with counters.

Postby Rob Cashwalker » 15 Jan 2009, 20:18

But what about my idea of just modifying those parts which look for mana keywords and adding new keywords - "pain: add B" for example, or like Orpheu would want - "remctr: add B"? Should this be as simple as I've posted?
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: Cards with counters.

Postby mtgrares » 15 Jan 2009, 21:16

It seems like adding remctr: add B and pain: add B shouldn't be too hard at least for the human player. The computer AI would have to be updated somehow. MTG Forge doesn't have "mana abilities" so I just use Strings like "tap: add B" to simulate mana abilities.

Just to clarify, "remctr: add B" would remove a counter add mana like Mirrodin's Core. While "pain: add B" would cause 1 damage to the player and add mana like City of Brass. (Well not exactly like City of Brass but I can't think of any painlands off the top of my head. City of Brass could be emulated "good enough" using pain keywords.

If anyone is up to the task, someone could also add "tap: add 2" or "tap: add BB"
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times

Re: Cards with counters.

Postby GandoTheBard » 15 Jan 2009, 22:19

Without the manapool adding multiple mana at once seems to be problematic. What if you only want to spend B of the BB added? or Perhaps only need 1 but tap the sol ring for 2? You should by rights have the extra in your pool until it clears. At which time you take a burn assuming the current game rules allow it.

Perhaps the next step with V1 is to go ahead and implement the correct mana system along with the pools (one for each player) and rules about the pools (such as when they clear etc).

each ManaPool would have a member for each type of mana possible: colorless, red, white, blue, green and black. Then you could add in a few keywords like ManaAllTypes and ManaColorless. Then youd have to teach the AI how to use the pool. :)

ALOT of cards become available if someone could figure out how to implement this without having to rewrite everything from scratch.
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: Cards with counters.

Postby jpb » 15 Jan 2009, 22:33

Mana pool is a very large endeavor in v1. I think it is more realistic if we do what forge says and first implement "tap: add BB" first. That will give whoever adds it knowledge of how the current system works. This will be very helpful when coming up with a solution for a mana pool later. If "tap: add BB" is added then there are a few simplified ways to handle it. None of which are in line with mtg rules, but would make coding it much more simple.

Assume GandoTheBard's scenario of trying to cast something which costs B when you only have a land which has "tap: add BB".

1) Deny the cast. Only allow BB to be used on spells which require BB.
2) Allow the cast. No mana burn. Extra B mana is discarded.
3) Allow the cast. Extra B is instantly burned and player loses a life.
jpb
 
Posts: 132
Joined: 05 Sep 2008, 13:12
Has thanked: 0 time
Been thanked: 0 time

PreviousNext

Return to Forge

Who is online

Users browsing this forum: No registered users and 77 guests


Who is online

In total there are 77 users online :: 0 registered, 0 hidden and 77 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 77 guests

Login Form