It is currently 09 Sep 2025, 21:40
   
Text Size

Card Contributions

Moderators: ubeefx, beholder, melvin, ShawnieBoy, Lodici, CCGHQ Admins

Re: Card Contributions

Postby 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

Postby 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.
User avatar
ShawnieBoy
Programmer
 
Posts: 601
Joined: 02 Apr 2012, 22:42
Location: UK
Has thanked: 80 times
Been thanked: 50 times

Re: Card Contributions

Postby 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.
User avatar
ShawnieBoy
Programmer
 
Posts: 601
Joined: 02 Apr 2012, 22:42
Location: UK
Has thanked: 80 times
Been thanked: 50 times

Re: Card Contributions

Postby 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
User avatar
melvin
AI Programmer
 
Posts: 1062
Joined: 21 Mar 2010, 12:26
Location: Singapore
Has thanked: 36 times
Been thanked: 459 times

Re: Card Contributions

Postby ShawnieBoy » 07 Aug 2014, 11:54

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
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.
User avatar
ShawnieBoy
Programmer
 
Posts: 601
Joined: 02 Apr 2012, 22:42
Location: UK
Has thanked: 80 times
Been thanked: 50 times

Re: Card Contributions

Postby melvin » 08 Aug 2014, 01:14

ShawnieBoy wrote:Does this still need to be the case?
I think there is merit to doing it this way, but I'm open to suggestions for change.

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).
User avatar
melvin
AI Programmer
 
Posts: 1062
Joined: 21 Mar 2010, 12:26
Location: Singapore
Has thanked: 36 times
Been thanked: 459 times

Re: Card Contributions

Postby 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.

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

Postby ShawnieBoy » 08 Aug 2014, 04:01

melvin wrote:
ShawnieBoy wrote:Does this still need to be the case?
I think there is merit to doing it this way, but I'm open to suggestions for change.

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).
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.

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.
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.
User avatar
ShawnieBoy
Programmer
 
Posts: 601
Joined: 02 Apr 2012, 22:42
Location: UK
Has thanked: 80 times
Been thanked: 50 times

Re: Card Contributions

Postby melvin » 08 Aug 2014, 04:20

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.
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:
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
User avatar
melvin
AI Programmer
 
Posts: 1062
Joined: 21 Mar 2010, 12:26
Location: Singapore
Has thanked: 36 times
Been thanked: 459 times

Re: Card Contributions

Postby melvin » 08 Aug 2014, 04:31

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.
Check out
https://code.google.com/p/magarena/sour ... ths.groovy
https://code.google.com/p/magarena/sour ... nts.groovy
User avatar
melvin
AI Programmer
 
Posts: 1062
Joined: 21 Mar 2010, 12:26
Location: Singapore
Has thanked: 36 times
Been thanked: 459 times

Re: Card Contributions

Postby 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.

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

Postby 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.
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);
        }
    }
]
User avatar
melvin
AI Programmer
 
Posts: 1062
Joined: 21 Mar 2010, 12:26
Location: Singapore
Has thanked: 36 times
Been thanked: 459 times

Re: Card Contributions

Postby melvin » 10 Aug 2014, 06:22

PalladiaMors wrote:I managed to code "when Covetous Dragon becomes an artifact, sacrifice it", but that was a little bit off
I'm curious as to what you mean by "little bit off". Can you provide more details?

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
User avatar
melvin
AI Programmer
 
Posts: 1062
Joined: 21 Mar 2010, 12:26
Location: Singapore
Has thanked: 36 times
Been thanked: 459 times

Re: Card Contributions

Postby 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?
PalladiaMors
 
Posts: 343
Joined: 12 Jul 2014, 17:40
Has thanked: 36 times
Been thanked: 22 times

Re: Card Contributions

Postby melvin » 10 Aug 2014, 13:45

PalladiaMors wrote:I'm trying to adapt the script for Conversion, but MagicTargetFilterFactory.MOUNTAIN is causing a crash. Is there a work around?
Sure,
Code: Select all
MagicTargetFilterFactory.singlePermanent("Mountain")
User avatar
melvin
AI Programmer
 
Posts: 1062
Joined: 21 Mar 2010, 12:26
Location: Singapore
Has thanked: 36 times
Been thanked: 459 times

PreviousNext

Return to Magarena

Who is online

Users browsing this forum: No registered users and 9 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 9 users online :: 0 registered, 0 hidden and 9 guests (based on users active over the past 10 minutes)
Most users ever online was 7303 on 15 Jul 2025, 20:46

Users browsing this forum: No registered users and 9 guests

Login Form