コード例 #1
0
        private Tuple <string, IRarity> ExtractExtraInfo(string url)
        {
            string extraHtml = WebUtility.HtmlDecode(_getExtraInfo(BaseUrl + url));

            Match m = _cardImageRegex.Match(extraHtml);

            if (!m.Success)
            {
                throw new ParserException("Could not find Card image in with " + url);
            }
            string pictureUrl = BaseUrl + m.Groups["url"].Value;

            m = _cardRarityRegex.Match(extraHtml);
            if (!m.Success)
            {
                throw new ParserException("Could not find Card rarity in with " + url);
            }
            string rarityString = m.Groups["rarity"].Value.Trim();

            if (rarityString.ToLower() == "mythic")
            {
                rarityString = "mythic rare";
            }
            else if (rarityString.ToLower() == "basic")
            {
                rarityString = "basic land";
            }
            IRarity rarity = MagicDatabase.GetRarity(rarityString);

            if (rarity == null)
            {
                throw new ParserException("Unknown rarity " + rarityString);
            }
            return(new Tuple <string, IRarity>(pictureUrl, rarity));
        }
コード例 #2
0
ファイル: Weapon.cs プロジェクト: KostadinovK/CSharp-OOP
 protected Weapon(Rarity rarity, string name)
 {
     Rarity   = rarity;
     Name     = name;
     Strength = 0;
     Vitality = 0;
     Agility  = 0;
 }
コード例 #3
0
 protected Weapon(string name, IRarity raritiy, int minDamage, int maxDamage, int numberOfSockets)
 {
     this.Name      = name;
     this.minDamage = minDamage;
     this.maxDamage = maxDamage;
     this.sockets   = new IGem[numberOfSockets];
     this.Raritiy   = raritiy;
 }
コード例 #4
0
 protected Weapon(IRarity rarity, int minDamage, int maxDamage, int numberOfSlots, string name)
 {
     this.baseMinDamage = minDamage;
     this.baseMaxDamage = maxDamage;
     slots       = new IGem[numberOfSlots];
     this.rarity = rarity;
     this.Name   = name;
 }
    public override void Execute(string[] args)
    {
        string[] weaponType = args[0].Split();
        IRarity  rarity     = rarityFactory.Create(weaponType[0]);
        IWeapon  weapon     = weaponFactory.Create(weaponType[1], args[1], rarity);

        Weapons.Add(weapon.Name, weapon);
    }
コード例 #6
0
        public IRarity CreateRarity(string rarityType)
        {
            Type rarity = Assembly.GetExecutingAssembly().GetTypes().FirstOrDefault(t => t.Name == rarityType);

            IRarity rarityInstance = (IRarity)Activator.CreateInstance(rarity);

            return(rarityInstance);
        }
コード例 #7
0
        public IWeapon CreateWeapon(IRarity rarity, string name, string type)
        {
            Type weaponType = Assembly.GetExecutingAssembly().GetTypes().FirstOrDefault(t => t.Name == type);

            IWeapon weapon = (IWeapon)Activator.CreateInstance(weaponType, new object[] { rarity, name });

            return(weapon);
        }
コード例 #8
0
 protected Weapon(IRarity rarity, string name, int socketsCount, int baseMinDmg, int baseMaxDmg)
 {
     Rarity          = rarity;
     Name            = name;
     SocketsCount    = socketsCount;
     sockets         = new IGem[SocketsCount];
     this.baseMinDmg = baseMinDmg;
     this.baseMaxDmg = baseMaxDmg;
 }
コード例 #9
0
        public IWeapon CreateWeapon(string typeAsString, string name, IRarity raritiy)
        {
            var type = Assembly
                       .GetExecutingAssembly()
                       .GetTypes()
                       .Where(t => t.Name == typeAsString)
                       .First();

            var instance = (IWeapon)Activator.CreateInstance(type, new object[] { name, raritiy });

            return(instance);
        }
    public IWeapon Create(string typeName, string name, IRarity rarity)
    {
        var type = FactoriesUtility.GetType(typeName + "Weapon");

        if (!typeof(IWeapon).IsAssignableFrom(type))
        {
            throw new ArgumentException("This type is not compatible");
        }

        IWeapon weapon = (IWeapon)Activator.CreateInstance(type, new object[] { rarity, name });

        return(weapon);
    }
    public IRarity Create(string typeName)
    {
        var type = FactoriesUtility.GetType(typeName + "Rarity");

        if (!typeof(IRarity).IsAssignableFrom(type))
        {
            throw new ArgumentException();
        }

        IRarity rarity = (IRarity)Activator.CreateInstance(type);

        return(rarity);
    }
コード例 #12
0
        public override void Execute()
        {
            string[] part1 = Data[1].Split();

            string rarityType = part1[0];
            string weaponType = part1[1];

            string weaponName = Data[2];

            IRarity rarity = rarityFactory.CreateRarity(rarityType);
            IWeapon weapon = weaponFactory.CreateWeapon(rarity, weaponName, weaponType);

            inventory.AddWeapon(weapon);
        }
コード例 #13
0
        public override void Execute(string[] input)
        {
            var weaponInfo = input[1].Split();

            var     weaponRarityAsString = weaponInfo[0];
            IRarity weaponRarity         = this.rarityFactory.CreateRarity(weaponInfo[0]);

            var weaponTypeAsString = weaponInfo[1];

            var weaponName = input[2];

            var weapon = this.weaponFactory.CreateWeapon(weaponTypeAsString, weaponName, weaponRarity);

            this.weaponRepository.Add(weapon);
        }
コード例 #14
0
        public int InsertNewCardEditionWithFakeGathererId(int idEdition, int idCard, int idRarity, string url)
        {
            using (new WriterLock(_lock))
            {
                IEdition edition = _editions.FirstOrDefault(e => e.Id == idEdition);
                IRarity  rarity  = _rarities.Values.FirstOrDefault(r => r.Id == idRarity);
                ICard    card    = _cardsbyId.GetOrDefault(idCard);

                if (rarity == null || card == null || edition == null)
                {
                    throw new ApplicationDbException("Data are not filled correctedly");
                }
                if (!edition.IsNoneGatherer())
                {
                    throw new ApplicationDbException("InsertNewCardEditionWithFakeGathererId could only used for NoneGatherer edition");
                }
                int existingIdGatherer = GetIdGatherer(card, edition);
                if (existingIdGatherer != 0)
                {
                    // could have been inserted by another thread
                    return(existingIdGatherer);
                }

                int idGatherer = GetNextFakeGathererId();

                CardEdition cardEdition = new CardEdition
                {
                    IdCard     = idCard,
                    IdGatherer = idGatherer,
                    IdEdition  = idEdition,
                    IdRarity   = idRarity,
                    Url        = url
                };

                AddToDbAndUpdateReferential(cardEdition, InsertInReferential);

                return(idGatherer);
            }
        }
コード例 #15
0
 public Axe(string name, IRarity raritiy)
     : base(name, raritiy, axeMinDamage, axeMaxDamage, axeNmberOfSockets)
 {
 }
コード例 #16
0
 private void InsertInReferential(IRarity rarity)
 {
     _rarities.Add(rarity.Name, rarity);
 }
コード例 #17
0
 public Knife(string name, IRarity raritiy)
     : base(name, raritiy, knifeMinDamage, knifeMaxDamage, knifeNmberOfSockets)
 {
 }
コード例 #18
0
ファイル: Sword.cs プロジェクト: NovaBG03/SoftUniExercises
 public Sword(string name, IRarity raritiy)
     : base(name, raritiy, swordMinDamage, swordMaxDamage, swordNmberOfSockets)
 {
 }
コード例 #19
0
 public AxeWeapon(IRarity rarity, string name) : base(rarity: rarity, minDamage: 5, maxDamage: 10, numberOfSlots: 4, name: name)
 {
 }
コード例 #20
0
 public SwordWeapon(IRarity rarity, string name) : base(rarity, minDamage: 4, maxDamage: 6, numberOfSlots: 3, name: name)
 {
 }
コード例 #21
0
 public Sword(IRarity rarity, string name) : base(rarity, name, MaxGems, MinDMG, MaxDMG)
 {
 }
 public KnifeWeapon(IRarity rarity, string name) : base(rarity, minDamage: 3, maxDamage: 4, numberOfSlots: 2, name: name)
 {
 }