PageRenderTime 71ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 2ms

/silverfish_control.cs

https://github.com/jrgutier/HRCustomClasses
C# | 13779 lines | 11393 code | 1907 blank | 479 comment | 3665 complexity | 7ba55afcfdd4068b47dd83f15c5fa223 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. using HREngine.API;
  2. using HREngine.API.Actions;
  3. using HREngine.API.Utilities;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Text;
  7. using System.IO;
  8. //using System.Linq;
  9. namespace HREngine.Bots
  10. {
  11. public class Bot : IBot
  12. {
  13. private int dirtytarget=-1;
  14. PenalityManager penman = PenalityManager.Instance;
  15. Silverfish sf;
  16. public Bot()
  17. {
  18. OnBattleStateUpdate = HandleOnBattleStateUpdate;
  19. OnMulliganStateUpdate = HandleBattleMulliganPhase;
  20. this.sf = new Silverfish();
  21. sf.setnewLoggFile();
  22. //Ai.Instance.autoTester(this);
  23. //Ai.Instance.autoTesterParallel(this);
  24. }
  25. public int getPlayfieldValue(Playfield p)
  26. {
  27. int retval = 0;
  28. retval -= p.evaluatePenality;
  29. retval += p.owncards.Count * 1;
  30. retval += p.ownMaxMana;
  31. retval -= p.enemyMaxMana;
  32. retval += p.ownMinions.Count * 10 / (p.mana + 1);
  33. retval -= p.enemyMinions.Count * 10 / (p.mana + 1);
  34. if (p.ownHeroHp + p.ownHeroDefence > 10)
  35. {
  36. retval += p.ownHeroHp + p.ownHeroDefence;
  37. }
  38. else
  39. {
  40. retval -= (11 - p.ownHeroHp - p.ownHeroDefence) * (11 - p.ownHeroHp - p.ownHeroDefence);
  41. }
  42. retval += -p.enemyHeroHp - p.enemyHeroDefence;
  43. retval += p.ownWeaponAttack;// +ownWeaponDurability;
  44. if (!p.enemyHeroFrozen)
  45. {
  46. retval -= p.enemyWeaponDurability * p.enemyWeaponAttack;
  47. }
  48. else
  49. {
  50. if (p.enemyWeaponDurability >= 1)
  51. {
  52. retval += 12;
  53. }
  54. }
  55. retval += p.owncarddraw * 5;
  56. retval -= p.enemycarddraw * 5;
  57. retval += p.ownMaxMana;
  58. if (p.enemyMinions.Count >= 0)
  59. {
  60. int anz = p.enemyMinions.Count;
  61. int owntaunt = p.ownMinions.FindAll(x => x.taunt == true).Count;
  62. int froggs = p.ownMinions.FindAll(x => x.name == "frog").Count;
  63. owntaunt -= froggs;
  64. if (owntaunt == 0) retval -= 10 * anz;
  65. retval += owntaunt * 10 - 11 * anz;
  66. }
  67. int playmobs = 0;
  68. foreach (Action a in p.playactions)
  69. {
  70. if (a.useability && a.card.name == "lesserheal" && ((a.enemytarget >= 10 && a.enemytarget <= 20) || a.enemytarget == 200)) retval -= 5;
  71. if (!a.cardplay) continue;
  72. if (a.card.type == CardDB.cardtype.MOB) playmobs++;
  73. //if (a.card.name == "arcanemissiles" && a.numEnemysBeforePlayed == 0) retval -= 10; // arkane missles on enemy hero is bad :D
  74. if (a.card.name == "flamestrike" && a.numEnemysBeforePlayed <= 2) retval -= 20;
  75. //save spell for all classes: (except for rouge if he has no combo)
  76. if (p.ownHeroName != "thief" && a.card.type == CardDB.cardtype.SPELL && (a.numEnemysBeforePlayed == 0 || a.enemytarget == 200)) retval -= 11;
  77. if (p.ownHeroName == "thief" && a.card.type == CardDB.cardtype.SPELL && (a.enemytarget == 200)) retval -= 11;
  78. }
  79. int mobsInHand = 0;
  80. foreach (Handmanager.Handcard hc in p.owncards)
  81. {
  82. if (hc.card.type == CardDB.cardtype.MOB) mobsInHand++;
  83. }
  84. if (p.ownMinions.Count - p.enemyMinions.Count >= 4 && mobsInHand >= 1)
  85. {
  86. retval += mobsInHand * 20;
  87. }
  88. foreach (Minion m in p.ownMinions)
  89. {
  90. retval += m.Hp * 1;
  91. retval += m.Angr * 2;
  92. retval += m.card.rarity;
  93. if (m.windfury) retval += m.Angr;
  94. if (m.divineshild) retval += 1;
  95. if (m.stealth) retval += 1;
  96. //if (m.poisonous) retval += 1;
  97. if (m.divineshild && m.taunt) retval += 4;
  98. }
  99. foreach (Minion m in p.enemyMinions)
  100. {
  101. retval -= m.Hp * 2;
  102. if (!m.frozen)
  103. {
  104. retval -= m.Angr * 2;
  105. if (m.windfury) retval -= m.Angr;
  106. }
  107. retval -= m.card.rarity;
  108. if (m.taunt) retval -= 5;
  109. if (m.divineshild) retval -= 1;
  110. if (m.stealth) retval -= 1;
  111. if (m.poisonous) retval -= 4;
  112. if (penman.priorityTargets.ContainsKey(m.name) && !m.silenced) retval -= penman.priorityTargets[m.name];
  113. if (m.Angr >= 4) retval -= 20;
  114. if (m.Angr >= 7) retval -= 50;
  115. }
  116. retval -= p.enemySecretCount;
  117. retval -= p.lostDamage;//damage which was to high (like killing a 2/1 with an 3/3 -> => lostdamage =2
  118. retval -= p.lostWeaponDamage;
  119. if (p.ownMinions.Count == 0) retval -= 20;
  120. if (p.enemyMinions.Count == 0) retval += 20;
  121. if (p.enemyHeroHp <= 0) retval = 10000;
  122. //soulfire etc
  123. int deletecardsAtLast = 0;
  124. foreach (Action a in p.playactions)
  125. {
  126. if (!a.cardplay) continue;
  127. if (a.card.name == "soulfire" || a.card.name == "doomguard" || a.card.name == "succubus") deletecardsAtLast = 1;
  128. if (deletecardsAtLast == 1 && !(a.card.name == "soulfire" || a.card.name == "doomguard" || a.card.name == "succubus")) retval -= 20;
  129. }
  130. if (p.enemyHeroHp >= 1 && p.ownHeroHp + p.ownHeroDefence - p.guessingHeroDamage <= 0) retval -= 1000;
  131. if (p.ownHeroHp <= 0) retval = -10000;
  132. p.value = retval;
  133. return retval;
  134. }
  135. private HREngine.API.Actions.ActionBase HandleBattleMulliganPhase()
  136. {
  137. HRLog.Write("handle mulligan");
  138. if (HRMulligan.IsMulliganActive())
  139. {
  140. var list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);
  141. foreach (var item in list)
  142. {
  143. if (item.GetEntity().GetCost() >= 4)
  144. {
  145. HRLog.Write("Rejecting Mulligan Card " + item.GetEntity().GetName() + " because it cost is >= 4.");
  146. HRMulligan.ToggleCard(item);
  147. }
  148. }
  149. sf.setnewLoggFile();
  150. return null;
  151. //HRMulligan.EndMulligan();
  152. }
  153. return null;
  154. }
  155. /// <summary>
  156. /// [EN]
  157. /// This handler is executed when the local player turn is active.
  158. ///
  159. /// [DE]
  160. /// Dieses Event wird ausgelöst wenn der Spieler am Zug ist.
  161. /// </summary>
  162. private HREngine.API.Actions.ActionBase HandleOnBattleStateUpdate()
  163. {
  164. try
  165. {
  166. if (HRBattle.IsInTargetMode() && dirtytarget >= 0)
  167. {
  168. HRLog.Write("dirty targeting...");
  169. HREntity target = getEntityWithNumber(dirtytarget);
  170. dirtytarget = -1;
  171. return new HREngine.API.Actions.TargetAction(target);
  172. }
  173. //SafeHandleBattleLocalPlayerTurnHandler();
  174. sf.updateEverything(this);
  175. Action moveTodo = Ai.Instance.bestmove;
  176. if (moveTodo == null)
  177. {
  178. HRLog.Write("end turn");
  179. return null;
  180. }
  181. HRLog.Write("play action");
  182. moveTodo.print();
  183. if (moveTodo.cardplay)
  184. {
  185. HRCard cardtoplay = getCardWithNumber(moveTodo.cardEntitiy);
  186. if (moveTodo.enemytarget >= 0)
  187. {
  188. HREntity target = getEntityWithNumber(moveTodo.enemyEntitiy);
  189. HRLog.Write("play: " + cardtoplay.GetEntity().GetName() + " target: " + target.GetName() + " " + (moveTodo.owntarget+1));
  190. Helpfunctions.Instance.logg("play: " + cardtoplay.GetEntity().GetName() + " target: " + target.GetName());
  191. if (moveTodo.card.type == CardDB.cardtype.MOB)
  192. {
  193. return new HREngine.API.Actions.PlayCardAction(cardtoplay, target, moveTodo.owntarget + 1);
  194. }
  195. return new HREngine.API.Actions.PlayCardAction(cardtoplay, target);
  196. }
  197. else
  198. {
  199. HRLog.Write("play: " + cardtoplay.GetEntity().GetName() + " target nothing" + " " + (moveTodo.owntarget + 1));
  200. if (moveTodo.card.type == CardDB.cardtype.MOB)
  201. {
  202. return new HREngine.API.Actions.PlayCardAction(cardtoplay, null, moveTodo.owntarget + 1);
  203. }
  204. return new HREngine.API.Actions.PlayCardAction(cardtoplay);
  205. }
  206. }
  207. if (moveTodo.minionplay )
  208. {
  209. HREntity attacker = getEntityWithNumber(moveTodo.ownEntitiy);
  210. HREntity target = getEntityWithNumber(moveTodo.enemyEntitiy);
  211. HRLog.Write("minion attack: " + attacker.GetName() + " target: " + target.GetName());
  212. Helpfunctions.Instance.logg("minion attack: " + attacker.GetName() + " target: " + target.GetName());
  213. return new HREngine.API.Actions.AttackAction(attacker,target);
  214. }
  215. if (moveTodo.heroattack)
  216. {
  217. HREntity attacker = getEntityWithNumber(moveTodo.ownEntitiy);
  218. HREntity target = getEntityWithNumber(moveTodo.enemyEntitiy);
  219. this.dirtytarget = moveTodo.enemyEntitiy;
  220. //HRLog.Write("heroattack: attkr:" + moveTodo.ownEntitiy + " defender: " + moveTodo.enemyEntitiy);
  221. HRLog.Write("heroattack: " + attacker.GetName() + " target: " + target.GetName());
  222. Helpfunctions.Instance.logg("heroattack: " + attacker.GetName() + " target: " + target.GetName());
  223. if (HRPlayer.GetLocalPlayer().HasWeapon())
  224. {
  225. HRLog.Write("hero attack with weapon");
  226. return new HREngine.API.Actions.AttackAction(HRPlayer.GetLocalPlayer().GetWeaponCard().GetEntity(), target);
  227. }
  228. HRLog.Write("hero attack without weapon");
  229. return new HREngine.API.Actions.AttackAction(HRPlayer.GetLocalPlayer().GetHero(), target);
  230. }
  231. if (moveTodo.useability)
  232. {
  233. HRCard cardtoplay = HRPlayer.GetLocalPlayer().GetHeroPower().GetCard();
  234. if (moveTodo.enemytarget >= 0)
  235. {
  236. HREntity target = getEntityWithNumber(moveTodo.enemyEntitiy);
  237. HRLog.Write("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target " + target.GetName());
  238. Helpfunctions.Instance.logg("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target " + target.GetName());
  239. return new HREngine.API.Actions.PlayCardAction(cardtoplay, target);
  240. }
  241. else
  242. {
  243. HRLog.Write("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target nothing");
  244. Helpfunctions.Instance.logg("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target nothing");
  245. return new HREngine.API.Actions.PlayCardAction(cardtoplay);
  246. }
  247. }
  248. }
  249. catch (Exception Exception)
  250. {
  251. HRLog.Write(Exception.Message);
  252. HRLog.Write(Environment.StackTrace);
  253. }
  254. return null;
  255. //HRBattle.FinishRound();
  256. }
  257. private HREntity getEntityWithNumber(int number)
  258. {
  259. foreach (HREntity e in this.getallEntitys())
  260. {
  261. if (number == e.GetEntityId()) return e;
  262. }
  263. return null;
  264. }
  265. private HRCard getCardWithNumber(int number)
  266. {
  267. foreach (HRCard e in this.getallHandCards())
  268. {
  269. if (number == e.GetEntity().GetEntityId()) return e;
  270. }
  271. return null;
  272. }
  273. private List<HREntity> getallEntitys()
  274. {
  275. List<HREntity> result = new List<HREntity>();
  276. HREntity ownhero = HRPlayer.GetLocalPlayer().GetHero();
  277. HREntity enemyhero = HRPlayer.GetEnemyPlayer().GetHero();
  278. HREntity ownHeroAbility = HRPlayer.GetLocalPlayer().GetHeroPower();
  279. List<HRCard> list2 = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.PLAY);
  280. List<HRCard> list3 = HRCard.GetCards(HRPlayer.GetEnemyPlayer(), HRCardZone.PLAY);
  281. result.Add(ownhero);
  282. result.Add(enemyhero);
  283. result.Add(ownHeroAbility);
  284. foreach (HRCard item in list2)
  285. {
  286. result.Add(item.GetEntity());
  287. }
  288. foreach (HRCard item in list3)
  289. {
  290. result.Add(item.GetEntity());
  291. }
  292. return result;
  293. }
  294. private List<HRCard> getallHandCards()
  295. {
  296. List<HRCard> list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);
  297. return list;
  298. }
  299. protected virtual void SafeHandleBattleLocalPlayerTurnHandler()
  300. {
  301. }
  302. protected virtual HRCard GetMinionByPriority(HRCard lastMinion = null)
  303. {
  304. return null;
  305. }
  306. }
  307. public class Silverfish
  308. {
  309. private bool singleLog = false;
  310. Settings sttngs = Settings.Instance;
  311. List<Minion> ownMinions = new List<Minion>();
  312. List<Minion> enemyMinions = new List<Minion>();
  313. List<Handmanager.Handcard> handCards = new List<Handmanager.Handcard>();
  314. int ownPlayerController = 0;
  315. List<string> ownSecretList = new List<string>();
  316. int enemySecretCount = 0;
  317. int currentMana = 0;
  318. int ownMaxMana = 0;
  319. int numMinionsPlayedThisTurn = 0;
  320. int cardsPlayedThisTurn = 0;
  321. int ueberladung = 0;
  322. string ownHeroWeapon = "";
  323. int heroWeaponAttack = 0;
  324. int heroWeaponDurability = 0;
  325. bool heroImmuneToDamageWhileAttacking = false;
  326. string enemyHeroWeapon = "";
  327. int enemyWeaponAttack = 0;
  328. int enemyWeaponDurability = 0;
  329. int heroAtk = 0;
  330. int heroHp = 30;
  331. int heroDefence = 0;
  332. string heroname = "";
  333. bool ownheroisread = false;
  334. int heroNumAttacksThisTurn = 0;
  335. bool heroHasWindfury = false;
  336. bool herofrozen = false;
  337. int enemyAtk = 0;
  338. int enemyHp = 30;
  339. string enemyHeroname = "";
  340. int enemyDefence = 0;
  341. bool enemyfrozen = false;
  342. CardDB.Card heroAbility = new CardDB.Card();
  343. bool ownAbilityisReady = false;
  344. int anzcards = 0;
  345. int enemyAnzCards = 0;
  346. int ownHeroFatigue = 0;
  347. int enemyHeroFatigue = 0;
  348. int ownDecksize = 0;
  349. int enemyDecksize = 0;
  350. private Dictionary<int, HRCard> RejectedCardList;
  351. private PlayCardAction NextFixedAction { get; set; }
  352. public Silverfish()
  353. {
  354. HRLog.Write("init Silverfish");
  355. string path = (HRSettings.Get.CustomRuleFilePath).Remove(HRSettings.Get.CustomRuleFilePath.Length - 13) + "UltimateLogs" + System.IO.Path.DirectorySeparatorChar;
  356. System.IO.Directory.CreateDirectory(path);
  357. sttngs.setFilePath((HRSettings.Get.CustomRuleFilePath).Remove(HRSettings.Get.CustomRuleFilePath.Length - 13));
  358. if (!singleLog)
  359. {
  360. sttngs.setLoggPath(path);
  361. }
  362. else
  363. {
  364. sttngs.setLoggPath((HRSettings.Get.CustomRuleFilePath).Remove(HRSettings.Get.CustomRuleFilePath.Length - 13));
  365. sttngs.setLoggFile("UILogg.txt");
  366. Helpfunctions.Instance.createNewLoggfile();
  367. }
  368. /*OnBattleStateUpdate = UpdateBattleState;
  369. OnMulliganStateUpdate = UpdateMulliganState;
  370. RejectedCardList = new Dictionary<int, HRCard>();
  371. NextFixedAction = null;*/
  372. }
  373. public void setnewLoggFile()
  374. {
  375. if (!singleLog)
  376. {
  377. sttngs.setLoggFile("UILogg" + DateTime.Now.ToString("_yyyy-MM-dd_HH-mm-ss") + ".txt");
  378. Helpfunctions.Instance.createNewLoggfile();
  379. }
  380. else
  381. {
  382. sttngs.setLoggFile("UILogg.txt");
  383. }
  384. }
  385. public void updateEverything(Bot botbase)
  386. {
  387. HRPlayer ownPlayer = HRPlayer.GetLocalPlayer();
  388. HRPlayer enemyPlayer = HRPlayer.GetEnemyPlayer();
  389. ownPlayerController = ownPlayer.GetHero().GetControllerId();//ownPlayer.GetHero().GetControllerId()
  390. // create hero + minion data
  391. getHerostuff();
  392. getMinions();
  393. getHandcards();
  394. // send ai the data:
  395. Hrtprozis.Instance.clearAll();
  396. Handmanager.Instance.clearAll();
  397. Hrtprozis.Instance.setOwnPlayer(ownPlayerController);
  398. Handmanager.Instance.setOwnPlayer(ownPlayerController);
  399. Hrtprozis.Instance.updatePlayer(this.ownMaxMana, this.currentMana, this.cardsPlayedThisTurn, this.numMinionsPlayedThisTurn, this.ueberladung, ownPlayer.GetHero().GetEntityId(), enemyPlayer.GetHero().GetEntityId());
  400. Hrtprozis.Instance.updateSecretStuff(this.ownSecretList, this.enemySecretCount);
  401. Hrtprozis.Instance.updateOwnHero(this.ownHeroWeapon, this.heroWeaponAttack, this.heroWeaponDurability, this.heroImmuneToDamageWhileAttacking, this.heroAtk, this.heroHp, this.heroDefence, this.heroname, this.ownheroisread, this.herofrozen, this.heroAbility, this.ownAbilityisReady, this.heroNumAttacksThisTurn, this.heroHasWindfury);
  402. Hrtprozis.Instance.updateEnemyHero(this.enemyHeroWeapon, this.enemyWeaponAttack, this.enemyWeaponDurability, this.enemyAtk, this.enemyHp, this.enemyDefence, this.enemyHeroname, this.enemyfrozen);
  403. Hrtprozis.Instance.updateMinions(this.ownMinions, this.enemyMinions);
  404. Handmanager.Instance.setHandcards(this.handCards, this.anzcards, this.enemyAnzCards);
  405. Hrtprozis.Instance.updateFatigueStats(this.ownDecksize, this.ownHeroFatigue, this.enemyDecksize, this.enemyHeroFatigue);
  406. // print data
  407. Hrtprozis.Instance.printHero();
  408. Hrtprozis.Instance.printOwnMinions();
  409. Hrtprozis.Instance.printEnemyMinions();
  410. Handmanager.Instance.printcards();
  411. // calculate stuff
  412. HRLog.Write("calculating stuff...");
  413. Ai.Instance.dosomethingclever(botbase);
  414. HRLog.Write("calculating ended!");
  415. }
  416. private void getHerostuff()
  417. {
  418. HRPlayer ownPlayer = HRPlayer.GetLocalPlayer();
  419. HRPlayer enemyPlayer = HRPlayer.GetEnemyPlayer();
  420. HREntity ownhero = ownPlayer.GetHero();
  421. HREntity enemyhero = enemyPlayer.GetHero();
  422. HREntity ownHeroAbility = ownPlayer.GetHeroPower();
  423. //player stuff#########################
  424. //this.currentMana =ownPlayer.GetTag(HRGameTag.RESOURCES) - ownPlayer.GetTag(HRGameTag.RESOURCES_USED) + ownPlayer.GetTag(HRGameTag.TEMP_RESOURCES);
  425. this.currentMana = ownPlayer.GetNumAvailableResources();
  426. this.ownMaxMana = ownPlayer.GetTag(HRGameTag.RESOURCES);//ownPlayer.GetRealTimeTempMana();
  427. Helpfunctions.Instance.logg("#######################################################################");
  428. Helpfunctions.Instance.logg("#######################################################################");
  429. Helpfunctions.Instance.logg("start calculations, current time: " + DateTime.Now.ToString("HH:mm:ss"));
  430. Helpfunctions.Instance.logg("#######################################################################");
  431. Helpfunctions.Instance.logg("mana " + currentMana + "/" + ownMaxMana);
  432. Helpfunctions.Instance.logg("own secretsCount: " + ownPlayer.GetSecretDefinitions().Count);
  433. enemySecretCount = HRCard.GetCards(enemyPlayer, HRCardZone.SECRET).Count;
  434. enemySecretCount = 0;
  435. Helpfunctions.Instance.logg("enemy secretsCount: " + enemySecretCount);
  436. this.ownSecretList = ownPlayer.GetSecretDefinitions();
  437. this.numMinionsPlayedThisTurn = ownPlayer.GetTag(HRGameTag.NUM_MINIONS_PLAYED_THIS_TURN);
  438. this.cardsPlayedThisTurn = ownPlayer.GetTag(HRGameTag.NUM_CARDS_PLAYED_THIS_TURN);
  439. //if (ownPlayer.HasCombo()) this.cardsPlayedThisTurn = 1;
  440. this.ueberladung = ownPlayer.GetTag(HRGameTag.RECALL_OWED);
  441. //get weapon stuff
  442. this.ownHeroWeapon = "";
  443. this.heroWeaponAttack = 0;
  444. this.heroWeaponDurability = 0;
  445. this.ownHeroFatigue = ownhero.GetFatigue();
  446. this.enemyHeroFatigue = enemyhero.GetFatigue();
  447. //this.ownDecksize = HRCard.GetCards(ownPlayer, HRCardZone.DECK).Count;
  448. //this.enemyDecksize = HRCard.GetCards(enemyPlayer, HRCardZone.DECK).Count;
  449. this.enemyHeroWeapon = "";
  450. this.enemyWeaponAttack = 0;
  451. this.enemyWeaponDurability = 0;
  452. if (enemyPlayer.HasWeapon())
  453. {
  454. HREntity weapon = enemyPlayer.GetWeaponCard().GetEntity();
  455. this.enemyHeroWeapon = CardDB.Instance.getCardDataFromID(weapon.GetCardId()).name;
  456. this.enemyWeaponAttack = weapon.GetATK();
  457. this.enemyWeaponDurability = weapon.GetDurability();
  458. }
  459. //own hero stuff###########################
  460. this.heroAtk = ownhero.GetATK();
  461. this.heroHp = ownhero.GetHealth() - ownhero.GetDamage();
  462. this.heroDefence = ownhero.GetArmor();
  463. this.heroname = Hrtprozis.Instance.heroIDtoName(ownhero.GetCardId());
  464. bool exausted = false;
  465. exausted = ownhero.IsExhausted();
  466. this.ownheroisread = true;
  467. this.heroImmuneToDamageWhileAttacking = (ownhero.IsImmune()) ? true : false;
  468. this.herofrozen = ownhero.IsFrozen();
  469. this.heroNumAttacksThisTurn = ownhero.GetNumAttacksThisTurn();
  470. this.heroHasWindfury = ownhero.HasWindfury();
  471. //int numberofattacks = ownhero.GetNumAttacksThisTurn();
  472. //HRLog.Write(ownhero.GetName() + " ready params ex: " + exausted + " " + heroAtk + " " + numberofattacks + " " + herofrozen);
  473. if (exausted == true)
  474. {
  475. this.ownheroisread = false;
  476. }
  477. if (exausted == false && this.heroAtk == 0)
  478. {
  479. this.ownheroisread = false;
  480. }
  481. if (herofrozen) ownheroisread = false;
  482. if (ownPlayer.HasWeapon())
  483. {
  484. HREntity weapon = ownPlayer.GetWeaponCard().GetEntity();
  485. this.ownHeroWeapon = CardDB.Instance.getCardDataFromID(weapon.GetCardId()).name;
  486. this.heroWeaponAttack = weapon.GetATK();
  487. this.heroWeaponDurability = weapon.GetTag(HRGameTag.DURABILITY) - weapon.GetTag(HRGameTag.DAMAGE);//weapon.GetDurability();
  488. this.heroImmuneToDamageWhileAttacking = false;
  489. if (this.ownHeroWeapon == "gladiatorslongbow")
  490. {
  491. this.heroImmuneToDamageWhileAttacking = true;
  492. }
  493. //HRLog.Write("weapon: " + ownHeroWeapon + " " + heroWeaponAttack + " " + heroWeaponDurability);
  494. }
  495. //enemy hero stuff###############################################################
  496. this.enemyAtk = enemyhero.GetATK();
  497. this.enemyHp = enemyhero.GetHealth() - enemyhero.GetDamage();
  498. this.enemyHeroname = Hrtprozis.Instance.heroIDtoName(enemyhero.GetCardId());
  499. this.enemyDefence = enemyhero.GetArmor();
  500. this.enemyfrozen = enemyhero.IsFrozen();
  501. //own hero ablity stuff###########################################################
  502. this.heroAbility = CardDB.Instance.getCardDataFromID(ownHeroAbility.GetCardId());
  503. this.ownAbilityisReady = (ownHeroAbility.IsExhausted()) ? false : true; // if exhausted, ability is NOT ready
  504. }
  505. private void getMinions()
  506. {
  507. ownMinions.Clear();
  508. enemyMinions.Clear();
  509. HRPlayer ownPlayer = HRPlayer.GetLocalPlayer();
  510. HRPlayer enemyPlayer = HRPlayer.GetEnemyPlayer();
  511. // ALL minions on Playfield:
  512. List<HRCard> list = HRCard.GetCards(ownPlayer, HRCardZone.PLAY);
  513. list.AddRange(HRCard.GetCards(enemyPlayer, HRCardZone.PLAY));
  514. List<HREntity> enchantments = new List<HREntity>();
  515. foreach (HRCard item in list)
  516. {
  517. HREntity entitiy = item.GetEntity();
  518. int zp = entitiy.GetZonePosition();
  519. if (entitiy.GetCardType() == HRCardType.MINION && zp >= 1)
  520. {
  521. //HRLog.Write("zonepos " + zp);
  522. CardDB.Card c = CardDB.Instance.getCardDataFromID(entitiy.GetCardId());
  523. Minion m = new Minion();
  524. m.name = c.name;
  525. m.card = c;
  526. m.Angr = entitiy.GetATK();
  527. m.maxHp = entitiy.GetHealth();
  528. m.Hp = m.maxHp - entitiy.GetDamage();
  529. m.wounded = false;
  530. if (m.maxHp > m.Hp) m.wounded = true;
  531. m.exhausted = entitiy.IsExhausted();
  532. m.taunt = (entitiy.HasTaunt()) ? true : false;
  533. m.charge = (entitiy.HasCharge()) ? true : false;
  534. m.numAttacksThisTurn = entitiy.GetNumAttacksThisTurn();
  535. int temp = entitiy.GetNumTurnsInPlay();
  536. m.playedThisTurn = (temp == 0) ? true : false;
  537. m.windfury = (entitiy.HasWindfury()) ? true : false;
  538. m.frozen = (entitiy.IsFrozen()) ? true : false;
  539. m.divineshild = (entitiy.HasDivineShield()) ? true : false;
  540. m.stealth = (entitiy.IsStealthed()) ? true : false;
  541. m.poisonous = (entitiy.IsPoisonous()) ? true : false;
  542. m.immune = (entitiy.IsImmune()) ? true : false;
  543. m.silenced = (entitiy.GetTag(HRGameTag.SILENCED) >= 1) ? true : false;
  544. m.zonepos = zp;
  545. m.id = m.zonepos - 1;
  546. m.entitiyID = entitiy.GetEntityId();
  547. m.enchantments.Clear();
  548. //HRLog.Write( m.name + " ready params ex: " + m.exhausted + " charge: " +m.charge + " attcksthisturn: " + m.numAttacksThisTurn + " playedthisturn " + m.playedThisTurn );
  549. m.Ready = false; // if exhausted, he is NOT ready
  550. if (!m.playedThisTurn && !m.exhausted && !m.frozen && (m.numAttacksThisTurn == 0 || (m.numAttacksThisTurn == 1 && m.windfury)))
  551. {
  552. m.Ready = true;
  553. }
  554. if (m.playedThisTurn && m.charge && (m.numAttacksThisTurn == 0 || (m.numAttacksThisTurn == 1 && m.windfury)))
  555. {
  556. //m.exhausted = false;
  557. m.Ready = true;
  558. }
  559. if (!m.silenced && (m.name == "ancientwatcher" || m.name == "ragnarosthefirelord"))
  560. {
  561. m.Ready = false;
  562. }
  563. if (entitiy.GetControllerId() == this.ownPlayerController) // OWN minion
  564. {
  565. this.ownMinions.Add(m);
  566. }
  567. else
  568. {
  569. this.enemyMinions.Add(m);
  570. }
  571. }
  572. // minions added
  573. if (entitiy.GetCardType() == HRCardType.WEAPON)
  574. {
  575. //HRLog.Write("found weapon!");
  576. if (entitiy.GetControllerId() == this.ownPlayerController) // OWN weapon
  577. {
  578. this.ownHeroWeapon = CardDB.Instance.getCardDataFromID(entitiy.GetCardId()).name;
  579. this.heroWeaponAttack = entitiy.GetATK();
  580. this.heroWeaponDurability = entitiy.GetDurability();
  581. //this.heroImmuneToDamageWhileAttacking = false;
  582. }
  583. else
  584. {
  585. this.enemyHeroWeapon = CardDB.Instance.getCardDataFromID(entitiy.GetCardId()).name;
  586. this.enemyWeaponAttack = entitiy.GetATK();
  587. this.enemyWeaponDurability = entitiy.GetDurability();
  588. }
  589. }
  590. if (entitiy.GetCardType() == HRCardType.ENCHANTMENT)
  591. {
  592. enchantments.Add(entitiy);
  593. }
  594. }
  595. foreach (HRCard item in list)
  596. {
  597. foreach (HREntity e in item.GetEntity().GetEnchantments())
  598. {
  599. enchantments.Add(e);
  600. }
  601. }
  602. // add enchantments to minions
  603. setEnchantments(enchantments);
  604. }
  605. private void setEnchantments(List<HREntity> enchantments)
  606. {
  607. foreach (HREntity bhu in enchantments)
  608. {
  609. //create enchantment
  610. Enchantment ench = CardDB.getEnchantmentFromCardID(bhu.GetCardId());
  611. ench.creator = bhu.GetCreatorId();
  612. ench.controllerOfCreator = bhu.GetControllerId();
  613. ench.cantBeDispelled = false;
  614. //if (bhu.c) ench.cantBeDispelled = true;
  615. foreach (Minion m in this.ownMinions)
  616. {
  617. if (m.entitiyID == bhu.GetAttached())
  618. {
  619. m.enchantments.Add(ench);
  620. //HRLog.Write("add enchantment " +bhu.GetCardId()+" to: " + m.entitiyID);
  621. }
  622. }
  623. foreach (Minion m in this.enemyMinions)
  624. {
  625. if (m.entitiyID == bhu.GetAttached())
  626. {
  627. m.enchantments.Add(ench);
  628. }
  629. }
  630. }
  631. }
  632. private void getHandcards()
  633. {
  634. handCards.Clear();
  635. this.anzcards = 0;
  636. this.enemyAnzCards = 0;
  637. List<HRCard> list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND);
  638. list.AddRange(HRCard.GetCards(HRPlayer.GetEnemyPlayer(), HRCardZone.HAND));
  639. foreach (HRCard item in list)
  640. {
  641. HREntity entitiy = item.GetEntity();
  642. if (entitiy.GetControllerId() == this.ownPlayerController && entitiy.GetZonePosition() >= 1) // own handcard
  643. {
  644. CardDB.Card c = CardDB.Instance.getCardDataFromID(entitiy.GetCardId());
  645. c.cost = entitiy.GetCost();
  646. c.entityID = entitiy.GetEntityId();
  647. Handmanager.Handcard hc = new Handmanager.Handcard();
  648. hc.card = c;
  649. hc.position = entitiy.GetZonePosition();
  650. hc.entity = entitiy.GetEntityId();
  651. handCards.Add(hc);
  652. this.anzcards++;
  653. }
  654. if (entitiy.GetControllerId() != this.ownPlayerController && entitiy.GetZonePosition() >= 1) // enemy handcard
  655. {
  656. this.enemyAnzCards++;
  657. }
  658. }
  659. }
  660. }
  661. // the ai :D
  662. //please ask/write me if you use this in your project
  663. public class Action
  664. {
  665. public bool cardplay = false;
  666. public bool heroattack = false;
  667. public bool useability = false;
  668. public bool minionplay = false;
  669. public CardDB.Card card;
  670. public int cardEntitiy = -1;
  671. public int owntarget = -1; //= target where card/minion is placed
  672. public int ownEntitiy = -1;
  673. public int enemytarget = -1; // target where red arrow is placed
  674. public int enemyEntitiy = -1;
  675. public int druidchoice = 0; // 1 left card, 2 right card
  676. public int numEnemysBeforePlayed = 0;
  677. public bool comboBeforePlayed = false;
  678. public void print()
  679. {
  680. Helpfunctions help = Helpfunctions.Instance;
  681. help.logg("current Action: ");
  682. if (this.cardplay)
  683. {
  684. help.logg("play " + this.card.name);
  685. if (this.druidchoice >= 1) help.logg("choose choise " + this.druidchoice);
  686. help.logg("with position " + this.cardEntitiy);
  687. if (this.owntarget >= 0)
  688. {
  689. help.logg("on position " + this.ownEntitiy);
  690. }
  691. if (this.enemytarget >= 0)
  692. {
  693. help.logg("and target to " + this.enemytarget + " " + this.enemyEntitiy);
  694. }
  695. }
  696. if (this.minionplay)
  697. {
  698. help.logg("attacker: " + this.owntarget + " enemy: " + this.enemytarget);
  699. help.logg("targetplace " + this.enemyEntitiy);
  700. }
  701. if (this.heroattack)
  702. {
  703. help.logg("attack with hero, enemy: " + this.enemytarget);
  704. help.logg("targetplace " + this.enemyEntitiy);
  705. }
  706. if (this.useability)
  707. {
  708. help.logg("useability ");
  709. if (this.enemytarget >= 0)
  710. {
  711. help.logg("on enemy: " + this.enemytarget + "targetplace " + this.enemyEntitiy);
  712. }
  713. }
  714. help.logg("");
  715. }
  716. }
  717. public class Playfield
  718. {
  719. public bool logging = false;
  720. public int evaluatePenality = 0;
  721. public int ownController = 0;
  722. public int ownHeroEntity = -1;
  723. public int enemyHeroEntity = -1;
  724. public int value = Int32.MinValue;
  725. public int guessingHeroDamage = 0;
  726. public int mana = 0;
  727. public int enemyHeroHp = 30;
  728. public string ownHeroName = "";
  729. public string enemyHeroName = "";
  730. public bool ownHeroReady = false;
  731. public int ownHeroNumAttackThisTurn = 0;
  732. public bool ownHeroWindfury = false;
  733. public List<string> ownSecretsIDList = new List<string>();
  734. public int enemySecretCount = 0;
  735. public int ownHeroHp = 30;
  736. public int ownheroAngr = 0;
  737. public bool ownHeroFrozen = false;
  738. public bool enemyHeroFrozen = false;
  739. public bool heroImmuneWhileAttacking = false;
  740. public int ownWeaponDurability = 0;
  741. public int ownWeaponAttack = 0;
  742. public string ownWeaponName = "";
  743. public int enemyWeaponAttack = 0;
  744. public int enemyWeaponDurability = 0;
  745. public List<Minion> ownMinions = new List<Minion>();
  746. public List<Minion> enemyMinions = new List<Minion>();
  747. public List<Handmanager.Handcard> owncards = new List<Handmanager.Handcard>();
  748. public List<Action> playactions = new List<Action>();
  749. public bool complete = false;
  750. public int owncarddraw = 0;
  751. public int ownHeroDefence = 0;
  752. public int enemycarddraw = 0;
  753. public int enemyAnzCards = 0;
  754. public int enemyHeroDefence = 0;
  755. public bool ownAbilityReady = false;
  756. public int doublepriest = 0;
  757. public int spellpower = 0;
  758. public bool auchenaiseelenpriesterin = false;
  759. public bool playedmagierinderkirintor = false;
  760. public bool playedPreparation = false;
  761. public int winzigebeschwoererin = 0;
  762. public int startedWithWinzigebeschwoererin = 0;
  763. public int zauberlehrling = 0;
  764. public int startedWithZauberlehrling = 0;
  765. public int managespenst = 0;
  766. public int startedWithManagespenst = 0;
  767. public int soeldnerDerVenture = 0;
  768. public int startedWithsoeldnerDerVenture = 0;
  769. public int beschwoerungsportal = 0;
  770. public int startedWithbeschwoerungsportal = 0;
  771. public int ownWeaponAttackStarted = 0;
  772. public int ownMobsCountStarted = 0;
  773. public int ownCardsCountStarted = 0;
  774. public int ownHeroHpStarted = 30;
  775. public int enemyHeroHpStarted = 30;
  776. public int mobsplayedThisTurn = 0;
  777. public int startedWithMobsPlayedThisTurn = 0;
  778. public int cardsPlayedThisTurn = 0;
  779. public int ueberladung = 0; //=recall
  780. public int ownMaxMana = 0;
  781. public int enemyMaxMana = 0;
  782. public int lostDamage = 0;
  783. public int lostHeal = 0;
  784. public int lostWeaponDamage = 0;
  785. public int ownDeckSize = 0;
  786. public int enemyDeckSize = 0;
  787. public int ownHeroFatigue = 0;
  788. public int enemyHeroFatigue = 0;
  789. public CardDB.Card ownHeroAblility;
  790. Helpfunctions help = Helpfunctions.Instance;
  791. private void addMinionsReal(List<Minion> source, List<Minion> trgt)
  792. {
  793. foreach (Minion m in source)
  794. {
  795. Minion mc = new Minion(m);
  796. trgt.Add(mc);
  797. }
  798. }
  799. private void addCardsReal(List<Handmanager.Handcard> source)
  800. {
  801. foreach (Handmanager.Handcard m in source)
  802. {
  803. Handmanager.Handcard mc = new Handmanager.Handcard();
  804. mc.card = new CardDB.Card(m.card);
  805. mc.position = m.position;
  806. mc.entity = m.entity;
  807. this.owncards.Add(mc);
  808. }
  809. }
  810. public Playfield()
  811. {
  812. this.ownController = Hrtprozis.Instance.getOwnController();
  813. this.ownHeroEntity = Hrtprozis.Instance.ownHeroEntity;
  814. this.enemyHeroEntity = Hrtprozis.Instance.enemyHeroEntitiy;
  815. this.mana = Hrtprozis.Instance.currentMana;
  816. this.ownMaxMana = Hrtprozis.Instance.ownMaxMana;
  817. this.enemyMaxMana = Hrtprozis.Instance.enemyMaxMana;
  818. this.evaluatePenality = 0;
  819. this.ownSecretsIDList = Hrtprozis.Instance.ownSecretList;
  820. this.enemySecretCount = Hrtprozis.Instance.enemySecretCount;
  821. addMinionsReal(Hrtprozis.Instance.ownMinions, ownMinions);
  822. addMinionsReal(Hrtprozis.Instance.enemyMinions, enemyMinions);
  823. addCardsReal(Handmanager.Instance.handCards);
  824. this.enemyHeroHp = Hrtprozis.Instance.enemyHp;
  825. this.ownHeroName = Hrtprozis.Instance.heroname;
  826. this.enemyHeroName = Hrtprozis.Instance.enemyHeroname;
  827. this.ownHeroHp = Hrtprozis.Instance.heroHp;
  828. this.complete = false;
  829. this.ownHeroReady = Hrtprozis.Instance.ownheroisread;
  830. this.ownHeroWindfury = Hrtprozis.Instance.ownHeroWindfury;
  831. this.ownHeroNumAttackThisTurn = Hrtprozis.Instance.ownHeroNumAttacksThisTurn;
  832. this.ownHeroFrozen = Hrtprozis.Instance.herofrozen;
  833. this.enemyHeroFrozen = Hrtprozis.Instance.enemyfrozen;
  834. this.ownheroAngr = Hrtprozis.Instance.heroAtk;
  835. this.heroImmuneWhileAttacking = Hrtprozis.Instance.heroImmuneToDamageWhileAttacking;
  836. this.ownWeaponDurability = Hrtprozis.Instance.heroWeaponDurability;
  837. this.ownWeaponAttack = Hrtprozis.Instance.heroWeaponAttack;
  838. this.ownWeaponName = Hrtprozis.Instance.ownHeroWeapon;
  839. this.owncarddraw = 0;
  840. this.ownHeroDefence = Hrtprozis.Instance.heroDefence;
  841. this.enemyHeroDefence = Hrtprozis.Instance.enemyDefence;
  842. this.enemyWeaponAttack = 0;//dont know jet
  843. this.enemyWeaponDurability = Hrtprozis.Instance.enemyWeaponDurability;
  844. this.enemycarddraw = 0;
  845. this.enemyAnzCards = Handmanager.Instance.enemyAnzCards;
  846. this.ownAbilityReady = Hrtprozis.Instance.ownAbilityisReady;
  847. this.ownHeroAblility = Hrtprozis.Instance.heroAbility;
  848. this.doublepriest = 0;
  849. this.spellpower = 0;
  850. value = -1000000;
  851. this.mobsplayedThisTurn = Hrtprozis.Instance.numMinionsPlayedThisTurn;
  852. this.startedWithMobsPlayedThisTurn = Hrtprozis.Instance.numMinionsPlayedThisTurn;// only change mobsplayedthisturm
  853. this.cardsPlayedThisTurn = Hrtprozis.Instance.cardsPlayedThisTurn;
  854. this.ueberladung = Hrtprozis.Instance.ueberladung;
  855. this.ownHeroFatigue = Hrtprozis.Instance.ownHeroFatigue;
  856. this.enemyHeroFatigue = Hrtprozis.Instance.enemyHeroFatigue;
  857. this.ownDeckSize = Hrtprozis.Instance.ownDeckSize;
  858. this.enemyDeckSize = Hrtprozis.Instance.enemyDeckSize;
  859. //need the following for manacost-calculation
  860. this.ownHeroHpStarted = this.ownHeroHp;
  861. this.enemyHeroHpStarted = this.enemyHeroHp;
  862. this.ownWeaponAttackStarted = this.ownWeaponAttack;
  863. this.ownCardsCountStarted = this.owncards.Count;
  864. this.ownMobsCountStarted = this.ownMinions.Count;
  865. this.playedmagierinderkirintor = false;
  866. this.playedPreparation = false;
  867. this.zauberlehrling = 0;
  868. this.winzigebeschwoererin = 0;
  869. this.managespenst = 0;
  870. this.soeldnerDerVenture = 0;
  871. this.beschwoerungsportal = 0;
  872. this.startedWithbeschwoerungsportal = 0;
  873. this.startedWithManagespenst = 0;
  874. this.startedWithWinzigebeschwoererin = 0;
  875. this.startedWithZauberlehrling = 0;
  876. this.startedWithsoeldnerDerVenture = 0;
  877. foreach (Minion m in this.ownMinions)
  878. {
  879. if (m.silenced) continue;
  880. if (m.name == "prophetvelen") this.doublepriest++;
  881. spellpower = spellpower + m.card.spellpowervalue;
  882. if (m.name == "auchenaisoulpriest") this.auchenaiseelenpriesterin = true;
  883. if (m.name == "pint-sizedsummoner")
  884. {
  885. this.winzigebeschwoererin++;
  886. this.startedWithWinzigebeschwoererin++;
  887. }
  888. if (m.name == "sorcerersapprentice")
  889. {
  890. this.zauberlehrling++;
  891. this.startedWithZauberlehrling++;
  892. }
  893. if (m.name == "manawraith")
  894. {
  895. this.managespenst++;
  896. this.startedWithManagespenst++;
  897. }
  898. if (m.name == "venturecomercenary")
  899. {
  900. this.soeldnerDerVenture++;
  901. this.startedWithsoeldnerDerVenture++;
  902. }
  903. if (m.name == "summoningportal")
  904. {
  905. this.beschwoerungsportal++;
  906. this.startedWithbeschwoerungsportal++;
  907. }
  908. foreach (Enchantment e in m.enchantments)// only at first init needed, after that its copied
  909. {
  910. if (e.CARDID == "NEW1_036e" || e.CARDID == "NEW1_036e2") m.cantLowerHPbelowONE = true;
  911. }
  912. }
  913. foreach (Minion m in this.enemyMinions)
  914. {
  915. if (m.silenced) continue;
  916. if (m.name == "manawraith")
  917. {
  918. this.managespenst++;
  919. this.startedWithManagespenst++;
  920. }
  921. }
  922. }
  923. public Playfield(Playfield p)
  924. {
  925. this.ownController = p.ownController;
  926. this.ownHeroEntity = p.ownHeroEntity;
  927. this.enemyHeroEntity = p.enemyHeroEntity;
  928. this.evaluatePenality = p.evaluatePenality;
  929. foreach (string s in p.ownSecretsIDList)
  930. { this.ownSecretsIDList.Add(s); }
  931. this.enemySecretCount = p.enemySecretCount;
  932. this.mana = p.mana;
  933. this.ownMaxMana = p.ownMaxMana;
  934. this.enemyMaxMana = p.enemyMaxMana;
  935. addMinionsReal(p.ownMinions, ownMinions);
  936. addMinionsReal(p.enemyMinions, enemyMinions);
  937. addCardsReal(p.owncards);
  938. this.enemyHeroHp = p.enemyHeroHp;
  939. this.ownHeroName = p.ownHeroName;
  940. this.enemyHeroName = p.enemyHeroName;
  941. this.ownHeroHp = p.ownHeroHp;
  942. this.playactions.AddRange(p.playactions);
  943. this.complete = false;
  944. this.ownHeroReady = p.ownHeroReady;
  945. this.ownHeroNumAttackThisTurn = p.ownHeroNumAttackThisTurn;
  946. this.ownHeroWindfury = p.ownHeroWindfury;
  947. this.ownheroAngr = p.ownheroAngr;
  948. this.ownHeroFrozen = p.ownHeroFrozen;
  949. this.enemyHeroFrozen = p.enemyHeroFrozen;
  950. this.heroImmuneWhileAttacking = p.heroImmuneWhileAttacking;
  951. this.owncarddraw = p.owncarddraw;
  952. this.ownHeroDefence = p.ownHeroDefence;
  953. this.enemyWeaponAttack = p.enemyWeaponAttack;
  954. this.enemycarddraw = p.enemycarddraw;
  955. this.enemyAnzCards = p.enemyAnzCards;
  956. this.enemyHeroDefence = p.enemyHeroDefence;
  957. this.ownWeaponDurability = p.ownWeaponDurability;
  958. this.ownWeaponAttack = p.ownWeaponAttack;
  959. this.ownWeaponName = p.ownWeaponName;
  960. this.lostDamage = p.lostDamage;
  961. this.lostWeaponDamage = p.lostWeaponDamage;
  962. this.lostHeal = p.lostHeal;
  963. this.ownAbilityReady = p.ownAbilityReady;
  964. this.ownHeroAblility = p.ownHeroAblility;
  965. this.doublepriest = 0;
  966. this.spellpower = 0;
  967. value = -1000000;
  968. this.mobsplayedThisTurn = p.mobsplayedThisTurn;
  969. this.startedWithMobsPlayedThisTurn = p.startedWithMobsPlayedThisTurn;
  970. this.cardsPlayedThisTurn = p.cardsPlayedThisTurn;
  971. this.ueberladung = p.ueberladung;
  972. this.ownDeckSize = p.ownDeckSize;
  973. this.enemyDeckSize = p.enemyDeckSize;
  974. this.ownHeroFatigue = p.ownHeroFatigue;
  975. this.enemyHeroFatigue = p.enemyHeroFatigue;
  976. //need the following for manacost-calculation
  977. this.ownHeroHpStarted = p.ownHeroHpStarted;
  978. this.enemyHeroHp = p.enemyHeroHp;
  979. this.ownWeaponAttackStarted = p.ownWeaponAttackStarted;
  980. this.ownCardsCountStarted = p.ownCardsCountStarted;
  981. this.ownMobsCountStarted = p.ownMobsCountStarted;
  982. this.startedWithWinzigebeschwoererin = p.startedWithWinzigebeschwoererin;
  983. this.playedmagierinderkirintor = p.playedmagierinderkirintor;
  984. this.startedWithZauberlehrling = p.startedWithZauberlehrling;
  985. this.startedWithWinzigebeschwoererin = p.startedWithWinzigebeschwoererin;
  986. this.startedWithManagespenst = p.startedWithManagespenst;
  987. this.startedWithsoeldnerDerVenture = p.startedWithsoeldnerDerVenture;
  988. this.startedWithbeschwoerungsportal = p.startedWithbeschwoerungsportal;
  989. this.zauberlehrling = 0;
  990. this.winzigebeschwoererin = 0;
  991. this.managespenst = 0;
  992. this.soeldnerDerVenture = 0;
  993. foreach (Minion m in this.ownMinions)
  994. {
  995. if (m.silenced) continue;
  996. if (m.name == "prophetvelen") this.doublepriest++;
  997. spellpower = spellpower + m.card.spellpowervalue;
  998. if (m.name == "auchenaisoulpriest") this.auchenaiseelenpriesterin = true;
  999. if (m.name == "pint-sizedsummoner") this.winzigebeschwoererin++;
  1000. if (m.name == "sorcerersapprentice") this.zauberlehrling++;
  1001. if (m.name == "manawraith") this.managespenst++;
  1002. if (m.name == "venturecomercenary") this.soeldnerDerVenture++;
  1003. if (m.name == "summoningportal") this.beschwoerungsportal++;
  1004. }
  1005. foreach (Minion m in this.enemyMinions)
  1006. {
  1007. if (m.silenced) continue;
  1008. if (m.name == "manawraith") this.managespenst++;
  1009. }
  1010. }
  1011. public bool isEqual(Playfield p)
  1012. {
  1013. if (this.enemySecretCount != p.enemySecretCount)
  1014. {
  1015. help.logg("enemy secrets changed ");
  1016. return false;
  1017. }
  1018. if (this.mana != p.mana || this.enemyMaxMana != p.enemyMaxMana || this.ownMaxMana != p.ownMaxMana)
  1019. {
  1020. help.logg("mana changed " + this.mana + " " + p.mana + " " + this.enemyMaxMana + " " + p.enemyMaxMana + " " + this.ownMaxMana + " " + p.ownMaxMana);
  1021. return false;
  1022. }
  1023. if (this.ownDeckSize != p.ownDeckSize || this.enemyDeckSize != p.enemyDeckSize || this.ownHeroFatigue != p.ownHeroFatigue || this.enemyHeroFatigue != p.enemyHeroFatigue)
  1024. {
  1025. help.logg("deck/fatigue changed " + this.ownDeckSize + " " + p.ownDeckSize + " " + this.enemyDeckSize + " " + p.enemyDeckSize + " " + this.ownHeroFatigue + " " + p.ownHeroFatigue + " " + this.enemyHeroFatigue + " " + p.enemyHeroFatigue);
  1026. }
  1027. if (this.cardsPlayedThisTurn != p.cardsPlayedThisTurn || this.mobsplayedThisTurn != p.mobsplayedThisTurn || this.ueberladung != p.ueberladung)
  1028. {
  1029. help.logg("stuff changed " + this.cardsPlayedThisTurn + " " + p.cardsPlayedThisTurn + " " + this.mobsplayedThisTurn + " " + p.mobsplayedThisTurn + " " + this.ueberladung + " " + p.ueberladung);
  1030. return false;
  1031. }

Large files files are truncated, but you can click here to view the full file