Goblin Charbelcher - (Discussion)

All code submission.

Goblin Charbelcher - (Discussion)

Postby hopefulcd » Sat Aug 14, 2010 12:12 pm

Advertising
Hi everyone. Recently I've been working on hardcoding Goblin Charbelcher into Wagic, and I've had both success and failure. So far, the list of positives and negatives for this card are as follows:

The positives
1) The card can correctly deal damage to the opponent
2) The card works good even when there are multiple copies of it on the battlefield at the same time.

The negatives
1) Since I couldn't figure out how to code in choosing a legal target, I set the opponent as the only target for the card.
2) The reordering of the revealed cards was very buggy. This was not properly implemented and still needs work.
3) The second time that you use a Goblin Charbelcher card, it doesn't work properly. You have to view/unview your library and advance phases in order for the card to reset itself. The third time that you try to use it, the card will do damage fine again.

Here's the code so far:

AllAbilities.h (The full file is attached)
Code: Select all
// 49771  -- Goblin Charbelcher
class AGoblinCharbelcher: public TargetAbility{
public:
  CardDisplay cd;
  ManaCost cost;
  int init;
  int nbcards;
  int dmg;

AGoblinCharbelcher(int id, MTGCardInstance * card) : TargetAbility(id,card) {
    int _cost[] = {Constants::MTG_COLOR_ARTIFACT, 3};
    cost = ManaCost(_cost,1);
    cd = CardDisplay(1, game, SCREEN_WIDTH/2, SCREEN_HEIGHT/2, NULL);
    int zones[] = {MTGGameZone::MY_LIBRARY};
    tc = NEW TargetZoneChooser(zones,1,source);
    dmg = 0;
    nbcards = 0;
    init = 0;
  }
 
  void Update(float dt){
    if (waitingForAnswer){
      if (!init){
   cd.resetObjects();
   int noLandYet = 1;
   nbcards = 0;
   game->currentlyActing()->getManaPool()->pay(& cost);
   MTGGameZone * library = game->currentlyActing()->game->library;
   
   while (noLandYet && nbcards < library->nb_cards)
   {
      MTGCardInstance * current =  game->currentlyActing()->game->library->cards[library->nb_cards - 1 - nbcards];
      
      if (current->hasType("Land"))
      {
         if(current->hasType("Mountain")) {dmg *= 2;}
         noLandYet = 0;
      }
      
      if (noLandYet)
      {
         nbcards++;
         dmg++;
      }
   }
   
   game->mLayers->stackLayer()->addDamage(source,game->players[1], dmg);
   source->tap();
   init = 1;
      }
      cd.Update(dt);
      //      cd.CheckUserInput(dt);
    }
  }

  void Render(float dt){
    if (waitingForAnswer){
      cd.Render();
    }
  }


  int fireAbility(){
   MTGLibrary * library = game->currentlyActing()->game->library;
   
   
   /*
   for(int i=0; i < nbcards; i++)
   {
      cd.AddCard(game->currentlyActing()->game->library->cards[i]);
      MTGCardInstance * card = library->removeCard(tc->getNextCardTarget());
      library->shuffleTopToBottom(1);
      library->addCard(card);
   }
   */
   
   
   init = 0;
   return 1;
  }

  int resolve(){return 1;};

  virtual ostream& toString(ostream& out) const
  {
    out << "AGoblinCharbelcher ::: cd : " << cd
   << " ; cost : " << cost
   << " ; nbcards  : " << nbcards
   << " ; dmg : " << dmg
   << " ; init : " << init
   << " (";
    return TargetAbility::toString(out) << ")";
  }
  AGoblinCharbelcher * clone() const{
    AGoblinCharbelcher * a =  NEW AGoblinCharbelcher(*this);
    a->isClone = 1;
    return a;
  }
};


MTGAbility.cpp (The full file is attached)
Code: Select all
//-- addon Mirrodin ---

   case 49771: //Goblin Charbelcher
   {
      game->addObserver(NEW AGoblinCharbelcher(_id, card));
      break;
   }


mtg.txt (This file is NOT attached, just add this card into the file.)
Code: Select all
[card]

name=Goblin Charbelcher
alias=49771

text={3}, {T}: Reveal cards from the top of your library until you reveal a land card. Goblin Charbelcher deals damage equal to the number of nonland cards revealed this way to target creature or player. If the revealed land card was a Mountain, Goblin Charbelcher deals double that damage instead. Put the revealed cards on the bottom of your library in any order.

mana={4}

type=Artifact

[/card]



(NOTE: You have to recompile Wagic after you edit the above files in order for the card to work.)

Any help or suggestions with coding this card would be very much appreciated. Thanks :)

[EDIT ABRA: moved topic to code submission]
Attachments
working.zip
(180.51 KiB) Downloaded 25 times
hopefulcd
 
Posts: 4
Joined: Sat May 22, 2010 7:51 pm

Re: Goblin Charbelcher - (Discussion)

Postby Zethfox » Sat Aug 14, 2010 3:42 pm

:D this is impressive, im going to have to dig into this later tonight...
Zethfox
 
Posts: 2814
Joined: Thu Jun 10, 2010 11:28 pm

Re: Goblin Charbelcher - (Discussion)

Postby Zethfox » Sun Aug 15, 2010 2:06 am

your on a much older revision then the current, meaning youll have to rightclick your wagthesource folder(of whatever you called it on your comp) and hit "SVN update" start with a fresh revision and manuelly reinsert your code again.

its hard to tell, tho i know by the code that it is working, theres no card display popping up for the cards that the opponent is reveal yet.

have you considered making this more generic? so the ability can be used for more then just charbelcher, look like with a few minor tweaks we could easyly make it work for mind funeral, charbelcher, and any card that reveals "until certain cards" are revealed" which would be a GREAT addition to the source.
Zethfox
 
Posts: 2814
Joined: Thu Jun 10, 2010 11:28 pm

Re: Goblin Charbelcher - (Discussion)

Postby sandman423 » Thu Sep 02, 2010 7:46 pm

So is it possible to get Mind Funeral or Cascade working?

Also Goblin Charbelcher would be awsome to put in the game for the Quick Kills, but It would be a pain to deal with if Comp use it.
sandman423
 
Posts: 462
Joined: Thu Sep 10, 2009 8:59 pm

Advertising


Return to Code submission

Who is online

Users browsing this forum: No registered users and 0 guests