It is currently 16 Apr 2024, 15:15
   
Text Size

How do you handle replacement effects?

General Discussion of the Intricacies

Moderator: CCGHQ Admins

How do you handle replacement effects?

Postby mtgrares » 09 Jun 2009, 18:31

MTG Forge doesn't implement any replacement effects like Yixlid Jailer but I know that Incantus does, how do you do it? And does anyone else have any ideas about replacement effects. Could events be replaced, changed, or filtered? This reminds of me of software pattern Chain of Responsibility but I'm not sure if it would be useful.
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times

Re: How do you handle replacement effects?

Postby MageKing17 » 09 Jun 2009, 19:42

mtgrares wrote:MTG Forge doesn't implement any replacement effects like Yixlid Jailer but I know that Incantus does, how do you do it? And does anyone else have any ideas about replacement effects. Could events be replaced, changed, or filtered? This reminds of me of software pattern Chain of Responsibility but I'm not sure if it would be useful.
Yixlid Jailer isn't a replacement effect. It's just a static ability that removes all abilities from cards in graveyards. We do that by simply having a static_tracking ability track the graveyard and say card.abilities.remove_all() for each card in the graveyard.

Replacement effects in Incantus are done by taking a function and replacing it with an object that pretends to be a function and winds up calling various replacement effects after asking the user which replacement effects to use first. It's one of those advanced constructs that I don't really understand the specifics of all that well, although I know (in general terms) what it's doing.
User avatar
MageKing17
Programmer
 
Posts: 473
Joined: 12 Jun 2008, 20:40
Has thanked: 5 times
Been thanked: 9 times

Re: How do you handle replacement effects?

Postby mtgrares » 11 Jun 2009, 18:28

Thanks MageKing. In Python you can replace an object's method, so you can change the method
RulesEngine.goToGraveyard(Card) so that it removes the card from the game instead. I'm using Java which doesn't have that kind of flexibility.
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times

Re: How do you handle replacement effects?

Postby telengard » 12 Jun 2009, 02:04

My engine would do something a little different.

A call to get[activated/static/triggered]_abilities would be hooked by the piece that removes the abilities and would then when called just check for being in the graveyard, if they were it would remove them from the list of abilities. I would probably have stuck this (if it existed in my game) in the negative replacement list (see below).

All hooks have a default implementation (in this case just return the piece's abilities as printed on the miniature). Each hook also has 4 lists, positive modifiers, positive replacements, negative modifiers, and negative replacements. These are used for cant trumps can etc. So far it's working well.

I have yet to implement choosing the order of applying modifiers (I have to do that to support 2 particular abilities).

~telengard
Author of Dreamblade:
viewtopic.php?f=51&t=1215
User avatar
telengard
DEVELOPER
 
Posts: 379
Joined: 23 May 2009, 23:04
Has thanked: 2 times
Been thanked: 27 times

Re: How do you handle replacement effects?

Postby MageKing17 » 12 Jun 2009, 02:58

mtgrares wrote:RulesEngine.goToGraveyard(Card)
Far simpler. Card.move_to(Zone). :)
User avatar
MageKing17
Programmer
 
Posts: 473
Joined: 12 Jun 2008, 20:40
Has thanked: 5 times
Been thanked: 9 times


Return to Magic Rules Engine Programming

Who is online

Users browsing this forum: No registered users and 15 guests


Who is online

In total there are 15 users online :: 0 registered, 0 hidden and 15 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: No registered users and 15 guests

Login Form