Advanced Strategic Command
ai-service1.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * *
3  * This program is free software; you can redistribute it and/or modify *
4  * it under the terms of the GNU General Public License as published by *
5  * the Free Software Foundation; either version 2 of the License, or *
6  * (at your option) any later version. *
7  * *
8  ***************************************************************************/
9 
10 #include <iostream>
11 
12 #include "ai-service1.h"
13 #include "../loaders.h"
14 #include "unittestutil.h"
15 #include "../turncontrol.h"
16 #include "../gamemap.h"
17 
19 {
20  auto_ptr<GameMap> game ( startMap("unittest-ai-refuel1.map"));
21 
22  Vehicle* veh = game->getField(2,10)->vehicle;
23 
24  assertOrThrow( veh != NULL );
25  assertOrThrow( veh->damage == 0 );
26 
27  next_turn( game.get(), NextTurnStrategy_Abort(), NULL, -1 );
28 
29  assertOrThrow( veh->damage > 0 );
30  int damage = veh->damage;
31 
32  /* the ammo of the attacking unit is exhausted.
33  The AI should service it with the service unit nearby */
34  next_turn( game.get(), NextTurnStrategy_Abort(), NULL, -1 );
35  next_turn( game.get(), NextTurnStrategy_Abort(), NULL, -1 );
36 
37  assertOrThrow( veh->damage > damage );
38 
39 }
40 
41 
43 {
44  auto_ptr<GameMap> game ( startMap("unittest-ai-refuel2.map"));
45 
46  Vehicle* veh = game->getField(4,6)->vehicle;
47 
48  assertOrThrow( veh != NULL );
49  assertOrThrow( veh->getResource( Resources(0,0,100)).fuel <= 1 );
50 
51  next_turn( game.get(), NextTurnStrategy_Abort(), NULL, -1 );
52  next_turn( game.get(), NextTurnStrategy_Abort(), NULL, -1 );
53 
54  assertOrThrow( veh->getResource( Resources(0,0,100)).fuel >= 100 );
55 
56 }
57 
58 
60 {
63 }
void testAiService2()
Definition: ai-service1.cpp:42
int getResource(int amount, int resourcetype, bool queryonly, int scope=1, int player=-1)
Definition: vehicle.cpp:328
int damage
Damage. 0 is no damage, when damage reaches 100 the container is destroyed.
#define assertOrThrow(expr)
Definition: errors.h:69
void testAiService()
Definition: ai-service1.cpp:59
void next_turn(GameMap *gamemap, const NextTurnStrategy &nextTurnStrategy, MapDisplayInterface *display, int playerView)
GameMap * startMap(const ASCString &filename)
void testAiService1()
Definition: ai-service1.cpp:18
Resources are basically the currency of ASC.
Definition: typen.h:97