コード例 #1
0
        public void TroopFactorySetup()
        {
            troopTypes = new Dictionary <string, TroopType>();
            string    json   = "{ 'Id':1,'Name':'Monkey','Type':'Ground','Damage':'6','Health':'50','PreferredTarget':'Ground','Template':'Basic'}";
            TroopType monkey = TroopReader.ReadJson(json);

            troopTypes.Add(monkey.Name, monkey);
        }
コード例 #2
0
        public void CreateTroop_Valid()
        {
            Dictionary <string, TroopType> troopTypes = new Dictionary <string, TroopType>();
            string    json   = "{ 'Id':1,'Name':'Monkey','Type':'Ground','Damage':'6','Health':'50','PreferredTarget':'Ground','Template':'Basic'}";
            TroopType monkey = TroopReader.ReadJson(json);

            troopTypes.Add(monkey.Name, monkey);

            TroopFactory factory = new TroopFactory(troopTypes);
            Troop        t       = factory.Create("Monkey");

            Assert.AreEqual(t.Info, monkey);
            Assert.AreEqual(t.CurrentHealth, monkey.Health);
        }
コード例 #3
0
ファイル: MockTroopFactory.cs プロジェクト: TarlSS/RiseOfOz
        public static TroopFactory Create()
        {
            Dictionary <string, TroopType> troopTypes = new Dictionary <string, TroopType>();
            string monkeyJ  = "{ 'Id':1,'Name':'Monkey','Type':'Ground','Damage':'6','Health':'50','PreferredTarget':'Ground','Template':'Basic'}";
            string wizardJ  = "{ 'Id':2,'Name':'Wizard','Type':'Ground','Damage':'6','Health':'60','PreferredTarget':'All','Template':'Basic'}";
            string balloonJ = "{ 'Id':3,'Name':'Balloon','Type':'Air','Damage':'8','Health':'55','PreferredTarget':'Ground','Template':'Basic'}";
            string fmonkeyJ = "{ 'Id':4,'Name':'Flying Monkey','Type':'Air','Damage':'6','Health':'50','PreferredTarget':'Air','Template':'Subtype'}";

            troopTypes.Add("Monkey", TroopReader.ReadJson(monkeyJ));
            troopTypes.Add("Wizard", TroopReader.ReadJson(wizardJ));
            troopTypes.Add("Flying Monkey", TroopReader.ReadJson(fmonkeyJ));
            troopTypes.Add("Balloon", TroopReader.ReadJson(balloonJ));

            TroopFactory factory = new TroopFactory(troopTypes);

            return(factory);
        }