CARDNAME can't be blocked by creatures with power...
Post MTG Forge Related Programming Questions Here
	Moderators: timmermac, Agetian, friarsol, Blacksmith, KrazyTheFox, CCGHQ Admins
			6 posts
			 • Page 1 of 1
		
	
CARDNAME can't be blocked by creatures with power...
 by slapshot5 » 15 Apr 2010, 14:42
by slapshot5 » 15 Apr 2010, 14:42 
Logical followup from Chris's earlier post...
This is based on the type of ability the Amrou Kithkin has.
The keyword will look like:
-slapshot5
			
		This is based on the type of ability the Amrou Kithkin has.
The keyword will look like:
- Code: Select all
- CARDNAME can't be blocked by creatures with power {rest of string}
- Code: Select all
- // CARDNAME can't be blocked by creatures with power ...
 int powerLimit2[] = {0};
 int keywordPosition2 = 0;
 boolean hasKeyword2 = false;
 
 //ArrayList<String> blockerKeywords = blocker.getKeyword();
 for (int i = 0; i < blockerKeywords.size(); i++) {
 if (blockerKeywords.get(i).toString().startsWith("CARDNAME can't be blocked by creatures with power")) {
 hasKeyword2 = true;
 keywordPosition2 = i;
 }
 }
 
 if (hasKeyword2) { // The keyword "CARDNAME can't be blocked by creatures with power" ... is present
 String tmpString = blocker.getKeyword().get(keywordPosition2).toString();
 String asSeparateWords[] = tmpString.trim().split(" ");
 
 if (asSeparateWords.length >= 9) {
 if (asSeparateWords[8].matches("[0-9][0-9]?")) {
 powerLimit2[0] = Integer.parseInt((asSeparateWords[8]).trim());
 
 if (blocker.getNetAttack() >= powerLimit2[0] && attacker.getKeyword().contains
 ("CARDNAME can't be blocked by creatures with power " + powerLimit2[0] + " or greater.")) return false;
 if (blocker.getNetAttack() <= powerLimit2[0] && attacker.getKeyword().contains
 ("CARDNAME can't be blocked by creatures with power " + powerLimit2[0] + " or less.")) return false;
 }
 }
 
 if (blocker.getNetAttack() > attacker.getNetAttack()
 && blocker.getKeyword().contains("CARDNAME can't be blocked by creatures with power greater than CARDNAME's power.")) return false;
 if (blocker.getNetAttack() >= attacker.getNetDefense()
 && blocker.getKeyword().contains("CARDNAME can't be blocked by creatures with power equal to or greater than CARDNAME's toughness.")) return false;
 
 }// hasKeyword CARDNAME can't be blocked by creatures with power ...
- Code: Select all
- Amrou Kithkin
 W W
 Creature Kithkin
 no text
 1/1
 CARDNAME can't be blocked by creatures with power 2 or greater.
-slapshot5
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: CARDNAME can't be blocked by creatures with power...
 by slapshot5 » 15 Apr 2010, 14:44
by slapshot5 » 15 Apr 2010, 14:44 
This would allow the following cards:
Amrou Kithkin
Fleet-Footed Monk
Goldmeadow Dodger (already included, but it is special cased. change to keyword)
Sneaky Homunculus
			
		Amrou Kithkin
Fleet-Footed Monk
Goldmeadow Dodger (already included, but it is special cased. change to keyword)
Sneaky Homunculus
- Code: Select all
- Amrou Kithkin
 W W
 Creature Kithkin
 no text
 1/1
 CARDNAME can't be blocked by creatures with power 2 or greater.
 Fleet-Footed Monk
 1 W
 Creature Human Monk
 no text
 1/1
 CARDNAME can't be blocked by creatures with power 2 or greater.
 Goldmeadow Dodger
 W
 Creature Kithkin Rogue
 no text
 1/1
 CARDNAME can't be blocked by creatures with power 4 or greater.
 Sneaky Homunculus
 1 U
 Creature Homunculus Illusion
 no text
 1/1
 CARDNAME can't be blocked by creatures with power 2 or greater.
 CARDNAME can't block creatures with power 2 or greater.
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: CARDNAME can't be blocked by creatures with power...
 by slapshot5 » 15 Apr 2010, 14:46
by slapshot5 » 15 Apr 2010, 14:46 
I should also point out, the following line in CombatUtil.canBlock() can then be commented out:
			
		- Code: Select all
- if(attacker.getName().equals("Goldmeadow Dodger")) return blocker.getNetAttack() < 4;
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
Re: CARDNAME can't be blocked by creatures with power...
 by Chris H. » 15 Apr 2010, 14:59
by Chris H. » 15 Apr 2010, 14:59 
Awesome work.   
 
Thank you, I will try to get it committed sometime tomorrow or the next day. Thank you.
			
		 
 Thank you, I will try to get it committed sometime tomorrow or the next day. Thank you.
- 
				 
 Chris H.
- Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: CARDNAME can't be blocked by creatures with power...
 by Chris H. » 15 Apr 2010, 17:41
by Chris H. » 15 Apr 2010, 17:41 
I have your code merged into my local copy and ran a test with Amrou Kithkin and the ability/restriction was not in effect.   I looked at the code for a while and it dawned on me that the code which creates a ArrayList<String> and then tests for the keyword needed to be changed to look at the attacker's keywords.
  I looked at the code for a while and it dawned on me that the code which creates a ArrayList<String> and then tests for the keyword needed to be changed to look at the attacker's keywords.
I made the change and it appears to work now. 
 
			
		 I looked at the code for a while and it dawned on me that the code which creates a ArrayList<String> and then tests for the keyword needed to be changed to look at the attacker's keywords.
  I looked at the code for a while and it dawned on me that the code which creates a ArrayList<String> and then tests for the keyword needed to be changed to look at the attacker's keywords.I made the change and it appears to work now.
 
 - Code: Select all
- ArrayList<String> attackerKeywords = attacker.getKeyword();
 for (int i = 0; i < attackerKeywords.size(); i++) {
 if (attackerKeywords.get(i).toString().startsWith("CARDNAME can't be blocked by creatures with power")) {
 hasKeyword2 = true;
 keywordPosition2 = i;
 }
- 
				 
 Chris H.
- Forge Moderator
- Posts: 6320
- Joined: 04 Nov 2008, 12:11
- Location: Mac OS X Yosemite
- Has thanked: 644 times
- Been thanked: 643 times
Re: CARDNAME can't be blocked by creatures with power...
 by slapshot5 » 15 Apr 2010, 18:45
by slapshot5 » 15 Apr 2010, 18:45 
D'oh!Chris H. wrote:I made the change and it appears to work now.
 
 That's what copy&paste will get you.
- slapshot5
- Programmer
- Posts: 1391
- Joined: 03 Jan 2010, 17:47
- Location: Mac OS X
- Has thanked: 25 times
- Been thanked: 68 times
			6 posts
			 • Page 1 of 1
		
	
Who is online
Users browsing this forum: Timothysow and 16 guests
