Ejemplo n.º 1
0
        internal Entity InitializeEntity(EntityDetails details)
        {
            UnitType unitType = Utils.GetUnitTypeFromString(details.UnitType);

            switch (unitType)
            {
            case UnitType.Unit:
            {
                var unit = new Entity(details);
                return(unit);
            }

            case UnitType.Hero:
            {
                var hero = new Hero(details);
                return(hero);
            }

            case UnitType.Tower:
            {
                var tower = new Entity(details);
                return(tower);
            }

            default:
            {
                var groot = new Entity(details);
                return(groot);
            }
            }
        }
Ejemplo n.º 2
0
 public Entity(EntityDetails details)
 {
     this.UnitId        = details.UnitId;
     this.Team          = details.Team;
     this.UnitType      = Utils.GetUnitTypeFromString(details.UnitType);
     this.Position      = details.Position;
     this.AttackRange   = details.AttackRange;
     this.Health        = details.Health;
     this.MaxHealth     = details.MaxHealth;
     this.AttackDamage  = details.AttackDamage;
     this.MovementSpeed = details.MovementSpeed;
 }
Ejemplo n.º 3
0
 public Hero(EntityDetails details)
     : base(details)
 {
     this.SkillCountdowns  = details.CountDowns;
     this.Mana             = details.Mana;
     this.MaxMana          = details.MaxMana;
     this.Shield           = details.Shield;
     this.ManaRegeneration = details.ManaRegeneration;
     this.HeroType         = Utils.GetHeroTypeFromString(details.HeroType);
     this.IsVisible        = details.IsVisible == Constants.IsVisibleValue;
     this.ItemsOwned       = details.ItemsOwned;
 }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            string[] inputs;
            int      myTeam = int.Parse(Console.ReadLine());
            int      bushAndSpawnPointCount = int.Parse(Console.ReadLine()); // usefrul from wood1, represents the number of bushes and the number of places where neutral units can spawn

            for (int i = 0; i < bushAndSpawnPointCount; i++)
            {
                inputs = Console.ReadLine().Split(' ');
                string entityType = inputs[0]; // BUSH, from wood1 it can also be SPAWN
                int    x          = int.Parse(inputs[1]);
                int    y          = int.Parse(inputs[2]);
                int    radius     = int.Parse(inputs[3]);
            }
            int itemCount = int.Parse(Console.ReadLine()); // useful from wood2

            var items   = new List <Item>();
            var myItems = new Dictionary <int, List <Item> >();

            for (int i = 0; i < itemCount; i++)
            {
                inputs = Console.ReadLine().Split(' ');
                string itemName         = inputs[0];            // contains keywords such as BRONZE, SILVER and BLADE, BOOTS connected by "_" to help you sort easier
                int    itemCost         = int.Parse(inputs[1]); // BRONZE items have lowest cost, the most expensive items are LEGENDARY
                int    damage           = int.Parse(inputs[2]); // keyword BLADE is present if the most important item stat is damage
                int    health           = int.Parse(inputs[3]);
                int    maxHealth        = int.Parse(inputs[4]);
                int    mana             = int.Parse(inputs[5]);
                int    maxMana          = int.Parse(inputs[6]);
                int    moveSpeed        = int.Parse(inputs[7]); // keyword BOOTS is present if the most important item stat is moveSpeed
                int    manaRegeneration = int.Parse(inputs[8]);
                int    isPotion         = int.Parse(inputs[9]); // 0 if it's not instantly consumed

                var item = new Item()
                {
                    Name             = itemName,
                    Cost             = itemCost,
                    Damage           = damage,
                    Health           = health,
                    MaxHealth        = maxHealth,
                    Mana             = mana,
                    MaxMana          = maxMana,
                    MoveSpeed        = moveSpeed,
                    ManaRegeneration = manaRegeneration,
                    IsPotion         = isPotion == Constants.IsPotionValue
                };

                items.Add(item);
            }

            // game loop
            while (true)
            {
                var gameContext = new GameContext(myItems);
                int gold        = int.Parse(Console.ReadLine());
                int enemyGold   = int.Parse(Console.ReadLine());
                int roundType   = int.Parse(Console.ReadLine()); // a positive value will show the number of heroes that await a command
                int entityCount = int.Parse(Console.ReadLine());

                gameContext.MyGold      = gold;
                gameContext.EnemyGold   = enemyGold;
                gameContext.RoundType   = roundType;
                gameContext.EntityCount = enemyGold;
                gameContext.Items       = items;

                for (int i = 0; i < entityCount; i++)
                {
                    inputs = Console.ReadLine().Split(' ');
                    int    unitId           = int.Parse(inputs[0]);
                    int    team             = int.Parse(inputs[1]);
                    string unitType         = inputs[2]; // UNIT, HERO, TOWER, can also be GROOT from wood1
                    int    x                = int.Parse(inputs[3]);
                    int    y                = int.Parse(inputs[4]);
                    int    attackRange      = int.Parse(inputs[5]);
                    int    health           = int.Parse(inputs[6]);
                    int    maxHealth        = int.Parse(inputs[7]);
                    int    shield           = int.Parse(inputs[8]); // useful in bronze
                    int    attackDamage     = int.Parse(inputs[9]);
                    int    movementSpeed    = int.Parse(inputs[10]);
                    int    stunDuration     = int.Parse(inputs[11]); // useful in bronze
                    int    goldValue        = int.Parse(inputs[12]);
                    int    countDown1       = int.Parse(inputs[13]); // all countDown and mana variables are useful starting in bronze
                    int    countDown2       = int.Parse(inputs[14]);
                    int    countDown3       = int.Parse(inputs[15]);
                    int    mana             = int.Parse(inputs[16]);
                    int    maxMana          = int.Parse(inputs[17]);
                    int    manaRegeneration = int.Parse(inputs[18]);
                    string heroType         = inputs[19];            // DEADPOOL, VALKYRIE, DOCTOR_STRANGE, HULK, IRONMAN
                    int    isVisible        = int.Parse(inputs[20]); // 0 if it isn't
                    int    itemsOwned       = int.Parse(inputs[21]); // useful from wood1

                    var unitDetails = new EntityDetails()
                    {
                        UnitId        = unitId,
                        Team          = team,
                        UnitType      = unitType,
                        Position      = new Position(x, y),
                        AttackRange   = attackRange,
                        Health        = health,
                        MaxHealth     = maxHealth,
                        Shield        = shield,
                        AttackDamage  = attackDamage,
                        MovementSpeed = movementSpeed,
                        StunDuration  = stunDuration,
                        GoldValue     = goldValue,
                        CountDowns    = new List <int>()
                        {
                            countDown1, countDown2, countDown3
                        },
                        Mana             = mana,
                        MaxMana          = maxMana,
                        ManaRegeneration = manaRegeneration,
                        HeroType         = heroType,
                        IsVisible        = isVisible,
                        ItemsOwned       = itemsOwned
                    };

                    Entity entity = gameContext.InitializeEntity(unitDetails);

                    if (entity.UnitType == UnitType.Groot)
                    {
                        gameContext.Groots.Add(entity);
                    }
                    else
                    {
                        if (myTeam == entity.Team)
                        {
                            if (entity.UnitType == UnitType.Hero)
                            {
                                gameContext.MyHeroes.Add(entity as Hero);
                            }
                            else
                            {
                                gameContext.MyUnits.Add(entity);
                            }
                        }
                        else
                        {
                            if (entity.UnitType == UnitType.Hero)
                            {
                                gameContext.EnemyHeroes.Add(entity as Hero);
                            }
                            else
                            {
                                gameContext.EnemyUnits.Add(entity);
                            }
                        }
                    }
                }

                // Write an action using Console.WriteLine()
                // To debug: Console.Error.WriteLine("Debug messages...");


                // If roundType has a negative value then you need to output a Hero name, such as "DEADPOOL" or "VALKYRIE".
                // Else you need to output roundType number of any valid action, such as "WAIT" or "ATTACK unitId"
                gameContext.ProcessTurn();
            }
        }