TheGamerASD / AWBW-API

A C# API for Advance Wars By Web.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AWBW-API

A C# API for Advance Wars By Web.

User Guide:

First, add this to your project:

using AWBW;

To use many of the API functions, you will need to create an BrowserAccount. To get the tokens required, look below:

Mozilla Firefox
  1. Open Advance Wars By Web.
  2. Log in to your account.
  3. Press F12.
  4. Open the Storage tab.
Google Chrome
  1. Open Advance Wars By Web.
  2. Log in to your account.
  3. Press F12.
  4. Open the Application tab.
  5. Expand the Cookies button under the Storage header.
  6. Click on the 'https://awbw.amarriner.com' button.

Here's how you can create a BrowserAccount object:

BrowserAccount account = new BrowserAccount("PHPSESSID HERE", "awbw_password HERE");

Make sure to keep these tokens private, as anyone with them can control your account.

Here are some examples of how to use the API:

Create API
AWBWApi api = new AWBWApi();
Get a Map
// Get map with ID '12345'
Map map = await api.GetMap(12345);
Create a TimerSettings Object
TimerSettings timer = new TimerSettings()
{
  initialTime = 2,
  initialTimeUnit = TimeUnit.Hours,
  increment = 30,
  incrementUnit = TimeUnit.Minutes,
  maxTurnTime = 1,
  maxTurnTimeUnit = TimeUnit.Days
};
Create a GameSettings Object
GameSettings settings = new GameSettings()
{
  timerSettings = timer,
  daysLimit = 20,
  weather = Weather.Clear,
  fog = true
};
Create a GameBans Object
GameBans bans = new GameBans()
{
  bannedCOs = TierList.Fog[4],
  bannedUnits = new Unit[] { Unit.BlackBomb, Unit.Stealth },
  labUnits = new Unit[] { Unit.Neotank }
};
Create a Game
// Create a public game with the name 'Game Name' and description 'This is the description of the game.'
Game game = await api.CreateGame(account, "Game Name", map, "This is the description of the game.", settings, bans);
Get a Game
// Get game with ID '456789'
Game game = await api.GetGame(account, 456789);
Join a Game
// Join a public game as Blue Moon with CO Colin.
await api.JoinGame(account, game, Country.BlueMoon, CO.Colin);

I'm still working on new features, so any feedback is appreciated.

About

A C# API for Advance Wars By Web.

License:MIT License


Languages

Language:C# 100.0%