예제 #1
0
 private void HandleGameActionFightSpellCastMessage(IAccount account, GameActionFightSpellCastMessage message)
 {
     SpellCasted?.Invoke(message);
 }
예제 #2
0
 private void OnSpellCasted(bool s)
 {
     RemoveEvents();
     SpellCasted?.Invoke(this, new SpellCastEvent(SpellId, s));
 }
예제 #3
0
        public IBattleAction OnPlayerAction(
            BattleUnitStack stackToAttack,
            IEnumerable <BattleUnitStack> yourArmy,
            IEnumerable <BattleUnitStack> enemyStacks
            )
        {
            Console.WriteLine($"{stackToAttack.Unit.GetType().Name} {stackToAttack.Number}");
            var enemyArmySize = enemyStacks.Count();
            var inputAction   = 0;

            while (inputAction < 1 || inputAction > 4)
            {
                Console.WriteLine("Your decision:");
                Console.WriteLine("1. Attack");
                Console.WriteLine("2. Spell");
                Console.WriteLine("3. Defence");
                Console.WriteLine("4. Await");
                var input = Console.ReadLine();
                int.TryParse(input, out inputAction);
            }

            switch (inputAction)
            {
            case 1:
                var inputAttack = 0;
                var iter        = 1;
                var attack      = new Attack(this, stackToAttack, yourArmy, enemyStacks);
                foreach (var stack in attack.Filter)
                {
                    Console.WriteLine($"{iter++}. {stack.Number} of {stack.Unit.GetType().Name}");
                }

                var input = Console.ReadLine();
                int.TryParse(input, out inputAttack);
                while (true)
                {
                    iter = 1;
                    foreach (var stack in attack.Filter)
                    {
                        if (iter == inputAttack)
                        {
                            var list = new List <BattleUnitStack>()
                            {
                                stack
                            };
                            list.AddRange(attack.Filter.Where(x => !x.Equals(stack)));
                            attack.OnTargetChoosed(list);
                            return(attack);
                        }

                        iter++;
                    }
                }

            case 2:
                var spell     = 0;
                var spellIter = 1;
                foreach (var spell_ in stackToAttack.Unit.Spells)
                {
                    Console.WriteLine($"{spellIter++}. {spell_.Name}");
                }

                var choosedSpell = Console.ReadLine();
                int.TryParse(choosedSpell, out spell);
                var nthSpell     = stackToAttack.Unit.Spells.Skip(spell - 1).First();
                var spellRefl    = nthSpell.GetConstructor(new[] { typeof(BattleUnitStack) });
                var createdSpell = (ISpell)spellRefl.Invoke(new object[] { stackToAttack });
                var spellAction  = new SpellCasted(this, createdSpell, yourArmy, enemyStacks);

                spell     = 0;
                spellIter = 1;
                foreach (var stack in spellAction.Filter)
                {
                    Console.WriteLine($"{spellIter++}. {stack.Number} of {stack.Unit.GetType().Name}");
                }

                var inputSpell = Console.ReadLine();
                int.TryParse(inputSpell, out spell);
                while (true)
                {
                    iter = 1;
                    foreach (var stack in spellAction.Filter)
                    {
                        if (iter == spell)
                        {
                            spellAction.OnTargetChoosed(new List <BattleUnitStack>()
                            {
                                stack
                            });
                            return(spellAction);
                        }

                        iter++;
                    }
                }

            case 3:
                return(new Defence(this, stackToAttack));

            case 4:
                return(new Await(this, stackToAttack));

            default:
                throw new Exception("?????????????????????????");
            }
        }