Page 1 of 1

When should two Cards have the same unique number?

PostPosted: 02 Jul 2011, 22:25
by Braids
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.

Re: When should two Cards have the same unique number?

PostPosted: 03 Jul 2011, 01:44
by Rob Cashwalker
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.

Re: When should two Cards have the same unique number?

PostPosted: 03 Jul 2011, 02:04
by Braids
Rob 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.
i've thought that myself. Card should be responsible for making copies of itself, either with a copy constructor
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.

Re: When should two Cards have the same unique number?

PostPosted: 03 Jul 2011, 13:06
by Hellfish
Last Known Information-copies is the only time Card instances should share a UniqueNumber,I believe.