File: action.cpp

package info (click to toggle)
attal 0.9.2-1.2
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 2,992 kB
  • ctags: 5,972
  • sloc: cpp: 44,510; sh: 160; makefile: 45
file content (171 lines) | stat: -rw-r--r-- 2,832 bytes parent folder | download | duplicates (2)
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/****************************************************************
**
** Attal : Lords of Doom
**
** action.cpp
** Manage actions of 'buildings'
**
** Version : $Id: action.cpp,v 1.2 2004/04/29 18:22:28 lusum Exp $
**
** Author(s) : Pascal Audoux
**
** Date : 23/01/2002
**
** Licence :    
**	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, or (at your option)
**      any later version.
**
**	This program is distributed in the hope that it will be useful,
** 	but WITHOUT ANY WARRANTY; without even the implied warranty of
**	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
**	GNU General Public License for more details.
**
****************************************************************/

#include "action.h"
 
// generic include files
// include files for QT
// application specific include files


// 
// ----- Action -----
// 

Action::Action()
{
	_list.setAutoDelete( true );	
	_type = Action::DATE;
}
	
QString Action::getActionTypeString( ActionType type )
{
	QString ret = "Unknown";


	switch( type ) {
		case DATE:
			ret = "date";
			break;
		case FIRSTTIME:
			ret = "first time";
			break;
		case FIRSTTIMELORD:
			ret = "first time lord";
			break;
		case NEXTTIME:
			ret = "next time";
			break;
	}

	return ret;
}


//
// ----- Elementary Action -----
//

ElementaryAction::ElementaryAction()
{
	_type = ElementaryAction::ATTACK;
	_arg = 0;
	_coeff = 0;
}

QString ElementaryAction::getElemTypeString( ElementaryType type )
{
	QString ret = "Unknown";


	switch( type ) {
		case ATTACK:
			ret = "attack";
			break;
		case DEFENSE:
			ret = "defense";
			break;
		case POWER:
			ret = "power";
			break;
		case KNOWLEDGE:
			ret = "knowledge";
			break;
		case MOVE:
			ret = "move";
			break;
		case MAXMOVE:
			ret = "maxmove";
			break;
		case TECHNICPOINT:
			ret = "techpoint";
			break;
		case MAXTECHNICPOINT:
			ret = "maxtechpoint";
			break;
		case MORALE:
			ret = "morale";
			break;
		case LUCK:
			ret = "luck";
			break;
		case VISION:
			ret = "vision";
			break;
		case EXPERIENCE:
			ret = "experience";
			break;
		case SKILL:
			ret = "skill";
			break;
		case ARTEFACT:
			ret = "artefact";
			break;
		case UNIT:
			ret = "unit";
			break;
		case RESSOURCE:
			ret = "resource";
			break;
		case RANDRESSOURCE:
			ret = "random resource";
			break;
	}

	return ret;
}



//
// ----- InsideAction -----
//

InsideAction::InsideAction()
{
	_params.setAutoDelete( true );
	_type = 0;
}

void InsideAction::addParam( int param )
{
	int * p = new int( param );
	_params.append( p );
}

int InsideAction::getParam( uint num )
{
	int ret = 0;

	if( num < _params.count() ) {
		ret = * ( _params.at( num ) );
	}

	return ret;
}