It is currently 13 Sep 2025, 05:03
   
Text Size

The card class and the player class

Post MTG Forge Related Programming Questions Here

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

The card class and the player class

Postby Sloth » 30 Aug 2011, 13:22

My plan was to give keywords to players via continuous static abilities (Shroud, Hexproof, ?). This seems to be rather simple, since most of the structure is there already.

When I was working on this, I wondered if it would be helpful to get the card class and the player class in line as much as possible, mainly by adding isValid and hasProperty to the player class with the same syntax.

Is there any benefit in adding an ancestor class for both of them and overwrite functions like isValid, hasKeyword, canTarget, addDamage, ...?
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: The card class and the player class

Postby friarsol » 30 Aug 2011, 14:00

Yea I think there's a bunch of benefit in adding a parent class for Cards and Players. I'd call these "GameObjects" but that's not really a great name.
friarsol
Global Moderator
 
Posts: 7593
Joined: 15 May 2010, 04:20
Has thanked: 243 times
Been thanked: 965 times

Re: The card class and the player class

Postby Sloth » 30 Aug 2011, 14:14

friarsol wrote:Yea I think there's a bunch of benefit in adding a parent class for Cards and Players. I'd call these "GameObjects" but that's not really a great name.
I think "GameObjects" is not so bad.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: The card class and the player class

Postby Rob Cashwalker » 30 Aug 2011, 16:19

GameEntity?

Might also help to make Planeswalkers operate closer to the rules.
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: The card class and the player class

Postby Sloth » 30 Aug 2011, 16:55

Rob Cashwalker wrote:GameEntity?

Might also help to make Planeswalkers operate closer to the rules.
GameEntity might be better, because object actually has a meaning in the comprehensive rules.
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times

Re: The card class and the player class

Postby Sloth » 01 Sep 2011, 15:26

I've added the GameEntity class as parent of Card and Player class. There's a lot of room to expand and use it. I guess the targeting code can be done a little more elegant with this (I haven't looked that much at targeting though).
User avatar
Sloth
Programmer
 
Posts: 3498
Joined: 23 Jun 2009, 19:40
Has thanked: 125 times
Been thanked: 507 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 24 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 24 users online :: 0 registered, 0 hidden and 24 guests (based on users active over the past 10 minutes)
Most users ever online was 7967 on 09 Sep 2025, 23:08

Users browsing this forum: No registered users and 24 guests

Login Form