35
/** The purpose of the action classes is to keep track about what a player has
36
* done. This information can e.g. then be sent over the network, so that a
37
* networked player then just has to decode and repeat the actions which the
38
* remote player has done.
40
* Each action item is derived from the abstract Action class. It has to
41
* contain three functions:
43
* - A loading constructor (which takes an XML_Helper parameter)
44
* - a save function which saves the data
45
* - a fillData function which takes some parameters and with these stores the
46
* data about what happened.
41
//! A temporary record of an event during gameplay.
43
* The purpose of the action classes is to keep track of what a player has
44
* done. This information can be sent over the network, so that a networked
45
* player then just has to decode and repeat the remote player's actions so
46
* that the game state is synchronised.
48
* Each action item is derived from the abstract Action class. It must
49
* contain three functions; A loading constructor (which takes an
50
* XML_Helper parameter), a save function which saves the data to the
51
* XML file, and a fillData function which takes some parameters and
52
* stores the pertinent data about what happened.
54
* Each Player has an Actionlist to which these actions belong.
60
//! An Action can be one of the following kinds.
62
/** A stack has moved. */
64
/** A stack has separated into two parts. */
66
/** A stack is fighting a city or another stack. */
68
/** A stack has merged with another stack. */
70
/** A stack containing a hero has examined a ruin. */
72
/** A stack has examined a temple. */
74
/** A stack has defeated a city and occupied it. */
76
/** A stack has defeated a city and pillaged it. */
78
/** A stack has defeated a city and razed it. */
80
/** A player has improved the defenses of a city. (Not used) */
82
/** A player has purchased a new Army unit to be produced
85
/** A player has changed production in a city to another
88
/** A stack has received a reward. */
90
/** A hero has received a new quest. */
92
/** A hero has picked up or dropped an item. */
94
/** An Army unit has advanced to a new level (Only used for
97
/** A stack has defeated a city and sacked it. */
99
/** A player has removed a stack. */
71
100
STACK_DISBAND = 18,
101
/** A player has changed what a signpost says. */
72
102
MODIFY_SIGNPOST = 19,
103
/** A player has changed the name of a city. */
105
/** A player has vectored Army units from one city to
108
/** A player has changed the order in which Army units do
111
/** A player has surrendered. */
113
/** A hero has planted an item in the ground. */
115
/** A newly produced Army unit arrives on the map. */
78
116
PRODUCE_UNIT = 25,
117
/** A new vectored Army unit has shown up at a location. */
79
118
PRODUCE_VECTORED_UNIT = 26,
119
/** The player's diplomatic relations with respect to another
120
* player has changed. */
80
121
DIPLOMATIC_STATE = 27,
122
/** The player's diplomatic proposal with respect to another
123
* player has changed. */
81
124
DIPLOMATIC_PROPOSAL = 28,
125
/** The player's diplomatic score with respect to another
126
* player has changed. */
82
127
DIPLOMATIC_SCORE = 29,
134
//! Default constructor.
86
135
Action(Type type);
137
Action(XML_Helper *helper);
87
140
virtual ~Action();
89
//! Returns debug information. Needs to be overwritten by derivatives
142
//! Returns debug information. Needs to be overwritten by derivatives.
90
143
virtual std::string dump() const = 0;
92
145
//! Save function. See XML_Helper for information about saving.
93
virtual bool save(XML_Helper* helper) const = 0;
146
bool save(XML_Helper* helper) const;
95
/** static load function (see XML_Helper)
97
* Whenever an action item is loaded, this function is called. It
98
* examines the stored id and calls the constructor of the appropriate
101
* @param helper the XML_Helper instance for the savegame
149
* static load function (see XML_Helper)
151
* Whenever an action item is loaded, this function is called. It
152
* examines the stored id and calls the constructor of the appropriate
155
* @param helper the XML_Helper instance for the savegame
157
//! Load the action from an opened saved-game file.
103
158
static Action* handle_load(XML_Helper* helper);
105
//! Copies an action to a new one
160
//! Make a new action from an existing one.
106
161
static Action* copy(const Action* a);
108
//! Returns the id which identifies the type of the action
163
//! Returns the Action::Type for this action.
109
164
Type getType() const {return d_type;}
166
void setPlayer(Uint32 p) { d_player = p; }
167
Uint32 getPlayer() const { return d_player; }
170
virtual bool doSave(XML_Helper* helper) const = 0;
115
176
//-----------------------------------------------------------------------------
178
//! A temporary record of a Stack moving.
180
* The purpose of the Action_Move class is to record when a stack has
181
* moved to a new position on the map.
117
183
class Action_Move : public Action
186
//! Make a new move action.
188
//! Load a new move action from an opened saved-game file.
121
189
Action_Move(XML_Helper* helper);
190
//! Destroy a move action.
193
//! Return some debug information about this action.
124
194
std::string dump() const;
125
bool save(XML_Helper* helper) const;
196
//! Save this move action to an opened saved-game file.
197
virtual bool doSave(XML_Helper* helper) const;
199
//! Populate the move action with the stack and it's new position.
127
200
bool fillData(Stack* s, Vector<int> dest);
131
204
Vector<int> d_dest;
207
//! A temporary record of a Stack being disbanded.
209
* The purpose of the Action_Disband class is to record when a stack has
210
* removed from the game. Disbanding is done to primarily to save the
211
* gold pieces paid out every turn as upkeep for the Army units in the Stack.
134
213
class Action_Disband: public Action
216
//! Make a new disband action.
137
217
Action_Disband();
218
//! Load a new disband action from an opened saved-game file.
138
219
Action_Disband(XML_Helper* helper);
220
//! Destroy a disband action.
139
221
~Action_Disband();
223
//! Return some debug information about this action.
141
224
std::string dump() const;
142
bool save(XML_Helper* helper) const;
226
//! Save this disband action to an opened saved-game file.
227
virtual bool doSave(XML_Helper* helper) const;
229
//! Populate the action with the Stack being removed.
144
230
bool fillData(Stack* s);
150
236
//-----------------------------------------------------------------------------
238
//! A temporary record of a Stack being split into two.
240
* The purpose of the Action_Split class is to record when a Stack has been
241
* separated into two parts. This happens when the Player groups only some
242
* of the Army units in the stack (not all), and then moves them to a new
243
* position on the map. When a split is completed there is the original
244
* stack (the remaining Army units in the stack that didn't change position),
245
* and a new stack added to the game (the stack containing the grouped army
152
248
class Action_Split : public Action
251
//! Make a new stack split action.
253
//! Load a new stack split action from an opened saved-game file.
156
254
Action_Split(XML_Helper* helper);
255
//! Destroy a stack split action.
258
//! Return some debug information about this action.
159
259
std::string dump() const;
160
bool save (XML_Helper* helper) const;
162
//! Both stacks have to be split already!!
261
//! Save this split action to an opened saved-game file.
262
bool doSave (XML_Helper* helper) const;
265
* Populate the Action_Split class with the original Stack, and the
266
* new stack that has been added to the game. Please note that the
267
* stacks have to be already split before this call.
269
//! Populate the action with pertinent data.
163
270
bool fillData(Stack* orig, Stack* added);
166
273
Uint32 d_orig, d_added;
167
274
Uint32 d_armies_moved[MAX_STACK_SIZE];
170
277
//-----------------------------------------------------------------------------
279
//! A temporary record of a fight between opposing Stack objects.
281
* The purpose of the Action_Fight class is to record the results of a
282
* fight between two Players.
172
284
class Action_Fight : public Action, public sigc::trackable
287
//! Make a new fight action.
289
//! Load a new fight action from an opened saved-game file.
176
290
Action_Fight(XML_Helper* helper);
291
//! Destroy a fight action.
294
//! Return some debug information about this action.
179
295
std::string dump() const;
180
bool save(XML_Helper* helper) const;
297
//! Save this fight action to an opened saved-game file.
298
virtual bool doSave(XML_Helper* helper) const;
301
* Populate the action with the Fight. Please note that the
302
* Fight must have already been faught.
304
//! Fill the action with pertinent data.
182
305
bool fillData(const Fight* f);
185
308
bool loadItem(std::string tag, XML_Helper* helper);
187
310
std::list<FightItem> d_history;
192
315
//-----------------------------------------------------------------------------
317
//! A temporary record of two Stack objects merging into one.
319
* The purpose of the Action_Join class is to record a Stack has had
320
* another Stack merged into it.
194
322
class Action_Join : public Action
325
//! Make a new stack join action.
327
//! Load a new stack join action from an opened saved-game file.
198
328
Action_Join(XML_Helper* helper);
329
//! Destroy a stack join action.
332
//! Return some debug information about this action.
201
333
std::string dump() const;
202
bool save(XML_Helper* helper) const;
335
//! Save this stack join action to an opened saved-game file.
336
virtual bool doSave(XML_Helper* helper) const;
339
* Populate the Action_Join class with the original Stack, and the
340
* stack that is merging into the original one. Please note that
341
* this method must be called before the merge takes place.
343
//! Populate the action with pertinent data.
203
344
bool fillData(Stack* orig, Stack* joining);
206
347
Uint32 d_orig_id, d_joining_id;
209
350
//-----------------------------------------------------------------------------
352
//! A temporary record of what happened when a Stack searched a Ruin.
354
* The purpose of the Action_Ruin class is to record what happens when a
355
* Stack containing a Hero attempts to search a Ruin.
211
357
class Action_Ruin : public Action
360
//! Make a new ruin search attempted action.
362
//! Load a new ruin search attempted action from a saved-game file.
215
363
Action_Ruin(XML_Helper* helper);
364
//! Destroy a ruin search attempted action.
367
//! Return some debug information about this action.
218
368
std::string dump() const;
219
bool save(XML_Helper* helper) const;
370
//! Save this ruin search attempted action to a saved-game file.
371
virtual bool doSave(XML_Helper* helper) const;
374
* Populate the Action_Ruin class with the Stack containing the
375
* Hero Army unit, and the Ruin being searched.
377
//! Populate the action with pertinent data.
221
378
bool fillData(Ruin* r, Stack* explorers);
380
//! Set whether or not the Stack was successful in searching the ruin.
223
381
void setSearched(bool searched) {d_searched = searched;}
251
426
//-----------------------------------------------------------------------------
428
//! A temporary record of what happened when a Player occupied a City.
430
* The purpose of the Action_Occupy class is to record when a Player has
431
* defeated a City and has occupied it. Ocuppying differs from sacking
432
* and pillaging in that none of the existing Army units in the City are
433
* exchanged for gold pieces.
253
435
class Action_Occupy : public Action
438
//! Make a new city occupy action.
440
//! Load a new city occupied action from an opened saved-game file.
257
441
Action_Occupy(XML_Helper* helper);
442
//! Destroy a city occupy action.
258
443
~Action_Occupy();
445
//! Return some debug information about this action.
260
446
std::string dump() const;
261
bool save(XML_Helper* helper) const;
448
//! Save this city occupied action to an opened saved-game file.
449
virtual bool doSave(XML_Helper* helper) const;
451
//! Populate the action with the City being occupied.
263
452
bool fillData (City* c);
269
458
//-----------------------------------------------------------------------------
460
//! A temporary record of what happened when a Player pillaged a City.
462
* The purpose of the Action_Pillage class is to record when a Player has
463
* defeated a City and has pillaged it. Pillaging a city results in the
464
* strongest Army unit being produced in that city being exchanged for an
465
* amount of gold pieces.
271
467
class Action_Pillage : public Action
470
//! Make a new city pillaged action.
274
471
Action_Pillage();
472
//! Load a new city pillaged action from an opened saved-game file.
275
473
Action_Pillage(XML_Helper* helper);
474
//! Destroy a city pillaged action.
276
475
~Action_Pillage();
477
//! Return some debug information about this action.
278
478
std::string dump() const;
279
bool save(XML_Helper* helper) const;
480
//! Save this city pillaged action to an opened saved-game file.
481
virtual bool doSave(XML_Helper* helper) const;
483
//! Populate the action with the City that has been pillaged.
281
484
bool fillData(City* c);
287
490
//-----------------------------------------------------------------------------
492
//! A temporary record of what happened when a Player sacked a City.
494
* The purpose of the Action_Sack class is to record when a Player has
495
* defeated a City and has sacked it. Sacking a city results in all
496
* Army units, except the weakest being exchanged for an amount of gold
289
499
class Action_Sack : public Action
502
//! Make a new city sacked action.
504
//! Load a new city sacked action from an opened saved-game file.
293
505
Action_Sack(XML_Helper* helper);
506
//! Destroy a city sacked action.
509
//! Return some debug information about this action.
296
510
std::string dump() const;
297
bool save(XML_Helper* helper) const;
512
//! Save this city sacked action to an opened saved-game file.
513
virtual bool doSave(XML_Helper* helper) const;
515
//! Populate the action with the City that has been sacked.
299
516
bool fillData(City* c);
305
522
//-----------------------------------------------------------------------------
524
//! A temporary record of what happened when a Player razed a City.
526
* The purpose of the Action_Raze class is to record when a Player has
527
* defeated a City and has razed it. Razing a city results in that
528
* city becoming uninhabitable, and it ceases to produce new Army units.
307
530
class Action_Raze : public Action
533
//! Make a new city razed action.
535
//! Load a new city razed action from an opened saved-game file.
311
536
Action_Raze(XML_Helper* helper);
537
//! Destroy a city razed action.
540
//! Return some debug information about this action.
314
541
std::string dump() const;
315
bool save(XML_Helper* helper) const;
543
//! Save this city razed action to an opened saved-game file.
544
virtual bool doSave(XML_Helper* helper) const;
546
//! Populate the action with the City that has been razed.
317
547
bool fillData (City* c);
323
553
//-----------------------------------------------------------------------------
555
//! A temporary record of what happened when a City's defenses were increased.
557
* The purpose of the Action_Upgrade class is to record when a Player has
558
* improved the City's defenses. This action is not currently used by
325
561
class Action_Upgrade : public Action
564
//! Make a new city upgraded action.
328
565
Action_Upgrade();
566
//! Load a new city upgraded action from an opened saved-game file.
329
567
Action_Upgrade(XML_Helper* helper);
568
//! Destroy a city upgraded action.
330
569
~Action_Upgrade();
571
//! Return some debug information about this action.
332
572
std::string dump() const;
333
bool save(XML_Helper* helper) const;
574
//! Save this city upgraded action to an opened saved-game file.
575
virtual bool doSave(XML_Helper* helper) const;
577
//! Populate the action with the City that has been upgraded.
335
578
bool fillData(City* c);
341
584
//-----------------------------------------------------------------------------
586
//! A temporary record of more production being added to a City.
588
* The purpose of the Action_Buy class is to record when a Player purchases
589
* a new Army unit for production in a City. When this happens the player
590
* specifies a production slot to hold the new Army unit type. Any existing
591
* Army unit type in that slot before the buy is removed.
592
* The idea here is that the city may produce one Army unit type from a set
593
* of available Army units, and this action records what happens when we make
594
* a new kind of Army unit available for production in the City.
595
* The army unit is taken from the Player's Armyset.
343
597
class Action_Buy : public Action
600
//! Make a new city buy production action.
602
//! Load a new city buy production action from a saved-game file.
347
603
Action_Buy(XML_Helper* helper);
604
//! Destroy a city buy production action.
607
//! Return some debug information about this action.
350
608
std::string dump() const;
351
bool save(XML_Helper* helper) const;
353
bool fillData(City* c, int slot, int prod);
610
//! Save this city buy production action to an opened saved-game file.
611
virtual bool doSave(XML_Helper* helper) const;
614
* Populate the Action_Buy with City where the buy has happened.
615
* Also populate it with the City's production slot that is now
616
* producing the new Army unit type. Lastly, populate the Action_Buy
617
* with the new Army unit type being produced.
619
//! Populate the action with pertinent data.
620
bool fillData(City* c, int slot, const Army *prod);
357
624
int d_slot, d_prod;
360
627
//-----------------------------------------------------------------------------
629
//! A temporary record of a change in production strategy in a City.
631
* The purpose of the Action_Production class is to record when the Player
632
* changes the production of new Army units within a City. The idea here
633
* is that the City has a set of available Army units that it may produce,
634
* and the Player has selected a different Army unit to produce, or has
635
* stopped production of new Army units altogether.
362
637
class Action_Production : public Action
640
//! Make a new city change production action.
365
641
Action_Production();
642
//! Load a new city change production action from a saved-game file.
366
643
Action_Production(XML_Helper* helper);
644
//! Destroy a city change production action.
367
645
~Action_Production();
647
//! Return some debug information about this action.
369
648
std::string dump() const;
370
bool save(XML_Helper* helper) const;
372
bool fillData(City* c, int prod);
650
//! Save this city change production action to a saved-game file.
651
virtual bool doSave(XML_Helper* helper) const;
654
* Populate the Action_Production with City where the change
655
* in production has taken place. Also populate it with the newly
656
* active production slot (-1 means stopped).
658
//! Populate the action with pertinent data.
659
bool fillData(City* c, int slot);
379
666
//-----------------------------------------------------------------------------
381
//this class will certainly have to be changed a lot, it doesn't handle anything
382
//else but gold, but I want at least a basic
668
//! A temporary record of a Player or Stack getting a Reward.
670
* The purpose of the Action_Reward class is to record when the Player
671
* has been given a Reward.
672
* It could be that the player has been given: Some gold pieces, a map that
673
* makes more of the map visible or information about the location of a new
674
* ruin. It could also be that the player's active stack has been given
675
* a number of allies. It could also be that the Player's active Stack
676
* contains a Hero, and the Reward is an Item for the Hero to carry.
384
678
class Action_Reward : public Action
681
//! Make a new player rewarded action.
683
//! Load a new player rewarded action from a saved-game file.
388
684
Action_Reward(XML_Helper* helper);
685
//! Destroy a player rewarded action.
389
686
~Action_Reward();
688
//! Return some debug information about this action.
391
689
std::string dump() const;
392
bool save(XML_Helper* helper) const;
394
bool fillData (Reward *);
691
//! Save this player rewarded action to a saved-game file.
692
virtual bool doSave(XML_Helper* helper) const;
694
//! Populate the Action_Reward with a Reward.
695
bool fillData (Stack *stack, Reward *r);
397
698
bool load(std::string tag, XML_Helper *helper);
398
699
Reward *d_reward;
402
704
//-----------------------------------------------------------------------------
403
// This class also may have some problems lateron, but should suffice for now.
706
//! A temporary record of a Hero initiating a new Quest.
708
* The purpose of the Action_Quest class is to record when a Player's
709
* Hero has gone to a Temple and initiated a new Quest.
405
711
class Action_Quest : public Action
714
//! Make a new hero quest assigned action.
716
//! Load a new hero quest assigned action from a saved-game file.
409
717
Action_Quest(XML_Helper* helper);
718
//! Destroy a hero quest assigned action.
721
//! Return some debug information about this action.
412
722
std::string dump() const;
413
bool save(XML_Helper* helper) const;
724
//! Save this hero quest assigned action to a saved-game file.
725
virtual bool doSave(XML_Helper* helper) const;
727
//! Populate the Action_Quest with a Quest.
415
728
bool fillData(Quest* q);
419
732
Uint32 d_questtype;
449
783
//-----------------------------------------------------------------------------
785
//! A temporary record of a Hero gaining a new level.
787
* The purpose of the Action_Level class is to record when a Player's Hero
788
* advances a level and subsequently gains a stat.
789
* Stats that may get increased are: Strength, Moves, and Sight (for use on
451
792
class Action_Level : public Action
795
//! Make a new level advancement action.
797
//! Load a new level advancement action from an opened saved-game file.
455
798
Action_Level(XML_Helper* helper);
799
//! Destroy a level advancement action.
802
//! Return some debug information about this action.
458
803
std::string dump() const;
459
bool save(XML_Helper* helper) const;
461
bool fillData(Uint32 unit, Army::Stat raised);
805
//! Save this level advancement action to an opened saved-game file.
806
virtual bool doSave(XML_Helper* helper) const;
809
* Populate the Action_Level class with the the Id of the Hero
810
* Army unit, and also the Hero's stat that has been raised as a
811
* result of the level advancement.
813
//! Populate the action with pertinent data.
814
bool fillData(Army *unit, Army::Stat raised);
468
821
//-----------------------------------------------------------------------------
823
//! A temporary record of a Player changing the contents of a Signpost.
825
* The purpose of the Action_ModifySignpost is to record when a Signpost
826
* has been altered by a player to have a different message on it. The
827
* idea here is that we're playing on a hidden map and a Player wants to
828
* thwart an opponent by changing what signs say before he can read them.
469
830
class Action_ModifySignpost: public Action
833
//! Make a new change signpost action.
472
834
Action_ModifySignpost();
835
//! Load a new change signpost action from an opened saved-game file.
473
836
Action_ModifySignpost(XML_Helper* helper);
837
//! Destroy a change signpost action.
474
838
~Action_ModifySignpost();
840
//! Return some debug information about this action.
476
841
std::string dump() const;
477
bool save(XML_Helper* helper) const;
843
//! Save this change signpost action to an opened saved-game file.
844
virtual bool doSave(XML_Helper* helper) const;
846
//! Populate the action with the signpost and the new message.
479
847
bool fillData(Signpost * s, std::string message);
482
850
Uint32 d_signpost;
483
851
std::string d_message;
486
854
//-----------------------------------------------------------------------------
856
//! A temporary record of a Player changing the name of a City.
858
* The purpose of the Action_RenameCity class is to record when a Player has
859
* changed the name of a City. The idea here is that a Player wants
860
* to gloat by renaming a newly conquered City.
487
862
class Action_RenameCity: public Action
865
//! Make a new city rename action.
490
866
Action_RenameCity();
867
//! Load a new city rename action from an opened saved-game file.
491
868
Action_RenameCity(XML_Helper* helper);
869
//! Destroy a city rename action.
492
870
~Action_RenameCity();
872
//! Return some debug information about this action.
494
873
std::string dump() const;
495
bool save(XML_Helper* helper) const;
875
//! Save this city rename action to an opened saved-game file.
876
virtual bool doSave(XML_Helper* helper) const;
878
//! Populate the action with the city being renamed and the new name.
497
879
bool fillData(City *c, std::string name);
501
883
std::string d_name;
504
886
//-----------------------------------------------------------------------------
888
//! A temporary record of a Player changing vectoring strategies for a City.
890
* The purpose of the Action_Vector class is to record when a Player has
891
* changed the vectoring policy of a City. The City's Army units can
892
* be vectored to another City or to a Hero's planted standard (Item).
893
* When units are vectored they take 2 turns to appear at their destination.
894
* While the vectored units are en route, they are invisible.
505
896
class Action_Vector: public Action
899
//! Make a new city vector action.
901
//! Load a new city vector action from an opened saved-game file.
509
902
Action_Vector(XML_Helper* helper);
903
//! Destroy a city vector action.
510
904
~Action_Vector();
906
//! Return some debug information about this action.
512
907
std::string dump() const;
513
bool save(XML_Helper* helper) const;
909
//! Save this city vector action to an opened saved-game file.
910
virtual bool doSave(XML_Helper* helper) const;
913
* Populate the Action_Vector class with the City being vectored
914
* from, and the destination position for the vectored units.
916
//! Populate the action with pertinent data.
515
917
bool fillData(City* src, Vector <int> dest);
519
921
Vector<int> d_dest;
522
924
//-----------------------------------------------------------------------------
926
//! A temporary record of a Player changing the fight order of an Armyset.
928
* The purpose of the Action_FightOrder action is to record when a Player
929
* changes the order in which Army units fight in battle.
523
931
class Action_FightOrder: public Action
934
//! Make a new fight order action.
526
935
Action_FightOrder();
936
//! Load a new fight order action from an opened saved-game file.
527
937
Action_FightOrder(XML_Helper* helper);
938
//! Destroy a fight order action.
528
939
~Action_FightOrder();
941
//! Return some debug information about this action.
530
942
std::string dump() const;
531
bool save(XML_Helper* helper) const;
944
//! Save this fight order action to an opened saved-game file.
945
virtual bool doSave(XML_Helper* helper) const;
947
//! Populate the action with a list of ranks, one per Army unit type.
533
948
bool fillData(std::list<Uint32> order);
536
951
std::list<Uint32> d_order;
539
954
//-----------------------------------------------------------------------------
956
//! A temporary record of a Player surrendering.
958
* The purpose of the Action_Resign class is to record when a Player has
959
* resigned from the game. Because these actions are held in a Player's
960
* Actionlist, we do not have to store the player's Id.
540
962
class Action_Resign: public Action
965
//! Make a new player resignation action.
967
//! Load a new player resignation action from an opened saved-game file.
544
968
Action_Resign(XML_Helper* helper);
969
//! Destroy a player resignation action.
545
970
~Action_Resign();
972
//! Return some debug information about this action.
547
973
std::string dump() const;
548
bool save(XML_Helper* helper) const;
975
//! Save this player resignation action to an opened saved-game file.
976
virtual bool doSave(XML_Helper* helper) const;
978
//! This method doesn't need to be called for Action_Resign actions.
553
982
//-----------------------------------------------------------------------------
984
//! A temporary record of a Hero planting a standard into the ground.
986
* The purpose of the Action_Plant class is to record when a Hero has
987
* planted a standard (e.g. a flag Item) into the ground, so that Army units
988
* can be vectored there.
554
990
class Action_Plant: public Action
993
//! Make a new item planted action.
995
//! Load a new item planted action from an opened saved-game file.
558
996
Action_Plant(XML_Helper* helper);
997
//! Destroy a item planted action.
1000
//! Return some debug information about this action.
561
1001
std::string dump() const;
562
bool save(XML_Helper* helper) const;
564
bool fillData(Uint32 hero, Uint32 item);
1003
//! Save this item planted action to an opened saved-game file.
1004
virtual bool doSave(XML_Helper* helper) const;
1006
//! Populate the action with the Id of the Hero and the Id of the Item.
1007
bool fillData(Hero *hero, Item *item);
571
1014
//-----------------------------------------------------------------------------
1016
//! A temporary record of a new Army unit showing up at a city.
1018
* The purpose of the Action_Produce class is to record when a new Army unit
1019
* is created. The idea here is that a City has produced a new Army unit.
1020
* The City might be vectoring elsewhere, so the unit doesn't show up in the
1021
* City that produced it. If vectoring is not enabled the Army unit shows
1022
* up right away in the host City.
1023
* The army unit is taken from the Player's Armyset.
572
1025
class Action_Produce: public Action
1028
//! Make a new unit produced action.
575
1029
Action_Produce();
1030
//! Load a new unit produced action from an opened saved-game file.
576
1031
Action_Produce(XML_Helper* helper);
1032
//! Destroy a unit produced action.
577
1033
~Action_Produce();
1035
//! Return some debug information about this action.
579
1036
std::string dump() const;
580
bool save(XML_Helper* helper) const;
582
bool fillData(Uint32 army_type, City *city, bool vectored);
1038
//! Save this unit produced action to an opened saved-game file.
1039
virtual bool doSave(XML_Helper* helper) const;
1042
* Populate the Action_Produce action with the army type being
1043
* produced, the City in which it has arrived, and also whether
1044
* or not this unit was prevented from showing up here because
1045
* it is being vectored elsewhere.
1047
//! Populate the action with pertinent data.
1048
bool fillData(const Army *a, City *city, bool vectored);
1050
//! Get the Id of the army type of the Army unit that was produced.
584
1051
Uint32 getArmyType() const {return d_army_type;}
1053
//! Get the Id of the City that produced the Army unit.
585
1054
Uint32 getCityId() const {return d_city;}
1056
//! Get whether or not the Army unit is being vectored elsewhere.
586
1057
bool getVectored() const {return d_vectored;}
588
1059
Uint32 d_army_type;
614
1109
//-----------------------------------------------------------------------------
1111
//! A temporary record of the diplomatic state changing.
1113
* The purpose of the Action_DiplomacyState action is to record our
1114
* diplomatic state with other players has it changes. The idea here is
1115
* that every player has a diplomatic status with every other player.
1116
* Although we might propose war on a given turn, we would achieve the
1117
* state of being at war on a later turn.
615
1119
class Action_DiplomacyState: public Action
1122
//! Make a new diplomatic state action.
618
1123
Action_DiplomacyState();
1124
//! Load a new diplomatic state action from an opened saved-game file.
619
1125
Action_DiplomacyState(XML_Helper* helper);
1126
//! Destroy a diplomatic state action.
620
1127
~Action_DiplomacyState();
1129
//! Return some debug information about this action.
622
1130
std::string dump() const;
623
bool save(XML_Helper* helper) const;
1132
//! Save this diplomatic state action to an opened saved-game file.
1133
virtual bool doSave(XML_Helper* helper) const;
1136
* Populate the Action_DiplomacyState class with the Player for
1137
* which we are in a state with. Also populate the action with
1138
* the new diplomatic state.
1140
//! Populate action with pertinent data.
625
1141
bool fillData(Player *player, Player::DiplomaticState state);
1143
//! Get the Id of the Player that we have entered a new state for.
627
1144
Uint32 getOpponentId() const {return d_opponent_id;}
628
Player::DiplomaticState getDiplomaticState() {return d_diplomatic_state;};
1146
//! Get the state that we're in with the other Player.
1147
Player::DiplomaticState getDiplomaticState() const
1148
{return d_diplomatic_state;};
630
1150
Uint32 d_opponent_id;
631
1151
Player::DiplomaticState d_diplomatic_state;
634
1154
//-----------------------------------------------------------------------------
1156
//! A temporary record of a diplomatic proposal.
1158
* The purpose of the Action_DiplomacyProposal action is to record our
1159
* diplomatic proposals to other players. The idea here is that the player
1160
* wishes to go to war with another Player and so offers/proposes war to a
1161
* prospective enemy.
635
1163
class Action_DiplomacyProposal: public Action
1166
//! Make a new diplomatic proposal action.
638
1167
Action_DiplomacyProposal();
1168
//! Load a new diplomatic proposal action from a saved-game file.
639
1169
Action_DiplomacyProposal(XML_Helper* helper);
1170
//! Destroy a diplomatic proposal action.
640
1171
~Action_DiplomacyProposal();
1173
//! Return some debug information about this action.
642
1174
std::string dump() const;
643
bool save(XML_Helper* helper) const;
1176
//! Save this diplomatic proposal action to an opened saved-game file.
1177
virtual bool doSave(XML_Helper* helper) const;
1180
* Populate the Action_DiplomacyProposal class with the Player for
1181
* which we have a new proposal for. Also populate the action with
1182
* the new diplomatic proposal.
1184
//! Populate action with pertinent data.
645
1185
bool fillData(Player *player, Player::DiplomaticProposal proposal);
1187
//! Get the Id of the Player that our proposal is for.
647
1188
Uint32 getOpponentId() const {return d_opponent_id;}
648
Player::DiplomaticProposal getDiplomaticProposal() {return d_diplomatic_proposal;};
1190
//! Get the proposal that we're offering.
1191
Player::DiplomaticProposal getDiplomaticProposal() const
1192
{return d_diplomatic_proposal;};
650
1194
Uint32 d_opponent_id;
651
1195
Player::DiplomaticProposal d_diplomatic_proposal;
654
1198
//-----------------------------------------------------------------------------
1200
//! A temporary record of the diplomatic score.
1202
* The purpose of the Action_DiplomacyScore is to record when a Player's
1203
* diplomatic opinion of another Player has changed. The idea here is that
1204
* an enemy player has razed a city and now our opinion of that player
655
1207
class Action_DiplomacyScore: public Action
1210
//! Make a new diplomatic score action.
658
1211
Action_DiplomacyScore();
1212
//! Load a new diplomatic score action from an opened saved-game file.
659
1213
Action_DiplomacyScore(XML_Helper* helper);
1214
//! Destroy a diplomatic score action.
660
1215
~Action_DiplomacyScore();
1217
//! Return some debug information about this action.
662
1218
std::string dump() const;
663
bool save(XML_Helper* helper) const;
1220
//! Save this diplomatic score action to an opened saved-game file.
1221
virtual bool doSave(XML_Helper* helper) const;
1224
* Populate the Action_DiplomacyScore class with the Player for
1225
* which we have changed our opinion of. Also populate the action
1226
* with the amount of change for that Player. The change can be
1227
* negative, and is added to the existing score to get the new
1230
//! Populate action with pertinent data.
665
1231
bool fillData(Player *player, int amount);
1233
//! Get the Id of the Player that our opinion has changed of.
667
1234
Uint32 getOpponentId() const {return d_opponent_id;}
668
int getAmountChange() {return d_amount;};
1236
//! Get the amount of the opinion change.
1237
int getAmountChange() const {return d_amount;};
670
1239
Uint32 d_opponent_id;
1243
//-----------------------------------------------------------------------------
1245
class Action_EndTurn: public Action
1248
//! Make a new end turn action.
1250
//! Load a new end turn action from an opened saved-game file.
1251
Action_EndTurn(XML_Helper* helper);
1252
//! Destroy a end turn action.
1255
//! Return some debug information about this action.
1256
std::string dump() const;
1258
//! Save this action to an opened saved-game file.
1259
virtual bool doSave(XML_Helper* helper) const;
1262
//-----------------------------------------------------------------------------
1264
class Action_ConquerCity : public Action
1267
//! Make a new city conquer action.
1268
Action_ConquerCity();
1269
//! Load a new city conquer action from an opened saved-game file.
1270
Action_ConquerCity(XML_Helper* helper);
1271
//! Destroy a city conquer action.
1272
~Action_ConquerCity();
1274
//! Return some debug information about this action.
1275
std::string dump() const;
1277
//! Save this city occupied action to an opened saved-game file.
1278
virtual bool doSave(XML_Helper* helper) const;
1280
//! Populate the action with the City being conquered.
1281
bool fillData (City* c, Stack *s);
1284
Uint32 d_city, d_stack;
1287
//-----------------------------------------------------------------------------
1289
class Action_RecruitHero : public Action
1292
//! Make a new recruit hero action.
1293
Action_RecruitHero();
1294
//! Load a new recruit hero action from an opened saved-game file.
1295
Action_RecruitHero(XML_Helper* helper);
1296
//! Destroy a recruit hero action.
1297
~Action_RecruitHero();
1299
//! Return some debug information about this action.
1300
std::string dump() const;
1302
//! Save this city occupied action to an opened saved-game file.
1303
virtual bool doSave(XML_Helper* helper) const;
1305
//! Populate the action.
1306
bool fillData(Hero* hero, City *city, int cost, int alliesCount, const Army *ally);
1310
Uint32 d_city, d_cost, d_allies, d_ally_army_type;
1312
bool load(std::string tag, XML_Helper *helper);
674
1315
#endif //ACTION_H