It is currently 29 Oct 2025, 07:59
   
Text Size

TgtP

Post MTG Forge Related Programming Questions Here

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

Re: TgtP

Postby slapshot5 » 17 Nov 2010, 23:40

And eventually, if Valid get smart enough to parse the hasProperty stuff, we can use:

Code: Select all
Tgt$Creature.Blue+YouCtrl
and the prompt would just magically be: "Select target blue creature you control"

without having backwards compat issues.

-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: TgtP

Postby friarsol » 17 Nov 2010, 23:50

So, Tgt$Artifact,Creature,Land instead of Tgt$A,C,L
So what's the difference between that and just using ValidTgts?
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: TgtP

Postby zerker2000 » 18 Nov 2010, 03:17

slapshot5 wrote:And eventually, if Valid get smart enough to parse the hasProperty stuff, we can use:

Code: Select all
Tgt$Creature.Blue+YouCtrl
and the prompt would just magically be: "Select target blue creature you control"

without having backwards compat issues.

-slapshot5
I would like to note that, when Valid gets that smart, it should also be able to parse " target blue creature you control", and restrict such unwieldy constructions to in-program use.
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.


--Eladamri, the Seed of Freyalise
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time

Re: TgtP

Postby slapshot5 » 18 Nov 2010, 04:32

friarsol wrote:
So, Tgt$Artifact,Creature,Land instead of Tgt$A,C,L
So what's the difference between that and just using ValidTgts?
You don't need TgtPrompt.
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: TgtP

Postby friarsol » 18 Nov 2010, 04:42

Why not just add something like this in AbilityFactory?

Code: Select all
if (hasValid){
  String prompt = mapParams.containsKey("TgtPrompt") ? mapParams.get("TgtPrompt") : "Select target " + mapParams.get("ValidTgts");
  abTgt = new Target(prompt, mapParams.get("ValidTgts").split(","), min, max);
}
This would make TgtPrompt optional for Targeting for the common circumstances, "Select target Creature" where the Prompt isn't necessary. Anything more complex could provide a Prompt.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: TgtP

Postby slapshot5 » 18 Nov 2010, 16:27

Is there any reason then that we need ValidTgts$ instead of just Tgt$ ?

That should simplify the syntax if everything uses something like this:

Tgt$Creature
Tgt$Enchantment.Blue+YouDontCtrl|TgtPrompt$Select target blue enchantment opponent controls.
Tgt$Artifact,Land
Tgt$Permanent.White

and TgtPrompt is just optional. We can put some kind of println or Log message (or runtime exception?) when it parses a Tgt$ that it can't generate a promper prompt for?

-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: TgtP

Postby friarsol » 18 Nov 2010, 17:08

Is there any reason then that we need ValidTgts$ instead of just Tgt$ ?
I think you have this whole thing a little backwards. ValidTgts came to be because Tgt$ was being used for backwards compatibility. Tgt$ is the "non-default" parameter here. This is why in the beginning (of this thread) I was trying to press TgtP not being used at all.

However, if you want to overwrite how Tgt$ works with what ValidTgts is already doing and eliminate ValidTgts$ this is what it requires:

1. Convert about 95 of the Tgt$ to their appropriate strings. For Damage spells that have P that means Player,Planeswalker+YouDontCtrl, a TgtPrompt needs to be added for any of those cases.

2. Next, you need to do a straight find/replace for ValidTgts$ to Tgt$ in the data files.

3. This section of code needs to be changed in AbilityFactory:

Code: Select all
if (mapParams.containsKey("ValidTgts"))
{
   hasValid = true;
   isTargeted = true;
}

if (mapParams.containsKey("Tgt"))
{
   isTargeted = true;
}

if (isTargeted)
{
   int min = mapParams.containsKey("TargetMin") ? Integer.parseInt(mapParams.get("TargetMin")) : 1;
   int max = mapParams.containsKey("TargetMax") ? Integer.parseInt(mapParams.get("TargetMax")) : 1;
   
   if (hasValid){
      abTgt = new Target(mapParams.get("TgtPrompt"), mapParams.get("ValidTgts").split(","), min, max);
   }
   else
      abTgt = new Target(mapParams.get("Tgt"), min, max);
   
   if (mapParams.containsKey("TgtZone"))   // if Targeting something not in play, this Key should be set
      abTgt.setZone(mapParams.get("TgtZone"));
}
to something like this:

Code: Select all
if (mapParams.containsKey("Tgt"))
{
   isTargeted = true;
   int min = mapParams.containsKey("TargetMin") ? Integer.parseInt(mapParams.get("TargetMin")) : 1;
   int max = mapParams.containsKey("TargetMax") ? Integer.parseInt(mapParams.get("TargetMax")) : 1;
   
   String prompt = mapParams.containsKey("TgtPrompt") ? mapParams.get("TgtPrompt") : "Target " + mapParams.get("ValidTgts");

   abTgt = new Target(prompt, mapParams.get("Tgt").split(","), min, max);
   
   if (mapParams.containsKey("TgtZone"))   // if Targeting something not in play, this Key should be set
      abTgt.setZone(mapParams.get("TgtZone"));
}
4. There may be some cleanup in a few places for unneeded code.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: TgtP

Postby slapshot5 » 18 Nov 2010, 19:22

friarsol wrote:Tgt$ is the "non-default" parameter here. This is why in the beginning (of this thread) I was trying to press TgtP not being used at all.
Right. I understand that. But backwards compat is no longer needed, right? And typing "Tgt$" is easier than "ValidTgts$". "Valid" has lost its meaning since everything uses valid behind the scenes (is this right?).

I don't feel a burning desire to change this part unless there is concensus.

I would definitely like to make the TgtPrompt optional when it is one of the simple cases I outlined above.

-slapshot5
slapshot5
Programmer
 
Posts: 1391
Joined: 03 Jan 2010, 17:47
Location: Mac OS X
Has thanked: 25 times
Been thanked: 68 times

Re: TgtP

Postby friarsol » 18 Nov 2010, 19:55

I'm not sure what you mean by "needed." Until cards using the shorthand are converted, it is still necessary. What they use behind the scenes, and how they are coded in the data files are completely different things. If you tried to be put Tgt$Creature right now it would not work because that Constructor expects shorthand.

Correct me if I'm wrong, but it mostly seems that you want to type less for the Tgt parameter. Good. I'm glad Ability_Factory is making things easier for everyone. So let's do things like this:

I whole-heartily approve with making Prompt optional. I even posted a two-liner that would make this happen. I'm not sure if you missed this when you shifted gears to the ValidTgt thing.

It may sound otherwise, but the changes you are proposing fall in line with what I had wanted originally, not using the Shorthand.

I just wanted you to be aware what went into this before you jumped in.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Previous

Return to Developer's Corner

Who is online

Users browsing this forum: ArchieRoW and 12 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 13 users online :: 1 registered, 0 hidden and 12 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: ArchieRoW and 12 guests

Login Form