Exemple #1
0
        private void CreateCommand(Match match)
        {
            //<name>.create(<health>, <damage>, <war effect>, <attack>)
            //Cenko.create(30, 15, Kamikaze, Paris)
            var name      = match.Groups[1].Value;
            var health    = int.Parse(match.Groups[3].Value);
            var damage    = int.Parse(match.Groups[4].Value);
            var wareffect = match.Groups[5].Value;
            var attack    = match.Groups[6].Value;

            var WarEffect = warEffectFactory.CreateWarEffect(wareffect);

            var Attack = attackFactory.CreateWarEffect(attack);

            //string name, int health, int damage, WarEffects warEffect, AttackTypes groupAttackType
            var Group = new HackGroup(name, health, damage, WarEffect, Attack);

            data.AddGroup(Group);
        }
Exemple #2
0
        public void Run()
        {
            List <string> input = reader.Reader();

            while (input[1] != "apocalypse")
            {
                switch (input[1])
                {
                case "create":
                    string        name          = input[0];
                    int           health        = int.Parse(input[2]);
                    int           damage        = int.Parse(input[3]);
                    string        warEffectName = input[4];
                    WarEffectType effectType;
                    if (!System.Enum.TryParse(warEffectName, out effectType))
                    {
                        throw new ArgumentException("Could not parse string to Enum!");
                    }
                    string attackType = input[5];
                    Attack attack;
                    if (!System.Enum.TryParse(attackType, out attack))
                    {
                        throw new ArgumentException("Could not parse string to Enum type!");
                    }
                    var effect      = warEffectFactory.CreateWarEffect(effectType, false, false);
                    var hackerGroup = hacherGroupFactory.CreateGacherGroup(name, health, damage, true, effect, attack);
                    this.gameData.AddGameData(name, hackerGroup);
                    break;

                case "attack":
                    // Implement attacks ..... //
                    string attacker = input[0];
                    string attacked = input[2];
                    if (IsHacherGroupsAlive(attacker) && IsHacherGroupsAlive(attacked))
                    {
                        var attacherGroup = FindHacherGroupByName(attacker);
                        var victimGroup   = FindHacherGroupByName(attacked);

                        if (!attacherGroup.WarEffect.IsWarEffectTogled)
                        {
                            ShouldTriggerAttackerWarEffect(attacherGroup);
                        }
                        if (!victimGroup.WarEffect.IsWarEffectTogled)
                        {
                            ShouldTrigerVictimWarEffect(attacherGroup, victimGroup);
                        }
                        else
                        {
                            PerformAttack(attacherGroup, victimGroup);
                        }
                    }
                    break;

                case "status":
                    GetGameStatus();
                    UpdateHackerGroups();
                    break;

                case "akbar":
                    UpdateHackerGroups();
                    break;

                default:
                    throw new AggregateException("Input cannot be understood!");
                }

                input = reader.Reader();
            }
        }