It is currently 27 Apr 2024, 06:51
   
Text Size

Masticore

Post MTG Forge Related Programming Questions Here

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Re: Masticore

Postby silly freak » 17 Feb 2010, 16:37

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/
___

where's the "trust me, that will work!" switch for the compiler?
Laterna Magica - blog, forum, project, 2010/09/06 release!
silly freak
DEVELOPER
 
Posts: 598
Joined: 26 Mar 2009, 07:18
Location: Vienna, Austria
Has thanked: 93 times
Been thanked: 25 times

Re: Masticore

Postby Chris H. » 17 Feb 2010, 17:28

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.
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Masticore

Postby DennisBergkamp » 17 Feb 2010, 17:28

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...
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Masticore

Postby neil828 » 19 Feb 2010, 02:57

Masticore Dosent say that you dic at random you choose
neil828
 
Posts: 1
Joined: 19 Feb 2010, 02:39
Has thanked: 0 time
Been thanked: 0 time

Re: Masticore

Postby zen » 19 Feb 2010, 19:31

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?
zen
 
Posts: 27
Joined: 13 Feb 2010, 19:21
Has thanked: 0 time
Been thanked: 0 time

Re: Masticore

Postby DennisBergkamp » 19 Feb 2010, 20:27

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
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Masticore

Postby zen » 20 Feb 2010, 13:01

Thanks for the masticore Dennis.
I learned a lot about message boxes and input from this.
zen
 
Posts: 27
Joined: 13 Feb 2010, 19:21
Has thanked: 0 time
Been thanked: 0 time

Re: Masticore

Postby DennisBergkamp » 20 Feb 2010, 19:17

No probs! It was mostly Zerker's code though, he coded Drekavac :)
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Masticore

Postby Rob Cashwalker » 21 Feb 2010, 04:42

It was a fairly ambitious first attempt though.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Masticore

Postby zerker2000 » 21 Feb 2010, 07:28

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).
O forest, hold thy wand'ring son
Though fears assail the door.
O foliage, cloak thy ravaged one
In vestments cut for war.


--Eladamri, the Seed of Freyalise
zerker2000
Programmer
 
Posts: 569
Joined: 09 May 2009, 21:40
Location: South Pasadena, CA
Has thanked: 0 time
Been thanked: 0 time

Re: Masticore

Postby mtgrares » 23 Feb 2010, 20:23

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:
mtgrares
DEVELOPER
 
Posts: 1352
Joined: 08 Sep 2008, 22:10
Has thanked: 3 times
Been thanked: 12 times

Previous

Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 91 guests


Who is online

In total there are 91 users online :: 0 registered, 0 hidden and 91 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 91 guests

Login Form