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)); }
protected Weapon(Rarity rarity, string name) { Rarity = rarity; Name = name; Strength = 0; Vitality = 0; Agility = 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; }
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); }
public IRarity CreateRarity(string rarityType) { Type rarity = Assembly.GetExecutingAssembly().GetTypes().FirstOrDefault(t => t.Name == rarityType); IRarity rarityInstance = (IRarity)Activator.CreateInstance(rarity); return(rarityInstance); }
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); }
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; }
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); }
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); }
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); }
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); } }
public Axe(string name, IRarity raritiy) : base(name, raritiy, axeMinDamage, axeMaxDamage, axeNmberOfSockets) { }
private void InsertInReferential(IRarity rarity) { _rarities.Add(rarity.Name, rarity); }
public Knife(string name, IRarity raritiy) : base(name, raritiy, knifeMinDamage, knifeMaxDamage, knifeNmberOfSockets) { }
public Sword(string name, IRarity raritiy) : base(name, raritiy, swordMinDamage, swordMaxDamage, swordNmberOfSockets) { }
public AxeWeapon(IRarity rarity, string name) : base(rarity: rarity, minDamage: 5, maxDamage: 10, numberOfSlots: 4, name: name) { }
public SwordWeapon(IRarity rarity, string name) : base(rarity, minDamage: 4, maxDamage: 6, numberOfSlots: 3, name: name) { }
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) { }