1 // Copyright (C) 2002, 2003, 2004, 2005, 2006 Ulf Lorenz 2 // Copyright (C) 2003 Michael Bartl 3 // Copyright (C) 2007, 2008, 2010, 2011, 2014, 2015, 2017 Ben Asselstine 4 // Copyright (C) 2008 Ole Laursen 5 // 6 // This program is free software; you can redistribute it and/or modify 7 // it under the terms of the GNU General Public License as published by 8 // the Free Software Foundation; either version 3 of the License, or 9 // (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU Library General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program; if not, write to the Free Software 18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19 // 02110-1301, USA. 20 21 #pragma once 22 #ifndef ACTION_H 23 #define ACTION_H 24 25 #include <gtkmm.h> 26 #include "vector.h" 27 #include <sigc++/trackable.h> 28 29 #include "fight.h" 30 #include "army.h" 31 #include "player.h" 32 33 class Quest; 34 class Stack; 35 class City; 36 class Signpost; 37 class Ruin; 38 class Temple; 39 class XML_Helper; 40 41 //! A temporary record of an event during gameplay. 42 /** 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. 47 * 48 * Each Player has an Actionlist to which these actions belong. 49 */ 50 51 class Action 52 { 53 public: 54 //! The xml tag of this object in a saved-game file. 55 static Glib::ustring d_tag; 56 57 //! An Action can be one of the following kinds. 58 enum Type { 59 /** A stack has moved. */ 60 STACK_MOVE = 1, 61 /** A stack has separated into two parts. */ 62 STACK_SPLIT = 2, 63 /** A stack is fighting a city or another stack. */ 64 STACK_FIGHT = 3, 65 /** A stack has merged with another stack. */ 66 STACK_JOIN = 4, 67 /** A stack containing a hero has examined a ruin. */ 68 RUIN_SEARCH = 5, 69 /** A stack has examined a temple. */ 70 TEMPLE_SEARCH = 6, 71 /** A stack has defeated a city and occupied it. */ 72 CITY_OCCUPY = 7, 73 /** A stack has defeated a city and pillaged it. */ 74 CITY_PILLAGE = 8, 75 /** A stack has defeated a city and razed it. */ 76 CITY_RAZE = 9, 77 /** A player has improved the defenses of a city. (Not used) */ 78 CITY_UPGRADE = 10, 79 /** A player has purchased a new Army unit to be produced 80 * in a city. */ 81 CITY_BUY = 11, 82 /** A player has changed production in a city to another 83 * Army unit.*/ 84 CITY_PROD = 12, 85 /** A stack has received a reward. */ 86 REWARD = 13, 87 /** A hero has received a new quest. */ 88 QUEST = 14, 89 /** A hero has picked up or dropped an item. */ 90 HERO_EQUIP = 15, 91 /** An Army unit has advanced to a new level (Only used for 92 * heroes). */ 93 UNIT_ADVANCE = 16, 94 /** A stack has defeated a city and sacked it. */ 95 CITY_SACK = 17, 96 /** A player has removed a stack. */ 97 STACK_DISBAND = 18, 98 /** A player has changed what a signpost says. */ 99 MODIFY_SIGNPOST = 19, 100 /** A player has changed the name of a city. */ 101 CITY_RENAME = 20, 102 /** A player has vectored Army units from one city to 103 * another. */ 104 CITY_VECTOR = 21, 105 /** A player has changed the order in which Army units do 106 * battle. */ 107 FIGHT_ORDER = 22, 108 /** A player has surrendered. */ 109 RESIGN = 23, 110 /** A hero has planted an item in the ground. */ 111 ITEM_PLANT = 24, 112 /** A newly produced Army unit arrives on the map. */ 113 PRODUCE_UNIT = 25, 114 /** A new vectored Army unit has shown up at a location. */ 115 PRODUCE_VECTORED_UNIT = 26, 116 /** The player's diplomatic relations with respect to another 117 * player has changed. */ 118 DIPLOMATIC_STATE = 27, 119 /** The player's diplomatic proposal with respect to another 120 * player has changed. */ 121 DIPLOMATIC_PROPOSAL = 28, 122 /** The player's diplomatic score with respect to another 123 * player has changed. */ 124 DIPLOMATIC_SCORE = 29, 125 END_TURN = 30, 126 CITY_CONQUER = 31, 127 RECRUIT_HERO = 32, 128 PLAYER_RENAME = 33, 129 CITY_DESTITUTE = 34, 130 INIT_TURN = 35, 131 CITY_LOOT = 36, 132 USE_ITEM = 37, 133 STACK_ORDER = 38, 134 STACKS_RESET = 39, 135 RUINS_RESET = 40, 136 COLLECT_TAXES_AND_PAY_UPKEEP = 41, 137 KILL_PLAYER = 42, 138 STACK_DEFEND = 43, 139 STACK_UNDEFEND = 44, 140 STACK_PARK = 45, 141 STACK_UNPARK = 46, 142 STACK_SELECT = 47, 143 STACK_DESELECT = 48 144 }; 145 static Glib::ustring actionTypeToString(Action::Type type); 146 static Action::Type actionTypeFromString(Glib::ustring str); 147 148 //! Default constructor. 149 Action(Type type); 150 151 //! Copy constructor (shallow). 152 Action(const Action &action); 153 154 //! Loading constructor. 155 Action(XML_Helper *helper); 156 157 //! Destructor. ~Action()158 virtual ~Action() {}; 159 160 //! Returns debug information. Needs to be overwritten by derivatives. 161 virtual Glib::ustring dump() const = 0; 162 163 //! Save function. See XML_Helper for information about saving. 164 bool save(XML_Helper* helper) const; 165 bool saveContents(XML_Helper* helper) const; 166 167 /** 168 * static load function (see XML_Helper) 169 * 170 * Whenever an action item is loaded, this function is called. It 171 * examines the stored id and calls the constructor of the appropriate 172 * action class. 173 * 174 * @param helper the XML_Helper instance for the savegame 175 */ 176 //! Load the action from an opened saved-game file. 177 static Action* handle_load(XML_Helper* helper); 178 179 //! Make a new action from an existing one. 180 static Action* copy(const Action* a); 181 182 //! Returns the Action::Type for this action. getType()183 Type getType() const {return d_type;} 184 185 protected: 186 virtual bool doSave(XML_Helper* helper) const = 0; 187 188 Type d_type; 189 }; 190 191 //----------------------------------------------------------------------------- 192 193 //! A temporary record of a Stack moving. 194 /** 195 * The purpose of the Action_Move class is to record when a stack has 196 * moved to a new position on the map. 197 */ 198 class Action_Move : public Action 199 { 200 public: 201 //! Make a new move action. 202 /** 203 * Populate the move action with the stack and it's new position. 204 */ 205 Action_Move(Stack* s, Vector<int> dest); 206 //! Copy constructor 207 Action_Move(const Action_Move &action); 208 //! Load a new move action from an opened saved-game file. 209 Action_Move(XML_Helper* helper); 210 //! Destroy a move action. ~Action_Move()211 ~Action_Move() {}; 212 213 //! Return some debug information about this action. 214 Glib::ustring dump() const; 215 216 //! Save this move action to an opened saved-game file. 217 virtual bool doSave(XML_Helper* helper) const; 218 getStackId()219 guint32 getStackId() const {return d_stack;}; getEndingPosition()220 Vector<int> getEndingPosition() const {return d_dest;}; getPositionDelta()221 Vector<int> getPositionDelta() const {return d_delta;}; setMovesLeft(guint32 mp)222 void setMovesLeft(guint32 mp) {d_moves_left = mp;} getMovesLeft()223 guint32 getMovesLeft() const {return d_moves_left;}; setHasShip(bool s)224 void setHasShip(bool s) {d_has_ship = s;} getHasShip()225 bool getHasShip() const {return d_has_ship;}; setHadShip(bool s)226 void setHadShip(bool s) {d_had_ship = s;} getHadShip()227 bool getHadShip() const {return d_had_ship;}; 228 229 private: 230 guint32 d_stack; 231 Vector<int> d_dest; 232 Vector<int> d_delta; 233 guint32 d_moves_left; 234 bool d_has_ship; 235 bool d_had_ship; 236 }; 237 238 //----------------------------------------------------------------------------- 239 240 //! A temporary record of a Stack being split into two. 241 /** 242 * The purpose of the Action_Split class is to record when a Stack has been 243 * separated into two parts. This happens when the Player groups only some 244 * of the Army units in the stack (not all), and then moves them to a new 245 * position on the map. When a split is completed there is the original 246 * stack (the remaining Army units in the stack that didn't change position), 247 * and a new stack added to the game (the stack containing the grouped army 248 * units). 249 */ 250 class Action_Split : public Action 251 { 252 public: 253 //! Make a new stack split action. 254 /** 255 * Populate the Action_Split class with the original Stack, and the 256 * new stack that has been added to the game. Please note that the 257 * stacks have to be already split before this call. 258 */ 259 Action_Split(Stack* orig, Stack* added); 260 //! Copy constructor 261 Action_Split(const Action_Split &action); 262 //! Load a new stack split action from an opened saved-game file. 263 Action_Split(XML_Helper* helper); 264 //! Destroy a stack split action. ~Action_Split()265 ~Action_Split() {}; 266 267 //! Return some debug information about this action. 268 Glib::ustring dump() const; 269 270 //! Save this split action to an opened saved-game file. 271 bool doSave (XML_Helper* helper) const; 272 getStackId()273 guint32 getStackId() const {return d_orig;}; getNewStackId()274 guint32 getNewStackId() const {return d_added;}; getGroupedArmyId(int idx)275 guint32 getGroupedArmyId(int idx) const {return d_armies_moved[idx];}; 276 private: 277 guint32 d_orig, d_added; 278 guint32 d_armies_moved[MAX_STACK_SIZE]; 279 }; 280 281 //! A temporary record of a Stack being disbanded. 282 /** 283 * The purpose of the Action_Disband class is to record when a stack has 284 * removed from the game. Disbanding is done to primarily to save the 285 * gold pieces paid out every turn as upkeep for the Army units in the Stack. 286 */ 287 class Action_Disband: public Action 288 { 289 public: 290 //! Make a new disband action. 291 /** 292 * Populate the action with the Stack being removed. 293 */ 294 Action_Disband(Stack *s); 295 //! Copy constructor 296 Action_Disband(const Action_Disband &action); 297 //! Load a new disband action from an opened saved-game file. 298 Action_Disband(XML_Helper* helper); 299 //! Destroy a disband action. ~Action_Disband()300 ~Action_Disband() {}; 301 302 //! Return some debug information about this action. 303 Glib::ustring dump() const; 304 305 //! Save this disband action to an opened saved-game file. 306 virtual bool doSave(XML_Helper* helper) const; 307 getStackId()308 guint32 getStackId() const {return d_stack;}; 309 310 private: 311 guint32 d_stack; 312 }; 313 314 315 //----------------------------------------------------------------------------- 316 317 //! A temporary record of a fight between opposing Stack objects. 318 /** 319 * The purpose of the Action_Fight class is to record the results of a 320 * fight between two Players. 321 */ 322 class Action_Fight : public Action 323 { 324 public: 325 //! Make a new fight action. 326 /** 327 * Populate the action with the Fight. Please note that the 328 * Fight must have already been faught. 329 */ 330 Action_Fight(const Fight* f); 331 //! Copy constructor 332 Action_Fight(const Action_Fight &action); 333 //! Load a new fight action from an opened saved-game file. 334 Action_Fight(XML_Helper* helper); 335 //! Destroy a fight action. ~Action_Fight()336 ~Action_Fight() {}; 337 338 //! Return some debug information about this action. 339 Glib::ustring dump() const; 340 341 //! Save this fight action to an opened saved-game file. 342 virtual bool doSave(XML_Helper* helper) const; 343 getBattleHistory()344 std::list<FightItem> getBattleHistory() const {return d_history;}; getAttackerStackIds()345 std::list<guint32> getAttackerStackIds() const {return d_attackers;}; getDefenderStackIds()346 std::list<guint32> getDefenderStackIds() const {return d_defenders;}; getAttackerArmyIds()347 std::list<guint32> getAttackerArmyIds() const {return d_attacker_army_ids;}; getDefenderArmyIds()348 std::list<guint32> getDefenderArmyIds() const {return d_defender_army_ids;}; 349 350 bool is_army_id_in_stacks(guint32 id, std::list<guint32> stack_ids) const; 351 private: 352 353 std::list<FightItem> d_history; 354 std::list<guint32> d_attackers; 355 std::list<guint32> d_defenders; 356 std::list<guint32> d_attacker_army_ids; 357 std::list<guint32> d_defender_army_ids; 358 359 bool stack_ids_to_stacks(std::list<guint32> stack_ids, std::list<Stack*> &stacks, guint32 &stack_id) const; 360 361 bool loadItem(XML_Helper* helper); 362 }; 363 364 //----------------------------------------------------------------------------- 365 366 //! A temporary record of two Stack objects merging into one. 367 /** 368 * The purpose of the Action_Join class is to record a Stack has had 369 * another Stack merged into it. 370 */ 371 class Action_Join : public Action 372 { 373 public: 374 //! Make a new stack join action. 375 /** 376 * Populate the Action_Join class with the original Stack, and the 377 * stack that is merging into the original one. Please note that 378 * this method must be called before the merge takes place. 379 */ 380 Action_Join(Stack* orig, Stack* joining); 381 //! Copy constructor 382 Action_Join(const Action_Join &action); 383 //! Load a new stack join action from an opened saved-game file. 384 Action_Join(XML_Helper* helper); 385 //! Destroy a stack join action. ~Action_Join()386 ~Action_Join() {}; 387 388 //! Return some debug information about this action. 389 Glib::ustring dump() const; 390 391 //! Save this stack join action to an opened saved-game file. 392 virtual bool doSave(XML_Helper* helper) const; 393 getReceivingStackId()394 guint32 getReceivingStackId() const {return d_orig_id;}; getJoiningStackId()395 guint32 getJoiningStackId() const {return d_joining_id;}; 396 private: 397 guint32 d_orig_id, d_joining_id; 398 }; 399 400 //----------------------------------------------------------------------------- 401 402 //! A temporary record of what happened when a Stack searched a Ruin. 403 /** 404 * The purpose of the Action_Ruin class is to record what happens when a 405 * Stack containing a Hero attempts to search a Ruin. 406 */ 407 class Action_Ruin : public Action 408 { 409 public: 410 //! Make a new ruin search attempted action. 411 /** 412 * Populate the Action_Ruin class with the Stack containing the 413 * Hero Army unit, and the Ruin being searched. 414 */ 415 Action_Ruin(Ruin* r, Stack* explorers); 416 //! Copy constructor 417 Action_Ruin(const Action_Ruin&action); 418 //! Load a new ruin search attempted action from a saved-game file. 419 Action_Ruin(XML_Helper* helper); 420 //! Destroy a ruin search attempted action. ~Action_Ruin()421 ~Action_Ruin() {}; 422 423 //! Return some debug information about this action. 424 Glib::ustring dump() const; 425 426 //! Save this ruin search attempted action to a saved-game file. 427 virtual bool doSave(XML_Helper* helper) const; 428 getRuinId()429 guint32 getRuinId() const {return d_ruin;}; getStackId()430 guint32 getStackId() const {return d_stack;}; getSearchSuccessful()431 bool getSearchSuccessful() const {return d_searched;}; 432 433 private: 434 guint32 d_ruin; 435 guint32 d_stack; 436 bool d_searched; 437 }; 438 439 //----------------------------------------------------------------------------- 440 441 //! A temporary record of what happened when a Stack visited a Temple. 442 /** 443 * The purpose of the Action_Temple class is to record what happens when 444 * a Stack visits a Temple. The Stack may be getting blessed, or instead it 445 * might be a Stack containing a Hero who is obtaining a new Quest. 446 */ 447 class Action_Temple : public Action 448 { 449 public: 450 //! Make a new temple search action. 451 /** 452 * Populate the Action_Temple class with the Stack and the Temple 453 * being searched. 454 */ 455 Action_Temple(Temple* t, Stack* s); 456 //! Copy constructor 457 Action_Temple(const Action_Temple &action); 458 //! Load a new temple search action from a saved-game file. 459 Action_Temple(XML_Helper* helper); 460 //! Destroy a temple search action. ~Action_Temple()461 ~Action_Temple() {}; 462 463 //! Return some debug information about this action. 464 Glib::ustring dump() const; 465 466 //! Save this temple search attempted action to a saved-game file. 467 virtual bool doSave(XML_Helper* helper) const; 468 getTempleId()469 guint32 getTempleId() const {return d_temple;}; getStackId()470 guint32 getStackId() const {return d_stack;}; 471 472 private: 473 guint32 d_temple; 474 guint32 d_stack; 475 }; 476 477 478 //----------------------------------------------------------------------------- 479 480 //! A temporary record of what happened when a Player occupied a City. 481 /** 482 * The purpose of the Action_Occupy class is to record when a Player has 483 * defeated a City and has occupied it. Ocuppying differs from sacking 484 * and pillaging in that none of the existing Army units in the City are 485 * exchanged for gold pieces. 486 */ 487 class Action_Occupy : public Action 488 { 489 public: 490 //! Make a new city occupy action. 491 Action_Occupy(City *c); 492 //! Copy constructor. 493 Action_Occupy(const Action_Occupy &action); 494 //! Load a new city occupied action from an opened saved-game file. 495 Action_Occupy(XML_Helper* helper); 496 //! Destroy a city occupy action. ~Action_Occupy()497 ~Action_Occupy() {}; 498 499 //! Return some debug information about this action. 500 Glib::ustring dump() const; 501 502 //! Save this city occupied action to an opened saved-game file. 503 virtual bool doSave(XML_Helper* helper) const; 504 getCityId()505 guint32 getCityId() const {return d_city;}; 506 507 private: 508 guint32 d_city; 509 }; 510 511 //----------------------------------------------------------------------------- 512 513 //! A temporary record of what happened when a Player pillaged a City. 514 /** 515 * The purpose of the Action_Pillage class is to record when a Player has 516 * defeated a City and has pillaged it. Pillaging a city results in the 517 * strongest Army unit being produced in that city being exchanged for an 518 * amount of gold pieces. 519 */ 520 class Action_Pillage : public Action 521 { 522 public: 523 //! Make a new city pillaged action. 524 Action_Pillage(City *c); 525 //! Copy constructor 526 Action_Pillage(const Action_Pillage &action); 527 //! Load a new city pillaged action from an opened saved-game file. 528 Action_Pillage(XML_Helper* helper); 529 //! Destroy a city pillaged action. ~Action_Pillage()530 ~Action_Pillage() {}; 531 532 //! Return some debug information about this action. 533 Glib::ustring dump() const; 534 535 //! Save this city pillaged action to an opened saved-game file. 536 virtual bool doSave(XML_Helper* helper) const; 537 getCityId()538 guint32 getCityId() const {return d_city;}; 539 540 private: 541 guint32 d_city; 542 }; 543 544 //----------------------------------------------------------------------------- 545 546 //! A temporary record of what happened when a Player sacked a City. 547 /** 548 * The purpose of the Action_Sack class is to record when a Player has 549 * defeated a City and has sacked it. Sacking a city results in all 550 * Army units, except the weakest being exchanged for an amount of gold 551 * pieces. 552 */ 553 class Action_Sack : public Action 554 { 555 public: 556 //! Make a new city sacked action. 557 Action_Sack(City *c); 558 //! Copy constructor 559 Action_Sack(const Action_Sack &action); 560 //! Load a new city sacked action from an opened saved-game file. 561 Action_Sack(XML_Helper* helper); 562 //! Destroy a city sacked action. ~Action_Sack()563 ~Action_Sack() {}; 564 565 //! Return some debug information about this action. 566 Glib::ustring dump() const; 567 568 //! Save this city sacked action to an opened saved-game file. 569 virtual bool doSave(XML_Helper* helper) const; 570 getCityId()571 guint32 getCityId() const {return d_city;}; 572 573 private: 574 guint32 d_city; 575 }; 576 577 //----------------------------------------------------------------------------- 578 579 //! A temporary record of what happened when a Player razed a City. 580 /** 581 * The purpose of the Action_Raze class is to record when a Player has 582 * defeated a City and has razed it. Razing a city results in that 583 * city becoming uninhabitable, and it ceases to produce new Army units. 584 */ 585 class Action_Raze : public Action 586 { 587 public: 588 //! Make a new city razed action. 589 Action_Raze(City *c); 590 //! Copy constructor 591 Action_Raze(const Action_Raze &action); 592 //! Load a new city razed action from an opened saved-game file. 593 Action_Raze(XML_Helper* helper); 594 //! Destroy a city razed action. ~Action_Raze()595 ~Action_Raze() {}; 596 597 //! Return some debug information about this action. 598 Glib::ustring dump() const; 599 600 //! Save this city razed action to an opened saved-game file. 601 virtual bool doSave(XML_Helper* helper) const; 602 getCityId()603 guint32 getCityId() const {return d_city;}; 604 605 private: 606 guint32 d_city; 607 }; 608 609 //----------------------------------------------------------------------------- 610 611 //! A temporary record of what happened when a City's defenses were increased. 612 /** 613 * The purpose of the Action_Upgrade class is to record when a Player has 614 * improved the City's defenses. This action is not currently used by 615 * LordsAWar. 616 */ 617 class Action_Upgrade : public Action 618 { 619 public: 620 //! Make a new city upgraded action. 621 /** 622 * Populate the action with the City that has been upgraded. 623 */ 624 Action_Upgrade(City *c); 625 //! Copy constructor 626 Action_Upgrade(const Action_Upgrade &action); 627 //! Load a new city upgraded action from an opened saved-game file. 628 Action_Upgrade(XML_Helper* helper); 629 //! Destroy a city upgraded action. ~Action_Upgrade()630 ~Action_Upgrade() {}; 631 632 //! Return some debug information about this action. 633 Glib::ustring dump() const; 634 635 //! Save this city upgraded action to an opened saved-game file. 636 virtual bool doSave(XML_Helper* helper) const; 637 getCityId()638 guint32 getCityId() const {return d_city;}; 639 640 private: 641 guint32 d_city; 642 }; 643 644 //----------------------------------------------------------------------------- 645 646 //! A temporary record of more production being added to a City. 647 /** 648 * The purpose of the Action_Buy class is to record when a Player purchases 649 * a new Army unit for production in a City. When this happens the player 650 * specifies a production slot to hold the new Army unit type. Any existing 651 * Army unit type in that slot before the buy is removed. 652 * The idea here is that the city may produce one Army unit type from a set 653 * of available Army units, and this action records what happens when we make 654 * a new kind of Army unit available for production in the City. 655 * The army unit is taken from the Player's Armyset. 656 */ 657 class Action_Buy : public Action 658 { 659 public: 660 //! Make a new city buy production action. 661 /** 662 * Populate the Action_Buy with City where the buy has happened. 663 * Also populate it with the City's production slot that is now 664 * producing the new Army unit type. Lastly, populate the Action_Buy 665 * with the new Army unit type being produced. 666 */ 667 Action_Buy(City* c, int slot, const ArmyProto *prod); 668 //! Copy constructor 669 Action_Buy(const Action_Buy &action); 670 //! Load a new city buy production action from a saved-game file. 671 Action_Buy(XML_Helper* helper); 672 //! Destroy a city buy production action. ~Action_Buy()673 ~Action_Buy() {}; 674 675 //! Return some debug information about this action. 676 Glib::ustring dump() const; 677 678 //! Save this city buy production action to an opened saved-game file. 679 virtual bool doSave(XML_Helper* helper) const; 680 getCityId()681 guint32 getCityId() const {return d_city;}; getProductionSlot()682 int getProductionSlot() const {return d_slot;}; getBoughtArmyTypeId()683 int getBoughtArmyTypeId() const {return d_prod;}; 684 private: 685 guint32 d_city; 686 int d_slot, d_prod; 687 }; 688 689 //----------------------------------------------------------------------------- 690 691 //! A temporary record of a change in production strategy in a City. 692 /** 693 * The purpose of the Action_Production class is to record when the Player 694 * changes the production of new Army units within a City. The idea here 695 * is that the City has a set of available Army units that it may produce, 696 * and the Player has selected a different Army unit to produce, or has 697 * stopped production of new Army units altogether. 698 */ 699 class Action_Production : public Action 700 { 701 public: 702 //! Make a new city change production action. 703 /** 704 * Populate the Action_Production with City where the change 705 * in production has taken place. Also populate it with the newly 706 * active production slot (-1 means stopped). 707 */ 708 Action_Production(City* c, int slot); 709 //! Copy constructor 710 Action_Production (const Action_Production &action); 711 //! Load a new city change production action from a saved-game file. 712 Action_Production(XML_Helper* helper); 713 //! Destroy a city change production action. ~Action_Production()714 ~Action_Production() {}; 715 716 //! Return some debug information about this action. 717 Glib::ustring dump() const; 718 719 //! Save this city change production action to a saved-game file. 720 virtual bool doSave(XML_Helper* helper) const; 721 getCityId()722 guint32 getCityId() const {return d_city;}; getSlot()723 int getSlot() const {return d_prod;}; 724 725 private: 726 guint32 d_city; 727 int d_prod; 728 }; 729 730 //----------------------------------------------------------------------------- 731 732 //! A temporary record of a Player or Stack getting a Reward. 733 /** 734 * The purpose of the Action_Reward class is to record when the Player 735 * has been given a Reward. 736 * It could be that the player has been given: Some gold pieces, a map that 737 * makes more of the map visible or information about the location of a new 738 * ruin. It could also be that the player's active stack has been given 739 * a number of allies. It could also be that the Player's active Stack 740 * contains a Hero, and the Reward is an Item for the Hero to carry. 741 */ 742 class Action_Reward : public Action 743 { 744 public: 745 //! Make a new player rewarded action. 746 Action_Reward(Stack *stack, Reward *r); 747 //! Copy constructor 748 Action_Reward (const Action_Reward &action); 749 //! Load a new player rewarded action from a saved-game file. 750 Action_Reward(XML_Helper* helper); 751 //! Destroy a player rewarded action. 752 ~Action_Reward(); 753 754 //! Return some debug information about this action. 755 Glib::ustring dump() const; 756 757 //! Save this player rewarded action to a saved-game file. 758 virtual bool doSave(XML_Helper* helper) const; 759 getReward()760 Reward *getReward() const {return d_reward;}; getStackId()761 guint32 getStackId() const {return d_stack;}; 762 763 private: 764 Reward *d_reward; 765 guint32 d_stack; 766 767 bool load(Glib::ustring tag, XML_Helper *helper); 768 }; 769 770 //----------------------------------------------------------------------------- 771 772 //! A temporary record of a Hero initiating a new Quest. 773 /** 774 * The purpose of the Action_Quest class is to record when a Player's 775 * Hero has gone to a Temple and initiated a new Quest. 776 */ 777 class Action_Quest : public Action 778 { 779 public: 780 //! Make a new hero quest assigned action. 781 Action_Quest(Quest* q); 782 //! Copy constructor 783 Action_Quest (const Action_Quest &action); 784 //! Load a new hero quest assigned action from a saved-game file. 785 Action_Quest(XML_Helper* helper); 786 //! Destroy a hero quest assigned action. ~Action_Quest()787 ~Action_Quest() {}; 788 789 //! Return some debug information about this action. 790 Glib::ustring dump() const; 791 792 //! Save this hero quest assigned action to a saved-game file. 793 virtual bool doSave(XML_Helper* helper) const; 794 getHeroId()795 guint32 getHeroId() const {return d_hero;}; getQuestType()796 guint32 getQuestType() const {return d_questtype;}; getData()797 guint32 getData() const {return d_data;}; getVictimPlayerId()798 guint32 getVictimPlayerId() const {return d_victim_player;}; 799 800 private: 801 guint32 d_hero; 802 guint32 d_questtype; 803 guint32 d_data; 804 guint32 d_victim_player; //victim player, only KILLARMIES uses this 805 }; 806 807 //----------------------------------------------------------------------------- 808 809 //! A temporary record of a Hero picking up or dropping an Item. 810 /** 811 * The purpose of the Action_Equip class is to record when a Player's Hero 812 * has picked up an Item or dropped it onto the ground. Heroes pick up 813 * and drop Items one at a time. 814 */ 815 class Action_Equip : public Action 816 { 817 public: 818 enum Slot { 819 // The Item is going neither to the ground or the backpack. 820 NONE = 0, 821 //! The Item has gone into the Hero's Backpack. 822 BACKPACK = 1, 823 //! The Item has been dropped onto the ground. 824 GROUND = 2}; 825 826 //! Make a new item equipped action. 827 /** 828 * Populate the Action_Equip class with the Id of the Hero, 829 * the Id of the Item and the destination of the Item in terms of 830 * it's Action_Equip::Slot. 831 */ 832 Action_Equip(Hero *hero, Item *item, Slot slot, Vector<int> pos); 833 //! Copy constructor 834 Action_Equip (const Action_Equip &action); 835 //! Load a new item equipped action from an opened saved-game file. 836 Action_Equip(XML_Helper* helper); 837 //! Destroy an item equipped action. ~Action_Equip()838 ~Action_Equip() {}; 839 840 //! Return some debug information about this action. 841 Glib::ustring dump() const; 842 843 //! Save this item equipped action to an opened saved-game file. 844 virtual bool doSave(XML_Helper* helper) const; 845 getHeroId()846 guint32 getHeroId() const {return d_hero;}; getItemId()847 guint32 getItemId() const {return d_item;}; getToBackpackOrToGround()848 guint32 getToBackpackOrToGround() const {return d_slot;}; getItemPos()849 Vector<int> getItemPos() const {return d_pos;}; 850 851 private: 852 guint32 d_hero; 853 guint32 d_item; 854 guint32 d_slot; 855 Vector<int> d_pos; 856 }; 857 858 //----------------------------------------------------------------------------- 859 860 //! A temporary record of a Hero gaining a new level. 861 /** 862 * The purpose of the Action_Level class is to record when a Player's Hero 863 * advances a level and subsequently gains a stat. 864 * Stats that may get increased are: Strength, Moves, and Sight (for use on 865 * a hidden map). 866 */ 867 class Action_Level : public Action 868 { 869 public: 870 //! Make a new level advancement action. 871 /** 872 * Populate the Action_Level class with the the Id of the Hero 873 * Army unit, and also the Hero's stat that has been raised as a 874 * result of the level advancement. 875 */ 876 Action_Level(Army *unit, Army::Stat raised); 877 //! Copy constructor 878 Action_Level (const Action_Level &action); 879 //! Load a new level advancement action from an opened saved-game file. 880 Action_Level(XML_Helper* helper); 881 //! Destroy a level advancement action. ~Action_Level()882 ~Action_Level() {}; 883 884 //! Return some debug information about this action. 885 Glib::ustring dump() const; 886 887 //! Save this level advancement action to an opened saved-game file. 888 virtual bool doSave(XML_Helper* helper) const; 889 getArmyId()890 guint32 getArmyId() const {return d_army;}; getStatToIncrease()891 guint32 getStatToIncrease() const {return d_stat;}; 892 893 private: 894 guint32 d_army; 895 guint32 d_stat; 896 }; 897 898 //----------------------------------------------------------------------------- 899 900 //! A temporary record of a Player changing the contents of a Signpost. 901 /** 902 * The purpose of the Action_ModifySignpost is to record when a Signpost 903 * has been altered by a player to have a different message on it. The 904 * idea here is that we're playing on a hidden map and a Player wants to 905 * thwart an opponent by changing what signs say before he can read them. 906 */ 907 class Action_ModifySignpost: public Action 908 { 909 public: 910 //! Make a new change signpost action. 911 /** 912 * Populate the action with the signpost and the new message. 913 */ 914 Action_ModifySignpost(Signpost * s, Glib::ustring message); 915 //! Copy constructor 916 Action_ModifySignpost(const Action_ModifySignpost &action); 917 //! Load a new change signpost action from an opened saved-game file. 918 Action_ModifySignpost(XML_Helper* helper); 919 //! Destroy a change signpost action. ~Action_ModifySignpost()920 ~Action_ModifySignpost() {}; 921 922 //! Return some debug information about this action. 923 Glib::ustring dump() const; 924 925 //! Save this change signpost action to an opened saved-game file. 926 virtual bool doSave(XML_Helper* helper) const; 927 getSignpostId()928 guint32 getSignpostId() const {return d_signpost;}; getSignContents()929 Glib::ustring getSignContents() const {return d_message;}; 930 931 private: 932 guint32 d_signpost; 933 Glib::ustring d_message; 934 }; 935 936 //----------------------------------------------------------------------------- 937 938 //! A temporary record of a Player changing the name of a City. 939 /** 940 * The purpose of the Action_RenameCity class is to record when a Player has 941 * changed the name of a City. The idea here is that a Player wants 942 * to gloat by renaming a newly conquered City. 943 */ 944 class Action_RenameCity: public Action 945 { 946 public: 947 //! Make a new city rename action. 948 /** 949 * Populate the action with the city being renamed and the new name. 950 */ 951 Action_RenameCity(City* c, Glib::ustring name); 952 //! Copy constructor 953 Action_RenameCity(const Action_RenameCity &action); 954 //! Load a new city rename action from an opened saved-game file. 955 Action_RenameCity(XML_Helper* helper); 956 //! Destroy a city rename action. ~Action_RenameCity()957 ~Action_RenameCity() {}; 958 959 //! Return some debug information about this action. 960 Glib::ustring dump() const; 961 962 //! Save this city rename action to an opened saved-game file. 963 virtual bool doSave(XML_Helper* helper) const; 964 getCityId()965 guint32 getCityId() const {return d_city;}; getNewCityName()966 Glib::ustring getNewCityName() const {return d_name;}; 967 private: 968 guint32 d_city; 969 Glib::ustring d_name; 970 }; 971 972 //----------------------------------------------------------------------------- 973 974 //! A temporary record of a Player changing vectoring strategies for a City. 975 /** 976 * The purpose of the Action_Vector class is to record when a Player has 977 * changed the vectoring policy of a City. The City's Army units can 978 * be vectored to another City or to a Hero's planted standard (Item). 979 * When units are vectored they take 2 turns to appear at their destination. 980 * While the vectored units are en route, they are invisible. 981 */ 982 class Action_Vector: public Action 983 { 984 public: 985 //! Make a new city vector action. 986 /** 987 * Populate the Action_Vector class with the City being vectored 988 * from, and the destination position for the vectored units. 989 */ 990 Action_Vector(City* src, Vector<int> dest); 991 //! Copy constructor 992 Action_Vector(const Action_Vector &action); 993 //! Load a new city vector action from an opened saved-game file. 994 Action_Vector(XML_Helper* helper); 995 //! Destroy a city vector action. ~Action_Vector()996 ~Action_Vector() {}; 997 998 //! Return some debug information about this action. 999 Glib::ustring dump() const; 1000 1001 //! Save this city vector action to an opened saved-game file. 1002 virtual bool doSave(XML_Helper* helper) const; 1003 getCityId()1004 guint32 getCityId() const {return d_city;}; getVectoringDestination()1005 Vector<int> getVectoringDestination() const {return d_dest;}; 1006 1007 private: 1008 guint32 d_city; 1009 Vector<int> d_dest; 1010 }; 1011 1012 //----------------------------------------------------------------------------- 1013 1014 //! A temporary record of a Player changing the fight order of an Armyset. 1015 /** 1016 * The purpose of the Action_FightOrder action is to record when a Player 1017 * changes the order in which Army units fight in battle. 1018 */ 1019 class Action_FightOrder: public Action 1020 { 1021 public: 1022 //! Make a new fight order action. 1023 /** 1024 * Populate the action with a list of ranks, one per Army unit type. 1025 */ 1026 Action_FightOrder(std::list<guint32> order); 1027 //! Copy constructor 1028 Action_FightOrder(const Action_FightOrder &action); 1029 //! Load a new fight order action from an opened saved-game file. 1030 Action_FightOrder(XML_Helper* helper); 1031 //! Destroy a fight order action. ~Action_FightOrder()1032 ~Action_FightOrder() {}; 1033 1034 //! Return some debug information about this action. 1035 Glib::ustring dump() const; 1036 1037 //! Save this fight order action to an opened saved-game file. 1038 virtual bool doSave(XML_Helper* helper) const; 1039 getFightOrder()1040 std::list<guint32> getFightOrder() const {return d_order;}; 1041 1042 private: 1043 std::list<guint32> d_order; 1044 }; 1045 1046 //----------------------------------------------------------------------------- 1047 1048 //! A temporary record of a Player surrendering. 1049 /** 1050 * The purpose of the Action_Resign class is to record when a Player has 1051 * resigned from the game. Because these actions are held in a Player's 1052 * Actionlist, we do not have to store the player's Id. 1053 */ 1054 class Action_Resign: public Action 1055 { 1056 public: 1057 //! Make a new player resignation action. 1058 Action_Resign(); 1059 //! Copy constructor 1060 Action_Resign(const Action_Resign &action); 1061 //! Load a new player resignation action from an opened saved-game file. 1062 Action_Resign(XML_Helper* helper); 1063 //! Destroy a player resignation action. ~Action_Resign()1064 ~Action_Resign() {}; 1065 1066 //! Return some debug information about this action. 1067 Glib::ustring dump() const; 1068 1069 //! Save this player resignation action to an opened saved-game file. 1070 virtual bool doSave(XML_Helper* helper) const; 1071 }; 1072 1073 //----------------------------------------------------------------------------- 1074 1075 //! A temporary record of a Hero planting a standard into the ground. 1076 /** 1077 * The purpose of the Action_Plant class is to record when a Hero has 1078 * planted a standard (e.g. a flag Item) into the ground, so that Army units 1079 * can be vectored there. 1080 */ 1081 class Action_Plant: public Action 1082 { 1083 public: 1084 //! Make a new item planted action. 1085 /** 1086 * Populate the action with the Id of the Hero and the Id of the Item. 1087 */ 1088 Action_Plant(Hero *hero, Item *item); 1089 //! Copy constructor 1090 Action_Plant(const Action_Plant &action); 1091 //! Load a new item planted action from an opened saved-game file. 1092 Action_Plant(XML_Helper* helper); 1093 //! Destroy a item planted action. ~Action_Plant()1094 ~Action_Plant() {}; 1095 1096 //! Return some debug information about this action. 1097 Glib::ustring dump() const; 1098 1099 //! Save this item planted action to an opened saved-game file. 1100 virtual bool doSave(XML_Helper* helper) const; 1101 getHeroId()1102 guint32 getHeroId() const {return d_hero;}; getItemId()1103 guint32 getItemId() const {return d_item;}; 1104 1105 private: 1106 guint32 d_hero; 1107 guint32 d_item; 1108 }; 1109 1110 //----------------------------------------------------------------------------- 1111 1112 //! A temporary record of a new Army unit showing up at a city. 1113 /** 1114 * The purpose of the Action_Produce class is to record when a new Army unit 1115 * is created. The idea here is that a City has produced a new Army unit. 1116 * The City might be vectoring elsewhere, so the unit doesn't show up in the 1117 * City that produced it. If vectoring is not enabled the Army unit shows 1118 * up right away in the host City. 1119 * This action is used primarily for reporting purposes. The player's 1120 * production report shows which army units were created in what cities. 1121 * The army unit is taken from the Player's Armyset. 1122 */ 1123 class Action_Produce: public Action 1124 { 1125 public: 1126 //! Make a new unit produced action. 1127 /** 1128 * Populate the Action_Produce action with the army type being 1129 * produced, the City in which it has arrived, and also whether 1130 * or not this unit was prevented from showing up here because 1131 * it is being vectored elsewhere. 1132 * 1133 * pos is the vectored location if we're vectoring 1134 * or it's the position on the map where the newly produced army ended 1135 * up. 1136 */ 1137 Action_Produce(const ArmyProdBase *army, City *city, bool vectored, 1138 Vector<int> pos, guint32 army_id, guint32 stack_id); 1139 //! Copy constructor 1140 Action_Produce(const Action_Produce &action); 1141 //! Load a new unit produced action from an opened saved-game file. 1142 Action_Produce(XML_Helper* helper); 1143 //! Destroy a unit produced action. 1144 ~Action_Produce(); 1145 1146 //! Return some debug information about this action. 1147 Glib::ustring dump() const; 1148 1149 //! Save this unit produced action to an opened saved-game file. 1150 virtual bool doSave(XML_Helper* helper) const; 1151 1152 //! Get the production details of the army that was produced. getArmy()1153 ArmyProdBase * getArmy() const {return d_army;} 1154 1155 //! Get the Id of the City that produced the Army unit. getCityId()1156 guint32 getCityId() const {return d_city;} 1157 1158 //! Get whether or not the Army unit is being vectored elsewhere. getVectored()1159 bool getVectored() const {return d_vectored;} 1160 1161 //! Get where this army ends up on the map. getDestination()1162 Vector<int> getDestination() const {return d_dest;} 1163 1164 //! Get the id of the army instance that was created. getArmyId()1165 guint32 getArmyId() const {return d_army_id;} 1166 1167 //! Get the id of the stack that the army instance that was created in. getStackId()1168 guint32 getStackId() const {return d_stack_id;} 1169 private: 1170 ArmyProdBase *d_army; 1171 guint32 d_city; 1172 bool d_vectored; 1173 Vector<int> d_dest; 1174 guint32 d_army_id; 1175 guint32 d_stack_id; 1176 1177 bool load(Glib::ustring tag, XML_Helper *helper); 1178 }; 1179 1180 1181 //----------------------------------------------------------------------------- 1182 1183 //! A temporary record of a vectored Army unit showing up at a city. 1184 /** 1185 * The purpose of the Action_ProduceVectored class is to record when a new 1186 * vectored Army unit arrives at it's destination. The idea here is that 1187 * two turns have passed since a unit was vectored, and now the unit has 1188 * shown up. 1189 * This action is used primarily for reporting purposes. The player's 1190 * production report shows which vectored army units arrived in what cities. 1191 * The army unit is taken from the Player's Armyset. 1192 */ 1193 class Action_ProduceVectored: public Action 1194 { 1195 public: 1196 //! Make a new vector arrival action. 1197 /** 1198 * Populate the Action_ProduceVectored with the Id of the army 1199 * unit type being produced, and the position on the map where 1200 * it has showing up. 1201 */ 1202 Action_ProduceVectored(ArmyProdBase *army, Vector<int> dest, 1203 Vector<int> src, guint32 target_army_id, 1204 guint32 target_stack_id); 1205 //! Copy constructor 1206 Action_ProduceVectored(const Action_ProduceVectored &action); 1207 //! Load a new vector arrival action from an opened saved-game file. 1208 Action_ProduceVectored(XML_Helper* helper); 1209 //! Destroy a vector arrival action. 1210 ~Action_ProduceVectored(); 1211 1212 //! Return some debug information about this action. 1213 Glib::ustring dump() const; 1214 1215 //! Save this vector arrival action to an opened saved-game file. 1216 virtual bool doSave(XML_Helper* helper) const; 1217 1218 //! Get the army type Id that has shown up. getArmy()1219 ArmyProdBase *getArmy() const {return d_army;}; 1220 1221 //! Get the position on the map where the army showed up. getDestination()1222 Vector<int> getDestination() const {return d_dest;} 1223 1224 //! Get the position on the map where the army is coming from. getOrigination()1225 Vector<int> getOrigination() const {return d_src;} 1226 1227 //! Get the expected army id of the newly arrived unit. getTargetArmyId()1228 guint32 getTargetArmyId() const {return d_target_army_id;} 1229 1230 //! Get the expected stack id of the newly arrived unit. getTargetStackId()1231 guint32 getTargetStackId() const {return d_target_stack_id;} 1232 private: 1233 ArmyProdBase *d_army; 1234 Vector<int> d_dest; 1235 Vector<int> d_src; 1236 guint32 d_target_army_id; 1237 guint32 d_target_stack_id; 1238 bool load(Glib::ustring tag, XML_Helper *helper); 1239 }; 1240 1241 //----------------------------------------------------------------------------- 1242 1243 //! A temporary record of the diplomatic state changing. 1244 /** 1245 * The purpose of the Action_DiplomacyState action is to record our 1246 * diplomatic state with other players has it changes. The idea here is 1247 * that every player has a diplomatic status with every other player. 1248 * Although we might propose war on a given turn, we would achieve the 1249 * state of being at war on a later turn. 1250 */ 1251 class Action_DiplomacyState: public Action 1252 { 1253 public: 1254 //! Make a new diplomatic state action. 1255 /** 1256 * Populate the Action_DiplomacyState class with the Player for 1257 * which we are in a state with. Also populate the action with 1258 * the new diplomatic state. 1259 */ 1260 Action_DiplomacyState(Player *p, Player::DiplomaticState state); 1261 //! Copy constructor 1262 Action_DiplomacyState(const Action_DiplomacyState &action); 1263 //! Load a new diplomatic state action from an opened saved-game file. 1264 Action_DiplomacyState(XML_Helper* helper); 1265 //! Destroy a diplomatic state action. ~Action_DiplomacyState()1266 ~Action_DiplomacyState() {}; 1267 1268 //! Return some debug information about this action. 1269 Glib::ustring dump() const; 1270 1271 //! Save this diplomatic state action to an opened saved-game file. 1272 virtual bool doSave(XML_Helper* helper) const; 1273 1274 //! Get the Id of the Player that we have entered a new state for. getOpponentId()1275 guint32 getOpponentId() const {return d_opponent_id;} 1276 1277 //! Get the state that we're in with the other Player. getDiplomaticState()1278 Player::DiplomaticState getDiplomaticState() const 1279 {return d_diplomatic_state;}; 1280 private: 1281 guint32 d_opponent_id; 1282 Player::DiplomaticState d_diplomatic_state; 1283 }; 1284 1285 //----------------------------------------------------------------------------- 1286 1287 //! A temporary record of a diplomatic proposal. 1288 /** 1289 * The purpose of the Action_DiplomacyProposal action is to record our 1290 * diplomatic proposals to other players. The idea here is that the player 1291 * wishes to go to war with another Player and so offers/proposes war to a 1292 * prospective enemy. 1293 */ 1294 class Action_DiplomacyProposal: public Action 1295 { 1296 public: 1297 //! Make a new diplomatic proposal action. 1298 /** 1299 * Populate the Action_DiplomacyProposal class with the Player for 1300 * which we have a new proposal for. Also populate the action with 1301 * the new diplomatic proposal. 1302 */ 1303 Action_DiplomacyProposal(Player *p, Player::DiplomaticProposal proposal); 1304 //! Copy constructor 1305 Action_DiplomacyProposal(const Action_DiplomacyProposal &action); 1306 //! Load a new diplomatic proposal action from a saved-game file. 1307 Action_DiplomacyProposal(XML_Helper* helper); 1308 //! Destroy a diplomatic proposal action. ~Action_DiplomacyProposal()1309 ~Action_DiplomacyProposal() {}; 1310 1311 //! Return some debug information about this action. 1312 Glib::ustring dump() const; 1313 1314 //! Save this diplomatic proposal action to an opened saved-game file. 1315 virtual bool doSave(XML_Helper* helper) const; 1316 1317 //! Get the Id of the Player that our proposal is for. getOpponentId()1318 guint32 getOpponentId() const {return d_opponent_id;} 1319 1320 //! Get the proposal that we're offering. getDiplomaticProposal()1321 Player::DiplomaticProposal getDiplomaticProposal() const 1322 {return d_diplomatic_proposal;}; 1323 private: 1324 guint32 d_opponent_id; 1325 Player::DiplomaticProposal d_diplomatic_proposal; 1326 }; 1327 1328 //----------------------------------------------------------------------------- 1329 1330 //! A temporary record of the diplomatic score. 1331 /** 1332 * The purpose of the Action_DiplomacyScore is to record when a Player's 1333 * diplomatic opinion of another Player has changed. The idea here is that 1334 * an enemy player has razed a city and now our opinion of that player 1335 * deteriorates. 1336 */ 1337 class Action_DiplomacyScore: public Action 1338 { 1339 public: 1340 //! Make a new diplomatic score action. 1341 /** 1342 * Populate the Action_DiplomacyScore class with the Player for 1343 * which we have changed our opinion of. Also populate the action 1344 * with the amount of change for that Player. The change can be 1345 * negative, and is added to the existing score to get the new 1346 * score. 1347 */ 1348 Action_DiplomacyScore(Player *p, int amount); 1349 //! Copy constructor. 1350 Action_DiplomacyScore(const Action_DiplomacyScore &action); 1351 //! Load a new diplomatic score action from an opened saved-game file. 1352 Action_DiplomacyScore(XML_Helper* helper); 1353 //! Destroy a diplomatic score action. ~Action_DiplomacyScore()1354 ~Action_DiplomacyScore() {}; 1355 1356 //! Return some debug information about this action. 1357 Glib::ustring dump() const; 1358 1359 //! Save this diplomatic score action to an opened saved-game file. 1360 virtual bool doSave(XML_Helper* helper) const; 1361 1362 //! Get the Id of the Player that our opinion has changed of. getOpponentId()1363 guint32 getOpponentId() const {return d_opponent_id;} 1364 1365 //! Get the amount of the opinion change. getAmountChange()1366 int getAmountChange() const {return d_amount;}; 1367 private: 1368 guint32 d_opponent_id; 1369 int d_amount; 1370 }; 1371 1372 //----------------------------------------------------------------------------- 1373 1374 //! A temporary record representing the ending of a turn. 1375 class Action_EndTurn: public Action 1376 { 1377 public: 1378 //! Make a new end turn action. 1379 Action_EndTurn(); 1380 //! Copy constructor 1381 Action_EndTurn(const Action_EndTurn &action); 1382 //! Load a new end turn action from an opened saved-game file. 1383 Action_EndTurn(XML_Helper* helper); 1384 //! Destroy a end turn action. ~Action_EndTurn()1385 ~Action_EndTurn() {}; 1386 1387 //! Return some debug information about this action. 1388 Glib::ustring dump() const; 1389 1390 //! Save this action to an opened saved-game file. 1391 virtual bool doSave(XML_Helper* helper) const; 1392 }; 1393 1394 //----------------------------------------------------------------------------- 1395 1396 //! A temporary record representing the taking-over of a city. 1397 class Action_ConquerCity : public Action 1398 { 1399 public: 1400 //! Make a new city conquer action. 1401 /** Populate the action with the City being conquered. 1402 */ 1403 Action_ConquerCity(City *c); 1404 //! Copy constructor 1405 Action_ConquerCity(const Action_ConquerCity &action); 1406 //! Load a new city conquer action from an opened saved-game file. 1407 Action_ConquerCity(XML_Helper* helper); 1408 //! Destroy a city conquer action. ~Action_ConquerCity()1409 ~Action_ConquerCity() {}; 1410 1411 //! Return some debug information about this action. 1412 Glib::ustring dump() const; 1413 1414 //! Save this city occupied action to an opened saved-game file. 1415 virtual bool doSave(XML_Helper* helper) const; 1416 getCityId()1417 guint32 getCityId() const {return d_city;}; 1418 private: 1419 guint32 d_city; 1420 }; 1421 1422 //----------------------------------------------------------------------------- 1423 1424 //! A temporary record representing a new hero showing up in a city. 1425 class Action_RecruitHero : public Action 1426 { 1427 public: 1428 //! Make a new recruit hero action. 1429 Action_RecruitHero(HeroProto* h, City *c, int cost, int alliesCount, const ArmyProto *ally); 1430 //! Copy a new recruit hero action 1431 Action_RecruitHero(const Action_RecruitHero &action); 1432 //! Load a new recruit hero action from an opened saved-game file. 1433 Action_RecruitHero(XML_Helper* helper); 1434 //! Destroy a recruit hero action. 1435 ~Action_RecruitHero(); 1436 1437 //! Return some debug information about this action. 1438 Glib::ustring dump() const; 1439 1440 //! Save this city occupied action to an opened saved-game file. 1441 virtual bool doSave(XML_Helper* helper) const; 1442 getHero()1443 HeroProto* getHero() const {return d_hero;}; getCityId()1444 guint32 getCityId() const {return d_city;}; getCost()1445 guint32 getCost() const {return d_cost;}; getNumAllies()1446 guint32 getNumAllies() const {return d_allies;}; getAllyArmyType()1447 guint32 getAllyArmyType() const {return d_ally_army_type;}; 1448 1449 private: 1450 HeroProto *d_hero; 1451 guint32 d_city, d_cost, d_allies, d_ally_army_type; 1452 1453 bool load(Glib::ustring tag, XML_Helper *helper); 1454 }; 1455 1456 //----------------------------------------------------------------------------- 1457 1458 //! A temporary record representing the renaming of the player. 1459 class Action_RenamePlayer: public Action 1460 { 1461 public: 1462 //! Make a new rename player action 1463 Action_RenamePlayer(Glib::ustring name); 1464 //! Copy constructor 1465 Action_RenamePlayer(const Action_RenamePlayer &action); 1466 //! Load a new rename player action from an opened saved-game file. 1467 Action_RenamePlayer(XML_Helper* helper); 1468 //! Destroy a rename player action. ~Action_RenamePlayer()1469 ~Action_RenamePlayer() {}; 1470 1471 //! Return some debug information about this action. 1472 Glib::ustring dump() const; 1473 1474 //! Save this city occupied action to an opened saved-game file. 1475 virtual bool doSave(XML_Helper* helper) const; 1476 getName()1477 Glib::ustring getName() const {return d_name;}; 1478 1479 private: 1480 Glib::ustring d_name; 1481 }; 1482 1483 //----------------------------------------------------------------------------- 1484 1485 //! A temporary record representing a unit production failure due to bankruptcy. 1486 class Action_CityTooPoorToProduce: public Action 1487 { 1488 public: 1489 //! Make a new city-too-poor action 1490 Action_CityTooPoorToProduce(City* c, const ArmyProdBase *army); 1491 //! Copy constructor 1492 Action_CityTooPoorToProduce(const Action_CityTooPoorToProduce &action); 1493 //! Load a new too-poor action from an opened saved-game file. 1494 Action_CityTooPoorToProduce(XML_Helper* helper); 1495 //! Destroy a too-poor action. ~Action_CityTooPoorToProduce()1496 ~Action_CityTooPoorToProduce() {}; 1497 1498 //! Return some debug information about this action. 1499 Glib::ustring dump() const; 1500 1501 //! Save this city occupied action to an opened saved-game file. 1502 virtual bool doSave(XML_Helper* helper) const; 1503 getCityId()1504 guint32 getCityId() const {return d_city;} getArmyType()1505 guint32 getArmyType() const {return d_army_type;} 1506 1507 private: 1508 guint32 d_city; 1509 guint32 d_army_type; 1510 }; 1511 1512 //----------------------------------------------------------------------------- 1513 1514 //! A temporary record representing the beginning of a turn. 1515 class Action_InitTurn: public Action 1516 { 1517 public: 1518 //! Make a new initialize turn action. 1519 Action_InitTurn(guint32 order); 1520 //! Copy constructor 1521 Action_InitTurn(const Action_InitTurn &action); 1522 //! Load a new initialize turn action from an opened saved-game file. 1523 Action_InitTurn(XML_Helper* helper); 1524 //! Destroy a initialize turn action. ~Action_InitTurn()1525 ~Action_InitTurn() {}; 1526 1527 //! Return some debug information about this action. 1528 Glib::ustring dump() const; 1529 1530 //! Save this action to an opened saved-game file. 1531 virtual bool doSave(XML_Helper* helper) const; 1532 1533 //! Return the turn order getTurnOrder()1534 guint32 getTurnOrder() const {return d_order;} 1535 private: 1536 guint32 d_order; 1537 }; 1538 1539 //----------------------------------------------------------------------------- 1540 1541 //! A temporary record of what happened when a Player loots a City. 1542 /** 1543 * The purpose of the Action_Loot class is to record when a Player has 1544 * defeated a City and has looted it. Looting a city results in the 1545 * looting player's coffers gaining some gold pieces while the looted 1546 * player's coffers decrease. 1547 */ 1548 class Action_Loot : public Action 1549 { 1550 public: 1551 //! Make a new city looting action. 1552 /** 1553 * Populate the action with the players involved and the amounts. 1554 */ 1555 Action_Loot(Player *looting_player, Player *looted_player, 1556 guint32 amount_to_add, guint32 amount_to_subtract); 1557 //! Copy constructor 1558 Action_Loot(const Action_Loot &action); 1559 //! Load a new city looting action from an opened saved-game file. 1560 Action_Loot(XML_Helper* helper); 1561 //! Destroy a city looting action. ~Action_Loot()1562 ~Action_Loot() {}; 1563 1564 //! Return some debug information about this action. 1565 Glib::ustring dump() const; 1566 1567 //! Save this city looting action to an opened saved-game file. 1568 virtual bool doSave(XML_Helper* helper) const; 1569 getAmountToAdd()1570 guint32 getAmountToAdd() const { return d_gold_added;}; getAmountToSubtract()1571 guint32 getAmountToSubtract() const { return d_gold_removed;}; getLootingPlayerId()1572 guint32 getLootingPlayerId() const {return d_looting_player_id;}; getLootedPlayerId()1573 guint32 getLootedPlayerId() const {return d_looted_player_id;}; 1574 1575 private: 1576 guint32 d_looting_player_id; 1577 guint32 d_looted_player_id; 1578 guint32 d_gold_added; 1579 guint32 d_gold_removed; 1580 }; 1581 1582 //----------------------------------------------------------------------------- 1583 1584 //! A temporary record of a Hero using an item. 1585 /** 1586 * The purpose of the Action_UseItem class is to record when a Player's 1587 * Hero has used an item. 1588 */ 1589 class Action_UseItem: public Action 1590 { 1591 public: 1592 //! Make a new use item action. 1593 Action_UseItem(Hero *hero, Item *item, Player *victim, City *friendly_city, City *enemy_city, City *neutral_city, City *city); 1594 //! Copy constructor 1595 Action_UseItem(const Action_UseItem &action); 1596 //! Load a new use item action from a saved-game file. 1597 Action_UseItem(XML_Helper* helper); 1598 //! Destroy a use item assigned action. ~Action_UseItem()1599 ~Action_UseItem() {}; 1600 1601 //! Return some debug information about this action. 1602 Glib::ustring dump() const; 1603 1604 //! Save this use item action to a saved-game file. 1605 virtual bool doSave(XML_Helper* helper) const; 1606 getHeroId()1607 guint32 getHeroId() const {return d_hero;}; getItemId()1608 guint32 getItemId() const {return d_item;}; getVictimPlayerId()1609 guint32 getVictimPlayerId() const {return d_victim_player;}; getFriendlyCityId()1610 guint32 getFriendlyCityId() const {return d_friendly_city;}; getEnemyCityId()1611 guint32 getEnemyCityId() const {return d_enemy_city;}; getNeutralCityId()1612 guint32 getNeutralCityId() const {return d_neutral_city;}; getCityId()1613 guint32 getCityId() const {return d_city;}; 1614 1615 private: 1616 guint32 d_hero; 1617 guint32 d_item; 1618 guint32 d_victim_player; 1619 guint32 d_friendly_city; 1620 guint32 d_enemy_city; 1621 guint32 d_neutral_city; 1622 guint32 d_city; 1623 }; 1624 1625 //----------------------------------------------------------------------------- 1626 1627 //! A temporary record of the armies in a stack being reordered. 1628 /** 1629 * The purpose of the Action_ReorderArmies class is to record when a Player 1630 * changes the ordering of a given stack. 1631 */ 1632 class Action_ReorderArmies: public Action 1633 { 1634 public: 1635 //! Make a new reorder armies action. 1636 /** 1637 * Populate the Action_ReorderArmies with the stack. 1638 */ 1639 Action_ReorderArmies(Stack *s); 1640 //! Copy constructor 1641 Action_ReorderArmies(const Action_ReorderArmies &action); 1642 //! Load a new reorder armies action from a saved-game file. 1643 Action_ReorderArmies(XML_Helper* helper); 1644 //! Destroy a reorder armies action. ~Action_ReorderArmies()1645 ~Action_ReorderArmies() {}; 1646 1647 //! Return some debug information about this action. 1648 Glib::ustring dump() const; 1649 1650 //! Save this reorder armies action to a saved-game file. 1651 virtual bool doSave(XML_Helper* helper) const; 1652 getArmyIds()1653 std::list<guint32> getArmyIds() const {return d_army_ids;}; getStackId()1654 guint32 getStackId() const {return d_stack_id;}; getPlayerId()1655 guint32 getPlayerId() const {return d_player_id;}; 1656 1657 private: 1658 guint32 d_stack_id; 1659 guint32 d_player_id; 1660 std::list<guint32> d_army_ids; 1661 }; 1662 1663 //----------------------------------------------------------------------------- 1664 1665 //! A temporary record of the players stacks being healed and moves reset. 1666 /** 1667 * The purpose of the Action_ResetStacks class is to record when a Player 1668 * has it's stacks healed and it's movement points recharged. 1669 */ 1670 class Action_ResetStacks: public Action 1671 { 1672 public: 1673 //! Make a new reset stacks action. 1674 Action_ResetStacks(Player *p); 1675 //! Copy constructor 1676 Action_ResetStacks(const Action_ResetStacks &action); 1677 //! Load a new reset stacks action from a saved-game file. 1678 Action_ResetStacks(XML_Helper* helper); 1679 //! Destroy a reset stacks action. ~Action_ResetStacks()1680 ~Action_ResetStacks() {}; 1681 1682 //! Return some debug information about this action. 1683 Glib::ustring dump() const; 1684 1685 //! Save this reset stacks action to a saved-game file. 1686 virtual bool doSave(XML_Helper* helper) const; 1687 getPlayerId()1688 guint32 getPlayerId() const {return d_player_id;}; 1689 1690 private: 1691 guint32 d_player_id; 1692 }; 1693 1694 //----------------------------------------------------------------------------- 1695 1696 //! A temporary record of the monsters in ruins being recharged.. 1697 /** 1698 * The purpose of the Action_ResetRuins class is to record when the neutral 1699 * player heals up the monsters in ruins. 1700 */ 1701 class Action_ResetRuins: public Action 1702 { 1703 public: 1704 //! Make a new reset ruins action. 1705 Action_ResetRuins(); 1706 //! Copy constructor 1707 Action_ResetRuins(const Action_ResetRuins &action); 1708 //! Load a new reset ruins action from a saved-game file. 1709 Action_ResetRuins(XML_Helper* helper); 1710 //! Destroy a reset ruins action. ~Action_ResetRuins()1711 ~Action_ResetRuins() {}; 1712 1713 //! Return some debug information about this action. 1714 Glib::ustring dump() const; 1715 1716 //! Save this reset ruins action to a saved-game file. 1717 virtual bool doSave(XML_Helper* helper) const; 1718 }; 1719 1720 //----------------------------------------------------------------------------- 1721 1722 //! A temporary record of a player making and paying out money. 1723 /** 1724 * The purpose of the Action_CollectTaxesAndPayUpkeeps class is to record when 1725 * a player makes money from her cities, and her stacks, and her heroes 1726 * magical items and pays out money to her stacks. 1727 */ 1728 class Action_CollectTaxesAndPayUpkeep: public Action 1729 { 1730 public: 1731 //! Make a new collect taxes and pay upkeep action. 1732 Action_CollectTaxesAndPayUpkeep(int toGold, int fromGold); 1733 //! Copy constructor 1734 Action_CollectTaxesAndPayUpkeep(const Action_CollectTaxesAndPayUpkeep &action); 1735 //! Load a new collect taxes and pay upkeep action from a saved-game file. 1736 Action_CollectTaxesAndPayUpkeep(XML_Helper* helper); 1737 //! Destroy a collect taxes and pay upkeep action. ~Action_CollectTaxesAndPayUpkeep()1738 ~Action_CollectTaxesAndPayUpkeep() {}; 1739 1740 //! Return some debug information about this action. 1741 Glib::ustring dump() const; 1742 getFromGold()1743 int getFromGold () const {return d_from_gold;} getToGold()1744 int getToGold () const {return d_to_gold;} 1745 1746 //! Save this collect taxes and pay upkeep action to a saved-game file. 1747 virtual bool doSave(XML_Helper* helper) const; 1748 private: 1749 int d_from_gold; 1750 int d_to_gold; 1751 }; 1752 1753 //----------------------------------------------------------------------------- 1754 1755 //! A temporary record of a player dying. 1756 /** 1757 * The purpose of the Action_Kill class is to record when a player has been 1758 * vanquished by foes. 1759 */ 1760 class Action_Kill: public Action 1761 { 1762 public: 1763 //! Make a kill action. 1764 Action_Kill(); 1765 //! Copy constructor 1766 Action_Kill(const Action_Kill &action); 1767 //! Load a new kill action from a saved-game file. 1768 Action_Kill(XML_Helper* helper); 1769 //! Destroy a kill action. ~Action_Kill()1770 ~Action_Kill() {}; 1771 1772 //! Return some debug information about this action. 1773 Glib::ustring dump() const; 1774 1775 //! Save this kill action to a saved-game file. 1776 virtual bool doSave(XML_Helper* helper) const; 1777 }; 1778 1779 //----------------------------------------------------------------------------- 1780 1781 //! A temporary record of a player putting a stack into defend mode. 1782 /** 1783 * The purpose of the Action_DefendStack class is to record when a player puts 1784 * a stack into defensive mode. This makes the stack appear as a tower. 1785 */ 1786 class Action_DefendStack: public Action 1787 { 1788 public: 1789 //! Make a defend stack action. 1790 /** 1791 * Supply the stack that is being put into defend mode. 1792 */ 1793 Action_DefendStack(Stack *s); 1794 //! Copy constructor 1795 Action_DefendStack (const Action_DefendStack &action); 1796 //! Load a new defend stack action from a saved-game file. 1797 Action_DefendStack (XML_Helper* helper); 1798 //! Destroy a defend stack action. ~Action_DefendStack()1799 ~Action_DefendStack() {}; 1800 1801 //! Return some debug information about this action. 1802 Glib::ustring dump() const; 1803 1804 //! Save this defend stack action to a saved-game file. 1805 virtual bool doSave(XML_Helper* helper) const; 1806 getStackId()1807 guint32 getStackId() const {return d_stack_id;}; 1808 private: 1809 guint32 d_stack_id; 1810 }; 1811 1812 //----------------------------------------------------------------------------- 1813 1814 //! A temporary record of a player taking a stack out of defend mode. 1815 /** 1816 * The purpose of the Action_UndefendStack class is to record when a player 1817 * takes a stack out of defensive mode. This means that the stack is no longer 1818 * depicted by a tower. 1819 */ 1820 class Action_UndefendStack: public Action 1821 { 1822 public: 1823 //! Make an undefend stack action. 1824 /** 1825 * Supply the stack that is being taken out of defend mode. 1826 */ 1827 Action_UndefendStack(Stack *s); 1828 //! Copy constructor 1829 Action_UndefendStack (const Action_UndefendStack &action); 1830 //! Load a new undefend stack action from a saved-game file. 1831 Action_UndefendStack (XML_Helper* helper); 1832 //! Destroy a undefend stack action. ~Action_UndefendStack()1833 ~Action_UndefendStack() {}; 1834 1835 //! Return some debug information about this action. 1836 Glib::ustring dump() const; 1837 1838 //! Save this undefend stack action to a saved-game file. 1839 virtual bool doSave(XML_Helper* helper) const; 1840 getStackId()1841 guint32 getStackId() const {return d_stack_id;}; 1842 private: 1843 guint32 d_stack_id; 1844 }; 1845 1846 //----------------------------------------------------------------------------- 1847 1848 //! A temporary record of a player putting a stack into parked mode. 1849 /** 1850 * The purpose of the Action_ParkStack class is to record when a player puts 1851 * a stack into parked mode. 1852 */ 1853 class Action_ParkStack: public Action 1854 { 1855 public: 1856 //! Make a park stack action. 1857 /** 1858 * Supply the stack that is being put into parked mode. 1859 */ 1860 Action_ParkStack(Stack *s); 1861 //! Copy constructor 1862 Action_ParkStack (const Action_ParkStack &action); 1863 //! Load a new park stack action from a saved-game file. 1864 Action_ParkStack (XML_Helper* helper); 1865 //! Destroy a park stack action. ~Action_ParkStack()1866 ~Action_ParkStack() {}; 1867 1868 //! Return some debug information about this action. 1869 Glib::ustring dump() const; 1870 1871 //! Save this park stack action to a saved-game file. 1872 virtual bool doSave(XML_Helper* helper) const; 1873 getStackId()1874 guint32 getStackId() const {return d_stack_id;}; 1875 private: 1876 guint32 d_stack_id; 1877 }; 1878 1879 //----------------------------------------------------------------------------- 1880 1881 //! A temporary record of a player taking a stack out of parked mode. 1882 /** 1883 * The purpose of the Action_UnparkStack class is to record when a player 1884 * takes a stack out of parked mode (a stationary condition that means we 1885 * don't want to move this stack any more this turn). 1886 */ 1887 class Action_UnparkStack: public Action 1888 { 1889 public: 1890 //! Make a unpark stack action. 1891 /** 1892 * Supply the stack that is being taken out of parked mode. 1893 */ 1894 Action_UnparkStack(Stack *s); 1895 //! Copy constructor 1896 Action_UnparkStack (const Action_UnparkStack &action); 1897 //! Load a new unpark stack action from a saved-game file. 1898 Action_UnparkStack (XML_Helper* helper); 1899 //! Destroy an unpark stack action. ~Action_UnparkStack()1900 ~Action_UnparkStack() {}; 1901 1902 //! Return some debug information about this action. 1903 Glib::ustring dump() const; 1904 1905 //! Save this unpark stack action to a saved-game file. 1906 virtual bool doSave(XML_Helper* helper) const; 1907 getStackId()1908 guint32 getStackId() const {return d_stack_id;}; 1909 private: 1910 guint32 d_stack_id; 1911 }; 1912 1913 //! A temporary record of a player selecting a stack to work with. 1914 /** 1915 * The purpose of the Action_SelectStack class is to record when a player 1916 * grabs a stack to work with. Only one stack can be selected at a time. 1917 */ 1918 class Action_SelectStack: public Action 1919 { 1920 public: 1921 //! Make a select stack action. 1922 /** 1923 * Supply the stack that is being selected 1924 */ 1925 Action_SelectStack(Stack *s); 1926 //! Copy constructor 1927 Action_SelectStack (const Action_SelectStack &action); 1928 //! Load a new select stack action from a saved-game file. 1929 Action_SelectStack (XML_Helper* helper); 1930 //! Destroy a select stack action. ~Action_SelectStack()1931 ~Action_SelectStack() {}; 1932 1933 //! Return some debug information about this action. 1934 Glib::ustring dump() const; 1935 1936 //! Save this select stack action to a saved-game file. 1937 virtual bool doSave(XML_Helper* helper) const; 1938 getStackId()1939 guint32 getStackId() const {return d_stack_id;}; 1940 private: 1941 guint32 d_stack_id; 1942 }; 1943 1944 //----------------------------------------------------------------------------- 1945 1946 //! A temporary record of a player deselecting a stack. 1947 /** 1948 * The purpose of the Action_DeselectStack class is to record when a player 1949 * removes focus from any and all stacks. 1950 */ 1951 class Action_DeselectStack: public Action 1952 { 1953 public: 1954 //! Make a deselect stack action. 1955 Action_DeselectStack(); 1956 //! Copy constructor 1957 Action_DeselectStack (const Action_DeselectStack &action); 1958 //! Load a new deselect stack action from a saved-game file. 1959 Action_DeselectStack (XML_Helper* helper); 1960 //! Destroy a deselect stack action. ~Action_DeselectStack()1961 ~Action_DeselectStack() {}; 1962 1963 //! Return some debug information about this action. 1964 Glib::ustring dump() const; 1965 1966 //! Save this deslect stack action to a saved-game file. 1967 virtual bool doSave(XML_Helper* helper) const; 1968 }; 1969 1970 #endif //ACTION_H 1971