Exemple #1
0
        private void CreatePlayer(int id)
        {
            Heroes.Core.Player player = new Heroes.Core.Player();
            player._id = id;
            player._wood = 20;
            player._mercury = 10;
            player._ore = 20;
            player._sulfur = 10;
            player._crystal = 10;
            player._gem = 10;
            player._gold = 20000;
            _players.Add(player);

            Random rnd = new Random();

            // hero
            Heroes.Core.Hero hero = (Heroes.Core.Hero)Heroes.Core.Setting._heros[id];
            hero._playerId = player._id;
            hero._player = player;
            hero._level = 1;
            hero._experience = rnd.Next(45, 99);
            hero.CalculateMaxSpellPoint();
            hero._spellPointLeft = hero._maxSpellPoint;
            hero._movementPoint = 1;
            hero._movementPointLeft = hero._movementPoint;
            player._heroes.Add(hero);

            // army
            {
                Heroes.Core.Army army = new Heroes.Core.Army();
                army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Pikeman]);
                army.AddAttribute(hero);
                army._heroId = hero._id;
                army._playerId = player._id;
                //army._qty = rnd.Next(20, 49);
                army._qty = rnd.Next(500, 999);
                army._slotNo = 1;
                hero._armyKSlots.Add(army._slotNo, army);

                army = new Heroes.Core.Army();
                army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Archer]);
                army.AddAttribute(hero);
                army._heroId = hero._id;
                army._playerId = player._id;
                //army._qty = rnd.Next(10, 19);
                army._qty = rnd.Next(500, 999);
                army._slotNo = 0;
                hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Griffin]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(10, 19);
                ////army._qty = rnd.Next(500, 999);
                //army._slotNo = 4;
                //hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Swordman]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(10, 19);
                ////army._qty = rnd.Next(500, 999);
                //army._slotNo = 5;
                //hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Cavalier]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(5, 9);
                ////army._qty = rnd.Next(500, 999);
                //army._slotNo = 2;
                //hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Monk]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(10, 19);
                ////army._qty = rnd.Next(500, 999);
                //army._slotNo = 6;
                //hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Angel]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(1, 4);
                ////army._qty = rnd.Next(500, 999);
                //army._slotNo = 3;
                //hero._armyKSlots.Add(army._slotNo, army);
            }

            // spells
            {
                Heroes.Core.Spell spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.MagicArrow]);
                spell.CalculateDamage(hero);
                hero._spells.Add(spell._id, spell);

                spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.Haste]);
                hero._spells.Add(spell._id, spell);
            }

            // castle
            {
                Heroes.Core.Town town = new Heroes.Core.Town();
                town._id = player._id;
                town._playerId = player._id;
                town._player = player;
                town._heroVisit = hero;
                player._castles.Add(town);

                // buildings
                {
                    Heroes.Core.Building building = new Heroes.Core.Building();
                    building.CopyFrom((Heroes.Core.Building)Heroes.Core.Setting._buildings[(int)Heroes.Core.BuildingIdEnum.VillageHall]);
                    town._buildingKIds.Add(building._id, building);

                    building = new Heroes.Core.Building();
                    building.CopyFrom((Heroes.Core.Building)Heroes.Core.Setting._buildings[(int)Heroes.Core.BuildingIdEnum.Tavern]);
                    town._buildingKIds.Add(building._id, building);

                    building = new Heroes.Core.Building();
                    building.CopyFrom((Heroes.Core.Building)Heroes.Core.Setting._buildings[(int)Heroes.Core.BuildingIdEnum.Fort]);
                    town._buildingKIds.Add(building._id, building);
                }
            }
        }
Exemple #2
0
        private bool CaptureMine(int count, int level)
        {
            // Few 1-4
            // Several 5-9
            // Pack 10-19
            // Lots 20-49
            // Horde 50-99
            // Throng 100-249
            // Swarm 250-499
            // Zounds 500-999
            // Legion 1000+

            Heroes.Core.Monster monster = new Heroes.Core.Monster();
            monster._id = 1;

            Random rnd = new Random();

            int totalQty = 0;

            if (level == 2)
                totalQty = rnd.Next(20, 49);
            if (level == 3)
                totalQty = rnd.Next(50, 99);
            else
                totalQty = rnd.Next(10, 19);
            totalQty *= (count + 1);

            int slots = rnd.Next(1, 5);
            int qtyPerSlot = totalQty / slots;

            int[] slotNos = null;
            Heroes.Core.Army army = null;
            if (slots == 1)
            {
                slotNos = new int[] { 3 };
            }
            else if (slots == 2)
            {
                slotNos = new int[] { 2, 4 };
            }
            else if (slots == 3)
            {
                slotNos = new int[] { 0, 3, 6 };
            }
            else if (slots == 4)
            {
                slotNos = new int[] { 0, 2, 4, 6 };
            }
            else if (slots == 5)
            {
                slotNos = new int[] { 0, 2, 3, 4, 6 };
            }

            foreach (int slotNo in slotNos)
            {
                army = new Heroes.Core.Army();
                army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Pikeman]);
                army._qty = qtyPerSlot;
                army._slotNo = slotNo;
                monster._armyKSlots.Add(army._slotNo, army);
            }

            return Battle(_currentHero, monster);
        }
Exemple #3
0
        private void InitPlayer(Heroes.Core.Player player, int startingHeroId)
        {
            player._wood = 20;
            player._mercury = 10;
            player._ore = 20;
            player._sulfur = 10;
            player._crystal = 10;
            player._gem = 10;
            player._gold = 20000;

            //player._wood = 10;
            //player._mercury = 0;
            //player._ore = 10;
            //player._sulfur = 0;
            //player._crystal = 0;
            //player._gem = 0;
            //player._gold = 10000;

            Random rnd = new Random();

            // hero
            Heroes.Core.Hero hero = (Heroes.Core.Hero)Heroes.Core.Setting._heros[startingHeroId];
            hero._playerId = player._id;
            hero._player = player;
            hero._level = 1;
            hero._experience = rnd.Next(45, 99);
            //hero._movementPoint = 1;
            hero._movementPoint = 2;
            hero._movementPointLeft = hero._movementPoint;
            player._heroes.Add(hero);

            // army
            {
                Heroes.Core.Army army = new Heroes.Core.Army();
                army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Pikeman]);
                army._heroId = hero._id;
                army._playerId = player._id;
                army._qty = rnd.Next(20, 49);
                //army._qty = rnd.Next(500, 999);
                army._slotNo = 1;
                hero._armyKSlots.Add(army._slotNo, army);

                army = new Heroes.Core.Army();
                army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Archer]);
                army._heroId = hero._id;
                army._playerId = player._id;
                army._qty = rnd.Next(10, 19);
                //army._qty = rnd.Next(500, 999);
                army._slotNo = 0;
                hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.RoyalGiffin]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(10, 19);
                //army._slotNo = 4;
                //hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Crusader]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(10, 19);
                //army._slotNo = 5;
                //hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Champion]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(5, 9);
                //army._slotNo = 2;
                //hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Zealot]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(10, 19);
                //army._slotNo = 6;
                //hero._armyKSlots.Add(army._slotNo, army);

                //army = new Heroes.Core.Army();
                //army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Archangel]);
                //army.AddAttribute(hero);
                //army._heroId = hero._id;
                //army._playerId = player._id;
                //army._qty = rnd.Next(1, 4);
                //army._slotNo = 3;
                //hero._armyKSlots.Add(army._slotNo, army);
            }

            // spells
            {
                Heroes.Core.Spell spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.MagicArrow]);
                hero._spells.Add(spell._id, spell);

                spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.IceBolt]);
                hero._spells.Add(spell._id, spell);

                spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.MeteorShower]);
                hero._spells.Add(spell._id, spell);

                spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.LightningBolt]);
                hero._spells.Add(spell._id, spell);

                spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.Implosion]);
                hero._spells.Add(spell._id, spell);

                spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.FireBall]);
                hero._spells.Add(spell._id, spell);

                spell = new Heroes.Core.Spell();
                spell.CopyFrom((Heroes.Core.Spell)Heroes.Core.Setting._spells[(int)Heroes.Core.SpellIdEnum.Inferno]);
                hero._spells.Add(spell._id, spell);
            }

            // artifacts
            //for (int i = 0; i < 20; i++)
            {
                GettingArtifactEventArg e2 = new GettingArtifactEventArg(Heroes.Core.Heros.ArtifactLevelEnum.Treasure);
                OnGettingArtifact(e2);

                if (e2._artifact != null)
                {
                    hero.AddArtifacts(e2._artifact);
                }
            }

            hero.CalculateAll();
            hero._spellPointLeft = hero._maxSpellPoint;

            // castle
            {
                Heroes.Core.Town town = new Heroes.Core.Town();
                town._id = player._id;
                town._playerId = player._id;
                town._player = player;
                town._heroVisit = hero;
                player._castles.Add(town);

                // buildings
                {
                    Heroes.Core.Building building = new Heroes.Core.Building();
                    building.CopyFrom((Heroes.Core.Building)Heroes.Core.Setting._buildings[(int)Heroes.Core.BuildingIdEnum.VillageHall]);
                    town._buildingKIds.Add(building._id, building);

                    building = new Heroes.Core.Building();
                    building.CopyFrom((Heroes.Core.Building)Heroes.Core.Setting._buildings[(int)Heroes.Core.BuildingIdEnum.Tavern]);
                    town._buildingKIds.Add(building._id, building);

                    building = new Heroes.Core.Building();
                    building.CopyFrom((Heroes.Core.Building)Heroes.Core.Setting._buildings[(int)Heroes.Core.BuildingIdEnum.Fort]);
                    town._buildingKIds.Add(building._id, building);
                }
            }
        }
Exemple #4
0
        private Heroes.Core.Monster CreateMonster(int[] armyLevels, int startingQtyIndex, int multiplier)
        {
            Heroes.Core.Monster monster = new Heroes.Core.Monster();
            monster._id = 1;

            Random rnd = new Random();

            // random monster level
            int levelIndex = rnd.Next(0, armyLevels.Length);
            int level = armyLevels[levelIndex];

            // create armyIds
            ArrayList ids = new ArrayList();
            Hashtable armies = Heroes.Core.Setting._armyKLevelKIds[level];
            foreach (int id in armies.Keys)
            {
                ids.Add(id);
            }

            int index = rnd.Next(0, ids.Count);
            int armyId = (int)ids[index];

            // random qty
            int totalQty = 0;
            {
                int qtyIndex = startingQtyIndex - levelIndex;   // less qty if higher level
                if (qtyIndex < 0) qtyIndex = 0;

                int minQty = 0;
                if (qtyIndex < _minQtys.Length) minQty = _minQtys[qtyIndex];
                else minQty = 99999;

                int maxQty = 0;
                if (qtyIndex < _minQtys.Length) maxQty = _maxQtys[qtyIndex];
                else maxQty = 99999;

                totalQty = rnd.Next(minQty, maxQty + 1);
                totalQty *= multiplier;
            }

            // random slot
            {
                int slots = 0;
                int qtyPerSlot = 0;

                // do until qty per slot is more than zero
                do
                {
                    slots = rnd.Next(1, 6);
                    qtyPerSlot = totalQty / slots;
                } while (qtyPerSlot <= 0);

                int[] slotNos = null;
                Heroes.Core.Army army = null;
                if (slots == 1)
                {
                    slotNos = new int[] { 3 };
                }
                else if (slots == 2)
                {
                    slotNos = new int[] { 2, 4 };
                }
                else if (slots == 3)
                {
                    slotNos = new int[] { 0, 3, 6 };
                }
                else if (slots == 4)
                {
                    slotNos = new int[] { 0, 2, 4, 6 };
                }
                else if (slots == 5)
                {
                    slotNos = new int[] { 0, 2, 3, 4, 6 };
                }

                foreach (int slotNo in slotNos)
                {
                    army = new Heroes.Core.Army();
                    army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[armyId]);
                    army._qty = qtyPerSlot;
                    army._slotNo = slotNo;
                    monster._armyKSlots.Add(army._slotNo, army);
                }
            }

            return monster;
        }
Exemple #5
0
        private bool CaptureMine(int count, int mineLevel)
        {
            Heroes.Core.Monster monster = new Heroes.Core.Monster();
            monster._id = 1;

            Random rnd = new Random();

            // random monster level
            int armyId = 0;
            int armyLevel = 0;
            {
                int[] armyIds = null;
                int[] armyLevels = null;

                if (mineLevel == 1)
                {
                    armyIds = new int[] { (int)Heroes.Core.ArmyIdEnum.Pikeman, (int)Heroes.Core.ArmyIdEnum.Halberdier,
                        (int)Heroes.Core.ArmyIdEnum.Archer, (int)Heroes.Core.ArmyIdEnum.Marksman };
                    armyLevels = new int[] { 1, 1, 2, 2 };
                }
                else if (mineLevel == 2)
                {
                    armyIds = new int[] {
                        (int)Heroes.Core.ArmyIdEnum.Griffin, (int)Heroes.Core.ArmyIdEnum.RoyalGiffin,
                        (int)Heroes.Core.ArmyIdEnum.Swordman, (int)Heroes.Core.ArmyIdEnum.Crusader };
                    armyLevels = new int[] { 3, 3, 4, 4 };
                }
                else if (mineLevel == 3)
                {
                    armyIds = new int[] { (int)Heroes.Core.ArmyIdEnum.Monk, (int)Heroes.Core.ArmyIdEnum.Zealot,
                        (int)Heroes.Core.ArmyIdEnum.Cavalier, (int)Heroes.Core.ArmyIdEnum.Champion,
                        (int)Heroes.Core.ArmyIdEnum.Angel, (int)Heroes.Core.ArmyIdEnum.Archangel };
                    armyLevels = new int[] { 5, 5, 6, 6, 7, 7 };
                }
                else
                {
                    armyIds = new int[] { (int)Heroes.Core.ArmyIdEnum.Pikeman };
                    armyLevels = new int[] { 1 };
                }

                int index = rnd.Next(0, armyIds.Length);
                armyId = armyIds[index];
                armyLevel = armyLevels[index];
            }

            // random qty
            int totalQty = 0;
            {
                int qtyIndex = 0;

                if (mineLevel == 2)
                    qtyIndex = count + 2 - armyLevel + 3;
                else if (mineLevel == 3)
                    qtyIndex = count + 2 - armyLevel + 5;
                else
                    qtyIndex = count + 2 - armyLevel + 1;

                if (qtyIndex < 0) qtyIndex = 0;

                int minQty = 0;
                if (qtyIndex < _minQtys.Length) minQty = _minQtys[qtyIndex];
                else minQty = 99999;

                int maxQty = 0;
                if (qtyIndex < _minQtys.Length) maxQty = _maxQtys[qtyIndex];
                else maxQty = 99999;

                totalQty = rnd.Next(minQty, maxQty);
            }

            // random slot
            {
                int slots = 0;
                int qtyPerSlot = 0;

                // do until qty per slot is more than zero
                do
                {
                    slots = rnd.Next(1, 6);
                    qtyPerSlot = totalQty / slots;
                } while (qtyPerSlot <= 0);

                int[] slotNos = null;
                Heroes.Core.Army army = null;
                if (slots == 1)
                {
                    slotNos = new int[] { 3 };
                }
                else if (slots == 2)
                {
                    slotNos = new int[] { 2, 4 };
                }
                else if (slots == 3)
                {
                    slotNos = new int[] { 0, 3, 6 };
                }
                else if (slots == 4)
                {
                    slotNos = new int[] { 0, 2, 4, 6 };
                }
                else if (slots == 5)
                {
                    slotNos = new int[] { 0, 2, 3, 4, 6 };
                }

                foreach (int slotNo in slotNos)
                {
                    army = new Heroes.Core.Army();
                    army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[armyId]);
                    army._qty = qtyPerSlot;
                    army._slotNo = slotNo;
                    monster._armyKSlots.Add(army._slotNo, army);
                }
            }

            StartingBattleEventArg e2 = new StartingBattleEventArg(this._currentHero, null, monster);
            OnStartingBattle(e2);

            return e2._success;
        }
Exemple #6
0
        public void ResurrectHero(Heroes.Core.Hero hero)
        {
            hero._armyKSlots.Clear();

            {
                Heroes.Core.Army army = new Heroes.Core.Army();
                army.CopyFrom((Heroes.Core.Army)Heroes.Core.Setting._armies[(int)Heroes.Core.ArmyIdEnum.Pikeman]);
                army.AddAttribute(hero);
                army._heroId = hero._id;
                army._playerId = hero._playerId;
                army._qty = 1;
                army._slotNo = 0;
                hero._armyKSlots.Add(army._slotNo, army);
            }
        }