It is currently 25 Apr 2024, 05:52
   
Text Size

Card name renamer for linux

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

Re: Card name renamer for linux

Postby verot » 11 Mar 2009, 21:37

Here is the code for spDamageP (spell damage to player), but my problem is, it doesn't work, and I don't know why, It's just puts the testcard into play, and I didn't found anything in the other files, I'd be really happy if somebody could tell me what's wrong with this or what i left out (after 6 hours of trying to figuring out why this isn't work... It became really frustrating working with the same 30-40 lines of code, without seeing any positive or negative results :( )

Code: Select all

  cardfactory.java
 
 
  private final int shouldspDamageP(Card c) {
      ArrayList a = c.getKeyword();
      for (int i = 0; i < a.size(); i++)
      {
         if (a.get(i).toString().startsWith("spDamageP"))
            return i;
      }
      return -1;
   }
   
   //---------------------------
   
       if (shouldspDamageP(card) != -1)
    {
       int n = shouldspDamageP(card);
       if (n != -1)
       {
          String parse = card.getKeyword().get(n).toString();
          card.removePrevIntrinsicKeyword(parse);
       
          card.clearSpellAbility();
       
          String k[] = parse.split(":");
          final String dmg = k[1];
       
          card.addSpellAbility(CardFactoryUtil.spellability_spDamageP(card, dmg));
       }
    }//SpDamageP
   
   
    cardfactoryutil.java
   
   
     public static SpellAbility spellability_spDamageP(final Card sourceCard, final String dmg)
  {
      final int damage = Integer.parseInt(dmg);
      
      final SpellAbility spDamageP = new Ability_Hand(sourceCard, sourceCard.getManaCost())
      {
         Card check;
         
         public boolean canPlayAI()
         {
                 return false;
         }
         
         //public void chooseTargetAI()
         //{
         //     CardFactoryUtil.AI_targetHuman();
         //      return;
        // }
         
         public void resolve()
         {
                  AllZone.GameAction.getPlayerLife(getTargetPlayer()).subtractLife(damage);
         }
      };
      spDamageP.setDescription(sourceCard.getName() + " deals " + damage + " damage to target player.");
      spDamageP.setStackDescription(sourceCard.getName() +" deals " + damage + " damage.");
      spDamageP.setBeforePayMana(CardFactoryUtil.input_targetCreaturePlayer(spDamageP));
      return spDamageP;
  }//Spellability_spDamageP
 
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 » 12 Mar 2009, 00:56

I'll mess around with this as well, and see if I can figure out what's going on... what are some of the spells that would use this by the way?
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 DennisBergkamp » 12 Mar 2009, 01:27

I got this to work for Lava Spike:
Code: Select all
Lava Spike
R
Sorcery
Lava Spike deals 3 damage to target player.
spDamageP:3
The one thing I did have to do to was change the line in CardFactoryUtil.java to use input_targetPlayer(spDamageP) instead:
Code: Select all
spDamageP.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spDamageP));
Since we would like our spells just to be able to target players. Then I uncommented the Lava Spike code in CardFactory.java, and I could still deal 3 damage to my opponent.

Strange though, your original stuff should have worked, even with input_targetCreaturePlayer().
What wasn't working exactly ?

One thing I'm noticing, however, is that I can cast my Lava Spike during the opponent's turn (if I'm not mistaken, this problem should exist with the spDamageCP keyword as well), so we need to add in a public boolean canPlay() method, which does a bunch checks and should return false when the spell in question is a sorcery and if it's the opponent turn. Anyway, this is more complicated but if you would like to have a shot at it go ahead, otherwise I could just add it in :)
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 » 12 Mar 2009, 06:23

card.clearSpellAbility();
This is one line I'm not so sure is necessary, and might conflict with other keywords. Example - Fiery Fall. Pretend we had a keyword script for the land-cycling - (we have regular cycling and we have tutors... and SearchMerc is a keyword for a specific tutor condition...) the cycling ability is added higher up in the code. Then this wipes it out. I know rares' original code uses it a lot, and I have no idea why....

As far as playing a sorcery on the opponent's turn... where in the original Lava Spike code is there any explicit checks for sorcery timing? Somewhere along the way MTGForge checks Card.isSorcery and Card.isInstant for the timing.... there's something inherently broken if the timing has to be hacked into the ability itself....
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 » 12 Mar 2009, 08:36

Oops, about input_targetCreaturePlayer(), it was originally input_targetPlayer() and then I changed to input_targetCreaturePlayer(), to test it out, and I left it there accidentally.

For me, this code just puts the card with spDamageP keyword into play (It doesn't ask for target), like a creature, and If I click on the card I can replicate it. By the way, I created a new testcard, with an original name, and then tried to change some original ones, but no luck :S

Maybe jre6 isn't the best choice =)
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 verot » 12 Mar 2009, 12:54

The problem was: I tried to compile MTGForge in linux, something is bugged with eclipse, or java in linux, and it always deleted the new .jar file, so I ran the old file :S :shock:

It's working on windows, so this is whebn the real fun starts =)
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 » 12 Mar 2009, 15:31

there's something inherently broken if the timing has to be hacked into the ability itself....
Yes, exactly, I'm not sure where though... and you're right, card.clearSpellAbility() might be the culprit.
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 DennisBergkamp » 13 Mar 2009, 00:13

Aha! card.clearSpellAbility() is NOT the culprit (in the CardFactory.java code all those burn spells used clearSpellAbility() as well).

However, changing this line:

Code: Select all
 final SpellAbility spDamageP =  new Ability_Hand(sourceCard, sourceCard.getManaCost())
To:

Code: Select all
final SpellAbility spDamageP = new Spell(sourceCard)
...will fix things though. I also changed this for spDamageCP.
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 » 13 Mar 2009, 08:23

Good =) Now I can concentrate on the AI part :D
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 » 13 Mar 2009, 15:30

Good =) Now I can concentrate on the AI part :D
This is good :)
A lot of the other cards could also use a major expansion on the AI logic, I've been very lazy when it comes to writing complete (smart) AI methods.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Previous

Return to Forge

Who is online

Users browsing this forum: Google [Bot] and 157 guests


Who is online

In total there are 158 users online :: 1 registered, 0 hidden and 157 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: Google [Bot] and 157 guests

Login Form