public Arena(string name, FightRules fightRules, IHero hero, ICreature creature) : base(name) { this.fightRules = fightRules; this.creature = creature; this.hero = hero; }
internal static HeroState FindState(IHero hero) { if (HeroStateDictionary.ContainsKey(hero)) return HeroStateDictionary[hero]; throw new InvalidOperationException("Hero was not found in the registry."); }
public override void GiveReward(IHero hero) { if (hero.UpForceLevel()) { hero.GetItem(ListOfPowers[hero.ForceLevel - 1]); } }
internal static void Remove(IHero hero) { if (HeroStateDictionary.ContainsKey(hero)) HeroStateDictionary.Remove(hero); if (HeroList.Contains(hero)) HeroList.Remove(hero); }
public HeroViewModel CreateHeroViewModel(IHero heroItemDataSource, bool isExperienceEditor) { return(new HeroViewModel { HeroImages = heroItemDataSource.HeroImages, HeroTitle = new HtmlString(_glassHtml.Editable(heroItemDataSource, i => i.HeroTitle, new { EnclosingTag = "h2" })), IsExperienceEditor = isExperienceEditor }); }
private void DrawingCameraTower(GameTime gameTime, IHero Hero) { for (int i = 0; i < OPCameraTowers.Count; i++) { if (!((CameraTower)OPCameraTowers[i]).Enabled) { ((CameraTower)OPCameraTowers[i]).Draw(gameTime); } } }
public override string Execute() { string heroName = this.Args[1]; List <string> itemArgs = new List <string>(this.Args); IHero hero = (this.Manager as HeroManager).heroes[heroName]; return(this.Manager.AddItemToHero(itemArgs, hero)); }
public MatthiusSpell(IHero hero, int X, int Y, string imageFile) : base(hero, X, Y, imageFile) { var dict = new Dictionary <IMob, Action>(); var willDie = new List <IMob>(); foreach (var mob in Model.Mobs.Where(mob => mob.DestroyByMatthiusSpell)) { if (Useful.CheckTouch(mob, X, Y)) { willDie.Add(mob); continue; } dict.Add(mob, () => { if (mob.MX == X && mob.MY == Y) { mob.Destroy(); } }); mob.OnMoveStart += dict[mob]; } foreach (var mob in willDie) { mob.Destroy(); } foreach (var mob in Model.Mobs.Where(mob => Math.Abs(mob.X - X) <= 1 && Math.Abs(mob.Y - Y) <= 1)) { if (mob is PenguinMob && !mob.CurrentAnimation.IsMoving) { var direction = GetOppositeDirection(this, mob); if (direction != Keys.None) { mob.GoTo(direction); } break; } } OnDestroy += () => { var ItemStack = Model.ItemsMap[X, Y]; if (ItemStack.Count > 0 && ItemStack.Peek() is ThreeItem) { Model.ItemsMap[X, Y].Peek().Destroy(); } foreach (var act in dict) { act.Key.OnMoveStart -= act.Value; } }; }
public static Arena Apply(IHero hero) { if (!isBossDefeated) { Boss enemy = new Boss(); return new Arena(string.Format("Going for the {0}", BuildingName), new FightRules(1, 1), hero, enemy); } return null; }
private void CreateHero(EnumHeroes eHero) { MyHero = (IHero)heroFactroy.Create(eHero); MyHero.Ability = (IAbility)abilityFactory.Create(eHero); Debug.Log(MyHero.Health); MyHero.Attack(); MyHero.CastAbility(); MyHero.Death(); MyHero.Move(); MyHero.Resurection(); }
public override string Execute() { string heroName = base.Arguments[0]; string heroType = base.Arguments[1]; IHero hero = this.heroFactory.CreateHero(heroName, heroType); string result = base.Manager.AddHero(hero); return(result); }
public static void RegisterAndInitializeState(IHero hero) { if (HeroStateDictionary.ContainsKey(hero)) return; //When we add a new hero, we initialize a new empty state for it. var NewHeroState = new HeroState(hero); HeroList.Add(hero); HeroStateDictionary.Add(hero, NewHeroState); }
private async Task <bool> ThrowUnstableConcoction(IHero enemyHero, IHero target) { if (!await CheckSilence()) { return(false); } if (!await CheckImmuneToMagic(target) && target != this) { return(false); } var attakerMessages = Sender.CreateMessageContainer(); attakerMessages.Add(lang => lang.ALCHEMIST_YouHaveThrownUC); var enemyMessages = enemyHero.Sender.CreateMessageContainer(); enemyMessages.Add(lang => lang.ALCHEMIST_TheEnemyHasThrownUC); UnstableConcoctionActivated = false; UnstableConcoctionCD = UnstableConcoctionDefaultCD; if (base.GetRandomNumber(1, 100) > 15) { target.GetDamage(target.CompileMagicDamage(UnstableConcoctionDamage)); target.StunCounter += UnstableConcoctionCounter; attakerMessages.Add(lang => lang.ALCHEMIST_UC_HasExploded); enemyMessages.Add(lang => lang.ALCHEMIST_UC_HasExploded); if (target == this) { attakerMessages.Add(lang => lang.YouStunnedYourself); enemyMessages.Add(lang => lang.TheEnemyHasStunnedItself); } else { attakerMessages.Add(lang => lang.YouStunnedEnemy); enemyMessages.Add(lang => lang.TheEnemyStunnedYou); } } else { attakerMessages.Add(lang => lang.YouMissedTheEnemy); enemyMessages.Add(lang => lang.TheEnemyMissedYou); } await attakerMessages.SendAsync(); await enemyMessages.SendAsync(); UnstableConcoctionCounter = 0; hero_target = null; return(true); }
public IHero CreateHero(string name, string heroType) { Type type = Type.GetType(heroType); IHero newHero = (IHero)Activator.CreateInstance(type, new object[] { name }); if (newHero is null) { throw new ArgumentException(Constants.HeroTypeNotFound, heroType); } return(newHero); }
public void AttachHero(HeroSide side, IHero hero) { if (side == HeroSide.Bottom) { friendlyHero = hero; } else { enemyHero = hero; } }
public override string Execute() { string heroName = InputArgs.ElementAt(0); string heroType = InputArgs.ElementAt(1); IHero newHero = container.heroFactory.CreateHero(heroName, heroType); container.Heroes.Add(newHero); string resultMessage = string.Format(Constants.HeroCreateMessage, heroType, heroName); return(resultMessage); }
public void ObjectModified(IHero hero) { var damage = hero.HP - currentHP; currentHP = hero.HP; if (damage < 0) { BattleField.strLog += String.Format("\nHero {0} damaged on: {1}", hero.Name, damage); } //Console.WriteLine(String.Format("Hero {0} damaged on: {1}",hero.Name,damage)); }
public BaseCharacterObject(IHero hero) { if (hero == null) { return; } HeroObject = hero; IsPlayerCharacter = hero.IsHumanPlayerCharacter; Name = hero.Name; }
public void Initialize(IHero owner, Vector2 position) { this.Owner = owner; this.transform.position = position; this.SetState(MinionState.Idle); this.attackState = MinionAttackState.None; this.stats.health.Initialize(); this.healthBar.Initialize(this); this.buffs.Enabled = true; }
public static Arena Apply(IHero hero) { if (!isBossDefeated) { Boss enemy = new Boss(); return(new Arena(string.Format("Going for the {0}", BuildingName), new FightRules(1, 1), hero, enemy)); } return(null); }
private IHero GetHero(string heroName) { IHero hero = heroes.FirstOrDefault(h => h.Name.Equals(heroName, StringComparison.OrdinalIgnoreCase)); if (hero == null) { throw new ArgumentException(string.Format(Constants.InvalidHeroTypeExceptionMsg, heroName)); } return(hero); }
public void Apply(IHero targetHero) { Contract.Assert(targetHero != null, "targetHero!=null"); if (!targetHero.OnTickEndEffectByType.ContainsKey(_effectBuilder.EffectId)) { targetHero.OnTickEndEffectByType[_effectBuilder.EffectId] = _effectBuilder.GetEffectForHero(targetHero); } targetHero.OnTickEndEffectByType[_effectBuilder.EffectId].IsEnabled = true; }
public string AddHero(string[] args) { if (this.heroes.Any(h => h.Name == args[0])) { throw new Exception($"Hero with the name \"{args[0]}\" has already been added!"); } IHero hero = this.heroFactory.CreateHero(args); this.heroes.Add(hero); return $"{args[1]} {args[0]} has been added."; }
private void Hero_OnMove(IHero sender, MovingArgs args) { var coloredSender = sender as ColoredConsoleHero; if ((sender.PosX == this.PosX) & (sender.PosY == this.PosY)) { OnExplosion?.Invoke(this, new ExplosionEventArgs() { corpse = sender }); } }
public override string Execute() { string name = this.args[1]; if (this.manager.heroes.ContainsKey(name)) { IHero hero = this.manager.heroes[name]; return(this.manager.AddItemToHero(args, hero)); } return("Hero does not exist!"); }
public async override Task <bool> UseAbilityTwo(IHero target) { if (UnstableConcoctionActivated) { return(await ThrowUnstableConcoction(target, target)); } else { hero_target = target; return(await UseUnstableConcoction(target)); } }
private static void AssertCreateValidHero(IHeroFactory factory, string name, int strength, float superModeLikeliness) { IHero hero = factory.CreateNewHero(name, strength, superModeLikeliness); string call = $@"CreateNewHero(""{name}"", {strength}, {superModeLikeliness})"; Assert.That(hero, Is.Not.Null, $"{call} should not return null."); Assert.That(hero.Name, Is.EqualTo(name), $"{call} does not set name correctly."); Assert.That(hero.Strength, Is.EqualTo(strength), $"{call} does not set strength correctly."); Assert.That(hero.SuperModeLikeliness, Is.EqualTo(superModeLikeliness), $"{call} does not set supermode likeliness correctly."); Assert.That(hero.Health, Is.EqualTo(100), "Health should be 100."); }
public override void Execute() { string name = "Pesho"; HeroClass heroClass = HeroClass.Assasin; int healthPoints = 150; int dmgStartOfRange = 12; int dmgEndOfRange = 18; IHero hero = this.factory.CreateAssasin(name, heroClass, healthPoints, dmgStartOfRange, dmgEndOfRange); this.data.ListHeros.Add(hero); }
public override void Execute() { string name = "Genka"; HeroClass heroClass = HeroClass.Cleric; int healthPoints = 100; int dmgStartOfRange = 8; int dmgEndOfRange = 10; IHero hero = this.factory.CreateCleric(name, heroClass, healthPoints, dmgStartOfRange, dmgEndOfRange); this.data.ListHeros.Add(hero); }
public static void DrinkPotion(IHero hero) { if (hero.PotionsCount > 0) { hero.UsePotion(); Dialoge.UsedPotion(hero); } else { Dialoge.NoPotions(); } }
public override void Execute() { string name = "Gesho"; HeroClass heroClass = HeroClass.Warrior; int healthPoints = 150; int dmgStartOfRange = 15; int dmgEndOfRange = 20; IHero hero = this.factory.CreateWarrior(name, heroClass, healthPoints, dmgStartOfRange, dmgEndOfRange); this.data.ListHeros.Add(hero); }
public override async Task <bool> Attack(IHero target) { float damage = 0.0f; var attakerMessages = Sender.CreateMessageContainer(); var excepterMessages = target.Sender.CreateMessageContainer(); if (GetRandomNumber(1, 101) >= target.MissChance) { damage += this.DPS + this.AdditionalDamage; damage -= target.Armor; if (GetRandomNumber(1, 101) <= StunHitChance) { target.StunCounter++; damage += StunDamage; attakerMessages.Add(lang => $"{lang.StunningHit}!"); excepterMessages.Add(lang => $"{lang.TheEnemyStunnedYou}"); } if (GetRandomNumber(1, 101) <= CriticalHitChance) { damage *= CriticalHitMultiplier; attakerMessages.Add(lang => $"{lang.CriticalHit}!"); excepterMessages.Add(lang => lang.TheEnemyDealtCriticalDamageToYou); } if (FurySwipesCurrentAdditionalDamage + FurySwipesDamagePerHit <= FurySwipesDamageLimit) { FurySwipesCurrentAdditionalDamage += FurySwipesDamagePerHit; damage += FurySwipesCurrentAdditionalDamage; } else { damage += 100.0f; FurySwipesCurrentAdditionalDamage = 0.0f; } attakerMessages.Add(lang => lang.GetAttackedMessageForAttacker(Convert.ToInt32(damage))); excepterMessages.Add(lang => lang.GetAttackedMessageForExcepter(Convert.ToInt32(damage))); } else { attakerMessages.Add(lang => lang.YouMissedTheEnemy); excepterMessages.Add(lang => lang.TheEnemyMissedYou); } target.GetDamage(damage); HP += (damage / 100 * HpStealPercent) + HpStealAdditional; await attakerMessages.SendAsync(); await excepterMessages.SendAsync(); return(true); }
public void GetHero_Should_Return_Null() { // Arrange string connectionString = ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString; IGenericContext db = new JusticeLeague(connectionString); Repository repo = new Repository(db); // Act IHero sut = repo.GetHero(0); // Assert Assert.IsNull(sut); }
public string AddHero(IList <string> arguments) { string heroName = arguments[0]; string heroTypeName = arguments[1]; IHero hero = heroFactory.CreateHero(heroTypeName, heroName); this.heroes.Add(hero.Name, hero); string result = string.Format(Constants.HeroCreateMessage, hero.GetType().Name, hero.Name);; return(result); }
private static void ExecuteTurn(IHero hero) { var Action = hero.DetermineAction(); var Outcome = ActionValidator.ValidateAction(hero, Action); if (!Outcome.Success) { Action = new PassAction(); //Show message? } ActionExecutor.Execute(hero, Action); }
public void SwitchHero() { if (!heroEnumerator.MoveNext()) { heroEnumerator = Heroes.GetEnumerator(); if (!heroEnumerator.MoveNext()) { throw new Exception("No heroes in the model"); } } CurrentHero = heroEnumerator.Current; }
public static bool IsCastableByWarrior(IHero hero, ISpell spell) { return(spell is IWarrior); //if (spell is IWarrior) //{ // return true; //} //else //{ // return false; //} }
public IList<IJob> GenerateJobsFor(IHero hero) { return Jobs.Where(job => (job.JobFightRules == PhysicalWorkRules && job.JobLevel >= hero.ForceLevel - 1 && job.JobLevel <= hero.ForceLevel + 1) || (job.JobFightRules == HeadWorkRules && job.JobLevel >= hero.MentalLevel - 1 && job.JobLevel <= hero.MentalLevel + 1) || (job.JobFightRules == BallancedWorkRules && job.JobLevel >= ((hero.ForceLevel + hero.MentalLevel) / 2) - 1 && job.JobLevel <= ((hero.ForceLevel + hero.MentalLevel) / 2) + 1)) .OrderBy(rule => rule.JobFightRules.ToString()) .ThenBy(wage => wage.Wage) .ToList(); }
public void Sell(ICommercialItem commercialItem, IHero hero) { // If ninja have enough money to pay, he pays if (hero.PayCash(commercialItem.Price)) { // If ninja accepts the item he takes it if (hero.GetItem(commercialItem)) { int index = this.goods.IndexOf(commercialItem); this.goods.RemoveAt(index); var itemRecharge = commercialItem.Clone(); this.goods.Insert(index, itemRecharge as ICommercialItem); TurnOver += commercialItem.Price; } else { // Return money hero.GetCash(commercialItem.Price); } } }
protected override ICreature PickCreature(IHero hero) { return new Bot(hero.MentalLevel); }
public Arena Practice(IHero hero) { ICreature enemy = this.PickCreature(hero); return new Arena("Practicing", this.rules, hero, enemy); }
protected override ICreature PickCreature(IHero hero) { return new Assassin(hero.ForceLevel); }
public static void Execute(IHero hero, IAction action) { return; }
public void RewardNinja(IHero hero, IJob chosenJob) { int heroCashReward = chosenJob.Wage; hero.GetCash(heroCashReward); this.FightResult = string.Format("Congratulation hero is now working at {0}", chosenJob.ToString()); }
public Arena ApplyForJob(IHero hero, IJob chosenJob) { EvilCreature enemy = this.ChooseEnemy(chosenJob); return new Arena(string.Format("Fighting for '{0}' position", chosenJob.Possition), chosenJob.JobFightRules, hero, enemy); }
public static IOutcome ValidateAction(IHero hero, IAction action) { return Outcomes.Success(); }
public static void SetStrength(IHero hero, int value) { var HeroState = HeroRepository.FindState(hero); HeroState.Strength = value; }
protected abstract ICreature PickCreature(IHero hero);
public SwordDecorator(IHero hero) { _hero = hero; }
public IOutcome Validate(IHero hero) { return Outcomes.Success(); }
public abstract void GiveReward(IHero hero);
public HeroState(IHero hero) { this.m_Hero = hero; }
private void DrawingCameraTower(GameTime gameTime, IHero Hero) { for (int i = 0; i < OPCameraTowers.Count; i++) { if (!((CameraTower)OPCameraTowers[i]).Enabled) { ((CameraTower)OPCameraTowers[i]).Draw(gameTime); } } }