It is currently 11 Sep 2025, 17:38
   
Text Size

When should two Cards have the same unique number?

Post MTG Forge Related Programming Questions Here

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

When should two Cards have the same unique number?

Postby 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.
"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. ;)
User avatar
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?

Postby 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.
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: When should two Cards have the same unique number?

Postby Braids » 03 Jul 2011, 02:04

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.
"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. ;)
User avatar
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?

Postby 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
User avatar
Hellfish
Programmer
 
Posts: 1297
Joined: 07 Jun 2009, 10:41
Location: South of the Pumphouse
Has thanked: 110 times
Been thanked: 169 times


Return to Developer's Corner

Who is online

Users browsing this forum: No registered users and 38 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 38 users online :: 0 registered, 0 hidden and 38 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 38 guests

Login Form