PDA

View Full Version : doomtrooper cards game



Paizo
13-06-2004, 06:16 PM
I would like to make a videogame on doomtrooper cards game.

the problem are the rules controls.
In this game there are obiously rules, no problem to make that; but a single card may ignore normal rules and make strange effect (this is legal).
What do you advice for the implementation of rules?
Note that the cards can be over 1000...

thanks

PS: sorry for my bad english :|

Mrwb
16-06-2004, 01:18 PM
First, I would create a card record containing all card stuff.
(I'm not sure what properties the cards in the game you're trying to create have, so I'm going for the MTG approch ;))


type
TCardProperties=record
//Basic card properties
Name: string;
Attack: byte;
Defence: byte;
xCost: byte; //unnamed mana cost
gCost: byte; //green mana cost
bCost: byte; //blue mana cost
rCost: byte; //red mana cost
bCost; byte; //Black mana cost
Type: byte; //Type of card: creature, enchantment etc.
CanTarget: boolean; //can the card target another card?
GameText: TStrings; //card text
CardBitmap: TBitmap; //card gfx
end;



You now have a record containing a card with the general attributes.
Then, you can create a card record containing variables which may alter
the general rules. For instance, in magic, there are cards that alter
the attributes (like deffence and attack) of other cards. Then you can just add/substract the
attack/defence of the target card when the given card is played. (hope that made sense)
The following demonstrates:



type
TCardSpecific=record
TargetCard: TCard;
Operator: byte; //0 for +, 1 for -
Attack: byte;
Defence: byte;
Kill: boolean; //kill the target card?
end;

Then, the basic card class would look like this:



type
TCard=class
ID: string; //Card ID
Alive: boolean; //is the card alive? (in play)
Properties: TCardProperties;
Specific: TCardSpecific;
Attack: boolean;
private
procedure AttackCard(Target: TCard);
public
procedure PlayCard;
procedure SaveCard(Filename: string);
procedure LoadCard(Filename: string);
end;

PlayCard would look something like this:



procedure TCard.PlayCard;
begin

if Properties.HasTarget then
begin
Specific.TargetCard=TargetCard;
if Properties.Operator=0 then
begin
TargetCard.Properties.Defence:=TargetCard.Properti es.Defence+Properties.Special.Defence;
TargetCard.Properties.Attack:=TargetCard.Propertie s.Attack+Properties.Special.Attack;
end
else
begin
TargetCard.Properties.Defence:=TargetCard.Properti es.Defence-Properties.Special.Defence;
TargetCard.Properties.Attack:=TargetCard.Propertie s.Attack-Properties.Special.Attack;
end
TargetCard.Alive:=Properties.Special.Kill;
end;
if Attack then
AttackCard(TargetCard);

end;



You can then write a simple editor that allows you to create cards and save them.

The gameloop would go something like this:
1. Wait until user selects a card to play. if selected, goto 2.
2. Check for special attributes. if it has special attrubutes, goto 3, else goto 4
3. Apply the special attributes to the game
4. Play the card and goto 1

This was writen in a hurry, so ignore typos etc ;)
I'll possibly add some more later, hope it helps :)

Paizo
03-11-2004, 05:10 PM
That's ok, thanks

But the problem are the rules!
In this game cards are allowed to go against normal rules.

e.g.: rules say " you can't attack your self"

a card say "you can attack your self if you have onother card in play"

The card should take effect.

But how to implement something like this i really don't know...

tux
03-11-2004, 05:44 PM
add another thing in the card record for a rule override, if the card has a rule then use it else use the global rule :)

{MSX}
03-11-2004, 07:02 PM
IMHO for this kind of game the best approach is the "event and query"(TM) (the name was just invented :P) so that cards are event guided and can query the system to know what they can do.
(i'm referring to magic too :P)

So let's say that a card X have "add +1/+1 when a red card is played", you should add a "hook" on the event relative to card playing, and in that event handler control if the card is red and do the powering up.

So the game goes:
- Player A play a card.
- The system ask to the cards "anyone cares if player A plays that card?" (by looking on the relative event table)
- The card X says "i care!" (by adding herself to the event table when it was played) and so the "add +1/+1" is triggered.

You can have all possible event. Card drawing, Card discarding, playing, creature dying, creature taking damages, life point losing, etc etc. The more events you prepare, the more card you can handle in your model (and the more code you will write, but not that much if you plan things well)

The same thing for each possible action.

Instead, when a creature X attack and player B uses it's creature Y to defend, Y ask X (with a query system) if he can block it. Y can reply with a standard answare (where you could handle things like flying, etc) or with a custom answare (that probably reduces to an overriden method, but that depends on how you implement things).

You can have lots of possibilities: quering a creature if it can attack, if it can take damage, if it can be played, ecc ecc, and the same for spells or whatever your game uses.

You should try to think about all possible cases and try to figure out a model that handles all.
I suggest to list some various cards (50 or 100 for example) and try and see if you can handle all them.

BTW DoomTrooper is the same as Mutant Chronicles ?

Paizo
16-11-2004, 10:44 AM
Doomtrooper is ambient in Mutant Chronicles universe.

{MSX}:

trikko told me about you, and i see also your senseless game and jabara stuff :D

Last time i was speaking with Trikko and come out the solution to use flags.
Is based on use a mask for contempled situation of play, so when a mask is verified the related function should be call.
For use this approach i have to write thousand of mask and function (cards are around 3000!)

Maybe i can better understand what you espose if you send me an email or a message in italian :oops:

K4Z
25-02-2005, 04:57 PM
Card games and rules handling is asked about quite alot . This may seem stupid at first but, let the players handle the rules. If something happens when a card comes into play, make the player have to do it.

I suggest having a look at MagicWorkstation. It's a program that lets players build Magic The Gathering decks and play them against other people online. The game part is set up just like in real life. Players play cards, handle there own life totals, tap there lands, attack with creatures, etc. The prgram it'self doesn't have rules coded in like, when the player attacks the program lowers the other players life total. Instead when one player attacks, the other player clicks is life and lowers it accordingly. Just like if they were playing face to face in real life.
You might think whats to stop someone changing there life to 100, well nothing. If in real life someone just decided to grab a hand full a tokens and give themselves 100 life, you'd just walk away.
So instead of killing yourself with writing code to automatically handle every single thing thats going on in the game, make options that allow the players to handle the rules.

Well unless you're trying to make something like MagicOnline, where you have tournaments,etc and play for real money, and real cards, where you absolutly cannot have someone cheating. but that's hell on the MagicOnline programmers, because they have to recode in all the 200+ new cards with every new block (every 4 months), and then try to fix up all the loose ends with wierd combos and stupid cards. With a new patch getting release all the time.
Hope all that makes sense.