A C# API for Advance Wars By Web.
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
- Open Advance Wars By Web.
- Log in to your account.
- Press F12.
- Open the Storage tab.
Google Chrome
- Open Advance Wars By Web.
- Log in to your account.
- Press F12.
- Open the Application tab.
- Expand the Cookies button under the Storage header.
- 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.
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.