Example #1
0
        public void BackToDefaultTest()
        {
            DynamicDataType tcgCardType = new DynamicDataType("Unit",
                                                              bools: new string[] { "Instant" },
                                                              bytes: new string[] { "Fire Cost" },
                                                              ints: new string[] { "Health", "Attack", "Armor" });

            {
                DynamicDataEntry card = new DynamicDataEntry(tcgCardType);

                card.SetBool("Instant", false);

                card.SetByte("Fire Cost", 2);

                card.SetInt("Health", 100);
                card.SetInt("Attack", -7);
                card.SetInt("Armor", 8);

                DynamicDataClone clone1 = new DynamicDataClone(card);
                clone1.SetBool("Instant", true);
                clone1.SetInt("Health", 99);
                clone1.SetByte("Fire Cost", 3);

                DynamicDataClone clone2 = TestCloneFull(clone1);

                // now set health back to default and see if it gets networked properly
                clone1.SetInt("Health", 100);

                TestCloneStale(clone1, clone2);

                // reset instant and fire cost and see if they are networked right
                clone1.SetBool("Instant", false);
                clone1.SetByte("Fire Cost", 2);

                TestCloneStale(clone1, clone2);
            }
        }
Example #2
0
        public void TCGCardReadWriteTest()
        {
            DynamicDataType tcgCardType = new DynamicDataType("TCG Card",
                                                              bools: new string[] { "Instant" },
                                                              bytes: new string[] { "Fire Cost", "Water Cost", "Rock Cost", "Wind Cost" },
                                                              ints: new string[] { "Health", "Attack", "Armor" },
                                                              strings: new string[] { "Name", "Description" });

            {
                DynamicDataEntry card = new DynamicDataEntry(tcgCardType);

                card.SetBool("Instant", false);

                card.SetByte("Fire Cost", 2);
                card.SetByte("Water Cost", 0);
                card.SetByte("Rock Cost", 1);
                card.SetByte("Wind Cost", 7);

                card.SetInt("Health", 100);
                card.SetInt("Attack", -7);
                card.SetInt("Armor", 8);

                card.SetString("Name", "Silver Spear");
                card.SetString("Description", "A very straightforward card");

                DynamicDataClone clone1 = new DynamicDataClone(card);
                clone1.SetBool("Instant", true);
                clone1.SetByte("Water Cost", 2);
                clone1.SetByte("Rock Cost", 0);
                clone1.SetInt("Health", 99);
                clone1.SetString("Name", "Silver Spear Copy");

                DynamicDataClone clone2 = TestCloneFull(clone1);

                clone1.SetInt("Health", 50);

                TestCloneStale(clone1, clone2);

                clone1.SetInt("Attack", 8);
                clone1.SetByte("Water Cost", 3);

                TestCloneStale(clone1, clone2);
            }

            {
                DynamicDataEntry card = new DynamicDataEntry(tcgCardType);

                card.SetBool("Instant", false);

                card.SetByte("Fire Cost", 0);
                card.SetByte("Water Cost", 35);
                card.SetByte("Rock Cost", 1);
                card.SetByte("Wind Cost", 0);

                card.SetInt("Health", 0);
                card.SetInt("Attack", 99999);
                card.SetInt("Armor", -1);

                card.SetString("Name", "Guard Tower");
                card.SetString("Description", "This structure does a modest and reasonable amount of damage with its " +
                               "balanced attack level. This description is reasonably long as well and " +
                               "definitely isn't too long, certainly not too long in an attempt to test " +
                               "how the system handles splitting very long strings. No difficulties will" +
                               " be undertaken in the effort to reconstruct this string. Living on easy" +
                               " street is all we do here.");

                DynamicDataClone clone1 = new DynamicDataClone(card);
                clone1.SetBool("Instant", true);
                clone1.SetByte("Water Cost", 2);
                clone1.SetByte("Rock Cost", 0);
                clone1.SetInt("Health", 99);
                clone1.SetString("Description", "changed This structure does a modest and reasonable amount of damage with its " +
                                 "balanced attack level. This description is reasonably long as well and " +
                                 "definitely isn't too long, certainly not too long in an attempt to test " +
                                 "how the system handles splitting very long strings. No difficulties will" +
                                 " be undertaken in the effort to reconstruct this string. Living on easy" +
                                 " street is all we do here.");

                DynamicDataClone clone2 = TestCloneFull(clone1);

                clone1.SetInt("Health", 50);

                TestCloneStale(clone1, clone2);

                clone1.SetInt("Attack", 8);
                clone1.SetByte("Water Cost", 3);

                clone1.SetString("Description", "changed again and again This structure does a modest and reasonable amount of damage with its " +
                                 "balanced attack level. This description is reasonably long as well and " +
                                 "definitely isn't too long, certainly not too long in an attempt to test " +
                                 "how the system handles splitting very long strings. No difficulties will" +
                                 " be undertaken in the effort to reconstruct this string. Living on easy" +
                                 " street is all we do here.");

                TestCloneStale(clone1, clone2);
            }

            {
                DynamicDataEntry card = new DynamicDataEntry(tcgCardType);

                card.SetBool("Instant", false);

                card.SetByte("Fire Cost", 0);
                card.SetByte("Water Cost", 35);
                card.SetByte("Rock Cost", 1);
                card.SetByte("Wind Cost", 0);

                card.SetInt("Health", 0);
                card.SetInt("Attack", 99999);
                card.SetInt("Armor", -1);

                card.SetString("Name", "Guard Tower");
                card.SetString("Description", "This structure does a modest and reasonable amount of damage with its " +
                               "balanced attack level. This description is reasonably long as well and " +
                               "definitely isn't too long, certainly not too long in an attempt to test " +
                               "how the system handles splitting very long strings. No difficulties will" +
                               " be undertaken in the effort to reconstruct this string. Living on easy" +
                               " street is all we do here.");

                DynamicDataClone clone1 = new DynamicDataClone(card);
                clone1.SetBool("Instant", true);
                clone1.SetByte("Water Cost", 2);
                clone1.SetByte("Rock Cost", 0);
                clone1.SetInt("Health", 99);
                clone1.SetString("Name", "Guard Tower Copy");

                DynamicDataClone clone2 = TestCloneFull(clone1);

                clone1.SetInt("Health", 50);

                TestCloneStale(clone1, clone2);

                clone1.SetInt("Attack", 8);
                clone1.SetByte("Water Cost", 3);

                TestCloneStale(clone1, clone2);
            }
        }