2
0

StupidAI.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. #include "stdafx.h"
  2. #include "StupidAI.h"
  3. #include "../../lib/BattleState.h"
  4. CStupidAI::CStupidAI(void)
  5. : side(-1), cb(NULL)
  6. {
  7. print("created");
  8. }
  9. CStupidAI::~CStupidAI(void)
  10. {
  11. print("destroyed");
  12. }
  13. void CStupidAI::init( IBattleCallback * CB )
  14. {
  15. print("init called, saving ptr to IBattleCallback");
  16. cb = CB;
  17. }
  18. void CStupidAI::actionFinished( const BattleAction *action )
  19. {
  20. print("actionFinished called");
  21. }
  22. void CStupidAI::actionStarted( const BattleAction *action )
  23. {
  24. print("actionStarted called");
  25. }
  26. BattleAction CStupidAI::activeStack( const CStack * stack )
  27. {
  28. print("activeStack called");
  29. if(stack->position % 17 < 5) //move army little towards enemy
  30. {
  31. THex dest = stack->position + !side*2 - 1;
  32. print(stack->nodeName() + "will be moved to " + boost::lexical_cast<std::string>(dest));
  33. return BattleAction::makeMove(stack, dest);
  34. }
  35. return BattleAction::makeDefend(stack);
  36. }
  37. void CStupidAI::battleAttack(const BattleAttack *ba)
  38. {
  39. print("battleAttack called");
  40. }
  41. void CStupidAI::battleStacksAttacked(const std::vector<BattleStackAttacked> & bsa)
  42. {
  43. print("battleStacksAttacked called");
  44. }
  45. void CStupidAI::battleEnd(const BattleResult *br)
  46. {
  47. print("battleEnd called");
  48. }
  49. void CStupidAI::battleResultsApplied()
  50. {
  51. print("battleResultsApplied called");
  52. }
  53. void CStupidAI::battleNewRoundFirst(int round)
  54. {
  55. print("battleNewRoundFirst called");
  56. }
  57. void CStupidAI::battleNewRound(int round)
  58. {
  59. print("battleNewRound called");
  60. }
  61. void CStupidAI::battleStackMoved(const CStack * stack, THex dest, int distance, bool end)
  62. {
  63. print("battleStackMoved called");;
  64. }
  65. void CStupidAI::battleSpellCast(const BattleSpellCast *sc)
  66. {
  67. print("battleSpellCast called");
  68. }
  69. void CStupidAI::battleStacksEffectsSet(const SetStackEffect & sse)
  70. {
  71. print("battleStacksEffectsSet called");
  72. }
  73. void CStupidAI::battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool Side)
  74. {
  75. print("battleStart called");
  76. side = Side;
  77. }
  78. void CStupidAI::battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, si32 lifeDrainFrom)
  79. {
  80. print("battleStacksHealedRes called");
  81. }
  82. void CStupidAI::battleNewStackAppeared(const CStack * stack)
  83. {
  84. print("battleNewStackAppeared called");
  85. }
  86. void CStupidAI::battleObstaclesRemoved(const std::set<si32> & removedObstacles)
  87. {
  88. print("battleObstaclesRemoved called");
  89. }
  90. void CStupidAI::battleCatapultAttacked(const CatapultAttack & ca)
  91. {
  92. print("battleCatapultAttacked called");
  93. }
  94. void CStupidAI::battleStacksRemoved(const BattleStacksRemoved & bsr)
  95. {
  96. print("battleStacksRemoved called");
  97. }
  98. void CStupidAI::print(const std::string &text) const
  99. {
  100. tlog0 << "CStupidAI [" << this <<"]: " << text << std::endl;
  101. }