Card name renamer for linux
by mtgrares
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
Re: Card name renamer for linux
by 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
-
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
by 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?
-
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
by DennisBergkamp » 12 Mar 2009, 01:27
I got this to work for Lava Spike:
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
- Code: Select all
Lava Spike
R
Sorcery
Lava Spike deals 3 damage to target player.
spDamageP:3
- Code: Select all
spDamageP.setBeforePayMana(CardFactoryUtil.input_targetPlayer(spDamageP));
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

-
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
by Rob Cashwalker » 12 Mar 2009, 06:23
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....card.clearSpellAbility();
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.
-
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
by 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 =)
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 =)
-
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
by 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
It's working on windows, so this is whebn the real fun starts =)

It's working on windows, so this is whebn the real fun starts =)
-
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
by DennisBergkamp » 12 Mar 2009, 15:31
Yes, exactly, I'm not sure where though... and you're right, card.clearSpellAbility() might be the culprit.there's something inherently broken if the timing has to be hacked into the ability itself....
-
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
by 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:
However, changing this line:
- Code: Select all
final SpellAbility spDamageP = new Ability_Hand(sourceCard, sourceCard.getManaCost())
- Code: Select all
final SpellAbility spDamageP = new Spell(sourceCard)
-
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
by verot » 13 Mar 2009, 08:23
Good =) Now I can concentrate on the AI part 

-
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
by DennisBergkamp » 13 Mar 2009, 15:30
This is goodGood =) Now I can concentrate on the AI part

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.
-
DennisBergkamp - AI Programmer
- Posts: 2602
- Joined: 09 Sep 2008, 15:46
- Has thanked: 0 time
- Been thanked: 0 time
40 posts
• Page 3 of 3 • 1, 2, 3
Who is online
Users browsing this forum: No registered users and 25 guests