@senators/bifrost
v2.1.5
Published
A powerful TypeScript library for interacting with OGame game servers, making your interstellar journey easier!
Downloads
1,313
Maintainers
Readme
English | 中文
🚀 A powerful TypeScript library for interacting with OGame game servers, making your interstellar journey easier!
✨ Features
- 🛡️ Complete OGame API wrapper
- 🔐 Secure account login and session management
- 🚀 Powerful fleet operation management
- 🌍 Comprehensive planet and resource management system
- 🏗️ Building and research queue control
- 🛠️ Type-safe API design
- ⚡ High-performance request handling
- 🔄 Real-time data updates and event hooks
🚀 Quick Start
Install
# Use npm
npm install @senators/bifrost
# Use yarn
yarn add @senators/bifrost
# Use pnpm
pnpm add @senators/bifrostUsage
import { Operator, Courier, Config } from '@senators/bifrost'
// Create configuration
const config = new Config()
// Create HTTP client
const courier = new Courier({
base: 'https://example.com',
timeout: 10000,
})
// Create operator instance
const operator = new Operator({
universe: 1,
username: 'username',
password: 'password',
courier,
config,
})
// Optional: Add hook functions
operator.onUpdateControl = async () => {
console.log('Updating overview data')
}
operator.onUpdateResearch = async () => {
console.log('Updating research data')
}
operator.onUpdatePlanets = async () => {
console.log('Updating planet data')
}
// ......
operator.onUpdatePlanetBuilding = async ({ planet }) => {
console.log(`Updating building data for planet ${planet.name}[${planet.coordinate.toString()}]`)
}
operator.onUpdatePlanetShipyard = async ({ planet }) => {
console.log(`Updating shipyard data for planet ${planet.name}[${planet.coordinate.toString()}]`)
}
// ......
// Update game data (handles login automatically)
await operator.update()
// Refresh one planet by ID
await operator.updatePlanet({ planetId: 1 })
// Or refresh a Planet instance directly
const planet = operator.planets.map.get(1)
if (planet) {
await operator.updatePlanet({ planet })
}
// Refresh only one part of a planet when needed
await operator.updatePlanetBuilding({ planetId: 1 })
await operator.updatePlanetShipyard({ planetId: 1 })
// Access game data
console.log(operator)🚀 Fleet Mission Example
Here's a complete example of how to send an expedition fleet:
import {
Operator,
Courier,
Config,
Fleet,
Elements,
FleetMission,
FleetSpeed,
FleetStaytime,
} from '@senators/bifrost'
// Initialize configuration and client
const config = new Config()
const courier = new Courier({
base: 'https://example.com',
timeout: 10000,
})
// Create operator
const operator = new Operator({
universe: 1,
username: 'username',
password: 'password',
courier,
config,
})
// Configure fleet
const ships = new Elements()
ships.set(210, 99999) // Set ship type 210, quantity 99999
// Create fleet mission
const fleet = new Fleet({
origin: 1, // Starting planet ID
target: {
galaxy: 1, // Target galaxy
system: 1, // Target system
planet: 1, // Target planet
type: 1, // Planet type: 1=planet
},
mission: FleetMission.Expedit, // Mission type: deep-space expedition
speed: FleetSpeed.Ten, // Speed: fastest
staytime: FleetStaytime.One, // Stay time: 1 hour
metal: 0, // Metal: 0
crystal: 0, // Crystal: 0
deuterium: 0, // Deuterium: 0
ships, // Ship configuration
})
// Execute fleet mission
console.log('Sending fleet...')
await operator.sendFleet(fleet)
console.log('Fleet sent!')
// Schedule execution (optional)
const INTERVAL_MINUTES = 20
setInterval(
async () => {
console.log(`Executing fleet mission ${new Date().toLocaleTimeString()}`)
await operator.sendFleet(fleet)
},
1000 * 60 * INTERVAL_MINUTES,
)🎯 Mission Types (FleetMission)
| ID | Member | Description |
| --- | ------------------------- | --------------------- |
| 1 | FleetMission.Attack | Attack target |
| 2 | FleetMission.Federation | Alliance mission |
| 3 | FleetMission.Transport | Transport resources |
| 4 | FleetMission.Deploy | Deploy fleet |
| 5 | FleetMission.Hold | Station in orbit |
| 6 | FleetMission.Espionage | Espionage mission |
| 7 | FleetMission.Colony | Establish colony |
| 8 | FleetMission.Harvest | Harvest resources |
| 9 | FleetMission.Destroy | Destroy moon |
| 10 | FleetMission.Missile | Missile attack |
| 11 | FleetMission.Expdm | Scout mission |
| 15 | FleetMission.Expedit | Deep-space expedition |
| 18 | FleetMission.Warexpedit | Trade mission |
🧩 Core Modules
| Module | Description | | ------------------ | ----------------------------------------------------------- | | Operator | 🧠 Core operations class, handles login and in-game actions | | Courier | 🌐 HTTP request handling, communicates with game server | | Fleet | 🚀 Fleet management, creates and executes fleet missions | | Planets/Planet | 🌍 Planet management system, handles all colonies | | Elements | 🏗️ In-game elements (resources, buildings, research, etc.) | | Queue | ⏳ Queue management, handles building and research queues | | Config | ⚙️ Configuration management, customizes client behavior |
🛠️ Development Guide
Building the Project
# Install dependencies
npm install
# Build the project
npm run buildCode Style
# Check code style
npm run lint
# Format code
npm run fmt📜 License
This project is licensed under the MIT License. You are free to use, modify, and distribute the code in this project.
🙏 Acknowledgments
- OGame - A fascinating space strategy game
- All contributors - Thank you for your valuable contributions!
🤝 Contributing
Issues and Pull Requests are welcome!
- Fork the project
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📞 Contact
If you have any questions or suggestions, please submit them via GitHub Issues.
