File: containercontrols.h

package info (click to toggle)
asc 2.1.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 59,052 kB
  • ctags: 25,676
  • sloc: cpp: 145,189; sh: 8,705; ansic: 5,564; makefile: 551; perl: 150
file content (94 lines) | stat: -rw-r--r-- 3,768 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/***************************************************************************
                          cargodialog.cpp  -  description
                             -------------------
    begin                : Tue Oct 24 2000
    copyright            : (C) 2000 by Martin Bickel
    email                : bickel@asc-hq.org
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef containercontrolsH
#define containercontrolsH

#include "containerbase.h"

class VehicleMovement;
class Player;
class GameMap;

class ContainerConstControls {
      const ContainerBase* container;

      const Player& getPlayer() const;
      const GameMap* getMap() const;
   public:
      ContainerConstControls( const ContainerBase* cb ) : container( cb ) {};

      bool unitProductionAvailable() const;

      //! returns 0 if the unit is producable and != 0 otherwise. THe bits in the result say why the unit is not producable
      int unitProductionPrerequisites( const Vehicletype* type ) const;

};

class ContainerControls : public ContainerConstControls {
      ContainerBase* container;

      GameMap* getMap();
      Player& getPlayer();
      int getPlayerNum();
      
   public:
      ContainerControls( ContainerBase* cb ) : ContainerConstControls( cb ), container( cb ) {};
      static VehicleMovement*   movement (  Vehicle* eht, bool simpleMode = false);

      
      Vehicle* produceUnit( const Vehicletype* type, bool fillWithAmmo, bool fillWithResources );

      Resources calcDestructionOutput( Vehicle* veh );
      void destructUnit( Vehicle* veh );

      bool unitTrainingAvailable( Vehicle* veh );
      void trainUnit( Vehicle* veh );

      vector<const Vehicletype*> productionLinesBuyable();
      
      Resources buildProductionLineResourcesNeeded( const Vehicletype* veh );
      int  buildProductionLine( const Vehicletype* veh );

      Resources removeProductionLineResourcesNeeded( const Vehicletype* veh );
      int  removeProductionLine( const Vehicletype* veh );
      
      //! only to be used by the AI, this doesn't consume any resources, so the unit must be discarded
      Vehicle* produceUnitHypothetically( const Vehicletype* type );

      void  fillResource (Vehicle* eht, int resourcetype, int newamount);
      void  fillAmmo (Vehicle* eht, int weapon, int newa );
      void refilleverything ( Vehicle* eht );
      void refillAmmo ( Vehicle* veh );
      void refillResources ( Vehicle* veh );
      void emptyeverything ( Vehicle* eht );
      int   getammunition ( int weapontype, int num, bool abbuchen, bool produceifrequired );
      bool  ammotypeavail ( int type );
      int  ammoProducable ( int weaptype, int num );
      int  produceAmmo ( int weaptype, int num );

      bool moveUnitUpAvail( const Vehicle* veh );
      bool moveUnitUp( Vehicle* veh );
      
      bool moveUnitDownAvail( const Vehicle* movingUnit );
      bool moveUnitDownAvail( const Vehicle* movingUnit, const Vehicle* newTransport );
      vector<Vehicle*> moveUnitDownTargets( const Vehicle* movingUnit );
      bool moveUnitDown( Vehicle* veh, Vehicle* newTransport );
      
};

#endif