public override string ToString()
        {
            string pl = $"InGameName = {InGameName}, Username = {Username}, Password = {Password}, Money = {Money}, Played Time = {PlayedTime}, Heroes:";

            Heroes.ForEach(h => pl += $"\n\t {h}");
            return(pl);
        }
Exemple #2
0
        public DotAData(string itemLocation, string heroLocation, string abilityLocation, string saveLocation = null)
        {
            Items  = Parseable.ParseItems <Item>(File.ReadAllLines(itemLocation)).Where(i => i.Valid).ToList();
            Heroes = Parseable.ParseItems <Hero>(File.ReadAllLines(heroLocation)).Where(h => h.Valid).ToList();

            //get the abilities and try to assign them to the heroes
            var abilities = Parseable.ParseItems <Ability>(File.ReadAllLines(abilityLocation));

            Heroes.ForEach(h => {
                foreach (var abilityName in h.AbilityList)
                {
                    var abilityMatch = abilities.FirstOrDefault(a => a.Name == abilityName);
                    if (abilityMatch != null)
                    {
                        h.Abilities.Add(abilityMatch);
                    }
                }

                //Try to assign the talents as well
                if (h.TalentList.Count() != 8)
                {
                    return;                            // 8 is what it should be
                }
                h.Talents.Add(new Talent()
                {
                    Level   = 10,
                    Option1 = abilities.FirstOrDefault(a => a.Name == h.TalentList[0])?.Effects.FirstOrDefault(),
                    Option2 = abilities.FirstOrDefault(a => a.Name == h.TalentList[1])?.Effects.FirstOrDefault()
                });
                h.Talents.Add(new Talent()
                {
                    Level   = 15,
                    Option1 = abilities.FirstOrDefault(a => a.Name == h.TalentList[2])?.Effects.FirstOrDefault(),
                    Option2 = abilities.FirstOrDefault(a => a.Name == h.TalentList[3])?.Effects.FirstOrDefault()
                });
                h.Talents.Add(new Talent()
                {
                    Level   = 20,
                    Option1 = abilities.FirstOrDefault(a => a.Name == h.TalentList[4])?.Effects.FirstOrDefault(),
                    Option2 = abilities.FirstOrDefault(a => a.Name == h.TalentList[5])?.Effects.FirstOrDefault()
                });
                h.Talents.Add(new Talent()
                {
                    Level   = 25,
                    Option1 = abilities.FirstOrDefault(a => a.Name == h.TalentList[6])?.Effects.FirstOrDefault(),
                    Option2 = abilities.FirstOrDefault(a => a.Name == h.TalentList[7])?.Effects.FirstOrDefault()
                });
            });

            if (!string.IsNullOrEmpty(saveLocation))
            {
                Save(saveLocation);
            }
        }
Exemple #3
0
        /// <summary>
        /// Part of the state machine.
        /// Runs when STATE = RUNNING &amp;&amp; NEXTSTEP = MAIN_READY
        /// </summary>
        public void MainReady()
        {
            if (History)
            {
                PowerHistory.Add(PowerHistoryBuilder.BlockStart(BlockType.TRIGGER, CurrentPlayer.Id, "", 1, 0));
            }

            Characters.ForEach(p =>
            {
                p.NumTurnsInPlay++;
                p.NumAttacksThisTurn = 0;
            });

            Heroes.ForEach(p =>
            {
                p.Controller.NumCardsDrawnThisTurn              = 0;
                p.Controller.NumCardsPlayedThisTurn             = 0;
                p.Controller.NumMinionsPlayedThisTurn           = 0;
                p.Controller.NumOptionsPlayedThisTurn           = 0;
                p.Controller.NumFriendlyMinionsThatDiedThisTurn = 0;
            });

            CurrentPlayer.Hero.IsExhausted       = false;
            CurrentPlayer.Hero.Power.IsExhausted = false;
            foreach (var e in CurrentPlayer.BoardZone)
            {
                e.IsSummoned  = false;
                e.IsExhausted = false;
            }

            // De-activate combo buff
            CurrentPlayer.IsComboActive = false;

            CurrentPlayer.NumMinionsPlayerKilledThisTurn         = 0;
            CurrentOpponent.NumMinionsPlayerKilledThisTurn       = 0;
            CurrentPlayer.NumFriendlyMinionsThatAttackedThisTurn = 0;
            NumMinionsKilledThisTurn = 0;
            CurrentPlayer.HeroPowerActivationsThisTurn = 0;

            CurrentPlayer.NumElementalsPlayedLastTurn = CurrentPlayer.NumElementalsPlayedThisTurn;
            CurrentPlayer.NumElementalsPlayedThisTurn = 0;

            if (History)
            {
                PowerHistory.Add(PowerHistoryBuilder.BlockEnd());
            }

            // set next step
            NextStep = Step.MAIN_START_TRIGGERS;
        }
Exemple #4
0
        /// <summary>
        /// Part of the state machine.
        /// Runs when STATE = RUNNING &amp;&amp; NEXTSTEP = FINAL_WRAPUP
        /// </summary>
        public void FinalWrapUp()
        {
            if (History)
            {
                PowerHistoryBuilder.BlockStart(Enums.BlockType.TRIGGER, Id, "", -1, 0);
            }

            Heroes.ForEach(p =>
            {
                if (p.Controller.PlayState == PlayState.LOSING || p.Controller.PlayState == PlayState.CONCEDED)
                {
                    p.Controller.PlayState          = PlayState.LOST;
                    p.Controller.Opponent.PlayState = PlayState.WON;
                }
            });

            if (History)
            {
                PowerHistoryBuilder.BlockEnd();
            }

            // set next step
            NextStep = Step.FINAL_GAMEOVER;
        }