コード例 #1
0
ファイル: Tester.cs プロジェクト: prbarcelon/GwApiNET
        public void LangTest()
        {
            NetworkHandler handler = new NetworkHandler();

            GwApi.Network = handler;
            var evennames = GwApi.GetEventNames(false, Language.German);
        }
コード例 #2
0
        public bool DictionaryAgeCacheStrategyExpiredTest(string maxAgeStr, string offsetStr)
        {
            var items  = GwApi.GetEventNames(true);
            var maxAge = TimeSpan.Parse(maxAgeStr);
            var offset = TimeSpan.Parse(offsetStr);

            items.LastUpdated = DateTime.Now.Add(offset);
            var strat1 = new AgeCacheStrategy(maxAge);
            var strat2 = new DictionaryCacheStrategy <EntryDictionary <Guid, EventNameEntry>, Guid, EventNameEntry>();

            return(strat2.Expired(items, strat1));
        }
コード例 #3
0
ファイル: GwApiTest.cs プロジェクト: prbarcelon/GwApiNET
        public void GetEventNamesTest(bool ignoreCache)
        {
            var actual   = GwApi.GetEventNames(ignoreCache);
            var expected = TestData.EventNameEntriesExpected;

            foreach (var pair in expected)
            {
                var actualEntry   = actual[pair.Key];
                var expectedEntry = pair.Value;
                Assert.NotNull(actualEntry);
                Assert.AreEqual(expectedEntry.Name, actualEntry.Name);
            }
        }
コード例 #4
0
        public EntryDictionary <Guid, EventNameEntry> GetEventNames(int mapID)
        {
            EntryCollection <EventEntry> x = GwApi.GetEvents(_bs.WorldID, mapID, null);
            HashSet <Guid> z = new HashSet <Guid>();

            foreach (EventEntry p in x)
            {
                z.Add(p.EventId);
            }
            var y = GwApi.GetEventNames();
            EntryDictionary <Guid, EventNameEntry> ret = new EntryDictionary <Guid, EventNameEntry>();

            y.Where(j => z.Contains(j.Value.Id)).ToList().ForEach(k => ret.Add(k.Key, k.Value));
            return(ret);
        }
コード例 #5
0
        public void EventsExample()
        {
            GwApi.Network = new NetworkHandler();
            // First lets find out what my world ID is
            var worldNames = GwApi.GetWorldNames();
            int world_id   = worldNames.Values.Single(w => w.Name == "Sorrow's Furnace").Id;

            // now lets get the event names and map names
            // These are lookups keyed on ID value
            var eventNames = GwApi.GetEventNames();
            var maps       = GwApi.GetMapNames();

            // Now lets get a list of events on my world
            // We can use include whatever information we want to query with
            // In this case we want all events where the world id = world_id
            // we could also reduce our search further by providing a map id or event an event id
            var events = GwApi.GetEvents(world_id, -1, null);

            // Lets print all of the active events
            // We can show the map the event is on and it's name
            var activeEvents = events.Where(e => e.State == EventState.Active);

            // Lets get the event details for all events
            // we could request a single event detail by providing the event id as well
            var eventDetails = GwApi.GetEventDetails();

            // we'll use a StringBuilder to compose our print list
            var sb = new StringBuilder("--- Active Event List ---\n");

            foreach (var e in activeEvents)
            {
                // event detail for current e
                var eventDetail = eventDetails[e.EventId];
                sb.AppendFormat("Name: {0}\n", eventDetail.Name);
                sb.AppendFormat("Map: {0}\n", maps[eventDetail.MapId].Name);
                sb.AppendFormat("Level: {0}\n", eventDetail.Level);
                sb.AppendLine("--------");
            }
            // Print the contents
            Console.WriteLine(sb.ToString());

            // We've just downloaded a bunch of data which takes a bit of time
            // Sepcifically the complete event details list
            // If we save this, the next time we need the list it will take very little time
            ResponseCache.Cache.Save();
        }
コード例 #6
0
 public EntryDictionary <Guid, EventNameEntry> GetEventNames()
 {
     return(GwApi.GetEventNames());
 }