Something went wrong. Try again.
Your trusty automation assistant in TLE Community misadventures!
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import lacuna from './test-instance'import { call, findPlanet, findBuilding, colonies, log, util } from '@tlecommunity/super-core'
import _ from 'lodash'
// `test-instance` has already logged in by the time this runs.Promise.resolve() .then(() => { log.info(`Session ID is ${lacuna.session.get()}`) return call(() => lacuna.empire.getStatus()) }) .then((result) => { log.info(`My name is ${result.empire.name}`) log.info(`I have ${result.empire.essentia} Essentia`)
const planetName = result.empire.colonies[result.empire.home_planet_id] return findPlanet(planetName) }) .then((planet) => { log.info(`My home planet is: ${planet.name} (${planet.id})`)
// Kill the session to test how `call()` handles it. lacuna.session.set('')
return findBuilding(planet.id, 'Planetary Command Center') }) .then((planetaryCommand) => { log.info(`The home planet's PCC is at level ${planetaryCommand.level}`)
return call(() => lacuna.planetaryCommand.viewPlans({ building_id: planetaryCommand.id })) }) .then((result) => { let numOfPlans = result.plans.length log.info(`There are ${numOfPlans} plans on ${result.status.body.name}`) return colonies() }) .then((result) => { let colonyNames = _.map(result, 'name').join(', ') log.info(`These are my colonies: ${colonyNames}`) }) .then(() => { log.info('Done') }) .catch((err) => { util.handlePromiseError(err) })