node package manager

lou

A node API for connecting to Lord of Ultima

node-lou

This node library provides methods to connect and retrieve information from the Lord of Ultima game API.

Installation

This package can be installed via the node npm package manager.

npm install node-lou

Usage

Since the release of v0.2, the node-lou library now permits multiple accounts to be used. This allows the library to send multiple requests in parallel to LoU decreasing the time it takes to complete certain requests and avoiding the LoU bot detection.

You must first connect to LoU using the createClient() method. Once the connection is made you can then request info from LoU easily.

var lou = require('node-lou')
 
lou.createClient({
  accts: [
    {
      email: 'myemail@domain.com'
    , pass: 'myloupassword'
    }
  , {
      email: 'anotheremail@domain.com'
    , pass: 'my2ndloupass'
    }
  ]
, world: {
    id: 55
  , url: 'prodgame10.lordofultima.com/128'
  }
}, function(err){
  // Connection complete...can now call other methods 
  
})

API

lou.createClient

Used to provide configuration data, authenticate with LoU, and connect to the world. Returns null if successful or an error as the first argument in the callback function

lou.createClient(config, callback)

lou.get

The get namespace contains methods for retrieving info from LoU. Some of these methods require several calls to the LoU API. These particular methods will take advantage of multiple LoU accounts to speed up the request.

// Get the current server timestamp and step used for time calculations 
lou.get.time(callback)
 
// Retrieve an authenticated account. If no email is provided will grab the next available account. 
var acct = lou.get.account(email)
 
// Retrieve alliance info by id 
lou.get.alliance(allianceId, callback)
 
// Retrieve alliance info by name 
lou.get.allianceByName(allianceName, callback)
 
// Retrieve the alliance info of a player by their id 
lou.get.playerAlliance(playerId, callback)
 
// Retrieve the members of an alliance by id 
lou.get.allianceMembers(allianceId, callback)
 
// Get a player's public info by id 
lou.get.player(playerId, callback)
 
// Retrieve public city information by give city id 
lou.get.city(cityId, callback)
 
// The next three methods retrieve complete listings of information 
// in the world and can take several seconds to complete. They 
// utilize multiple accounts to speed up this process. 
lou.get.allAlliances(callback)
lou.get.allPlayers(callback)
lou.get.playerByName(playerName, callback)

lou.get.my

This namespace contains methods for gathering information specific to a configured account. Must supply the email address of the desired account. Since these are specific to an account, they return private information.

lou.get.my.alliance(acctEmail, callback)
lou.get.my.allianceMembers(acctEmail, callback)
lou.get.my.player(acctEmail, callback)
lou.get.my.cities(acctEmail, callback)

lou.send

The send namespace contains methods for LoU commands that trigger an action. These methods can be considered against the LoU Gameplay rules and may result in a ban of the offending account. I am not responsible for the use of the below methods.

lou.send.resource(acctEmail, sendOptions, callback)

lou.raw

This method exposes the communication to LoU for sending raw requests. The first argument must contain two elements, an endpoint string and a data object. The data object is what is sent to the LoU server while the endpoint specifies it's destination. The example provided is the raw request for retrieving an alliance by id.

lou.get.raw({
  endpoint: 'GetPublicAllianceInfo'
, data: {
    session: sessKey
  , id: allianceId
  }
}, callback)

Examples

A simple example of retrieving a player's city with only his name and the city name. Check the examples directory for more examples.

var playerName = 'PastorBones'
  , cityName = 'Jericho'
  
// First, create our client and get a connection 
lou.createClient({
  accts: [
    {
      email: 'myemail@domain.com'
    , pass: 'myloupassword'
    }
  ]
, world: {
    id: 55
  , url: 'prodgame10.lordofultima.com/128'
  }
}, function(err){
  if(err) console.log(err)
  else {
    // Connection complete...retrieve our player info by his name 
    lou.get.playerByName(playerName, function(err, player){
      if(err) console.log(err)
      else {
        // We now have our player info, loop and find his city 
        player.c.forEach(function(city){
          if(city.n.toLowerCase() === cityName.toLowerCase()) {
            // This is our city 
            console.log(city)
          }
        })
      }
    })
  }
})

Contributing

Fork the node-lou repository on GitHub and send a Pull Request.

Notes

  • Requires the 'htmlparser' and 'async' node modules.
  • Early in it's development, the API may change in future releases

TODO

  • Add the rest of the API functions
  • Instill better error checking throughout library on supplied attributes
  • Develope a node compatible javascript library for decrypting world data (base91)
  • High-level functions
    • city layout generation
    • time calculations for resources and travel distances
    • boss and dungeon calculations for amount of troops to send

License

Copyright (c) 2012 Roger Mayfield (pastor_bones@yahoo.com)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.