hasKeyword
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins
1 post
• Page 1 of 1
hasKeyword
by Rob Cashwalker » 04 Nov 2009, 21:07
As my first revision to learn how to use the SVN integration, I made a change in how keyword code should be defined.
Previously, we had 241 lines of code to define "should{Keyword}" methods.
I think this hasKeyword method should be moved to the Card.java.
Previously, we had 241 lines of code to define "should{Keyword}" methods.
- Code: Select all
private final int shouldPTPumpCard(Card c)
{
ArrayList<String> a = c.getKeyword();
for(int i = 0; i < a.size(); i++)
if(a.get(i).toString().startsWith("PTPump"))
return i;
return -1;
}
//same thing, for "KPump" - self-targeted keyword adding abilities
private final int shouldKPumpCard(Card c)
{
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if(a.get(i).toString().startsWith("KPump"))
return i;
return -1;
}
//same thing, for "PTKPump" - self-targeted power and/or toughness pumping
//plus keyword adding abilities
private final int shouldPTKPumpCard(Card c)
{
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if(a.get(i).toString().startsWith("PTKPump"))
return i;
return -1;
}
//"TgtKPump" - targeted keyword adding abilities
private final int shouldTgtKPumpCard(Card c)
{
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if(a.get(i).toString().startsWith("TgtKPump"))
return i;
return -1;
}
// Check for self-regenerate ability
private final int shouldRegenerateMe(Card c) {
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("RegenerateMe"))
return i;
return -1;
}
// Check for Cycling ability
private final int shouldCycle(Card c) {
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("Cycling"))
return i;
return -1;
}
private final int shouldSporeSaproling(Card c) {
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("Remove three spore counters"))
return i;
return -1;
}
private final int shouldSpDamageTgt(Card c) {
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
{
if (a.get(i).toString().startsWith("spDamageTgt"))
return i;
}
return -1;
}
private final int shouldSpDamageCP(Card c) {
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
{
if (a.get(i).toString().startsWith("spDamageCP"))
return i;
}
return -1;
}
private final int shouldSpDamageP(Card c) {
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
{
if (a.get(i).toString().startsWith("spDamageP"))
return i;
}
return -1;
}
private final int shouldRebelSearch(Card c) {
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("SearchRebel"))
return i;
return -1;
}
private final int shouldMercSearch(Card c) {
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("SearchMerc"))
return i;
return -1;
}
private final int shouldMorph(Card c) {
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("Morph"))
return i;
return -1;
}
private final int shouldDevour(Card c) {
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("Devour"))
return i;
return -1;
}
private final int shouldSpellbomb(Card c) {
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("1, Sacrifice"))//
if(a.get(i).equals("1, Sacrifice "+c.getName()+": Draw a card."))
return i;
return -1;
}
private final int shouldModular(Card c) {
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
{
if (a.get(i).toString().startsWith("Modular"))
return i;
}
return -1;
}
private final int shouldUntap(Card c) {
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("Untap"))
return i;
return -1;
}
private final int shouldFlashback(Card c) {
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("Flashback"))
return i;
return -1;
}
private final int shouldAbDamageCP(Card c) {
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
{
if (a.get(i).toString().startsWith("abDamageCP"))
return i;
}
return -1;
}
private final int shouldAbTgtPTPumpCard(Card c)
{
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("abTgtPTPump"))
return i;
return -1;
}
private final int shouldSpPumpTgt(Card c){
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("spPumpTgt"))
return i;
return -1;
}
private final int shouldSpDestroyTgt(Card c){
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("spDestroyTgt:"))
return i;
return -1;
}
private final int shouldSpDrawCards(Card c){
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("spDrawCards"))
return i;
return -1;
}
// spLoseLifeGainLife
private final int shouldSpLoseLifeGainLife(Card c){
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("spLoseLifeGainLife"))
return i;
return -1;
}
// spRaiseDead
private final int shouldSpRaiseDead(Card c){
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith("spRaiseDead"))
return i;
return -1;
}
- Code: Select all
private final int hasKeyword(Card c, String k)
{
ArrayList<String> a = c.getKeyword();
for (int i = 0; i < a.size(); i++)
if (a.get(i).toString().startsWith(k))
return i;
return -1;
}
- Code: Select all
while(hasKeyword(card, "KPump") != -1)
{
int n = hasKeyword(card, "KPump");
if(n != -1)
{
String parse = card.getKeyword().get(n).toString();
card.removeIntrinsicKeyword(parse);
...
I think this hasKeyword method should be moved to the Card.java.
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
1 post
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 10 guests