Ejemplo n.º 1
0
        /// <summary>
        /// Decode a queued task from an encoded string
        /// </summary>
        /// <param name="data">Encoded string</param>
        /// <returns>Decoded task</returns>
        public static TQueue FromString(string data)
        {
            TQueue task = new TQueue();

            foreach (string attribute in data.Split(','))
            {
                string[] kvpair = attribute.Trim().Split(':');
                if (kvpair.Length != 2)
                {
                    continue;
                }

                switch (kvpair[0])
                {
                    case "Bid":
                        task.Bid = Convert.ToInt32(kvpair[1]);
                        break;
                    case "Gid":
                        task.Gid = Convert.ToInt32(kvpair[1]);
                        break;
                    case "TargetLevel":
                        task.TargetLevel = Convert.ToInt32(kvpair[1]);
                        break;
                    case "Status":
                        task.Status = kvpair[1];
                        break;
                    case "QueueType":
                        task.QueueType = (TQueueType)Enum.Parse(typeof(TQueueType), kvpair[1]);
                        break;
                    case "ExtraOptions":
                        task.ExtraOptions = kvpair[1];
                        break;
                    case "Paused":
                        task.Paused = Boolean.Parse(kvpair[1]);
                        break;
                }
            }

            return task;
        }
Ejemplo n.º 2
0
 public int testPossibleNow(int VillageID, TQueue Q)
 {
     var CV = TD.Villages[VillageID];
     if (CV.Buildings.ContainsKey(Q.Bid) && CV.Buildings[Q.Bid].Gid == Q.Gid && CV.Buildings[Q.Bid].Level != 0)
         return Buildings.CheckLevelFull(Q.Gid, CV.Buildings[Q.Bid].Level, CV.isCapital) ? -1 : 0;
     return testPossibleNewNow(TD.Tribe, TD.Villages, CV, Q.Gid, Q.Bid);
 }