When should two Cards have the same unique number?
Post MTG Forge Related Programming Questions Here
Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins
4 posts
• Page 1 of 1
When should two Cards have the same unique number?
by Braids » 02 Jul 2011, 22:25
i'm experimenting with tweaking CardFactory to be more efficient. don't worry, Chris H. i won't commit before the beta.
at first glance, it seems sensible that each Card be given a unique ID every time by the Card constructor. this makes great sense to me. and that's what happens. except that certain copy operations also copy the unique ID. that baffles me. can anyone explain why or when this is a good idea?
is it so the card's identity is still accurate even when a copy of it has been placed on the stack?
i think not handling this correctly is why my prior efforts with CardFactory failed. not that i want to resurrect that code really. i just think it's the reason.
at first glance, it seems sensible that each Card be given a unique ID every time by the Card constructor. this makes great sense to me. and that's what happens. except that certain copy operations also copy the unique ID. that baffles me. can anyone explain why or when this is a good idea?
is it so the card's identity is still accurate even when a copy of it has been placed on the stack?
i think not handling this correctly is why my prior efforts with CardFactory failed. not that i want to resurrect that code really. i just think it's the reason.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. 

-
Braids - Programmer
- Posts: 556
- Joined: 22 Jun 2011, 00:39
- Location: Unknown. Hobby: Driving myself and others to constructive madness.
- Has thanked: 1 time
- Been thanked: 1 time
Re: When should two Cards have the same unique number?
by Rob Cashwalker » 03 Jul 2011, 01:44
The copy code is used in a number of places... At the very least, a card needs certain details copied every time it changes zones. I've always wondered if we couldn't just make the Card object cloneable, then the copy operation becomes part of the card object, instead of a function in CardFactory.
The Force will be with you, Always.
-
Rob Cashwalker - Programmer
- Posts: 2167
- Joined: 09 Sep 2008, 15:09
- Location: New York
- Has thanked: 5 times
- Been thanked: 40 times
Re: When should two Cards have the same unique number?
by Braids » 03 Jul 2011, 02:04
i've thought that myself. Card should be responsible for making copies of itself, either with a copy constructorRob Cashwalker wrote:. . . I've always wondered if we couldn't just make the Card object cloneable, then the copy operation becomes part of the card object, instead of a function in CardFactory.
public Card(Card x) or cloning
public Object clone()
my main question still remains. should two Card instances ever share a unique ID? if so, why? it seems like that's breaking some kind of unwritten rule.
"That is the dumbest thing I've ever seen." --Rob Cashwalker, regarding Innistrad double-sided cards. One of the first times he and I have ever agreed on something. 

-
Braids - Programmer
- Posts: 556
- Joined: 22 Jun 2011, 00:39
- Location: Unknown. Hobby: Driving myself and others to constructive madness.
- Has thanked: 1 time
- Been thanked: 1 time
Re: When should two Cards have the same unique number?
by Hellfish » 03 Jul 2011, 13:06
Last Known Information-copies is the only time Card instances should share a UniqueNumber,I believe.
So now you're
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
Screaming for the blood of the cookie monster
Evil puppet demon of obesity
Time to change the tune of his fearful ballad
C is for "Lettuce," that's good enough for me
-
Hellfish - Programmer
- Posts: 1297
- Joined: 07 Jun 2009, 10:41
- Location: South of the Pumphouse
- Has thanked: 110 times
- Been thanked: 169 times
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 38 guests