// 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();

 

 

<textarea class="brush: csharp; collapse: true;" style="height: 668px; width: 731px" rows="1" cols="1">// 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(); </textarea>

Last edited Sep 1, 2013 at 1:19 AM by cneal13x, version 1

Comments

No comments yet.