Sample of hardcoded cards?

If you have a question about the SVN and the code, or if you have code to propose then please post in this forum.
Do not post request here.

Sample of hardcoded cards?

Postby Shishio » Sat Dec 20, 2008 3:35 pm

Can we see a couple samples of hardcoded cards? Maybe how Mind Twist works, or how Aladdin's Lamp works etc? Just so we can see a sample of how the game recognizes the hardcode and if we card editors can get a closer relation to what we are working with or how a new function/action might help to be incorperated.

I'm not sure how difficult it is to use hardcode to translate into an auto= function, but I'm under the impression that there are enough of us to be able to cover coding ALL the cards so Wololo doesn't have to anymore and concentrate on the game itself. Being that way, hardcoding MOST cards will be obsolete. I know some cards with really strange rules (like flipping a coin etc.) will still need it, but we could get more auto= rules granted or multiple autos if Wololo can work more on the game and us on the cards, right?

I'm not sure if that's the direction it's supposed to be going, but I'd be willing to code tons of cards if it saves Wololo time on doing it.
Shishio
 
Posts: 64
Joined: Fri Dec 12, 2008 6:28 pm
Location: Zanesville, Oh

Re: Sample of hardcoded cards?

Postby wololo » Sun Dec 21, 2008 8:19 am

AllAbilities.h stores the code for most hardcoded abilities:
http://code.google.com/p/wagic/source/b ... bilities.h

MTGAbilitiy.cpp currently has a part of the parser, as well as the method that creates the Abilities according to the card id. Most of the time, this creates an object defined in AllAbilities.h and adds it to the list of Abilities in the game, but for instants and sorceries, it generally does some random stuff without bothering to create a new Ability and add it to the game.
Look especially for AbilityFactory::magicText and AbilityFactory::addAbilities
http://code.google.com/p/wagic/source/b ... bility.cpp

TargetChooser.cpp contains the parser for targets, and creates TargetChooser objects, which are the ones that help the application decide what target is valid or not. Look in particular for the class TargetChooserFactory
http://code.google.com/p/wagic/source/b ... hooser.cpp

When you add new hardcoded cards, you can ask yourself the following question:
- Is there another hardcoded card that does something similar ?
If so, should I simply copy/paste its code (generally the answer is NO), or try to create a new general class that can handle both cases (usually better) ? If I create a global class, how easy is it (and how interesting for users is it) to allow it to be manipulated through the parser and _cards.dat ?
If there is no similar hardcoded card, why is that ? The answer is generally that a deeper change in the code is required for these cards to work. An exemple is alternate costs (sacrifice, etc..) that require not only to code the card abilities themselves, but to code the associated GUI...


Here is the code for mind twist (MTGAbility.cpp).

Code: Select all
  case 1167: //Mind Twist
    {
      int xCost = spell->cost->getConvertedCost() - 1;
      for (int i = 0; i < xCost; i++){
        game->opponent()->game->discardRandom(game->opponent()->game->hand);
      }
      break;
    }
wololo
Site Admin
 
Posts: 3709
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Re: Sample of hardcoded cards?

Postby Shishio » Mon Dec 22, 2008 12:33 am

Wow, yeah, that is a bit to drink in all at once, but I do understand some of it by doing a few tutorials of other stuff for PSP.
Shishio
 
Posts: 64
Joined: Fri Dec 12, 2008 6:28 pm
Location: Zanesville, Oh

Re: Sample of hardcoded cards?

Postby wololo » Mon Dec 22, 2008 6:50 am

Shishio wrote:Wow, yeah, that is a bit to drink in all at once, but I do understand some of it by doing a few tutorials of other stuff for PSP.


This code has nothing related to the PSP. All the specific PSP code is in the JGE library. If you want to program specifically for the PSP, we have a few PSP specific bugs that you might want to look into, such as the fact that the psp crashes when put in sleep mode.

Coding the cards has nothing to do with the PSP, so if it's cards that you're interested in, you only need a good background in OO programming
wololo
Site Admin
 
Posts: 3709
Joined: Wed Oct 15, 2008 12:42 am
Location: Japan

Advertising


Return to SVN & Programmers' section

Who is online

Users browsing this forum: No registered users and 1 guest