示例#1
0
        public static bool Remove(this PowerHistory powerHistory, Func <IPowerHistoryEntry, bool> p)
        {
            int count = powerHistory.Full.Count;

            var copy = new PowerHistory();

            powerHistory.Where(e => !p(e)).ForEach(e => copy.Add(e));

            powerHistory.Clear();
            powerHistory.AddRange(copy);
            return(count > powerHistory.Full.Count);
        }
示例#2
0
        public static void AddRangeFirst(this PowerHistory dest, PowerHistory src)
        {
            var tmp = new PowerHistory();

            tmp.AddRange(src);

            for (int i = 0; i < dest.Full.Count; ++i)
            {
                tmp.Add(dest.Full[i]);
            }

            dest.Clear();
            dest.AddRange(tmp);
        }
示例#3
0
        //public static string PrintBoard(this HearthNode state, XmlWriter x)
        //{
        //	var str = new StringBuilder();

        //	x.WriteTurn(state.Game);

        //	str.AppendLine("------------");
        //	str.AppendLine($"| Turn {state.Game.Turn} |");
        //	str.AppendLine("------------");
        //	str.AppendLine("-----------------------------------------------------------------------------------------------------");
        //	str.AppendLine(state.Game.FullPrint() + "-----------------------------------------------------------------------------------------------------");
        //	str.AppendLine($"{(state.Game.CurrentPlayer == state.Game.Player1 ? $"{state.Game.Player1.Hero.Card.Name}" : $"{state.Game.Player2.Hero.Card.Name}")} is thinking...");

        //	return str.ToString();
        //}

        /// <summary>
        /// Sorts this PowerHistory to match the HSReplay xml structure
        /// </summary>
        /// <param name="powerHistory"></param>
        public static void HSReplaySort(this PowerHistory powerHistory)
        {
            var first  = new PowerHistory();
            var second = new PowerHistory();

            foreach (IPowerHistoryEntry e in powerHistory.Full)
            {
                if (e.PowerType == PowerType.CREATE_GAME)
                {
                    first.Add(e);
                }

                else if (e.PowerType == PowerType.FULL_ENTITY)
                {
                    var fe = (PowerHistoryFullEntity)e;
                    if (fe.Entity.Tags[GameTag.CONTROLLER] == 1)
                    {
                        first.Add(e);
                    }

                    else if (fe.Entity.Tags[GameTag.CONTROLLER] == 2)
                    {
                        second.Add(e);
                    }
                }
            }

            powerHistory.Remove(e => first.Full.Contains(e) || second.Full.Contains(e));

            first.AddRange(second);
            second.Clear();
            second.AddRange(powerHistory);

            powerHistory.Clear();
            powerHistory.AddRange(first);
            powerHistory.AddRange(second);
        }