Exemplo n.º 1
0
        public RecycleVariables Clone(CardGame cg)
        {
            var ret = new RecycleVariables();

            ret.vars = CloneDictionary(cg);
            return(ret);
        }
Exemplo n.º 2
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            RecycleVariables other = obj as RecycleVariables;

            if (other == null)
            {
                return(false);
            }

            foreach (String key in vars.Keys)
            {
                var thistemp  = vars[key];
                var othertemp = other.vars[key];
                if (thistemp is int i)
                {
                    if (i != (int)othertemp)
                    {
                        Console.WriteLine("Ints not equal in vars"); return(false);
                    }
                }
                else if (thistemp is bool b)
                {
                    if (b != (bool)othertemp)
                    {
                        Console.WriteLine("Bool not equal in vars"); return(false);
                    }
                }
                else if (thistemp is string s)
                {
                    if (!s.Equals(othertemp as string))
                    {
                        Console.WriteLine("String not equal in vars"); return(false);
                    }
                }
                else if (thistemp is String[] sa)
                {
                    if (!sa.SequenceEqual(othertemp as String[]))
                    {
                        Console.WriteLine("String Arrays not equal in vars"); return(false);
                    }
                }
                else if (thistemp is Player p)
                {
                    if (!p.Equals(othertemp as Player))
                    {
                        Console.WriteLine("Player not equal in vars"); return(false);
                    }
                }
                else if (thistemp is List <Player> lp)
                {
                    if (!lp.SequenceEqual(othertemp as List <Player>))
                    {
                        Console.WriteLine("List Player not equal in vars"); return(false);
                    }
                }
                else if (thistemp is List <Team> lt)
                {
                    if (!lt.SequenceEqual(othertemp as List <Team>))
                    {
                        Console.WriteLine("List Team not equal in vars"); return(false);
                    }
                }
                else if (thistemp is Team t)
                {
                    if (!t.Equals(othertemp as Team))
                    {
                        Console.WriteLine("Team not equal in vars"); return(false);
                    }
                }
                else if (thistemp is Card c)
                {
                    if (!c.Equals(othertemp as Card))
                    {
                        Console.WriteLine("Card not equal in vars"); return(false);
                    }
                }
                else if (thistemp is List <Card> lc)
                {
                    if (!lc.SequenceEqual(othertemp as List <Card>))
                    {
                        Console.WriteLine("List Card not equal in vars"); return(false);
                    }
                }
                else if (thistemp is CardCollection cc)
                {
                    if (!cc.Equals(othertemp as CardCollection))
                    {
                        Console.WriteLine("CardCollection not equal in vars"); return(false);
                    }
                }
                else
                {
                    throw new NotImplementedException();
                }
            }


            // if (!other.vars.SequenceEqual(vars))
            //{  // UNFORTUNATELY NEED TO HARDCODE HOW TO DEAL WITH CERTAIN THINGS
            //return false; }

            return(true);
        }