Exemple #1
0
    void ConstructPlayerCardDatabase(JsonData CardData, List <Card> Database)
    {
        for (int i = 0; i < CardData.Count; i++)
        {
            int      id       = (int)CardData[i]["id"];
            string   title    = CardData[i]["title"].ToString();
            Faction  faction  = (Faction)System.Enum.Parse(typeof(Faction), CardData[i]["faction"].ToString(), true);
            CardType cardType = (CardType)System.Enum.Parse(typeof(CardType), CardData[i]["type"].ToString(), true);
            string   slug     = CardData[i]["slug"].ToString();

            if (cardType == CardType.Special)
            {
                Ability   magicCardAbility = (Ability)System.Enum.Parse(typeof(Ability), CardData[i]["ability"].ToString(), true);
                AffectRow rowToAffect      = (AffectRow)System.Enum.Parse(typeof(AffectRow), CardData[i]["affects"].ToString(), true);
                string    description      = CardData[i]["desc"].ToString();
                MagicCardFactory = new MagicCardFactory();
                //Add magic card to database
                Database.Add(MagicCardFactory.CreateMagicCard(id, title, cardType, faction, slug, magicCardAbility, rowToAffect, description));
            }
            else
            {
                int     attackValue = (int)CardData[i]["attackValue"];
                Ability cardAbility = (Ability)System.Enum.Parse(typeof(Ability), CardData[i]["ability"].ToString(), true);
                UnitCardFactory = new UnitCardFactory();
                //Add monster card to database
                Database.Add(UnitCardFactory.CreateUnitCard(id, title, cardType, faction, slug, attackValue, cardAbility));
            }
        }
    }
Exemple #2
0
 public Weather(int id, string title, CardType type, Faction faction, string slug, Ability ability, AffectRow rowToAffect, string description)
     : base(id, title, type, faction, slug, ability, rowToAffect, description)
 {
 }
Exemple #3
0
 public MagicCard(int id, string title, CardType type, Faction faction, string slug, Ability ability, AffectRow rowToAffect, string description) :
     base(id, title, type, faction, slug)
 {
     this.Ability     = ability;
     this.RowToAffect = rowToAffect;
     this.Description = description;
     FindToRowField();
 }
Exemple #4
0
        public MagicCard CreateMagicCard(int id, string title, CardType type, Faction faction, string slug, Ability ability, AffectRow rowToAffect, string description)
        {
            MagicCard magicCard = null;

            switch (ability)
            {
            case Ability.Weather:
                magicCard = new Weather(id, title, type, faction, slug, ability, rowToAffect, description);
                break;

            case Ability.ClearSkies:
                magicCard = new ClearSkies(id, title, type, faction, slug, ability, rowToAffect, description);
                break;

            default:
                break;
            }
            return(magicCard);
        }