Page 4 of 4

Re: Masticore

PostPosted: 17 Feb 2010, 16:37
by silly freak
this is not more than some debugging output, it should be okay. i can't tell you why exactly it happened if the files are there though...


these libs are available at code.google.com/p/google-collections/

Re: Masticore

PostPosted: 17 Feb 2010, 17:28
by Chris H.
zen wrote:How do I get these libs?

import com.google.common.base.Function;
import com.google.common.collect.ComputationException;
import com.google.common.collect.MapMaker;

they're coming up as unresolved
`
There should be a "google-collect-1.0.jar" file in the /res/lib/ folder. You may need to go back to the build path command and make sure that you include the google-collect-1.0.jar file.

Re: Masticore

PostPosted: 17 Feb 2010, 17:28
by DennisBergkamp
The google collections library should be included already though (in res/lib, or in the source rar I included I put it in /lib).
Just be sure to add it to your build path.

It seems you're very close to getting this thing working Zen :)

EDIT: seems like Chris just posted a few seconds before I did...

Re: Masticore

PostPosted: 19 Feb 2010, 02:57
by neil828
Masticore Dosent say that you dic at random you choose

Re: Masticore

PostPosted: 19 Feb 2010, 19:31
by zen
Hi all,
finally got to start programming cards after wasting infinite time on installation and setup issues. Much thanks to Dennis, sillyfreak, and Chris for their help.

so how bout that masticore...
cards.txt is pretty strait forward thanks to the implementation of the card interpreter the team has build, with regeneration, and creature_a to creature_b direct damage built in.

Masticore
4
Artifact Creature
Choose and discard a card during your upkeep, or sacrifice Masticore.
4/4
RegenerateMe:2
abDamageTgtC2:1


so the upkeep code is a little tricky, and needs one last hack i'd say before it works properly.
GameActionUtil.java

Code: Select all
private static void upkeep_Masticore()
      {
         final String player = AllZone.Phase.getActivePlayer();
         PlayerZone playZone = AllZone.getZone(Constant.Zone.Play, player);
         
         CardList list = new CardList(playZone.getCards());
         list = list.getName("Masticore");
         
         Ability ability;
         for (int i = 0; i < list.size(); i++)
         {
            final Card m = list.get(0);
            ability = new Ability(list.get(i), "0")
            {
               public void resolve()
               {   !!!need hack here!!!
                  AllZone.GameAction.discard(getTargetCard());
               }
            };// Ability
         Input runtime = new Input()
              {
                private static final long serialVersionUID = -4302110760957471033L;

              public void showMessage()
                {
                  stopSetNext(CardFactoryUtil.input_discard());
                }
              };
            ability.setStackDescription(player + "discards a card");
            AllZone.Stack.add(ability);
         }// for
      }//upkeep_Masticore
basically my question is: how do i retrieve the card that was set in the Input method later in the resolve method when it's time to get that card discarded, and also check if it's null in which case masticore needs to die?

Re: Masticore

PostPosted: 19 Feb 2010, 20:27
by DennisBergkamp
I got it working through this piece of code (mostly copied and pasted from Drekavac).

Code: Select all
private static void upkeep_Masticore()
    {
       final String player = AllZone.Phase.getActivePlayer();
       PlayerZone playZone = AllZone.getZone(Constant.Zone.Play, player);
       
       CardList list = new CardList(playZone.getCards());
       list = list.getName("Masticore");
       
       Ability ability;
       for (int i = 0; i < list.size(); i++)
       {
          final Card crd = list.get(i);
          
          final Input discard = new Input()
          {
             private static final long serialVersionUID = 2252076866782738069L;
            public void showMessage()
               {
                 AllZone.Display.showMessage(crd + " - Discard a card from your hand");
                 ButtonUtil.enableOnlyCancel();
               }
               public void selectCard(Card c, PlayerZone zone)
               {
                 if(zone.is(Constant.Zone.Hand))
                 {
                   AllZone.GameAction.discard(c);
                   stop();
                 }
                }
                public void selectButtonCancel()
                {
                  AllZone.GameAction.sacrifice(crd);
                  stop();
                }
           };//Input
           
          ability = new Ability(crd, "0")
          {
            public void resolve()
            {
              if(crd.getController().equals(Constant.Player.Human))
              {
                if(AllZone.Human_Hand.getCards().length == 0)
                  AllZone.GameAction.sacrifice(crd);
                else
                  AllZone.InputControl.setInput(discard);
              }
              else //comp
              {
                CardList list = new CardList(AllZone.Computer_Hand.getCards());
               
                if (list.size() != 0)
                   AllZone.GameAction.discard(list.get(0));
                else
                    AllZone.GameAction.sacrifice(crd);
              }//else
            }//resolve()
          };//Ability
          ability.setStackDescription(crd + " - sacrifice Masticore unless you discard a card.");
          AllZone.Stack.add(ability);
       }// for
    }//upkeep_Masticore

Re: Masticore

PostPosted: 20 Feb 2010, 13:01
by zen
Thanks for the masticore Dennis.
I learned a lot about message boxes and input from this.

Re: Masticore

PostPosted: 20 Feb 2010, 19:17
by DennisBergkamp
No probs! It was mostly Zerker's code though, he coded Drekavac :)

Re: Masticore

PostPosted: 21 Feb 2010, 04:42
by Rob Cashwalker
It was a fairly ambitious first attempt though.

Re: Masticore

PostPosted: 21 Feb 2010, 07:28
by zerker2000
I don't think I originally coded it; I do remember fixing its inputting while working on some part of comesIntoPlay handling(Drekvac used to force you to discard, and then suicide if the card was a creature).

Re: Masticore

PostPosted: 23 Feb 2010, 20:23
by mtgrares
Zen, Masticore is a very tough card to program, so you did very well. :-)

I think I coded Drekavac a long, long time ago but it doesn't really matter. :lol: