Esempio n. 1
0
        public static void GetBuildings(Session session, string bodyID)
        {
            JsonTextWriter req = session.Request("get_buildings",
                                           session.cache.session_id,
                                           bodyID);

              if (session.Post(URL,req) == 0)
              {
            Response.Result result = session.response.result as Response.Result;

            IEnumerator b = result.buildings.GetEnumerator();

            Infrastructure buildings = new Infrastructure();

            buildings.date = result.status.server.time;  // save server time

            while (b.MoveNext())
            {
              KeyValuePair<string,Response.Result.Building> k =
            (KeyValuePair<string,Response.Result.Building>) b.Current;

              k.Value.id = k.Key;

              buildings.Add(k.Value);
            }

            string filename = String.Format("{0}.xml",result.status.body.name);

            XmlSerializer serializer = new XmlSerializer(typeof(Infrastructure));
            Stream stream = new FileStream(filename,FileMode.Create);
            serializer.Serialize(stream,buildings);
            stream.Close();
              }
        }
Esempio n. 2
0
        public static void Abandon(Session session, string bodyID)
        {
            JsonTextWriter req = session.Request("abandon",
                                           session.cache.session_id,
                                           bodyID);

              session.Post(URL,req);
        }
Esempio n. 3
0
        public static void GetBuildable(Session session, string bodyID, string x, string y, string tag)
        {
            JsonTextWriter req = session.Request("get_buildable",
                                           session.cache.session_id,
                                           bodyID,x,y,tag);

              session.Post(URL,req);
        }
Esempio n. 4
0
        public static void Rename(Session session, string bodyID, string name)
        {
            JsonTextWriter req = session.Request("rename",
                                           session.cache.session_id,
                                           bodyID,name);

              session.Post(URL,req);
        }
Esempio n. 5
0
        public static void GetStatus(Session session, string bodyID)
        {
            JsonTextWriter req = session.Request("view",
                                           session.cache.session_id,
                                           bodyID);

              session.Post(URL,req);
        }
        public static void BuildHalls(Session session, string buildingID, int save)
        {
            int count,total=0;

            foreach (string [] glyph in HallRecipe)
            {
                count = Math.Min(Math.Min(((Stack<string>) glyphs[glyph[0]]).Count,
                                      	((Stack<string>) glyphs[glyph[1]]).Count),
              	           	 Math.Min(((Stack<string>) glyphs[glyph[2]]).Count,
                                      	((Stack<string>) glyphs[glyph[3]]).Count));

                for (int i = count; i > save; i--) {
                    JsonTextWriter req = session.Request("assemble_glyphs",
                                                     session.cache.session_id,
                                                     buildingID);
                    req.WriteStartArray ();

                    for (int j=0; j < glyph.Length; j++)
                        req.WriteString(((Stack<string>) glyphs[glyph[j]]).Pop());

                    if (session.Post(URL,req) != 0) break;

                    total++;
                }
            }

            Console.WriteLine("\n{0} hall(s) assembled!",total);

              IEnumerator pEnum = pType.GetEnumerator();

              foreach (string [] recipe in HallRecipe)
              {
            Console.WriteLine();
            foreach (string glyph in recipe)
            {
              pEnum.MoveNext();
              Console.WriteLine("{0,3:D} {1}-{2}",
                            ((Stack<string>) glyphs[glyph]).Count,
                            pEnum.Current.ToString(),glyph);
            }
              }
        }
        public static void AssembleGlyphs(Session session, string buildingID, params string [] ids)
        {
            JsonTextWriter req = session.Request("assemble_glyphs",
                                                 session.cache.session_id,
                                                 buildingID);
            req.WriteStartArray ();
            foreach (string id in ids)
                req.WriteString(id);

            session.Post(URL,req);
        }
        public static void GetGlyphs(Session session, string buildingID)
        {
            JsonTextWriter req = session.Request("get_glyphs",
                                                 session.cache.session_id,
                                                 buildingID);

            //session.onData += ProcessResult;

            if (session.Post(URL,req) == 0) {
            //Next two lines perform same thing old ProcessResult did
            foreach (Result.Glyph glyph in session.response.result.glyphs)
              ((Stack<string>) (glyphs[glyph.type])).Push(glyph.id);

            IEnumerator pEnum = pType.GetEnumerator();
                foreach (string [] recipe in HallRecipe)
                {
                    Console.WriteLine();
                    foreach (string glyph in recipe)
              {
            pEnum.MoveNext();
            Console.WriteLine("{0,3:D} {1}-{2}",
                            ((Stack<string>) glyphs[glyph]).Count,
                            pEnum.Current.ToString(),glyph);
              }
                }

                int count = 0;

            foreach (string [] glyph in HallRecipe)
                    count += Math.Min(Math.Min(((Stack<string>) glyphs[glyph[0]]).Count,
                                           	((Stack<string>) glyphs[glyph[1]]).Count),
                                  	Math.Min(((Stack<string>) glyphs[glyph[2]]).Count,
                                           	((Stack<string>) glyphs[glyph[3]]).Count));

            Console.WriteLine("\nYou can build {0} hall(s)",count);
            }
            //session.onData -= ProcessResult;
        }