protected Gem(ClarityEnum clarity, int baseStrength, int baseAgility, int baseVitality) { this.Clarity = clarity; this.BaseStrength = baseStrength; this.BaseAgility = baseAgility; this.BaseVitality = baseVitality; }
public override void Execute() { string[] commandArgs = this.Data.Split(';'); string weaponName = commandArgs[0]; int slotIndex = int.Parse(commandArgs[1]); string[] gemArgs = commandArgs[2].Split(); ClarityEnum clarity = (ClarityEnum)Enum.Parse(typeof(ClarityEnum), gemArgs[0], true); string gemName = gemArgs[1]; GemFactory gemFactory = new GemFactory(); IGem gem = gemFactory.CreateGem(clarity, gemName); this.Repository.Weapons .FirstOrDefault(w => w.Name == weaponName) .AddGem(slotIndex, gem); }
public IGem CreateGem(ClarityEnum clarity, string gemName) { Assembly assembly = Assembly.GetExecutingAssembly(); Type type = assembly.GetTypes().FirstOrDefault(t => t.Name == gemName); if (type == null) { throw new InvalidOperationException("Invalid Gem Type!"); } if (!typeof(IGem).IsAssignableFrom(type)) { throw new InvalidOperationException($"{type} is not a Gem!"); } return((IGem)Activator.CreateInstance(type, new object[] { clarity })); }
public Amethyst(ClarityEnum clarity) : base(clarity, 2, 8, 4) { }
public Ruby(ClarityEnum clarity) : base(clarity, 7, 2, 5) { }
public Emerald(ClarityEnum clarity) : base(clarity, 1, 4, 9) { }