Page 1 of 1

Adding cards pt. II

PostPosted: 23 Sep 2008, 16:31
by DennisBergkamp
I've been having fun adding some cards, I added in a bunch of Counterspells, Harrow (which still has some minor issues), Gaea's Blessing (except it doesn't shuffle itself back into the library yet when it gets put into the grave), Boomerang and some random (simple) creatures.
Most of the AI code for these cards is very limited (zero for the Counterspells), I'll try to add some, so that the AI can actually play some of these spells. Then I'll post them here on the forums.

What I would like to add are some creatures that have a triggered ability when they attack or deal combat damage (Shadowmage Infiltrator, Thieving Magpie, Hypnotic Specter, etc.). Does anyone know how to implement those?

Re: Adding cards pt. II

PostPosted: 23 Sep 2008, 19:12
by jpb
Currently the code for doing things at a specific time in mtg forge is done in that phase. Look how actions are taken during upkeep in GameActionUtil.java. These same type of checks would need to be done for the cards you want to implement. It's very ugly.

I would really like if in v2 all creatures, enchantments, artifacts, etc, and all play areas got notified whenever an event occurred with detailed info on the event; so have an event object which contains all the objects/info involved and what action each took, etc. This would allow the coding of cards like Hypnotic Specter to be very easy and bug free, ie.

Code: Select all
//Hypnotic Spector's discard ability
event_listener(Event event){
  //check if the event was combat damage
  if(event.action() == AllZone.Constants.combatDamage){
    //if it was combat damage check that this hypnotic spector was the source and that it hit the opponent (not one of the opponent's creatures/planeswalkers)
    if(event.source() == card && event.target().isPlayer()){
      //make player discard a card from there hand.
    }
  }
}
I plan on taking a look at the v2 alpha forge posted to see how the v2 will handle these type of abilities.

Re: Adding cards pt. II

PostPosted: 23 Sep 2008, 20:48
by DennisBergkamp
Ahh, yes I agree. These kind of checks wouldn't have to be made constantly, if it would be event-driven.

When/where did Forge post a V2 alpha, by the way?

P.S. It's funny, I just implemented Gerrard's Verdict. I guess the computer never ever draws land cards? He just "manifests" them somehow... I was just testing to see if my "gain 3 life" per land discard worked, but I could never ever get him to discard a land card (even though I played three GVs in a row).

Re: Adding cards pt. II

PostPosted: 24 Sep 2008, 00:52
by GandoTheBard
I think the computer rarely keeps land in hand. It simply plays them as soon as it gets them and it keeps hands with little or no land in them. Or as you said maybe it has a percentage chance to manifest a land each turn. I say a percentage because after hundreds of games I can say for certain that the computer does not always play a land each turn though it seems that it is rarely ever mana screwed unlike the human player who experiences mana screw of some form every 3rd game or so or every 2 in 5 if you are unlucky.

Re: Adding cards pt. II

PostPosted: 24 Sep 2008, 01:35
by jpb
In GameAction.java is why the computer doesn't get mana screwed. If you do not want this cheat enabled then set smoothLand to false and rebuild the project.

Code: Select all
//do this instead of shuffling Computer's deck
    boolean smoothLand = true;

    if(smoothLand)
    {
      Card[] c = smoothComputerManaCurve(AllZone.Computer_Library.getCards());
      AllZone.Computer_Library.setCards(c);
    }
    else
    {
      AllZone.Computer_Library.setCards(AllZone.Computer_Library.getCards());
      this.shuffle(Constant.Player.Computer);
    }
Here is the smoothComputerManaCurve

Code: Select all
  //this is where the computer cheats
  //changes AllZone.Computer_Library
  private Card[] smoothComputerManaCurve(Card[] in)
  {
    CardList library = new CardList(in);
    library.shuffle();

    //remove all land
    CardList land = library.getType("Land");
    for(int i = 0; i < land.size(); i++)
      library.remove(land.get(i));

    //non-basic lands are removed, because the computer doesn't seem to
    //effectively used them very well
    land = threadLand(land);

    //mana weave, total of 7 land
    library.add(7, land.get(0));
    library.add(8, land.get(1));
    library.add(9, land.get(2));
    library.add(10, land.get(3));
    library.add(11, land.get(4));

    //add the rest of land to the end of the deck
    for(int i = 0; i < land.size(); i++)
      if(! library.contains(land.get(i)))
      library.add(land.get(i));

/*
    //check
    for(int i = 0; i < 12; i++)
      System.out.println(library.get(i));
*/
    return library.toArray();
  }//smoothComputerManaCurve()

Re: Adding cards pt. II

PostPosted: 24 Sep 2008, 02:41
by GandoTheBard
Oooh so it effectively stacks the deck...well that explains the amazing land draws. But thats not always a good thing. For a deck like Stompy where you only really need 3-4 lands a land every turn means you are missing good creature drops after the first 3 or 4 turns. Now Stompy can kill pretty quickly but in all thats a deck where smooth land draw isnt as good as clumped draws.

Anyway it would be nice if there was a way for someone who doesnt want to deal with code diving/compiling to set the cheat on or off (Ini file?). And maybe have it work for both players instead of just the computer. I mean its not as much of a cheat if its fairly done.