Card Contributions
by ubeefx
Moderators: ubeefx, beholder, melvin, ShawnieBoy, Lodici, CCGHQ Admins
Re: Card Contributions
by PalladiaMors » 07 Aug 2014, 03:41
Posting the groovy, it's still crashing. It's really similar to the other stuff I've done besides the Sacrifice_Island thing, so maybe I've messed up with the formatting somewhere?
- Code: Select all
[
new MagicAtUpkeepTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPlayer upkeepPlayer) {
return permanent.isController(upkeepPlayer) ?
new MagicEvent(
permanent,
new MagicMayChoice("Sacrifice an island?"),
this,
"PN may\$ sacrifice an island. If PN doesn't, sacrifice SN and it deals 6 damage to you."
):
MagicEvent.NONE;
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
if (event.getPlayer().controlsPermanent(MagicSubType.Island) && event.isYes()) {
game.addEvent(new MagicSacrificePermanentEvent(event.getPermanent(),event.getPlayer(),new MagicTargetChoice("an Island to sacrifice"));
} else {
game.doAction(new MagicSacrificeAction(event.getPermanent()));
final MagicDamage damage = new MagicDamage(event.getSource(),event.getPlayer(),6)
game.doAction(new MagicDealDamageAction(damage));
}
}
}
]
- PalladiaMors
- Posts: 343
- Joined: 12 Jul 2014, 17:40
- Has thanked: 36 times
- Been thanked: 22 times
Re: Card Contributions
by ShawnieBoy » 07 Aug 2014, 03:59
Looking at it, the first addEvent needs another close bracket, and the final MagicDamage needs a semi-colon at the end.
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Card Contributions
by ShawnieBoy » 07 Aug 2014, 04:10
Oh, but thinking about it, the sacrifice choice should be on resolution, not when it goes on the stack. As in the choice whether or not to sacrifice a land.
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Card Contributions
by melvin » 07 Aug 2014, 04:30
The may choice is decided when it goes onto the stack, this is a house rule of Magarena.
"most choices are made when a spell or ability is put on the stack" -- https://code.google.com/p/magarena/wiki/GameRules
"most choices are made when a spell or ability is put on the stack" -- https://code.google.com/p/magarena/wiki/GameRules
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Re: Card Contributions
by ShawnieBoy » 07 Aug 2014, 11:54
Does this still need to be the case? We've changed the Game Design Principles a lot https://code.google.com/p/magarena/wiki/GameDesign : Max mana cost 9, Max 3 colors in mana cost, No cards that only work well in monocolor don't qualify any more.melvin wrote:The may choice is decided when it goes onto the stack, this is a house rule of Magarena.
"most choices are made when a spell or ability is put on the stack" -- https://code.google.com/p/magarena/wiki/GameRules
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Card Contributions
by melvin » 08 Aug 2014, 01:14
I think there is merit to doing it this way, but I'm open to suggestions for change.ShawnieBoy wrote:Does this still need to be the case?
The way I see it, the benefit of this design is that the associated target (if any) will not be chosen if the choice is no, reducing the number of options to consider. Eg. "you may destroy target creature"
The alternative is that the target must always be chosen, then in cases where the may choice is no, the extra decision to choose the target is wasted. This results in more steps for the player (less smooth gameplay), more decisions to make for the AI (lousier AI).
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Re: Card Contributions
by PalladiaMors » 08 Aug 2014, 02:35
I was trying to come up with a code for the card group "When you control no X, sacrifice this". I was looking at the list of groovy triggers but couldn't find anything that matches that, so I thought about asking you guys for help.
I figured out how to check for permanents of a type through Sarcomancy, and used the script as a base for a test Covetous Dragon. This is obviously not representing the card well because it just checks at the upkeep instead of constantly. I don't know if there is a trigger for that or not. In case there isn't, how would you guys feel about treating it as a static ability? This is also not quite adequate, since it's not a static ability but a triggered one that can trigger at any time, but in practice I believe that this would make very little difference. Only thing I can think about are cards that counter triggered abilities or activate on triggered abilities, but these are so rare - I can find only 4 such cards in the explorer.
I figured out how to check for permanents of a type through Sarcomancy, and used the script as a base for a test Covetous Dragon. This is obviously not representing the card well because it just checks at the upkeep instead of constantly. I don't know if there is a trigger for that or not. In case there isn't, how would you guys feel about treating it as a static ability? This is also not quite adequate, since it's not a static ability but a triggered one that can trigger at any time, but in practice I believe that this would make very little difference. Only thing I can think about are cards that counter triggered abilities or activate on triggered abilities, but these are so rare - I can find only 4 such cards in the explorer.
- Code: Select all
[
new MagicAtUpkeepTrigger() {
@Override
public MagicEvent executeTrigger(final MagicGame game,final MagicPermanent permanent,final MagicPlayer upkeepPlayer) {
return permanent.isController(upkeepPlayer) && game.getNrOfPermanents(MagicType.Artifact) == 0 ?
new MagicEvent(
permanent,
this,
"Sacrifice SN."
) :
MagicEvent.NONE;
}
@Override
public void executeEvent(final MagicGame game, final MagicEvent event) {
game.doAction(new MagicSacrificeAction(event.getPermanent()));
}
}
]
- PalladiaMors
- Posts: 343
- Joined: 12 Jul 2014, 17:40
- Has thanked: 36 times
- Been thanked: 22 times
Re: Card Contributions
by ShawnieBoy » 08 Aug 2014, 04:01
In the Elder Spawn example above, this wouldn't be creating more choices, just changing when the choice is made. The trigger should go onto the stack, then when it resolves it then asks "Do you want to sacrifice an Island?" then performs an event depending on the choice.melvin wrote:I think there is merit to doing it this way, but I'm open to suggestions for change.ShawnieBoy wrote:Does this still need to be the case?
The way I see it, the benefit of this design is that the associated target (if any) will not be chosen if the choice is no, reducing the number of options to consider. Eg. "you may destroy target creature"
The alternative is that the target must always be chosen, then in cases where the may choice is no, the extra decision to choose the target is wasted. This results in more steps for the player (less smooth gameplay), more decisions to make for the AI (lousier AI).
These would have to be Static abilities, kinda the inverse of the "SN gets <whatever> as long as you control a <whatever>" Or a variation on the 'Gain control, for as long as you control SN'. Most, if not all, are dealing with Abilities or Permanent States, none are triggering an event from them though.PalladiaMors wrote:I was trying to come up with a code for the card group "When you control no X, sacrifice this". I was looking at the list of groovy triggers but couldn't find anything that matches that, so I thought about asking you guys for help.
-
ShawnieBoy - Programmer
- Posts: 601
- Joined: 02 Apr 2012, 22:42
- Location: UK
- Has thanked: 80 times
- Been thanked: 50 times
Re: Card Contributions
by melvin » 08 Aug 2014, 04:20
Right, but I'm speaking more generally for all "you may do X". If we do it for the "X unless you do Y" type, where choice is in Y and Y is done during resolution, I think it is reasonable because:ShawnieBoy wrote:In the Elder Spawn example above, this wouldn't be creating more choices, just changing when the choice is made. The trigger should go onto the stack, then when it resolves it then asks "Do you want to sacrifice an Island?" then performs an event depending on the choice.
1. doing it this way for some "you may" and not others will be inconsistent
2. X unless you do Y where choice Y is done during resolution doesn't create wasted choices as you've pointed out
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Re: Card Contributions
by melvin » 08 Aug 2014, 04:31
Check outPalladiaMors wrote:I was trying to come up with a code for the card group "When you control no X, sacrifice this". I was looking at the list of groovy triggers but couldn't find anything that matches that, so I thought about asking you guys for help.
https://code.google.com/p/magarena/sour ... ths.groovy
https://code.google.com/p/magarena/sour ... nts.groovy
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Re: Card Contributions
by PalladiaMors » 10 Aug 2014, 05:49
I gave up on the above idea - I managed to code "when Covetous Dragon becomes an artifact, sacrifice it", but that was a little bit off. Thanks for trying to point the way to me, though, I was just too dumb to get it done.
Trying to combine Blanket of Night and Evil Presence to do Blood Moon (which would lead to other cards of that type such as Conversion, Glaciers). I came up with the script below. It's crashing on punctuation, I tried to remove/include comas here and there, but I can't get it right. I'm posting here because it feels like it's close, if I'm way off and this isn't the way to do it, never mind.
Trying to combine Blanket of Night and Evil Presence to do Blood Moon (which would lead to other cards of that type such as Conversion, Glaciers). I came up with the script below. It's crashing on punctuation, I tried to remove/include comas here and there, but I can't get it right. I'm posting here because it feels like it's close, if I'm way off and this isn't the way to do it, never mind.
- Code: Select all
[
new MagicStatic(
MagicLayer.Ability,
MagicTargetFilterFactory.NONBASIC_LAND
) {
@Override
public void modAbilityFlags(final MagicPermanent source, final MagicPermanent permanent, final Set<MagicAbility> flags) {
permanent.loseAllAbilities();
permanent.addAbility(new MagicTapManaActivation(MagicManaType.getList("{R}")));
},
new MagicStatic(
MagicLayer.Type,
MagicTargetFilterFactory.NONBASIC_LAND
) {
@Override
public void modSubTypeFlags(final MagicPermanent permanent, final Set<MagicSubType> flags) {
flags.clear();
flags.add(MagicSubType.Mountain);
}
}
]
- PalladiaMors
- Posts: 343
- Joined: 12 Jul 2014, 17:40
- Has thanked: 36 times
- Been thanked: 22 times
Re: Card Contributions
by melvin » 10 Aug 2014, 06:06
The groovy code is missing a closing curly brace '}'. There should two closing brace after the addAbility, the first one closes the block that started at modAbilityFlags, the second closes the block that started at new MagicStatic.
Below is the corrected version that loads successfully, not play tested though.
Below is the corrected version that loads successfully, not play tested though.
- Code: Select all
[
new MagicStatic(
MagicLayer.Ability,
MagicTargetFilterFactory.NONBASIC_LAND
) {
@Override
public void modAbilityFlags(final MagicPermanent source, final MagicPermanent permanent, final Set<MagicAbility> flags) {
permanent.loseAllAbilities();
permanent.addAbility(new MagicTapManaActivation(MagicManaType.getList("{R}")));
}
},
new MagicStatic(
MagicLayer.Type,
MagicTargetFilterFactory.NONBASIC_LAND
) {
@Override
public void modSubTypeFlags(final MagicPermanent permanent, final Set<MagicSubType> flags) {
flags.clear();
flags.add(MagicSubType.Mountain);
}
}
]
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Re: Card Contributions
by melvin » 10 Aug 2014, 06:22
I'm curious as to what you mean by "little bit off". Can you provide more details?PalladiaMors wrote:I managed to code "when Covetous Dragon becomes an artifact, sacrifice it", but that was a little bit off
I've tried it myself following the example of Dark Depths, and it seems to work well. You find it at https://code.google.com/p/magarena/sour ... gon.groovy
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Re: Card Contributions
by PalladiaMors » 10 Aug 2014, 12:49
I was a bit frustrated that I didn't manage to do it and ended up deleting the script. Basically the two references you gently indicated were cards that referred to themselves (Student of Elements gaining an ability and Dark Depths counting the number of counters). I don't know enough to change the script to refer to other permanents. "Little bit" was sarcasm, of course, I was completely off (I'm making fun of myself with that phrase, Melvin, for trying to do one thing and coming up with something completely different). Thanks for doing the card, I'll try to use it for the other stuff. Good job!
Edit: I'm trying to adapt the script for Conversion, but MagicTargetFilterFactory.MOUNTAIN is causing a crash. Is there a work around?
Edit: I'm trying to adapt the script for Conversion, but MagicTargetFilterFactory.MOUNTAIN is causing a crash. Is there a work around?
- PalladiaMors
- Posts: 343
- Joined: 12 Jul 2014, 17:40
- Has thanked: 36 times
- Been thanked: 22 times
Re: Card Contributions
by melvin » 10 Aug 2014, 13:45
Sure,PalladiaMors wrote:I'm trying to adapt the script for Conversion, but MagicTargetFilterFactory.MOUNTAIN is causing a crash. Is there a work around?
- Code: Select all
MagicTargetFilterFactory.singlePermanent("Mountain")
-
melvin - AI Programmer
- Posts: 1062
- Joined: 21 Mar 2010, 12:26
- Location: Singapore
- Has thanked: 36 times
- Been thanked: 459 times
Who is online
Users browsing this forum: No registered users and 9 guests