public override bool Equals(System.Object obj) { if (obj == null) { return(false); } DefaultStorage <T> ds = obj as DefaultStorage <T>; if (ds == null) { return(false); } if (ds.GetDefault().GetType() != GetDefault().GetType()) { return(false); } if (ds.owner.GetType() != owner.GetType()) { return(false); } if (ds.owner.id != owner.id) { return(false); } if (!ds.dict.SequenceEqual(dict)) { return(false); } return(true); }
public readonly int id; // index of Owner in the CardGame list for its type public Owner(string name, int id) { // Use 0, "", and an empty PointMap for defaults intBins = new DefaultStorage <int>(0, this); stringBins = new DefaultStorage <string>("", this); pointBins = new DefaultStorage <PointMap>(new PointMap(new List <ValueTuple <string, string, int> >()), this); cardBins = new CardStorage(this); // Record the name and id this.name = name; this.id = id; }
/******* * Clone the objects to make a complete copy */ public DefaultStorage <T> Clone(Owner other) { var cloneDefaultT = GetDefault(); var ret = new DefaultStorage <T>(cloneDefaultT, other); foreach (var bin in dict.Keys) { if (dict[bin] is ICloneable c) { ret[bin] = (T)c.Clone(); } else { ret[bin] = dict[bin]; } } return(ret); }