It is currently 09 Nov 2025, 03:14
   
Text Size

Card name renamer for linux

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

Re: Card name renamer for linux

Postby verot » 05 Mar 2009, 21:25

I tried the newest eclipse... It compiled the code once =), I hope I can make it to work tomorrow =)
I'm not confident enough nor in c++, neither in java, to code without a working compiler =), and I like testing my codes, and immediately fix the bugs :)

I'm thinking about the madness ability I think that would be okay for start, I have already an idea how I should make it, that way I can learn about how MTGForge's functions work :)
Last edited by verot on 05 Mar 2009, 22:34, edited 1 time in total.
User avatar
verot
 
Posts: 14
Joined: 04 Mar 2009, 22:42
Location: <- there
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby DennisBergkamp » 05 Mar 2009, 21:54

Wow, this is very cool - madness would be awesome!

EDIT: However, it's probably not the easiest thing to start on. But to give you a hint, you will need to check out the discard(Card c) method in GameAction.java.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby Rob Cashwalker » 06 Mar 2009, 04:46

Yeah, madness might be too maddening to start off with....

I'd suggest working out a generic way to make all damage spells and/or abilities. Such that Shock could be cards.txt implemented as:

Shock
R
Instant
no text
spDamageCP:2

And Prodigal Sorcerer as:

Prodigal Sorcerer
2 U
Creature Human Wizard
no text
1/1
abDamageCP T:1

And this one's probably the only generic damage to creatures only, but it's good to have all variations available....

Storm Spirit
3 W U G
Creature Elemental Spirit
no text
3/3
Flying
abDamageC T:2

Damage to players only:

Flame Jet
1 R
Sorcery
no text
Cycling:2
spDamageP:3

Flamewave Invoker
2 R
Creature Goblin Mutant
no text
2/2
abDamageP 7 R:5

Not only should this be a simple exercise, it's such a common effect, that even with just the Damage Creature or Player effects, you would be responsible for adding well over a hundred cards. (and it's one less keyword from my to-do list) Just look at the code for these existing cards, plus look at the code at the top of CardFactory to handle keywords. Madness effects are not common, and would practically require each card to be custom coded.
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: Card name renamer for linux

Postby verot » 06 Mar 2009, 08:20

Maybe this would be better to start with, If I can make Eclipse to work, I'll start working on it.
User avatar
verot
 
Posts: 14
Joined: 04 Mar 2009, 22:42
Location: <- there
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby Almost_Clever » 06 Mar 2009, 12:12

Rob Cashwalker wrote:Yeah, madness might be too maddening to start off with....

I'd suggest working out a generic way to make all damage spells and/or abilities. Such that Shock could be cards.txt implemented as:

Shock
R
Instant
no text
spDamageCP:2

...

Not only should this be a simple exercise, it's such a common effect, that even with just the Damage Creature or Player effects, you would be responsible for adding well over a hundred cards. (and it's one less keyword from my to-do list) Just look at the code for these existing cards, plus look at the code at the top of CardFactory to handle keywords. Madness effects are not common, and would practically require each card to be custom coded.
Don't forget to include planeswalkers. Just fixing the player/planeswalker damage issue would be a big help.
A woman came up to me and said / "I'd like to poison your mind / With wrong ideas that appeal to you / Though I am not unkind."
User avatar
Almost_Clever
Tester
 
Posts: 345
Joined: 15 Jan 2009, 01:46
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby Rob Cashwalker » 06 Mar 2009, 18:03

Didn't Dennis fix that already? Or was that just for damage spells, and not abilities?
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: Card name renamer for linux

Postby DennisBergkamp » 06 Mar 2009, 19:20

I think I only fixed this for certain cards (Lightning Bolt, Lightning Helix, Volcanic Hammer, etc.) ... although I do remember also doing this for Prodigal Sorcerer and the like. But there might be a few I missed.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby Rob Cashwalker » 06 Mar 2009, 21:37

Right. So verot could use those as templates for the ability code?
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: Card name renamer for linux

Postby verot » 06 Mar 2009, 22:39

I starder working on spDamageCP, didn't had much time today, but I finished the basics, and I used Shock's canPlayAI() function, I'll modify it when the keyword will work, I have some ideas how to make it better, I hope I can pull them off =) I hope I can finish it tomorrow, It's hard and slow at the moment I have to search for all the functions I need =)

edit: It should work now, gotta get a working compiler =)
User avatar
verot
 
Posts: 14
Joined: 04 Mar 2009, 22:42
Location: <- there
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby Rob Cashwalker » 08 Mar 2009, 07:14

verot wrote:I starder working on spDamageCP, didn't had much time today, but I finished the basics, and I used Shock's canPlayAI() function, I'll modify it when the keyword will work, I have some ideas how to make it better, I hope I can pull them off =) I hope I can finish it tomorrow, It's hard and slow at the moment I have to search for all the functions I need =)

edit: It should work now, gotta get a working compiler =)
That's awesome!

Don't fret too much about the compiler.... If you post the code in a thread, we'll all review it, and someone with a working compiler can merge it and see how it does.

BTW, if anyone's wondering about why I suggested the keywords to be spDamageCP and abDamageCP.... I've realized that there is a difference in how a spell ability is coded for a spell versus the permanent abilities. I'm thinking we should modify the already implemented effect keywords to follow this pattern. For example, spTgtPTPump (eventually) for Giant Growth; abPTPump for Shivan Dragon; spDamageCP for Shock; abDamageCP for Prodigal Pyromancer and so forth.
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: Card name renamer for linux

Postby verot » 08 Mar 2009, 09:39

Here it is, I hope it'll work =)

CardFactoryUtil.java (line 585)
Code: Select all
 public static SpellAbility spellability_DamageCP(final Card sourceCard, final String dmg)
  {
   final int damage = Integer.parseInt(dmg); // converting string dmg -> int

   final SpellAbility DamageCP =  new Ability_Hand(sourceCard, dmg)
   {
      //Shock's code here atm
      public boolean canPlayAI()
      {
          if(AllZone.Human_Life.getLife() <= damage)
            return true;
            
          PlayerZone compHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
           CardList hand = new CardList(compHand.getCards());
               
           if (hand.size() >= 8)
            return true;
         
          check = getFlying();
          return check != null;
      }
          
      public void chooseTargetAI()
      {
          if(AllZone.Human_Life.getLife() <= damage)
          {
            setTargetPlayer(Constant.Player.Human);
            return;
          }
            
          PlayerZone compHand = AllZone.getZone(Constant.Zone.Hand, Constant.Player.Computer);
           CardList hand = new CardList(compHand.getCards());
            
          if(getFlying() == null && hand.size() >= 7 ) //not 8, since it becomes 7 when getting cast
           {
              setTargetPlayer(Constant.Player.Human);
              return;
           }
         
          Card c = getFlying();
          if((c == null) || (! check.equals(c)))
            throw new RuntimeException(card +" error in chooseTargetAI() - Card c is " +c +",  Card check is " +check);
         
          setTargetCard(c);
      }//chooseTargetAI()
         
         //uses "damage" variable
           Card getFlying()
           {
             CardList flying = CardFactoryUtil.AI_getHumanCreature("Flying");
             for(int i = 0; i < flying.size(); i++)
               if(flying.get(i).getDefense() <= damage)
                 return flying.get(i);
         
             return null;
           }
         public void resolve()
         {
            final SpellAbility spell = new Spell(sourceCard)
            {
              public void resolve()
              {
                if(getTargetCard() != null)
                {
                  if(AllZone.GameAction.isCardInPlay(getTargetCard()))
                  {
                    Card c = getTargetCard();
                    c.addDamage(damage);
                  }
                }
                else
                  AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
              }//resolve()
             
            card.clearSpellAbility();
            card.addSpellAbility(spell);
            spell.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(spell));
            }
         }

   };
   DamageCP.setDescripion(sourceCard + " deals " + damage + " damage to creature or player.");
    DamageCP.setStackDescription(sourceCard +" deals " + damage + " damage.");
    return DamageCP;
  }//spellabiliy_DamageCP
CardFactory.java (line 145)
Code: Select all
   private final int shouldspDamageCP(Card c) {
      ArrayList a = c.getKeyword();
      for (int i = 0; i < a.size(); i++)
      {
         if (a.get(i).toString().startsWith("DamageCP"))
            return i;

      }
      return -1;
   }
CardFactory.java (line 914)
Code: Select all
    //Spell damage cards  CP means Computer and Player (like shock, Lightning Bolt)
    if (shouldspDamageCP  != -1)
    {
       int n = shouldDamageCP(card);
       if (n != -1)
       {
          String parse = card.getKeyword().get(n).toString();
          card.removeKeyword(parse);
          
          String k[] = parse.split(":");
          final string dmg = k[1];
          
            card.addSpellAbility(CardFactoryUtil.spellability_DamageCP(card, dmg));
       }
    }
P.S: Which jre version I need to compile it? 5 or 6?
User avatar
verot
 
Posts: 14
Joined: 04 Mar 2009, 22:42
Location: <- there
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby DennisBergkamp » 08 Mar 2009, 17:56

Looks good, skimming through the code, I think this should do the trick :)

Compiling should work on both versions, I'm pretty sure.
For now, I could just copy + paste this into my version, then release a new beta soon. I'm still completing some half-finished cards, and I'm in the process of finishing up some rewrite (still 500+ compile errors in my CardFactory.java as a result of it), so I can't really test it yet. But definitely soon, thanks a lot for this addition :mrgreen:
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby verot » 08 Mar 2009, 23:01

I could compile it with one version of jre, but then I installed an another one, now I got 500+ errors, 1 of them in run.java (I didn't edited it), and I have a weird error with an "};" It says I have to remove the ";", but when I remove it then an another error appears that says there is a missing ";" =)
User avatar
verot
 
Posts: 14
Joined: 04 Mar 2009, 22:42
Location: <- there
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby DennisBergkamp » 09 Mar 2009, 01:41

I could compile it with one version of jre, but then I installed an another one, now I got 500+ errors, 1 of them in run.java (I didn't edited it), and I have a weird error with an "};" It says I have to remove the ";", but when I remove it then an another error appears that says there is a missing ";" =)
Uh oh... that doesn't look good :shock:
Anyway, I've copied + pasted your code, and after messing around with it for awhile, it's working now :) I applied the keyword to Shock, Lightning Bolt and Volcanic Hammer. They work as expected, although I haven't tested the AI side yet.

Thanks!!!!
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby verot » 09 Mar 2009, 13:29

YESS! I uninstalled jre5, and messed up with eclipse's settings, now it can build mtgforge :mrgreen:
User avatar
verot
 
Posts: 14
Joined: 04 Mar 2009, 22:42
Location: <- there
Has thanked: 0 time
Been thanked: 0 time

PreviousNext

Return to Forge

Who is online

Users browsing this forum: No registered users and 99 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 99 users online :: 0 registered, 0 hidden and 99 guests (based on users active over the past 10 minutes)
Most users ever online was 9298 on 10 Oct 2025, 12:54

Users browsing this forum: No registered users and 99 guests

Login Form