PageRenderTime 59ms CodeModel.GetById 16ms 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
  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. }
  1032. if (this.ownHeroName != p.ownHeroName || this.enemyHeroName != p.enemyHeroName)
  1033. {
  1034. help.logg("hero name changed ");
  1035. return false;
  1036. }
  1037. if (this.ownHeroHp != p.ownHeroHp || this.ownheroAngr != p.ownheroAngr || this.ownHeroDefence != p.ownHeroDefence || this.ownHeroFrozen != p.ownHeroFrozen || this.heroImmuneWhileAttacking != p.heroImmuneWhileAttacking)
  1038. {
  1039. help.logg("ownhero changed " + this.ownHeroHp + " " + p.ownHeroHp + " " + this.ownheroAngr + " " + p.ownheroAngr + " " + this.ownHeroDefence + " " + p.ownHeroDefence + " " + this.ownHeroFrozen + " " + p.ownHeroFrozen + " " + this.heroImmuneWhileAttacking + " " + p.heroImmuneWhileAttacking);
  1040. return false;
  1041. }
  1042. if (this.ownHeroReady != p.ownHeroReady || this.ownWeaponAttack != p.ownWeaponAttack || this.ownWeaponDurability != p.ownWeaponDurability || this.ownHeroNumAttackThisTurn != p.ownHeroNumAttackThisTurn || this.ownHeroWindfury != p.ownHeroWindfury)
  1043. {
  1044. help.logg("weapon changed " + this.ownHeroReady + " " + p.ownHeroReady + " " + this.ownWeaponAttack + " " + p.ownWeaponAttack + " " + this.ownWeaponDurability + " " + p.ownWeaponDurability + " " + this.ownHeroNumAttackThisTurn + " " + p.ownHeroNumAttackThisTurn + " " + this.ownHeroWindfury + " " + p.ownHeroWindfury);
  1045. return false;
  1046. }
  1047. if (this.enemyHeroHp != p.enemyHeroHp || this.enemyWeaponAttack != p.enemyWeaponAttack || this.enemyHeroDefence != p.enemyHeroDefence || this.enemyWeaponDurability != p.enemyWeaponDurability || this.enemyHeroFrozen != p.enemyHeroFrozen)
  1048. {
  1049. help.logg("enemyhero changed " + this.enemyHeroHp + " " + p.enemyHeroHp + " " + this.enemyWeaponAttack + " " + p.enemyWeaponAttack + " " + this.enemyHeroDefence + " " + p.enemyHeroDefence + " " + this.enemyWeaponDurability + " " + p.enemyWeaponDurability + " " + this.enemyHeroFrozen + " " + p.enemyHeroFrozen);
  1050. return false;
  1051. }
  1052. if (this.auchenaiseelenpriesterin != p.auchenaiseelenpriesterin || this.winzigebeschwoererin != p.winzigebeschwoererin || this.zauberlehrling != p.zauberlehrling || this.managespenst != p.managespenst || this.soeldnerDerVenture != p.soeldnerDerVenture || this.beschwoerungsportal != p.beschwoerungsportal || this.doublepriest != p.doublepriest)
  1053. {
  1054. help.logg("special minions changed " + this.auchenaiseelenpriesterin + " " + p.auchenaiseelenpriesterin + " " + this.winzigebeschwoererin + " " + p.winzigebeschwoererin + " " + this.zauberlehrling + " " + p.zauberlehrling + " " + this.managespenst + " " + p.managespenst + " " + this.soeldnerDerVenture + " " + p.soeldnerDerVenture + " " + this.beschwoerungsportal + " " + p.beschwoerungsportal + " " + this.doublepriest + " " + p.doublepriest);
  1055. return false;
  1056. }
  1057. if (this.ownHeroAblility.name != p.ownHeroAblility.name)
  1058. {
  1059. help.logg("hero ability changed ");
  1060. return false;
  1061. }
  1062. if (this.spellpower != p.spellpower)
  1063. {
  1064. help.logg("spellpower changed");
  1065. return false;
  1066. }
  1067. if (this.ownMinions.Count != p.ownMinions.Count || this.enemyMinions.Count != p.enemyMinions.Count)
  1068. {
  1069. help.logg("minions count or hand changed");
  1070. return false;
  1071. }
  1072. bool minionbool = true;
  1073. for (int i = 0; i < this.ownMinions.Count; i++)
  1074. {
  1075. Minion dis = this.ownMinions[i]; Minion pis = p.ownMinions[i];
  1076. //if (dis.entitiyID == 0) dis.entitiyID = pis.entitiyID;
  1077. //if (pis.entitiyID == 0) pis.entitiyID = dis.entitiyID;
  1078. if (dis.entitiyID != pis.entitiyID) minionbool = false;
  1079. if (dis.Angr != pis.Angr || dis.Hp != pis.Hp || dis.maxHp != pis.maxHp || dis.numAttacksThisTurn != pis.numAttacksThisTurn) minionbool = false;
  1080. if (dis.Ready != pis.Ready) minionbool = false; // includes frozen, exhaunted
  1081. if (dis.playedThisTurn != pis.playedThisTurn || dis.numAttacksThisTurn != pis.numAttacksThisTurn) minionbool = false;
  1082. if (dis.silenced != pis.silenced || dis.stealth != pis.stealth || dis.taunt != pis.taunt || dis.windfury != pis.windfury || dis.wounded != pis.wounded || dis.zonepos != pis.zonepos) minionbool = false;
  1083. if (dis.divineshild != pis.divineshild || dis.cantLowerHPbelowONE != pis.cantLowerHPbelowONE || dis.immune != pis.immune) minionbool = false;
  1084. }
  1085. if (minionbool == false)
  1086. {
  1087. help.logg("ownminions changed");
  1088. return false;
  1089. }
  1090. for (int i = 0; i < this.enemyMinions.Count; i++)
  1091. {
  1092. Minion dis = this.enemyMinions[i]; Minion pis = p.enemyMinions[i];
  1093. //if (dis.entitiyID == 0) dis.entitiyID = pis.entitiyID;
  1094. //if (pis.entitiyID == 0) pis.entitiyID = dis.entitiyID;
  1095. if (dis.entitiyID != pis.entitiyID) minionbool = false;
  1096. if (dis.Angr != pis.Angr || dis.Hp != pis.Hp || dis.maxHp != pis.maxHp || dis.numAttacksThisTurn != pis.numAttacksThisTurn) minionbool = false;
  1097. if (dis.Ready != pis.Ready) minionbool = false; // includes frozen, exhaunted
  1098. if (dis.playedThisTurn != pis.playedThisTurn || dis.numAttacksThisTurn != pis.numAttacksThisTurn) minionbool = false;
  1099. if (dis.silenced != pis.silenced || dis.stealth != pis.stealth || dis.taunt != pis.taunt || dis.windfury != pis.windfury || dis.wounded != pis.wounded || dis.zonepos != pis.zonepos) minionbool = false;
  1100. if (dis.divineshild != pis.divineshild || dis.cantLowerHPbelowONE != pis.cantLowerHPbelowONE || dis.immune != pis.immune) minionbool = false;
  1101. }
  1102. if (minionbool == false)
  1103. {
  1104. help.logg("enemyminions changed");
  1105. return false;
  1106. }
  1107. for (int i = 0; i < this.owncards.Count; i++)
  1108. {
  1109. Handmanager.Handcard dishc = this.owncards[i]; Handmanager.Handcard pishc = p.owncards[i];
  1110. if (dishc.position != pishc.position || dishc.entity != pishc.entity || dishc.card.getManaCost(this) != pishc.card.getManaCost(p))
  1111. {
  1112. help.logg("handcard changed: " + dishc.card.name);
  1113. return false;
  1114. }
  1115. }
  1116. return true;
  1117. }
  1118. public int getValuee()
  1119. {
  1120. //isnt used anymore :D
  1121. //if (value >= -200000) return value;
  1122. int retval = 0;
  1123. return retval;
  1124. }
  1125. public List<targett> getAttackTargets()
  1126. {
  1127. List<targett> trgts = new List<targett>();
  1128. List<targett> trgts2 = new List<targett>();
  1129. trgts2.Add(new targett(200, this.enemyHeroEntity));
  1130. bool hastanks = false;
  1131. foreach (Minion m in this.enemyMinions)
  1132. {
  1133. if (m.stealth) continue; // cant target stealth
  1134. if (m.taunt)
  1135. {
  1136. hastanks = true;
  1137. trgts.Add(new targett(m.id + 10, m.entitiyID));
  1138. }
  1139. else
  1140. {
  1141. trgts2.Add(new targett(m.id + 10, m.entitiyID));
  1142. }
  1143. }
  1144. if (hastanks) return trgts;
  1145. return trgts2;
  1146. }
  1147. public int getBestPlace(CardDB.Card card)
  1148. {
  1149. if (card.type != CardDB.cardtype.MOB) return 0;
  1150. if (this.ownMinions.Count == 0) return 0;
  1151. if (this.ownMinions.Count == 1) return 1;
  1152. int[] places = new int[this.ownMinions.Count];
  1153. int i = 0;
  1154. int tempval = 0;
  1155. if (card.name == "sunfuryprotector" || card.name == "defenderofargus") // bestplace, if right and left minions have no taunt + lots of hp, dont make priority-minions to taunt
  1156. {
  1157. i = 0;
  1158. foreach (Minion m in this.ownMinions)
  1159. {
  1160. places[i] = 0;
  1161. tempval = 0;
  1162. if (!m.taunt)
  1163. {
  1164. tempval -= m.Hp;
  1165. }
  1166. else
  1167. {
  1168. tempval = 30;
  1169. }
  1170. if (m.name == "flametonguetotem") tempval += 50;
  1171. if (m.name == "raidleader") tempval += 10;
  1172. if (m.name == "grimscaleoracle") tempval += 10;
  1173. if (m.name == "direwolfalpha") tempval += 50;
  1174. if (m.name == "murlocwarleader") tempval += 10;
  1175. if (m.name == "southseacaptain") tempval += 10;
  1176. if (m.name == "stormwindchampion") tempval += 10;
  1177. if (m.name == "timberwolf") tempval += 10;
  1178. if (m.name == "leokk") tempval += 10;
  1179. if (m.name == "northshirecleric") tempval += 10;
  1180. if (m.name == "sorcerersapprentice") tempval += 10;
  1181. if (m.name == "pint-sizedsummoner") tempval += 10;
  1182. if (m.name == "summoningportal") tempval += 10;
  1183. if (m.name == "scavenginghyena") tempval += 10;
  1184. places[i] = tempval;
  1185. i++;
  1186. }
  1187. i = 0;
  1188. int bestpl = 7;
  1189. int bestval = 10000;
  1190. foreach (Minion m in this.ownMinions)
  1191. {
  1192. int prev = 0;
  1193. int next = 0;
  1194. if (i >= 1) prev = places[i - 1];
  1195. next = places[i];
  1196. if (bestval > prev + next)
  1197. {
  1198. bestval = prev + next;
  1199. bestpl = i;
  1200. }
  1201. i++;
  1202. }
  1203. return bestpl;
  1204. }
  1205. // normal placement
  1206. int cardvalue = card.Attack * 2 + card.Health;
  1207. if (card.tank)
  1208. {
  1209. cardvalue += 5;
  1210. cardvalue += card.Health;
  1211. }
  1212. if (card.name == "flametonguetotem") cardvalue += 50;
  1213. if (card.name == "raidleader") cardvalue += 10;
  1214. if (card.name == "grimscaleoracle") cardvalue += 10;
  1215. if (card.name == "direwolfalpha") cardvalue += 50;
  1216. if (card.name == "murlocwarleader") cardvalue += 10;
  1217. if (card.name == "southseacaptain") cardvalue += 10;
  1218. if (card.name == "stormwindchampion") cardvalue += 10;
  1219. if (card.name == "timberwolf") cardvalue += 10;
  1220. if (card.name == "leokk") cardvalue += 10;
  1221. if (card.name == "northshirecleric") cardvalue += 10;
  1222. if (card.name == "sorcerersapprentice") cardvalue += 10;
  1223. if (card.name == "pint-sizedsummoner") cardvalue += 10;
  1224. if (card.name == "summoningportal") cardvalue += 10;
  1225. if (card.name == "scavenginghyena") cardvalue += 10;
  1226. cardvalue += 1;
  1227. i = 0;
  1228. foreach (Minion m in this.ownMinions)
  1229. {
  1230. places[i] = 0;
  1231. tempval = m.Angr * 2 + m.maxHp;
  1232. if (m.taunt)
  1233. {
  1234. tempval += 6;
  1235. tempval += m.maxHp;
  1236. }
  1237. if (m.name == "flametonguetotem") tempval += 50;
  1238. if (m.name == "raidleader") tempval += 10;
  1239. if (m.name == "grimscaleoracle") tempval += 10;
  1240. if (m.name == "direwolfalpha") tempval += 50;
  1241. if (m.name == "murlocwarleader") tempval += 10;
  1242. if (m.name == "southseacaptain") tempval += 10;
  1243. if (m.name == "stormwindchampion") tempval += 10;
  1244. if (m.name == "timberwolf") tempval += 10;
  1245. if (m.name == "leokk") tempval += 10;
  1246. if (m.name == "northshirecleric") tempval += 10;
  1247. if (m.name == "sorcerersapprentice") tempval += 10;
  1248. if (m.name == "pint-sizedsummoner") tempval += 10;
  1249. if (m.name == "summoningportal") tempval += 10;
  1250. if (m.name == "scavenginghyena") tempval += 10;
  1251. places[i] = tempval;
  1252. i++;
  1253. }
  1254. //bigminion if >=10
  1255. int bestplace = 0;
  1256. int bestvale = 0;
  1257. tempval = 0;
  1258. i = 0;
  1259. for (int j = 0; j <= this.ownMinions.Count; j++)
  1260. {
  1261. int prev = cardvalue;
  1262. int next = cardvalue;
  1263. if (i >= 1) prev = places[i - 1];
  1264. if (i < this.ownMinions.Count) next = places[i];
  1265. if (cardvalue >= prev && cardvalue >= next)
  1266. {
  1267. tempval = 2 * cardvalue - prev - next;
  1268. if (tempval > bestvale)
  1269. {
  1270. bestplace = i;
  1271. bestvale = tempval;
  1272. }
  1273. }
  1274. if (cardvalue <= prev && cardvalue <= next)
  1275. {
  1276. tempval = -2 * cardvalue + prev + next;
  1277. if (tempval > bestvale)
  1278. {
  1279. bestplace = i;
  1280. bestvale = tempval;
  1281. }
  1282. }
  1283. i++;
  1284. }
  1285. return bestplace;
  1286. }
  1287. public int getBestPlacePrint(CardDB.Card card)
  1288. {
  1289. if (card.type != CardDB.cardtype.MOB) return 0;
  1290. if (this.ownMinions.Count == 0) return 0;
  1291. if (this.ownMinions.Count == 1) return 1;
  1292. int[] places = new int[this.ownMinions.Count];
  1293. int i = 0;
  1294. int tempval = 0;
  1295. if (card.name == "sunfuryprotector" || card.name == "defenderofargus") // bestplace, if right and left minions have no taunt + lots of hp, dont make priority-minions to taunt
  1296. {
  1297. i = 0;
  1298. foreach (Minion m in this.ownMinions)
  1299. {
  1300. places[i] = 0;
  1301. tempval = 0;
  1302. if (!m.taunt)
  1303. {
  1304. tempval -= m.Hp;
  1305. }
  1306. else
  1307. {
  1308. tempval = 30;
  1309. }
  1310. if (m.name == "flametonguetotem") tempval += 50;
  1311. if (m.name == "raidleader") tempval += 10;
  1312. if (m.name == "grimscaleoracle") tempval += 10;
  1313. if (m.name == "direwolfalpha") tempval += 50;
  1314. if (m.name == "murlocwarleader") tempval += 10;
  1315. if (m.name == "southseacaptain") tempval += 10;
  1316. if (m.name == "stormwindchampion") tempval += 10;
  1317. if (m.name == "timberwolf") tempval += 10;
  1318. if (m.name == "leokk") tempval += 10;
  1319. if (m.name == "northshirecleric") tempval += 10;
  1320. if (m.name == "sorcerersapprentice") tempval += 10;
  1321. if (m.name == "pint-sizedsummoner") tempval += 10;
  1322. if (m.name == "summoningportal") tempval += 10;
  1323. if (m.name == "scavenginghyena") tempval += 10;
  1324. places[i] = tempval;
  1325. i++;
  1326. }
  1327. i = 0;
  1328. int bestpl = 7;
  1329. int bestval = 10000;
  1330. foreach (Minion m in this.ownMinions)
  1331. {
  1332. help.logg(places[i] + "");
  1333. int prev = 0;
  1334. int next = 0;
  1335. if (i >= 1) prev = places[i - 1];
  1336. next = places[i];
  1337. if (bestval > prev + next)
  1338. {
  1339. bestval = prev + next;
  1340. bestpl = i;
  1341. }
  1342. i++;
  1343. }
  1344. return bestpl;
  1345. }
  1346. // normal placement
  1347. int cardvalue = card.Attack * 2 + card.Health;
  1348. if (card.tank)
  1349. {
  1350. cardvalue += 5;
  1351. cardvalue += card.Health;
  1352. }
  1353. if (card.name == "flametonguetotem") cardvalue += 50;
  1354. if (card.name == "raidleader") cardvalue += 10;
  1355. if (card.name == "grimscaleoracle") cardvalue += 10;
  1356. if (card.name == "direwolfalpha") cardvalue += 50;
  1357. if (card.name == "murlocwarleader") cardvalue += 10;
  1358. if (card.name == "southseacaptain") cardvalue += 10;
  1359. if (card.name == "stormwindchampion") cardvalue += 10;
  1360. if (card.name == "timberwolf") cardvalue += 10;
  1361. if (card.name == "leokk") cardvalue += 10;
  1362. if (card.name == "northshirecleric") cardvalue += 10;
  1363. if (card.name == "sorcerersapprentice") cardvalue += 10;
  1364. if (card.name == "pint-sizedsummoner") cardvalue += 10;
  1365. if (card.name == "summoningportal") cardvalue += 10;
  1366. if (card.name == "scavenginghyena") cardvalue += 10;
  1367. cardvalue += 1;
  1368. i = 0;
  1369. foreach (Minion m in this.ownMinions)
  1370. {
  1371. places[i] = 0;
  1372. tempval = m.Angr * 2 + m.maxHp;
  1373. if (m.taunt)
  1374. {
  1375. tempval += 6;
  1376. tempval += m.maxHp;
  1377. }
  1378. if (m.name == "flametonguetotem") tempval += 50;
  1379. if (m.name == "raidleader") tempval += 10;
  1380. if (m.name == "grimscaleoracle") tempval += 10;
  1381. if (m.name == "direwolfalpha") tempval += 50;
  1382. if (m.name == "murlocwarleader") tempval += 10;
  1383. if (m.name == "southseacaptain") tempval += 10;
  1384. if (m.name == "stormwindchampion") tempval += 10;
  1385. if (m.name == "timberwolf") tempval += 10;
  1386. if (m.name == "leokk") tempval += 10;
  1387. if (m.name == "northshirecleric") tempval += 10;
  1388. if (m.name == "sorcerersapprentice") tempval += 10;
  1389. if (m.name == "pint-sizedsummoner") tempval += 10;
  1390. if (m.name == "summoningportal") tempval += 10;
  1391. if (m.name == "scavenginghyena") tempval += 10;
  1392. places[i] = tempval;
  1393. help.logg(places[i] + "");
  1394. i++;
  1395. }
  1396. //bigminion if >=10
  1397. int bestplace = 0;
  1398. int bestvale = 0;
  1399. tempval = 0;
  1400. i = 0;
  1401. help.logg(cardvalue + " (own)");
  1402. i = 0;
  1403. for (int j = 0; j <= this.ownMinions.Count; j++)
  1404. {
  1405. int prev = cardvalue;
  1406. int next = cardvalue;
  1407. if (i >= 1) prev = places[i - 1];
  1408. if (i < this.ownMinions.Count)
  1409. {
  1410. next = places[i];
  1411. }
  1412. if (cardvalue >= prev && cardvalue >= next)
  1413. {
  1414. tempval = 2 * cardvalue - prev - next;
  1415. if (tempval > bestvale)
  1416. {
  1417. bestplace = i;
  1418. bestvale = tempval;
  1419. }
  1420. }
  1421. if (cardvalue <= prev && cardvalue <= next)
  1422. {
  1423. tempval = -2 * cardvalue + prev + next;
  1424. if (tempval > bestvale)
  1425. {
  1426. bestplace = i;
  1427. bestvale = tempval;
  1428. }
  1429. }
  1430. i++;
  1431. }
  1432. help.logg(bestplace + " (best)");
  1433. return bestplace;
  1434. }
  1435. public void endTurn()
  1436. {
  1437. this.complete = true;
  1438. endTurnBuffs(true);//end own buffs
  1439. endTurnEffect(true);//own turn ends
  1440. startTurnEffect(false);//enemy turn begins
  1441. guessHeroDamage();
  1442. simulateTraps();
  1443. }
  1444. private void guessHeroDamage()
  1445. {
  1446. int ghd = 0;
  1447. foreach (Minion m in this.enemyMinions)
  1448. {
  1449. if (m.frozen) continue;
  1450. ghd += m.Angr;
  1451. if (m.windfury) ghd += m.Angr;
  1452. }
  1453. if (this.enemyHeroName == "druid") ghd++;
  1454. if (this.enemyHeroName == "mage") ghd++;
  1455. if (this.enemyHeroName == "thief") ghd++;
  1456. if (this.enemyHeroName == "hunter") ghd += 2;
  1457. ghd += enemyWeaponAttack;
  1458. foreach (Minion m in this.ownMinions)
  1459. {
  1460. if (m.frozen) continue;
  1461. if (m.taunt) ghd -= m.Hp;
  1462. if (m.taunt && m.divineshild) ghd -= 1;
  1463. }
  1464. this.guessingHeroDamage = Math.Max(0, ghd);
  1465. }
  1466. private void simulateTraps()
  1467. {
  1468. // DONT KILL ENEMY HERO (cause its only guessing)
  1469. foreach (string secretID in this.ownSecretsIDList)
  1470. {
  1471. //hunter secrets############
  1472. if (secretID == "EX1_554") //snaketrap
  1473. {
  1474. //call 3 snakes (if possible)
  1475. int posi = this.ownMinions.Count - 1;
  1476. CardDB.Card kid = CardDB.Instance.getCardData("snake");
  1477. callKid(kid, posi, true);
  1478. callKid(kid, posi, true);
  1479. callKid(kid, posi, true);
  1480. }
  1481. if (secretID == "EX1_609") //snipe
  1482. {
  1483. //kill weakest minion of enemy
  1484. List<Minion> temp = new List<Minion>(this.enemyMinions);
  1485. temp.Sort((a, b) => a.Angr.CompareTo(b.Angr));//take the weakest
  1486. if (temp.Count == 0) continue;
  1487. Minion m = temp[0];
  1488. minionGetDamagedOrHealed(m, 4, 0, false);
  1489. }
  1490. if (secretID == "EX1_610") //explosive trap
  1491. {
  1492. //take 2 damage to each enemy
  1493. List<Minion> temp = new List<Minion>(this.enemyMinions);
  1494. foreach (Minion m in temp)
  1495. {
  1496. minionGetDamagedOrHealed(m, 2, 0, false);
  1497. }
  1498. attackEnemyHeroWithoutKill(2);
  1499. }
  1500. if (secretID == "EX1_611") //freezing trap
  1501. {
  1502. //return weakest enemy minion to hand
  1503. List<Minion> temp = new List<Minion>(this.enemyMinions);
  1504. temp.Sort((a, b) => a.Angr.CompareTo(b.Angr));//take the weakest
  1505. if (temp.Count == 0) continue;
  1506. Minion m = temp[0];
  1507. minionReturnToHand(m, false);
  1508. }
  1509. if (secretID == "EX1_533") // missdirection
  1510. {
  1511. // first damage to your hero is nulled -> lower guessingHeroDamage
  1512. List<Minion> temp = new List<Minion>(this.enemyMinions);
  1513. temp.Sort((a, b) => a.Angr.CompareTo(b.Angr));//take the weakest
  1514. if (temp.Count == 0) continue;
  1515. Minion m = temp[0];
  1516. this.guessingHeroDamage = Math.Max(0, this.guessingHeroDamage -= Math.Max(m.Angr, 1));
  1517. this.ownHeroDefence += this.enemyMinions.Count;// the more the enemy minions has on board, the more the posibility to destroy something other :D
  1518. }
  1519. //mage secrets############
  1520. if (secretID == "EX1_287") //counterspell
  1521. {
  1522. // what should we do?
  1523. this.ownHeroDefence += 5;
  1524. }
  1525. if (secretID == "EX1_289") //ice barrier
  1526. {
  1527. this.ownHeroDefence += 8;
  1528. }
  1529. if (secretID == "EX1_295") //ice barrier
  1530. {
  1531. //set the guessed Damage to zero
  1532. this.guessingHeroDamage = 0;
  1533. }
  1534. if (secretID == "EX1_294") //mirror entity
  1535. {
  1536. //summon snake ( a weak minion)
  1537. int posi = this.ownMinions.Count - 1;
  1538. CardDB.Card kid = CardDB.Instance.getCardData("snake");
  1539. callKid(kid, posi, true);
  1540. }
  1541. if (secretID == "tt_010") //spellbender
  1542. {
  1543. //whut???
  1544. // add 2 to your defence (most attack-buffs give +2, lots of damage spells too)
  1545. this.ownHeroDefence += 2;
  1546. }
  1547. if (secretID == "EX1_594") // vaporize
  1548. {
  1549. // first damage to your hero is nulled -> lower guessingHeroDamage and destroy weakest minion
  1550. List<Minion> temp = new List<Minion>(this.enemyMinions);
  1551. temp.Sort((a, b) => a.Angr.CompareTo(b.Angr));//take the weakest
  1552. if (temp.Count == 0) continue;
  1553. Minion m = temp[0];
  1554. this.guessingHeroDamage = Math.Max(0, this.guessingHeroDamage -= Math.Max(m.Angr, 1));
  1555. minionGetDestroyed(m, false);
  1556. }
  1557. //pala secrets############
  1558. if (secretID == "EX1_132") // eye for an eye
  1559. {
  1560. // enemy takes one damage
  1561. attackEnemyHeroWithoutKill(1);
  1562. }
  1563. if (secretID == "EX1_130") // noble sacrifice
  1564. {
  1565. //lower guessed hero damage
  1566. List<Minion> temp = new List<Minion>(this.enemyMinions);
  1567. temp.Sort((a, b) => a.Angr.CompareTo(b.Angr));//take the weakest
  1568. if (temp.Count == 0) continue;
  1569. Minion m = temp[0];
  1570. this.guessingHeroDamage = Math.Max(0, this.guessingHeroDamage -= Math.Max(m.Angr, 1));
  1571. }
  1572. if (secretID == "EX1_136") // redemption
  1573. {
  1574. // we give our weakest minion a divine shield :D
  1575. List<Minion> temp = new List<Minion>(this.ownMinions);
  1576. temp.Sort((a, b) => a.Hp.CompareTo(b.Hp));//take the weakest
  1577. if (temp.Count == 0) continue;
  1578. foreach (Minion m in temp)
  1579. {
  1580. if (m.divineshild) continue;
  1581. m.divineshild = true;
  1582. break;
  1583. }
  1584. }
  1585. if (secretID == "EX1_379") // repentance
  1586. {
  1587. // set his current lowest hp minion to x/1
  1588. List<Minion> temp = new List<Minion>(this.enemyMinions);
  1589. temp.Sort((a, b) => a.Hp.CompareTo(b.Hp));//take the weakest
  1590. if (temp.Count == 0) continue;
  1591. Minion m = temp[0];
  1592. m.Hp = 1;
  1593. m.maxHp = 1;
  1594. }
  1595. }
  1596. }
  1597. private void endTurnBuffs(bool own)
  1598. {
  1599. List<Minion> temp = new List<Minion>();
  1600. if (own)
  1601. {
  1602. temp.AddRange(this.ownMinions);
  1603. }
  1604. else
  1605. {
  1606. temp.AddRange(this.enemyMinions);
  1607. }
  1608. // end buffs
  1609. foreach (Minion m in temp)
  1610. {
  1611. m.cantLowerHPbelowONE = false;
  1612. m.immune = false;
  1613. List<Enchantment> tempench = new List<Enchantment>(m.enchantments);
  1614. foreach (Enchantment e in tempench)
  1615. {
  1616. if (e.CARDID == "EX1_316e")//ueberwaeltigende macht
  1617. {
  1618. minionGetDestroyed(m, own);
  1619. }
  1620. if (e.CARDID == "CS2_046e")//kampfrausch
  1621. {
  1622. debuff(m, e);
  1623. }
  1624. if (e.CARDID == "CS2_045e")// waffe felsbeiser
  1625. {
  1626. debuff(m, e);
  1627. }
  1628. if (e.CARDID == "EX1_046e")// dunkeleisenzwerg
  1629. {
  1630. debuff(m, e);
  1631. }
  1632. if (e.CARDID == "CS2_188o")// ruchloserunteroffizier
  1633. {
  1634. debuff(m, e);
  1635. }
  1636. if (e.CARDID == "EX1_055o")// manasuechtige
  1637. {
  1638. debuff(m, e);
  1639. }
  1640. if (e.CARDID == "EX1_549o")//zorn des wildtiers
  1641. {
  1642. debuff(m, e);
  1643. }
  1644. if (e.CARDID == "EX1_334e")// dunkler wahnsin (control minion till end of turn)
  1645. {
  1646. //"uncontrol minion"
  1647. minionGetControlled(m, !own, true);
  1648. }
  1649. }
  1650. }
  1651. temp.Clear();
  1652. if (own)
  1653. {
  1654. temp.AddRange(this.enemyMinions);
  1655. }
  1656. else
  1657. {
  1658. temp.AddRange(this.ownMinions);
  1659. }
  1660. foreach (Minion m in temp)
  1661. {
  1662. m.cantLowerHPbelowONE = false;
  1663. m.immune = false;
  1664. List<Enchantment> tempench = new List<Enchantment>(m.enchantments);
  1665. foreach (Enchantment e in tempench)
  1666. {
  1667. if (e.CARDID == "EX1_046e")// dunkeleisenzwerg
  1668. {
  1669. debuff(m, e);
  1670. }
  1671. if (e.CARDID == "CS2_188o")// ruchloserunteroffizier
  1672. {
  1673. debuff(m, e);
  1674. }
  1675. if (e.CARDID == "EX1_549o")//zorn des wildtiers
  1676. {
  1677. debuff(m, e);
  1678. }
  1679. }
  1680. }
  1681. }
  1682. private void endTurnEffect(bool own)
  1683. {
  1684. List<Minion> temp = new List<Minion>();
  1685. List<Minion> ownmins = new List<Minion>();
  1686. List<Minion> enemymins = new List<Minion>();
  1687. if (own)
  1688. {
  1689. temp.AddRange(this.ownMinions);
  1690. ownmins.AddRange(this.ownMinions);
  1691. enemymins.AddRange(this.enemyMinions);
  1692. }
  1693. else
  1694. {
  1695. temp.AddRange(this.enemyMinions);
  1696. ownmins.AddRange(this.enemyMinions);
  1697. enemymins.AddRange(this.ownMinions);
  1698. }
  1699. foreach (Minion m in temp)
  1700. {
  1701. if (m.silenced) continue;
  1702. if (m.name == "barongeddon") // all other chards get dmg get 2 dmg
  1703. {
  1704. List<Minion> temp2 = new List<Minion>(this.ownMinions);
  1705. foreach (Minion mm in temp2)
  1706. {
  1707. if (mm.entitiyID != m.entitiyID)
  1708. {
  1709. minionGetDamagedOrHealed(mm, 2, 0, true);
  1710. }
  1711. }
  1712. temp2.Clear();
  1713. temp2.AddRange(this.enemyMinions);
  1714. foreach (Minion mm in temp2)
  1715. {
  1716. if (mm.entitiyID != m.entitiyID)
  1717. {
  1718. minionGetDamagedOrHealed(mm, 2, 0, false);
  1719. }
  1720. }
  1721. attackOrHealHero(2, true);
  1722. attackOrHealHero(2, false);
  1723. }
  1724. if (m.name == "bloodimp" || m.name == "youngpriestess") // buff a minion
  1725. {
  1726. List<Minion> temp2 = new List<Minion>(ownmins);
  1727. temp2.Sort((a, b) => a.Hp.CompareTo(b.Hp));//buff the weakest
  1728. foreach (Minion mins in Helpfunctions.TakeList(temp2, 1))
  1729. {
  1730. minionGetBuffed(mins, 0, 1, own);
  1731. }
  1732. }
  1733. if (m.name == "masterswordsmith") // buff a minion
  1734. {
  1735. List<Minion> temp2 = new List<Minion>(ownmins);
  1736. temp2.Sort((a, b) => a.Angr.CompareTo(b.Angr));//buff the weakest
  1737. foreach (Minion mins in Helpfunctions.TakeList(temp2, 1))
  1738. {
  1739. minionGetBuffed(mins, 1, 0, own);
  1740. }
  1741. }
  1742. if (m.name == "emboldener3000") // buff a minion
  1743. {
  1744. List<Minion> temp2 = new List<Minion>(this.enemyMinions);
  1745. temp2.Sort((a, b) => -a.Angr.CompareTo(b.Angr));//buff the strongest enemy
  1746. foreach (Minion mins in Helpfunctions.TakeList(temp2, 1))
  1747. {
  1748. minionGetBuffed(mins, 1, 0, false);//buff alyways enemy :D
  1749. }
  1750. }
  1751. if (m.name == "gruul") // gain +1/+1
  1752. {
  1753. minionGetBuffed(m, 1, 1, own);
  1754. }
  1755. if (m.name == "etherealarcanist") // gain +2/+2
  1756. {
  1757. if (own && this.ownSecretsIDList.Count >= 1)
  1758. {
  1759. minionGetBuffed(m, 2, 2, own);
  1760. }
  1761. if (!own && this.enemySecretCount >= 1)
  1762. {
  1763. minionGetBuffed(m, 2, 2, own);
  1764. }
  1765. }
  1766. if (m.name == "manatidetotem") // draw card
  1767. {
  1768. if (own)
  1769. {
  1770. this.owncarddraw++;
  1771. this.drawACard("");
  1772. }
  1773. else
  1774. {
  1775. this.enemycarddraw++;
  1776. }
  1777. }
  1778. if (m.name == "healingtotem") // heal
  1779. {
  1780. List<Minion> temp2 = new List<Minion>(ownmins);
  1781. foreach (Minion mins in temp2)
  1782. {
  1783. minionGetDamagedOrHealed(mins, 0, 1, own);
  1784. }
  1785. }
  1786. if (m.name == "hogger") // summon
  1787. {
  1788. int posi = m.id;
  1789. CardDB.Card kid = CardDB.Instance.getCardData("gnoll");
  1790. callKid(kid, posi, own);
  1791. }
  1792. if (m.name == "impmaster") // damage itself and summon
  1793. {
  1794. int posi = m.id;
  1795. if (m.Hp == 1) posi--;
  1796. minionGetDamagedOrHealed(m, 1, 0, own);
  1797. CardDB.Card kid = CardDB.Instance.getCardData("imp");
  1798. callKid(kid, posi, own);
  1799. }
  1800. if (m.name == "natpagle") // draw card
  1801. {
  1802. if (own)
  1803. {
  1804. this.owncarddraw++;
  1805. this.drawACard("");
  1806. }
  1807. else
  1808. {
  1809. this.enemycarddraw++;
  1810. }
  1811. }
  1812. if (m.name == "ragnarosthefirelord") // summon
  1813. {
  1814. if (this.enemyMinions.Count >= 1)
  1815. {
  1816. List<Minion> temp2 = new List<Minion>(enemymins);
  1817. temp2.Sort((a, b) => -a.Hp.CompareTo(b.Hp));//damage the stronges
  1818. foreach (Minion mins in Helpfunctions.TakeList(temp2, 1))
  1819. {
  1820. minionGetDamagedOrHealed(mins, 8, 0, !own);
  1821. }
  1822. }
  1823. else
  1824. {
  1825. attackOrHealHero(8, !own);
  1826. }
  1827. }
  1828. if (m.name == "repairbot") // heal damaged char
  1829. {
  1830. attackOrHealHero(-6, false);
  1831. }
  1832. if (m.card.CardID == "EX1_tk9") //treant which is destroyed
  1833. {
  1834. minionGetDestroyed(m, own);
  1835. }
  1836. if (m.name == "ysera") // draw card
  1837. {
  1838. if (own)
  1839. {
  1840. this.owncarddraw++;
  1841. this.drawACard("yseraawakens");
  1842. }
  1843. else
  1844. {
  1845. this.enemycarddraw++;
  1846. }
  1847. }
  1848. }
  1849. }
  1850. private void startTurnEffect(bool own)
  1851. {
  1852. List<Minion> temp = new List<Minion>();
  1853. List<Minion> ownmins = new List<Minion>();
  1854. List<Minion> enemymins = new List<Minion>();
  1855. if (own)
  1856. {
  1857. temp.AddRange(this.ownMinions);
  1858. ownmins.AddRange(this.ownMinions);
  1859. enemymins.AddRange(this.enemyMinions);
  1860. }
  1861. else
  1862. {
  1863. temp.AddRange(this.enemyMinions);
  1864. ownmins.AddRange(this.enemyMinions);
  1865. enemymins.AddRange(this.ownMinions);
  1866. }
  1867. bool untergang = false;
  1868. foreach (Minion m in temp)
  1869. {
  1870. if (m.silenced) continue;
  1871. if (m.name == "demolisher") // deal 2 dmg
  1872. {
  1873. List<Minion> temp2 = new List<Minion>(enemymins);
  1874. foreach (Minion mins in temp2)
  1875. {
  1876. minionGetDamagedOrHealed(mins, 2, 0, !own);
  1877. }
  1878. }
  1879. if (m.name == "doomsayer") // destroy
  1880. {
  1881. untergang = true;
  1882. }
  1883. if (m.name == "homingchicken") // ok
  1884. {
  1885. minionGetDestroyed(m, own);
  1886. if (own)
  1887. {
  1888. this.owncarddraw += 3;
  1889. this.drawACard("");
  1890. this.drawACard("");
  1891. this.drawACard("");
  1892. }
  1893. else
  1894. {
  1895. this.enemycarddraw += 3;
  1896. }
  1897. }
  1898. if (m.name == "lightwell") // heal
  1899. {
  1900. if (ownmins.Count >= 1)
  1901. {
  1902. List<Minion> temp2 = new List<Minion>(ownmins);
  1903. bool healed = false;
  1904. foreach (Minion mins in temp2)
  1905. {
  1906. if (mins.wounded)
  1907. {
  1908. minionGetDamagedOrHealed(mins, 0, 3, own);
  1909. healed = true;
  1910. break;
  1911. }
  1912. }
  1913. if (!healed) attackOrHealHero(-3, own);
  1914. }
  1915. else
  1916. {
  1917. attackOrHealHero(-3, own);
  1918. }
  1919. }
  1920. if (m.name == "poultryizer") //
  1921. {
  1922. if (this.ownMinions.Count >= 1)
  1923. {
  1924. List<Minion> temp2 = new List<Minion>(this.ownMinions);
  1925. temp2.Sort((a, b) => -a.Hp.CompareTo(b.Hp));//damage the stronges
  1926. foreach (Minion mins in temp2)
  1927. {
  1928. CardDB.Card c = CardDB.Instance.getCardDataFromID("Mekka4t");
  1929. minionTransform(mins, c, true);
  1930. break;
  1931. }
  1932. }
  1933. else
  1934. {
  1935. List<Minion> temp2 = new List<Minion>(this.enemyMinions);
  1936. temp2.Sort((a, b) => a.Hp.CompareTo(b.Hp));//damage the lowest
  1937. foreach (Minion mins in temp2)
  1938. {
  1939. CardDB.Card c = CardDB.Instance.getCardDataFromID("Mekka4t");
  1940. minionTransform(mins, c, false);
  1941. break;
  1942. }
  1943. }
  1944. }
  1945. }
  1946. foreach (Minion m in enemymins) // search for corruption in other minions
  1947. {
  1948. List<Enchantment> elist = new List<Enchantment>(m.enchantments);
  1949. foreach (Enchantment e in elist)
  1950. {
  1951. if (e.CARDID == "CS2_063e")//corruption
  1952. {
  1953. if (own && e.controllerOfCreator == this.ownController) // own turn + we owner of curruption
  1954. {
  1955. minionGetDestroyed(m, false);
  1956. }
  1957. if (!own && e.controllerOfCreator != this.ownController)
  1958. {
  1959. minionGetDestroyed(m, true);
  1960. }
  1961. }
  1962. }
  1963. }
  1964. if (untergang)
  1965. {
  1966. foreach (Minion mins in ownmins)
  1967. {
  1968. minionGetDestroyed(mins, own);
  1969. }
  1970. foreach (Minion mins in enemymins)
  1971. {
  1972. minionGetDestroyed(mins, !own);
  1973. }
  1974. }
  1975. }
  1976. private int getSpellDamageDamage(int dmg)
  1977. {
  1978. int retval = dmg;
  1979. retval += this.spellpower;
  1980. if (this.doublepriest >= 1) retval *= (2 * this.doublepriest);
  1981. return retval;
  1982. }
  1983. private int getSpellHeal(int heal)
  1984. {
  1985. int retval = heal;
  1986. retval += this.spellpower;
  1987. if (this.auchenaiseelenpriesterin) retval *= -1;
  1988. if (this.doublepriest >= 1) retval *= (2 * this.doublepriest);
  1989. return retval;
  1990. }
  1991. private void attackEnemyHeroWithoutKill(int dmg)
  1992. {
  1993. int oldHp = this.enemyHeroHp;
  1994. if (this.enemyHeroDefence <= 0)
  1995. {
  1996. this.enemyHeroHp = Math.Min(30, this.enemyHeroHp - dmg);
  1997. }
  1998. else
  1999. {
  2000. if (this.enemyHeroDefence > 0)
  2001. {
  2002. int rest = enemyHeroDefence - dmg;
  2003. if (rest < 0)
  2004. {
  2005. this.enemyHeroHp += rest;
  2006. }
  2007. this.enemyHeroDefence = Math.Max(0, this.enemyHeroDefence - dmg);
  2008. }
  2009. }
  2010. if (oldHp >= 1 && this.enemyHeroHp == 0) this.enemyHeroHp = 1;
  2011. }
  2012. private void attackOrHealHero(int dmg, bool own) // negative damage is heal
  2013. {
  2014. if (own)
  2015. {
  2016. if (dmg < 0 || this.ownHeroDefence <= 0)
  2017. {
  2018. //heal
  2019. int copy = this.ownHeroHp;
  2020. if (dmg < 0 && this.ownHeroHp - dmg > 30) this.lostHeal += this.ownHeroHp - dmg - 30;
  2021. this.ownHeroHp = Math.Min(30, this.ownHeroHp - dmg);
  2022. if (copy < this.ownHeroHp)
  2023. {
  2024. triggerAHeroGetHealed(own);
  2025. }
  2026. }
  2027. else
  2028. {
  2029. if (this.ownHeroDefence > 0 && dmg > 0)
  2030. {
  2031. int rest = this.ownHeroDefence - dmg;
  2032. if (rest < 0)
  2033. {
  2034. this.ownHeroHp += rest;
  2035. }
  2036. this.ownHeroDefence = Math.Max(0, this.ownHeroDefence - dmg);
  2037. }
  2038. }
  2039. }
  2040. else
  2041. {
  2042. if (dmg < 0 || this.enemyHeroDefence <= 0)
  2043. {
  2044. int copy = this.enemyHeroHp;
  2045. if (dmg < 0 && this.enemyHeroHp - dmg > 30) this.lostHeal += this.enemyHeroHp - dmg - 30;
  2046. this.enemyHeroHp = Math.Min(30, this.enemyHeroHp - dmg);
  2047. if (copy < this.enemyHeroHp)
  2048. {
  2049. triggerAHeroGetHealed(own);
  2050. }
  2051. }
  2052. else
  2053. {
  2054. if (this.enemyHeroDefence > 0 && dmg > 0)
  2055. {
  2056. int rest = enemyHeroDefence - dmg;
  2057. if (rest < 0)
  2058. {
  2059. this.enemyHeroHp += rest;
  2060. }
  2061. this.enemyHeroDefence = Math.Max(0, this.enemyHeroDefence - dmg);
  2062. }
  2063. }
  2064. }
  2065. }
  2066. private void debuff(Minion m, Enchantment e)
  2067. {
  2068. int anz = m.enchantments.RemoveAll(x => x.creator == e.creator && x.CARDID == e.CARDID);
  2069. if (anz >= 1)
  2070. {
  2071. for (int i = 0; i < anz; i++)
  2072. {
  2073. if (e.charge && !m.card.Charge && m.enchantments.FindAll(x => x.charge == true).Count == 0)
  2074. {
  2075. m.charge = false;
  2076. }
  2077. if (e.taunt && !m.card.tank && m.enchantments.FindAll(x => x.taunt == true).Count == 0)
  2078. {
  2079. m.taunt = false;
  2080. }
  2081. if (e.divineshild && m.enchantments.FindAll(x => x.divineshild == true).Count == 0)
  2082. {
  2083. m.divineshild = false;
  2084. }
  2085. if (e.windfury && !m.card.windfury && m.enchantments.FindAll(x => x.windfury == true).Count == 0)
  2086. {
  2087. m.divineshild = false;
  2088. }
  2089. if (e.imune && m.enchantments.FindAll(x => x.imune == true).Count == 0)
  2090. {
  2091. m.immune = false;
  2092. }
  2093. minionGetBuffed(m, -e.angrbuff, -e.hpbuff, true);
  2094. }
  2095. }
  2096. }
  2097. private void deleteEffectOf(string CardID, int creator)
  2098. {
  2099. // deletes the effect of the cardID with creator from all minions
  2100. Enchantment e = CardDB.getEnchantmentFromCardID(CardID);
  2101. e.creator = creator;
  2102. List<Minion> temp = new List<Minion>(this.ownMinions);
  2103. foreach (Minion m in temp)
  2104. {
  2105. debuff(m, e);
  2106. }
  2107. temp.Clear();
  2108. temp.AddRange(this.enemyMinions);
  2109. foreach (Minion m in temp)
  2110. {
  2111. debuff(m, e);
  2112. }
  2113. }
  2114. private void deleteEffectOfWithExceptions(string CardID, int creator, List<int> exeptions)
  2115. {
  2116. // deletes the effect of the cardID with creator from all minions
  2117. Enchantment e = CardDB.getEnchantmentFromCardID(CardID);
  2118. e.creator = creator;
  2119. foreach (Minion m in this.ownMinions)
  2120. {
  2121. if (!exeptions.Contains(m.id))
  2122. {
  2123. debuff(m, e);
  2124. }
  2125. }
  2126. foreach (Minion m in this.enemyMinions)
  2127. {
  2128. if (!exeptions.Contains(m.id))
  2129. {
  2130. debuff(m, e);
  2131. }
  2132. }
  2133. }
  2134. private void addEffectToMinionNoDoubles(Minion m, Enchantment e, bool own)
  2135. {
  2136. foreach (Enchantment es in m.enchantments)
  2137. {
  2138. if (es.CARDID == e.CARDID && es.creator == e.creator) return;
  2139. }
  2140. m.enchantments.Add(e);
  2141. if (e.angrbuff >= 1 || e.hpbuff >= 1)
  2142. {
  2143. minionGetBuffed(m, e.angrbuff, e.hpbuff, own);
  2144. }
  2145. if (e.charge) minionGetCharge(m);
  2146. if (e.divineshild) m.divineshild = true;
  2147. if (e.taunt) m.taunt = true;
  2148. if (e.windfury) minionGetWindfurry(m);
  2149. if (e.imune) m.immune = true;
  2150. }
  2151. private void adjacentBuffer(Minion m, string enchantment, int before, int after, bool own)
  2152. {
  2153. List<Minion> lm = new List<Minion>();
  2154. if (own)
  2155. {
  2156. lm.AddRange(this.ownMinions);
  2157. }
  2158. else
  2159. {
  2160. lm.AddRange(this.enemyMinions);
  2161. }
  2162. List<int> exeptions = new List<int>();
  2163. exeptions.Add(before);
  2164. exeptions.Add(after);
  2165. deleteEffectOfWithExceptions(enchantment, m.entitiyID, exeptions);
  2166. Enchantment e = CardDB.getEnchantmentFromCardID(enchantment);
  2167. e.creator = m.entitiyID;
  2168. e.controllerOfCreator = this.ownController;
  2169. if (before >= 0)
  2170. {
  2171. Minion bef = lm[before];
  2172. addEffectToMinionNoDoubles(bef, e, own);
  2173. }
  2174. if (after < lm.Count)
  2175. {
  2176. Minion bef = lm[after];
  2177. addEffectToMinionNoDoubles(bef, e, own);
  2178. }
  2179. }
  2180. private void adjacentBuffUpdate(bool own)
  2181. {
  2182. int before = -1;
  2183. int after = 1;
  2184. List<Minion> lm = new List<Minion>();
  2185. if (own)
  2186. {
  2187. lm.AddRange(this.ownMinions);
  2188. }
  2189. else
  2190. {
  2191. lm.AddRange(this.enemyMinions);
  2192. }
  2193. foreach (Minion m in lm)
  2194. {
  2195. /*
  2196. if (m.name == "direwolfalpha")
  2197. {
  2198. string enchantment = "EX1_162o";
  2199. //help.logg("buffupdate " + m.entitiyID);
  2200. adjacentBuffer(m, enchantment, before, after, own);
  2201. }
  2202. if (m.name == "flametonguetotem")
  2203. {
  2204. string enchantment = "EX1_565o";
  2205. adjacentBuffer(m, enchantment, before, after, own);
  2206. }
  2207. before++;
  2208. after++;
  2209. */
  2210. getNewEffects(m, own, m.id, false);
  2211. }
  2212. }
  2213. private void endEffectsDueToDeath(Minion m, bool own)
  2214. { // minion which grants effect died
  2215. if (m.name == "raidleader") // if he dies, lower attack of all minions of his side
  2216. {
  2217. deleteEffectOf("CS2_122e", m.entitiyID);
  2218. }
  2219. if (m.name == "grimscaleoracle")
  2220. {
  2221. deleteEffectOf("EX1_508o", m.entitiyID);
  2222. }
  2223. if (m.name == "direwolfalpha")
  2224. {
  2225. deleteEffectOf("EX1_162o", m.entitiyID);
  2226. }
  2227. if (m.name == "murlocwarleader")
  2228. {
  2229. deleteEffectOf("EX1_507e", m.entitiyID);
  2230. }
  2231. if (m.name == "southseacaptain")
  2232. {
  2233. deleteEffectOf("NEW1_027e", m.entitiyID);
  2234. }
  2235. if (m.name == "stormwindchampion")
  2236. {
  2237. deleteEffectOf("CS2_222o", m.entitiyID);
  2238. }
  2239. if (m.name == "timberwolf")
  2240. {
  2241. deleteEffectOf("DS1_175o", m.entitiyID);
  2242. }
  2243. if (m.name == "leokk")
  2244. {
  2245. deleteEffectOf("NEW1_033o", m.entitiyID);
  2246. }
  2247. //lowering truebaugederalte
  2248. foreach (Minion mnn in this.ownMinions)
  2249. {
  2250. if (mnn.name == "oldmurk-eye" && m.card.race == 14)
  2251. {
  2252. minionGetBuffed(mnn, -1, 0, true);
  2253. }
  2254. }
  2255. foreach (Minion mnn in this.enemyMinions)
  2256. {
  2257. if (mnn.name == "oldmurk-eye" && m.card.race == 14)
  2258. {
  2259. minionGetBuffed(mnn, -1, 0, false);
  2260. }
  2261. }
  2262. //no deathrattle, but lowering the weapon
  2263. if (m.name == "spitefulsmith" && m.wounded)// remove weapon changes form hasserfuelleschmiedin
  2264. {
  2265. if (own && this.ownWeaponDurability >= 1)
  2266. {
  2267. this.ownWeaponAttack -= 2;
  2268. this.ownheroAngr -= 2;
  2269. }
  2270. if (!own && this.enemyWeaponDurability >= 1) this.enemyWeaponAttack -= 2;
  2271. }
  2272. }
  2273. private void getNewEffects(Minion m, bool own, int placeOfNewMob, bool isSummon)
  2274. {
  2275. bool havekriegshymnenanfuehrerin = false;
  2276. List<Minion> temp = new List<Minion>();
  2277. int controller = 0;
  2278. if (own)
  2279. {
  2280. temp.AddRange(this.ownMinions);
  2281. controller = this.ownController;
  2282. }
  2283. else
  2284. {
  2285. temp.AddRange(this.enemyMinions);
  2286. controller = 0;
  2287. }
  2288. int ownanz = temp.Count;
  2289. if (own && isSummon && this.ownWeaponName == "swordofjustice")
  2290. {
  2291. minionGetBuffed(m, 1, 1, own);
  2292. this.lowerWeaponDurability(1, true);
  2293. }
  2294. int adjacentplace = 1;
  2295. if (isSummon) adjacentplace = 0;
  2296. foreach (Minion ownm in temp)
  2297. {
  2298. if (ownm.silenced) continue; // silenced minions dont buff
  2299. if (isSummon && ownm.name == "warsongcommander")
  2300. {
  2301. havekriegshymnenanfuehrerin = true;
  2302. }
  2303. if (ownm.name == "raidleader" && ownm.entitiyID != m.entitiyID)
  2304. {
  2305. Enchantment e = CardDB.getEnchantmentFromCardID("CS2_122e");
  2306. e.creator = ownm.entitiyID;
  2307. e.controllerOfCreator = controller;
  2308. addEffectToMinionNoDoubles(m, e, own);
  2309. }
  2310. if (ownm.name == "leokk" && ownm.entitiyID != m.entitiyID)
  2311. {
  2312. Enchantment e = CardDB.getEnchantmentFromCardID("NEW1_033o");
  2313. e.creator = ownm.entitiyID;
  2314. e.controllerOfCreator = controller;
  2315. addEffectToMinionNoDoubles(m, e, own);
  2316. }
  2317. if (ownm.name == "stormwindchampion" && ownm.entitiyID != m.entitiyID)
  2318. {
  2319. Enchantment e = CardDB.getEnchantmentFromCardID("CS2_222o");
  2320. e.creator = ownm.entitiyID;
  2321. e.controllerOfCreator = controller;
  2322. addEffectToMinionNoDoubles(m, e, own);
  2323. }
  2324. if (ownm.name == "grimscaleoracle" && m.card.race == 14 && ownm.entitiyID != m.entitiyID)
  2325. {
  2326. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_508o");
  2327. e.creator = ownm.entitiyID;
  2328. e.controllerOfCreator = controller;
  2329. addEffectToMinionNoDoubles(m, e, own);
  2330. }
  2331. if (ownm.name == "murlocwarleader" && m.card.race == 14 && ownm.entitiyID != m.entitiyID)
  2332. {
  2333. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_507e");
  2334. e.creator = ownm.entitiyID;
  2335. e.controllerOfCreator = controller;
  2336. addEffectToMinionNoDoubles(m, e, own);
  2337. }
  2338. if (ownm.name == "southseacaptain" && m.card.race == 23)
  2339. {
  2340. Enchantment e = CardDB.getEnchantmentFromCardID("NEW1_027e");
  2341. e.creator = ownm.entitiyID;
  2342. e.controllerOfCreator = controller;
  2343. addEffectToMinionNoDoubles(m, e, own);
  2344. }
  2345. if (ownm.name == "timberwolf" && (TAG_RACE)m.card.race == TAG_RACE.PET)
  2346. {
  2347. Enchantment e = CardDB.getEnchantmentFromCardID("DS1_175o");
  2348. e.creator = ownm.entitiyID;
  2349. e.controllerOfCreator = controller;
  2350. addEffectToMinionNoDoubles(m, e, own);
  2351. }
  2352. if (isSummon && ownm.name == "tundrarhino" && (TAG_RACE)m.card.race == TAG_RACE.PET)
  2353. {
  2354. minionGetCharge(m);
  2355. }
  2356. if (ownm.name == "direwolfalpha")
  2357. {
  2358. if (ownm.id == placeOfNewMob + 1 || ownm.id == placeOfNewMob - adjacentplace)
  2359. {
  2360. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_162o");
  2361. e.creator = ownm.entitiyID;
  2362. e.controllerOfCreator = controller;
  2363. addEffectToMinionNoDoubles(m, e, own);
  2364. }
  2365. else
  2366. {
  2367. //remove effect!!
  2368. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_162o");
  2369. e.creator = ownm.entitiyID;
  2370. e.controllerOfCreator = controller;
  2371. debuff(m, e);
  2372. }
  2373. }
  2374. if (ownm.name == "flametonguetotem")
  2375. {
  2376. if (ownm.id == placeOfNewMob + 1 || ownm.id == placeOfNewMob - adjacentplace)
  2377. {
  2378. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_565o");
  2379. e.creator = ownm.entitiyID;
  2380. e.controllerOfCreator = controller;
  2381. addEffectToMinionNoDoubles(m, e, own);
  2382. }
  2383. else
  2384. {
  2385. //remove effect!!
  2386. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_565o");
  2387. e.creator = ownm.entitiyID;
  2388. e.controllerOfCreator = controller;
  2389. debuff(m, e);
  2390. }
  2391. }
  2392. }
  2393. //buff oldmurk
  2394. if (isSummon && m.name == "oldmurk-eye" && own)
  2395. {
  2396. int murlocs = 0;
  2397. foreach (Minion mnn in this.ownMinions)
  2398. {
  2399. if (mnn.card.race == 14) murlocs++;
  2400. }
  2401. foreach (Minion mnn in this.enemyMinions)
  2402. {
  2403. if (mnn.card.race == 14) murlocs++;
  2404. }
  2405. minionGetBuffed(m, murlocs, 0, true);
  2406. }
  2407. // minions that gave ALL minions buffs
  2408. temp.Clear();
  2409. if (own)
  2410. {
  2411. temp.AddRange(this.enemyMinions);
  2412. controller = 0;
  2413. }
  2414. else
  2415. {
  2416. temp.AddRange(this.ownMinions);
  2417. controller = this.ownController;
  2418. }
  2419. foreach (Minion ownm in temp) // the enemy grimmschuppenorakel!
  2420. {
  2421. if (ownm.silenced) continue; // silenced minions dont buff
  2422. if (ownm.name == "grimscaleoracle" && m.card.race == 14 && ownm.entitiyID != m.entitiyID)
  2423. {
  2424. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_508o");
  2425. e.creator = ownm.entitiyID;
  2426. e.controllerOfCreator = controller;
  2427. addEffectToMinionNoDoubles(m, e, own);
  2428. }
  2429. if (ownm.name == "murlocwarleader" && m.card.race == 14 && ownm.entitiyID != m.entitiyID)
  2430. {
  2431. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_507e");
  2432. e.creator = ownm.entitiyID;
  2433. e.controllerOfCreator = controller;
  2434. addEffectToMinionNoDoubles(m, e, own);
  2435. }
  2436. }
  2437. if (isSummon && havekriegshymnenanfuehrerin && m.Angr <= 3)
  2438. {
  2439. minionGetCharge(m);
  2440. }
  2441. }
  2442. private void deathrattle(Minion m, bool own)
  2443. {
  2444. if (!m.silenced)
  2445. {
  2446. //real deathrattles
  2447. if (m.card.CardID == "EX1_534")//m.name == "savannenhochmaehne"
  2448. {
  2449. CardDB.Card c = CardDB.Instance.getCardData("hyena");
  2450. callKid(c, m.id - 1, own);
  2451. callKid(c, m.id - 1, own);
  2452. }
  2453. if (m.name == "harvestgolem")
  2454. {
  2455. CardDB.Card c = CardDB.Instance.getCardData("damagedgolem");
  2456. callKid(c, m.id - 1, own);
  2457. }
  2458. if (m.name == "cairnebloodhoof")
  2459. {
  2460. CardDB.Card c = CardDB.Instance.getCardData("bainebloodhoof");
  2461. callKid(c, m.id - 1, own);
  2462. //penaltity for summon this thing :D (so we dont kill it only to have a new minion)
  2463. this.evaluatePenality += 5;
  2464. }
  2465. if (m.name == "thebeast")
  2466. {
  2467. CardDB.Card c = CardDB.Instance.getCardData("finkleeinhorn");
  2468. callKid(c, m.id - 1, own);
  2469. }
  2470. if (m.name == "lepergnome")
  2471. {
  2472. attackOrHealHero(2, !own);
  2473. }
  2474. if (m.name == "loothoarder")
  2475. {
  2476. if (own)
  2477. {
  2478. this.owncarddraw++;
  2479. drawACard("");
  2480. }
  2481. else
  2482. {
  2483. this.enemycarddraw++;
  2484. }
  2485. }
  2486. if (m.name == "bloodmagethalnos")
  2487. {
  2488. if (own)
  2489. {
  2490. this.owncarddraw++;
  2491. drawACard("");
  2492. }
  2493. else
  2494. {
  2495. this.enemycarddraw++;
  2496. }
  2497. }
  2498. if (m.name == "abomination")
  2499. {
  2500. if (logging) help.logg("deathrattle monstrositaet:");
  2501. attackOrHealHero(2, false);
  2502. attackOrHealHero(2, true);
  2503. List<Minion> temp = new List<Minion>(this.ownMinions);
  2504. foreach (Minion mnn in temp)
  2505. {
  2506. minionGetDamagedOrHealed(mnn, 2, 0, true);
  2507. }
  2508. temp.Clear();
  2509. temp.AddRange(this.enemyMinions);
  2510. foreach (Minion mnn in temp)
  2511. {
  2512. minionGetDamagedOrHealed(mnn, 2, 0, false);
  2513. }
  2514. }
  2515. if (m.name == "tirionfordring")
  2516. {
  2517. if (own)
  2518. {
  2519. CardDB.Card c = CardDB.Instance.getCardData("ashbringer");
  2520. this.equipWeapon(c);
  2521. }
  2522. else
  2523. {
  2524. this.enemyWeaponAttack = 5;
  2525. this.enemyWeaponDurability = 3;
  2526. }
  2527. }
  2528. if (m.name == "sylvanaswindrunner")
  2529. {
  2530. List<Minion> temp = new List<Minion>();
  2531. if (own)
  2532. {
  2533. List<Minion> temp2 = new List<Minion>(this.enemyMinions);
  2534. temp2.Sort((a, b) => a.Angr.CompareTo(b.Angr));
  2535. temp.AddRange(Helpfunctions.TakeList(temp2, Math.Min(2, this.enemyMinions.Count)));
  2536. }
  2537. else
  2538. {
  2539. List<Minion> temp2 = new List<Minion>(this.ownMinions);
  2540. temp2.Sort((a, b) => -a.Angr.CompareTo(b.Angr));
  2541. temp.AddRange(temp2);
  2542. }
  2543. if (temp.Count >= 1)
  2544. {
  2545. if (own)
  2546. {
  2547. Minion target = new Minion();
  2548. target = temp[0];
  2549. if (target.taunt && !temp[1].taunt) target = temp[1];
  2550. minionGetControlled(target, true, false);
  2551. }
  2552. else
  2553. {
  2554. Minion target = new Minion();
  2555. target = temp[0];
  2556. foreach (Minion mnn in temp)
  2557. {
  2558. if (mnn.Ready)
  2559. {
  2560. target = mnn;
  2561. break;
  2562. }
  2563. }
  2564. minionGetControlled(target, false, false);
  2565. }
  2566. }
  2567. }
  2568. }
  2569. //deathrattle enchantments // these can be triggered after an silence (if they are casted after the silence)
  2570. bool geistderahnen = false;
  2571. foreach (Enchantment e in m.enchantments)
  2572. {
  2573. if (e.CARDID == "CS2_038e" && !geistderahnen)
  2574. {
  2575. //revive minion due to "geist der ahnen"
  2576. CardDB.Card kid = m.card;
  2577. int pos = this.ownMinions.Count - 1;
  2578. if (!own) pos = this.enemyMinions.Count - 1;
  2579. callKid(kid, pos, own);
  2580. geistderahnen = true;
  2581. }
  2582. //Seele des Waldes
  2583. if (e.CARDID == "EX1_158e")
  2584. {
  2585. //revive minion due to "geist der ahnen"
  2586. CardDB.Card kid = CardDB.Instance.getCardDataFromID("EX1_158t");//Treant
  2587. int pos = this.ownMinions.Count - 1;
  2588. if (!own) pos = this.enemyMinions.Count - 1;
  2589. callKid(kid, pos, own);
  2590. }
  2591. }
  2592. }
  2593. private void triggerAMinionDied(Minion m, bool own)
  2594. {
  2595. List<Minion> temp = new List<Minion>();
  2596. List<Minion> temp2 = new List<Minion>();
  2597. if (own)
  2598. {
  2599. temp.AddRange(this.ownMinions);
  2600. temp2.AddRange(this.enemyMinions);
  2601. }
  2602. else
  2603. {
  2604. temp.AddRange(this.enemyMinions);
  2605. temp2.AddRange(this.ownMinions);
  2606. }
  2607. foreach (Minion mnn in temp)
  2608. {
  2609. if (mnn.silenced) continue;
  2610. if (mnn.name == "scavenginghyena" && m.card.race == 20)
  2611. {
  2612. mnn.Angr += 2; mnn.Hp += 1;
  2613. }
  2614. if (mnn.name == "flesheatingghoul")
  2615. {
  2616. mnn.Angr += 1;
  2617. }
  2618. if (mnn.name == "cultmaster")
  2619. {
  2620. if (own)
  2621. {
  2622. this.owncarddraw++;
  2623. drawACard("");
  2624. }
  2625. else
  2626. {
  2627. this.enemycarddraw++;
  2628. }
  2629. }
  2630. }
  2631. foreach (Minion mnn in temp2)
  2632. {
  2633. if (mnn.silenced) continue;
  2634. if (mnn.name == "flesheatingghoul")
  2635. {
  2636. mnn.Angr += 1;
  2637. }
  2638. }
  2639. }
  2640. private void minionGetDestroyed(Minion m, bool own)
  2641. {
  2642. if (own)
  2643. {
  2644. removeMinionFromList(m, this.ownMinions, true);
  2645. }
  2646. else
  2647. {
  2648. removeMinionFromList(m, this.enemyMinions, false);
  2649. }
  2650. }
  2651. private void minionReturnToHand(Minion m, bool own)
  2652. {
  2653. if (own)
  2654. {
  2655. removeMinionFromListNoDeath(m, this.ownMinions, true);
  2656. drawACard(m.card.name);
  2657. }
  2658. else
  2659. {
  2660. removeMinionFromListNoDeath(m, this.enemyMinions, false);
  2661. }
  2662. }
  2663. private void minionTransform(Minion m, CardDB.Card c, bool own)
  2664. {
  2665. Minion tranform = createNewMinion(c, m.id, own);
  2666. Minion temp = new Minion();
  2667. temp.setMinionTominion(m);
  2668. m.setMinionTominion(tranform);
  2669. m.entitiyID = -2;
  2670. this.endEffectsDueToDeath(temp, own);
  2671. adjacentBuffUpdate(own);
  2672. if (logging) help.logg("minion got sheep" + m.name + " " + m.Angr);
  2673. }
  2674. private void minionGetSilenced(Minion m, bool own)
  2675. {
  2676. //TODO
  2677. m.taunt = false;
  2678. m.stealth = false;
  2679. m.charge = false;
  2680. m.divineshild = false;
  2681. m.poisonous = false;
  2682. //delete enrage (if minion is silenced the first time)
  2683. if (m.wounded && m.card.Enrage && !m.silenced)
  2684. {
  2685. deleteWutanfall(m, own);
  2686. }
  2687. //delete enrage (if minion is silenced the first time)
  2688. if (m.frozen && m.numAttacksThisTurn == 0 && !(m.name == "ancientwatcher" || m.name == "ragnarosthefirelord") && !m.playedThisTurn)
  2689. {
  2690. m.Ready = true;
  2691. }
  2692. m.frozen = false;
  2693. if (!m.silenced && (m.name == "ancientwatcher" || m.name == "ragnarosthefirelord") && !m.playedThisTurn && m.numAttacksThisTurn == 0)
  2694. {
  2695. m.Ready = true;
  2696. }
  2697. endEffectsDueToDeath(m, own);//the minion doesnt die, but its effect is ending
  2698. m.enchantments.Clear();
  2699. m.Angr = m.card.Attack;
  2700. if (m.maxHp < m.card.Health)//minion has lower maxHp as his card -> heal his hp
  2701. {
  2702. m.Hp += m.card.Health - m.maxHp; //heal minion
  2703. }
  2704. m.maxHp = m.card.Health;
  2705. if (m.Hp > m.maxHp) m.Hp = m.maxHp;
  2706. getNewEffects(m, own, m.id, false);// minion get effects of others
  2707. m.silenced = true;
  2708. }
  2709. private void minionGetControlled(Minion m, bool newOwner, bool canAttack)
  2710. {
  2711. List<Minion> newOwnerList = new List<Minion>();
  2712. if (newOwner) { newOwnerList = new List<Minion>(this.ownMinions); }
  2713. else { newOwnerList.AddRange(this.enemyMinions); }
  2714. if (newOwnerList.Count >= 7) return;
  2715. if (newOwner)
  2716. {
  2717. removeMinionFromListNoDeath(m, this.enemyMinions, !newOwner);
  2718. m.Ready = false;
  2719. this.getNewEffects(m, newOwner, newOwnerList.Count, false);
  2720. addMiniontoList(m, this.ownMinions, newOwnerList.Count, newOwner);
  2721. if (m.charge || canAttack)
  2722. {
  2723. m.charge = false;
  2724. minionGetCharge(m);
  2725. }
  2726. }
  2727. else
  2728. {
  2729. removeMinionFromListNoDeath(m, this.ownMinions, !newOwner);
  2730. //m.Ready=false;
  2731. addMiniontoList(m, this.enemyMinions, newOwnerList.Count, newOwner);
  2732. //if (m.charge) minionGetCharge(m);
  2733. }
  2734. }
  2735. private void minionGetWindfurry(Minion m)
  2736. {
  2737. if (m.windfury) return;
  2738. m.windfury = true;
  2739. if (!m.playedThisTurn && m.numAttacksThisTurn <= 1)
  2740. {
  2741. m.Ready = true;
  2742. }
  2743. if (!m.charge && m.numAttacksThisTurn <= 1)
  2744. {
  2745. m.Ready = true;
  2746. }
  2747. }
  2748. private void minionGetCharge(Minion m)
  2749. {
  2750. if (m.charge) return;
  2751. m.charge = true;
  2752. if (m.playedThisTurn && (m.numAttacksThisTurn == 0 || (m.numAttacksThisTurn == 1 && m.windfury)))
  2753. {
  2754. m.Ready = true;
  2755. }
  2756. }
  2757. private void minionGetReady(Minion m) // minion get ready due to attack-buff
  2758. {
  2759. if (!m.silenced && (m.name == "ancientwatcher" || m.name == "ragnarosthefirelord")) return;
  2760. if (!m.playedThisTurn && !m.frozen && (m.numAttacksThisTurn == 0 || (m.numAttacksThisTurn == 1 && m.windfury)))
  2761. {
  2762. m.Ready = true;
  2763. }
  2764. }
  2765. private void minionGetBuffed(Minion m, int attackbuff, int hpbuff, bool own)
  2766. {
  2767. if (m.Angr == 0 && attackbuff >= 1) minionGetReady(m);
  2768. m.Angr = Math.Max(0, m.Angr + attackbuff);
  2769. if (hpbuff >= 1)
  2770. {
  2771. m.Hp = m.Hp + hpbuff;
  2772. m.maxHp = m.maxHp + hpbuff;
  2773. }
  2774. else
  2775. {
  2776. //debuffing hp, lower only maxhp (unless maxhp < hp)
  2777. m.maxHp = m.maxHp + hpbuff;
  2778. if (m.maxHp < m.Hp)
  2779. {
  2780. m.Hp = m.maxHp;
  2781. }
  2782. }
  2783. if (m.maxHp == m.Hp)
  2784. {
  2785. m.wounded = false;
  2786. }
  2787. else
  2788. {
  2789. m.wounded = true;
  2790. }
  2791. if (m.name == "lightspawn" && !m.silenced)
  2792. {
  2793. m.Angr = m.Hp;
  2794. }
  2795. if (m.Hp <= 0)
  2796. {
  2797. if (own)
  2798. {
  2799. this.removeMinionFromList(m, this.ownMinions, true);
  2800. if (logging) help.logg("own " + m.name + " died");
  2801. }
  2802. else
  2803. {
  2804. this.removeMinionFromList(m, this.enemyMinions, false);
  2805. if (logging) help.logg("enemy " + m.name + " died");
  2806. }
  2807. }
  2808. }
  2809. private void deleteWutanfall(Minion m, bool own)
  2810. {
  2811. if (m.name == "angrychicken")
  2812. {
  2813. minionGetBuffed(m, -5, 0, own);
  2814. }
  2815. if (m.name == "amaniberserker")
  2816. {
  2817. minionGetBuffed(m, -3, 0, own);
  2818. }
  2819. if (m.name == "taurenwarrior")
  2820. {
  2821. minionGetBuffed(m, -3, 0, own);
  2822. }
  2823. if (m.name == "grommashhellscream")
  2824. {
  2825. minionGetBuffed(m, -6, 0, own);
  2826. }
  2827. if (m.name == "ragingworgen")
  2828. {
  2829. minionGetBuffed(m, -1, 0, own);
  2830. minionGetWindfurry(m);
  2831. }
  2832. if (m.name == "spitefulsmith")
  2833. {
  2834. if (own && this.ownWeaponDurability >= 1)
  2835. {
  2836. this.ownWeaponAttack -= 2;
  2837. this.ownheroAngr -= 2;
  2838. }
  2839. if (!own && this.enemyWeaponDurability >= 1) this.enemyWeaponAttack -= 2;
  2840. }
  2841. }
  2842. private void wutanfall(Minion m, bool woundedBefore, bool own) // = enrange effects
  2843. {
  2844. if (!m.card.Enrage) return; // if minion has no enrange, do nothing
  2845. if (woundedBefore == m.wounded || m.silenced) return; // if he was wounded, and still is (or was unwounded) do nothing
  2846. if (m.wounded && m.Hp >= 1) //is wounded, wasnt wounded before, grant wutanfall
  2847. {
  2848. if (m.name == "angrychicken")
  2849. {
  2850. minionGetBuffed(m, 5, 0, own);
  2851. }
  2852. if (m.name == "amaniberserker")
  2853. {
  2854. minionGetBuffed(m, 3, 0, own);
  2855. }
  2856. if (m.name == "taurenwarrior")
  2857. {
  2858. minionGetBuffed(m, 3, 0, own);
  2859. }
  2860. if (m.name == "grommashhellscream")
  2861. {
  2862. minionGetBuffed(m, 6, 0, own);
  2863. }
  2864. if (m.name == "ragingworgen")
  2865. {
  2866. minionGetBuffed(m, 1, 0, own);
  2867. minionGetWindfurry(m);
  2868. }
  2869. if (m.name == "spitefulsmith")
  2870. {
  2871. if (own && this.ownWeaponDurability >= 1)
  2872. {
  2873. this.ownWeaponAttack += 2;
  2874. this.ownheroAngr += 2;
  2875. }
  2876. if (!own && this.enemyWeaponDurability >= 1) this.enemyWeaponAttack += 2;
  2877. }
  2878. }
  2879. if (!m.wounded) // reverse buffs
  2880. {
  2881. deleteWutanfall(m, own);
  2882. }
  2883. }
  2884. private void triggerAHeroGetHealed(bool own)
  2885. {
  2886. foreach (Minion mnn in this.ownMinions)
  2887. {
  2888. if (mnn.silenced) continue;
  2889. if (mnn.name == "lightwarden")
  2890. {
  2891. minionGetBuffed(mnn, 2, 0, true);
  2892. }
  2893. }
  2894. foreach (Minion mnn in this.enemyMinions)
  2895. {
  2896. if (mnn.silenced) continue;
  2897. if (mnn.name == "lightwarden")
  2898. {
  2899. minionGetBuffed(mnn, 2, 0, false);
  2900. }
  2901. }
  2902. }
  2903. private void triggerAMinionGetHealed(Minion m, bool own)
  2904. {
  2905. foreach (Minion mnn in this.ownMinions)
  2906. {
  2907. if (mnn.silenced) continue;
  2908. if (mnn.name == "northshirecleric")
  2909. {
  2910. this.owncarddraw++;
  2911. drawACard("");
  2912. }
  2913. if (mnn.name == "lightwarden")
  2914. {
  2915. minionGetBuffed(mnn, 2, 0, true);
  2916. }
  2917. }
  2918. foreach (Minion mnn in this.enemyMinions)
  2919. {
  2920. if (mnn.silenced) continue;
  2921. if (mnn.name == "northshirecleric")
  2922. {
  2923. this.enemycarddraw++;
  2924. }
  2925. if (mnn.name == "lightwarden")
  2926. {
  2927. minionGetBuffed(mnn, 2, 0, false);
  2928. }
  2929. }
  2930. }
  2931. private void triggerAMinionGetDamage(Minion m, bool own)
  2932. {
  2933. //minion take dmg
  2934. if (m.name == "acolyteofpain" && !m.silenced)
  2935. {
  2936. if (own)
  2937. {
  2938. this.owncarddraw++;
  2939. drawACard("");
  2940. }
  2941. else
  2942. {
  2943. this.enemycarddraw++;
  2944. }
  2945. }
  2946. if (m.name == "gurubashiberserker" && !m.silenced)
  2947. {
  2948. minionGetBuffed(m, 3, 0, own);
  2949. }
  2950. foreach (Minion mnn in this.ownMinions)
  2951. {
  2952. if (mnn.silenced) continue;
  2953. if (mnn.name == "frothingberserker")
  2954. {
  2955. mnn.Angr++;
  2956. }
  2957. if (own)
  2958. {
  2959. if (mnn.name == "armorsmith")
  2960. {
  2961. this.ownHeroDefence++;
  2962. }
  2963. }
  2964. }
  2965. foreach (Minion mnn in this.enemyMinions)
  2966. {
  2967. if (mnn.silenced) continue;
  2968. if (mnn.name == "frothingberserker")
  2969. {
  2970. mnn.Angr++;
  2971. }
  2972. if (!own)
  2973. {
  2974. if (mnn.name == "armorsmith")
  2975. {
  2976. this.enemyHeroDefence++;
  2977. }
  2978. }
  2979. }
  2980. }
  2981. private void minionGetDamagedOrHealed(Minion m, int damages, int heals, bool own)
  2982. {
  2983. minionGetDamagedOrHealed(m, damages, heals, own, false);
  2984. }
  2985. private void minionGetDamagedOrHealed(Minion m, int damages, int heals, bool own, bool dontCalcLostDmg)
  2986. {
  2987. int damage = damages;
  2988. int heal = heals;
  2989. bool woundedbefore = m.wounded;
  2990. if (heal < 0) // heal was shifted in damage
  2991. {
  2992. damage = -1 * heal;
  2993. heal = 0;
  2994. }
  2995. if (damage >= 1 && m.divineshild)
  2996. {
  2997. m.divineshild = false;
  2998. if (!own && !dontCalcLostDmg) this.lostDamage += damage * damage;
  2999. return;
  3000. }
  3001. if (m.cantLowerHPbelowONE && damage >= 1 && damage >= m.Hp) damage = m.Hp - 1;
  3002. if (!own && !dontCalcLostDmg && m.Hp < damage) this.lostDamage += (damage - m.Hp) * (damage - m.Hp);
  3003. int hpcopy = m.Hp;
  3004. if (damage >= 1)
  3005. {
  3006. m.Hp = m.Hp - damage;
  3007. }
  3008. if (heal >= 1)
  3009. {
  3010. if (own && !dontCalcLostDmg && heal <= 999 && m.Hp + heal > m.maxHp) this.lostHeal += m.Hp + heal - m.maxHp;
  3011. m.Hp = m.Hp + Math.Min(heal, m.maxHp - m.Hp);
  3012. }
  3013. if (m.Hp > hpcopy)
  3014. {
  3015. //minionWasHealed
  3016. triggerAMinionGetHealed(m, own);
  3017. }
  3018. if (m.Hp < hpcopy)
  3019. {
  3020. triggerAMinionGetDamage(m, own);
  3021. }
  3022. if (m.maxHp == m.Hp)
  3023. {
  3024. m.wounded = false;
  3025. }
  3026. else
  3027. {
  3028. m.wounded = true;
  3029. }
  3030. this.wutanfall(m, woundedbefore, own);
  3031. if (m.name == "lightspawn" && !m.silenced)
  3032. {
  3033. m.Angr = m.Hp;
  3034. }
  3035. if (m.Hp <= 0)
  3036. {
  3037. if (own)
  3038. {
  3039. this.removeMinionFromList(m, this.ownMinions, true);
  3040. if (logging) help.logg("own " + m.name + " died");
  3041. }
  3042. else
  3043. {
  3044. this.removeMinionFromList(m, this.enemyMinions, false);
  3045. if (logging) help.logg("enemy " + m.name + " died");
  3046. }
  3047. }
  3048. }
  3049. private void copyMinion(Minion target, Minion source)
  3050. {
  3051. target.name = source.name;
  3052. target.Angr = source.Angr;
  3053. target.card = CardDB.Instance.getCardDataFromID(source.card.CardID);
  3054. target.charge = source.charge;
  3055. target.divineshild = source.divineshild;
  3056. target.exhausted = source.exhausted;
  3057. target.frozen = source.frozen;
  3058. target.Hp = source.Hp;
  3059. target.immune = source.immune;
  3060. target.maxHp = source.maxHp;
  3061. target.playedThisTurn = source.playedThisTurn;
  3062. target.poisonous = source.poisonous;
  3063. target.silenced = source.silenced;
  3064. target.stealth = source.stealth;
  3065. target.taunt = source.taunt;
  3066. target.windfury = source.windfury;
  3067. target.wounded = source.wounded;
  3068. target.Ready = false;
  3069. if (target.charge) target.Ready = true;
  3070. foreach (Enchantment e in source.enchantments)
  3071. {
  3072. Enchantment ne = CardDB.getEnchantmentFromCardID(e.CARDID);
  3073. target.enchantments.Add(ne);
  3074. }
  3075. }
  3076. private void removeMinionFromListNoDeath(Minion m, List<Minion> l, bool own)
  3077. {
  3078. l.Remove(m);
  3079. int i = 0;
  3080. foreach (Minion mnn in l)
  3081. {
  3082. mnn.id = i;
  3083. mnn.zonepos = i + 1;
  3084. i++;
  3085. }
  3086. this.endEffectsDueToDeath(m, own);
  3087. adjacentBuffUpdate(own);
  3088. }
  3089. private void removeMinionFromList(Minion m, List<Minion> l, bool own)
  3090. {
  3091. l.Remove(m);
  3092. int i = 0;
  3093. foreach (Minion mnn in l)
  3094. {
  3095. mnn.id = i;
  3096. mnn.zonepos = i + 1;
  3097. i++;
  3098. }
  3099. this.endEffectsDueToDeath(m, own);
  3100. this.deathrattle(m, own);
  3101. this.triggerAMinionDied(m, own);
  3102. adjacentBuffUpdate(own);
  3103. }
  3104. private void attack(int attacker, int target, bool dontcount)
  3105. {
  3106. Minion m = new Minion();
  3107. bool attackOwn = true;
  3108. if (attacker < 10)
  3109. {
  3110. m = this.ownMinions[attacker];
  3111. attackOwn = true;
  3112. }
  3113. if (attacker >= 10 && attacker < 20)
  3114. {
  3115. m = this.enemyMinions[attacker - 10];
  3116. attackOwn = false;
  3117. }
  3118. if (!dontcount)
  3119. {
  3120. m.numAttacksThisTurn++;
  3121. if (m.windfury && m.numAttacksThisTurn == 2)
  3122. {
  3123. m.Ready = false;
  3124. }
  3125. if (!m.windfury)
  3126. {
  3127. m.Ready = false;
  3128. }
  3129. }
  3130. if (logging) help.logg(".attck with" + m.name + " A " + m.Angr + " H " + m.Hp);
  3131. if (target == 200)//target is hero
  3132. {
  3133. attackOrHealHero(m.Angr, false);
  3134. return;
  3135. }
  3136. bool enemyOwn = false;
  3137. Minion enemy = new Minion();
  3138. if (target < 10)
  3139. {
  3140. enemy = this.ownMinions[target];
  3141. enemyOwn = true;
  3142. }
  3143. if (target >= 10 && target < 20)
  3144. {
  3145. enemy = this.enemyMinions[target - 10];
  3146. enemyOwn = false;
  3147. }
  3148. int ownAttack = m.Angr;
  3149. int enemyAttack = enemy.Angr;
  3150. // defender take damage
  3151. if (m.card.poisionous)
  3152. {
  3153. minionGetDestroyed(enemy, enemyOwn);
  3154. }
  3155. else
  3156. {
  3157. int oldHP = enemy.Hp;
  3158. minionGetDamagedOrHealed(enemy, ownAttack, 0, enemyOwn);
  3159. if (oldHP > enemy.Hp && m.name == "waterelemental") enemy.frozen = true;
  3160. }
  3161. //attacker take damage
  3162. if (!m.immune)
  3163. {
  3164. if (enemy.card.poisionous)
  3165. {
  3166. minionGetDestroyed(m, attackOwn);
  3167. }
  3168. else
  3169. {
  3170. int oldHP = m.Hp;
  3171. minionGetDamagedOrHealed(m, enemyAttack, 0, attackOwn);
  3172. if (oldHP > m.Hp && enemy.name == "waterelemental") m.frozen = true;
  3173. }
  3174. }
  3175. }
  3176. public void attackWithMinion(Minion ownMinion, int target, int targetEntity, int penality)
  3177. {
  3178. this.evaluatePenality += penality;
  3179. Action a = new Action();
  3180. a.minionplay = true;
  3181. a.owntarget = ownMinion.id;
  3182. a.ownEntitiy = ownMinion.entitiyID;
  3183. a.enemytarget = target;
  3184. a.enemyEntitiy = targetEntity;
  3185. a.numEnemysBeforePlayed = this.enemyMinions.Count;
  3186. a.comboBeforePlayed = (this.cardsPlayedThisTurn >= 1) ? true : false;
  3187. this.playactions.Add(a);
  3188. if (logging) help.logg("attck with" + ownMinion.name + " " + ownMinion.id + " trgt " + target + " A " + ownMinion.Angr + " H " + ownMinion.Hp);
  3189. attack(ownMinion.id, target, false);
  3190. //draw a card if the minion has enchantment from: Segen der weisheit
  3191. int segenderweisheitAnz = 0;
  3192. foreach (Enchantment e in ownMinion.enchantments)
  3193. {
  3194. if (e.CARDID == "EX1_363e2" && e.controllerOfCreator == this.ownController)
  3195. {
  3196. segenderweisheitAnz++;
  3197. }
  3198. }
  3199. this.owncarddraw += segenderweisheitAnz;
  3200. for (int i = 0; i < segenderweisheitAnz; i++)
  3201. {
  3202. drawACard("");
  3203. }
  3204. }
  3205. private void addMiniontoList(Minion m, List<Minion> l, int pos, bool own)
  3206. {
  3207. List<Minion> newmins = new List<Minion>(l);
  3208. l.Clear();
  3209. int i = 0;
  3210. foreach (Minion mnn in newmins)
  3211. {
  3212. if (pos == i)
  3213. {
  3214. m.id = i;
  3215. m.zonepos = i + 1;
  3216. l.Add(m);
  3217. i++;
  3218. }
  3219. mnn.id = i;
  3220. mnn.zonepos = i + 1;
  3221. l.Add(mnn);
  3222. i++;
  3223. }
  3224. // maybe he is last mob
  3225. if (pos == i)
  3226. {
  3227. m.id = i;
  3228. m.zonepos = i + 1;
  3229. l.Add(m);
  3230. i++;
  3231. }
  3232. adjacentBuffUpdate(own);
  3233. triggerPlayedAMinion(m.card, own);
  3234. }
  3235. private Minion createNewMinion(CardDB.Card c, int placeOfNewMob, bool own)
  3236. {
  3237. Minion m = new Minion();
  3238. m.card = c;
  3239. m.entitiyID = c.entityID;
  3240. m.Posix = 0;
  3241. m.Posiy = 0;
  3242. m.Angr = c.Attack;
  3243. m.Hp = c.Health;
  3244. m.maxHp = c.Health;
  3245. m.name = c.name;
  3246. m.playedThisTurn = true;
  3247. m.numAttacksThisTurn = 0;
  3248. m.id = placeOfNewMob;
  3249. m.zonepos = placeOfNewMob + 1;
  3250. if (c.windfury) m.windfury = true;
  3251. if (c.tank) m.taunt = true;
  3252. if (c.Charge)
  3253. {
  3254. m.Ready = true;
  3255. m.charge = true;
  3256. }
  3257. if (c.poisionous) m.poisonous = true;
  3258. if (c.Stealth) m.stealth = true;
  3259. if (m.name == "lightspawn" && !m.silenced)
  3260. {
  3261. m.Angr = m.Hp;
  3262. }
  3263. this.getNewEffects(m, own, placeOfNewMob, true);
  3264. return m;
  3265. }
  3266. private void doBattleCryWithTargeting(Minion c, int target, int choice)
  3267. {
  3268. //target is the target AFTER spawning mobs
  3269. int attackbuff = 0;
  3270. int hpbuff = 0;
  3271. int heal = 0;
  3272. int damage = 0;
  3273. bool spott = false;
  3274. bool divineshild = false;
  3275. bool windfury = false;
  3276. bool silence = false;
  3277. bool destroy = false;
  3278. bool frozen = false;
  3279. bool stealth = false;
  3280. bool backtohand = false;
  3281. bool own = true;
  3282. if (target >= 10 && target < 20)
  3283. {
  3284. own = false;
  3285. }
  3286. Minion m = new Minion();
  3287. if (target < 10)
  3288. {
  3289. m = this.ownMinions[target];
  3290. }
  3291. if (target >= 10 && target < 20)
  3292. {
  3293. m = this.enemyMinions[target - 10];
  3294. }
  3295. if (c.name == "ancientoflore")
  3296. {
  3297. if (choice == 2)
  3298. {
  3299. heal = 5;
  3300. }
  3301. }
  3302. if (c.name == "keeperofthegrove")
  3303. {
  3304. if (choice == 1)
  3305. {
  3306. damage = 2;
  3307. }
  3308. if (choice == 2)
  3309. {
  3310. silence = true;
  3311. }
  3312. }
  3313. if (c.name == "crazedalchemist")
  3314. {
  3315. if (target < 10)
  3316. {
  3317. bool woundedbef = m.wounded;
  3318. int temp = m.Angr;
  3319. m.Angr = m.Hp;
  3320. m.Hp = temp;
  3321. m.maxHp = temp;
  3322. m.wounded = false;
  3323. wutanfall(m, woundedbef, true);
  3324. if (m.Hp <= 0) minionGetDestroyed(m, true);
  3325. }
  3326. if (target >= 10 && target < 20)
  3327. {
  3328. bool woundedbef = m.wounded;
  3329. int temp = m.Angr;
  3330. m.Angr = m.Hp;
  3331. m.Hp = temp;
  3332. m.maxHp = temp;
  3333. m.wounded = false;
  3334. wutanfall(m, woundedbef, false);
  3335. if (m.Hp <= 0) minionGetDestroyed(m, false);
  3336. }
  3337. }
  3338. if (c.name == "si7agent" && this.cardsPlayedThisTurn >= 1)
  3339. {
  3340. damage = 2;
  3341. }
  3342. if (c.name == "kidnapper" && this.cardsPlayedThisTurn >= 1)
  3343. {
  3344. backtohand = true;
  3345. }
  3346. if (c.name == "masterofdisguise")
  3347. {
  3348. stealth = true;
  3349. }
  3350. if (c.name == "cabalshadowpriest")
  3351. {
  3352. minionGetControlled(m, true, false);
  3353. }
  3354. if (c.name == "ironbeakowl" || c.name == "spellbreaker") //eisenschnabeleule, zauberbrecher
  3355. {
  3356. silence = true;
  3357. }
  3358. if (c.name == "shatteredsuncleric")
  3359. {
  3360. attackbuff = 1;
  3361. hpbuff = 1;
  3362. }
  3363. if (c.name == "ancientbrewmaster")
  3364. {
  3365. backtohand = true;
  3366. }
  3367. if (c.name == "youthfulbrewmaster")
  3368. {
  3369. backtohand = true;
  3370. }
  3371. if (c.name == "darkirondwarf")
  3372. {
  3373. //attackbuff = 2;
  3374. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_046e");
  3375. e.creator = c.entitiyID;
  3376. e.controllerOfCreator = this.ownController;
  3377. addEffectToMinionNoDoubles(m, e, own);
  3378. }
  3379. if (c.name == "hungrycrab")
  3380. {
  3381. destroy = true;
  3382. /*Enchantment e = CardDB.getEnchantmentFromCardID("NEW1_017e");
  3383. e.creator = c.entitiyID;
  3384. e.controllerOfCreator = this.ownController;
  3385. addEffectToMinionNoDoubles(c, e, true);//buff own hungrige krabbe*/
  3386. minionGetBuffed(c, 2, 2, true);
  3387. }
  3388. if (c.name == "abusivesergeant")
  3389. {
  3390. Enchantment e = CardDB.getEnchantmentFromCardID("CS2_188o");
  3391. e.creator = c.entitiyID;
  3392. e.controllerOfCreator = this.ownController;
  3393. addEffectToMinionNoDoubles(m, e, own);
  3394. }
  3395. if (c.name == "crueltaskmaster")
  3396. {
  3397. attackbuff = 2;
  3398. damage = 1;
  3399. }
  3400. if (c.name == "frostelemental")
  3401. {
  3402. frozen = true;
  3403. }
  3404. if (c.name == "elvenarcher")
  3405. {
  3406. damage = 1;
  3407. }
  3408. if (c.name == "voodoodoctor")
  3409. {
  3410. heal = 2;
  3411. }
  3412. if (c.name == "templeenforcer")
  3413. {
  3414. hpbuff = 3;
  3415. }
  3416. if (c.name == "ironforgerifleman")
  3417. {
  3418. damage = 1;
  3419. }
  3420. if (c.name == "stormpikecommando")
  3421. {
  3422. damage = 2;
  3423. }
  3424. if (c.name == "houndmaster")
  3425. {
  3426. attackbuff = 2;
  3427. hpbuff = 2;
  3428. spott = true;
  3429. }
  3430. if (c.name == "aldorpeacekeeper")
  3431. {
  3432. attackbuff = 1 - m.Angr;
  3433. }
  3434. if (c.name == "theblackknight")
  3435. {
  3436. destroy = true;
  3437. }
  3438. if (c.name == "argentprotector")
  3439. {
  3440. divineshild = true; // Grants NO buff
  3441. }
  3442. if (c.name == "windspeaker")
  3443. {
  3444. windfury = true;
  3445. }
  3446. if (c.name == "fireelemental")
  3447. {
  3448. damage = 3;
  3449. }
  3450. if (c.name == "earthenringfarseer")
  3451. {
  3452. heal = 3;
  3453. }
  3454. if (c.name == "biggamehunter")
  3455. {
  3456. destroy = true;
  3457. }
  3458. if (c.name == "alexstrasza")
  3459. {
  3460. if (target == 100)
  3461. {
  3462. this.ownHeroHp = 15;
  3463. }
  3464. if (target == 200)
  3465. {
  3466. this.enemyHeroHp = 15;
  3467. }
  3468. }
  3469. if (c.name == "facelessmanipulator")
  3470. {//todo, test this :D
  3471. copyMinion(c, m);
  3472. }
  3473. //make effect on target
  3474. //ownminion
  3475. if (target < 10)
  3476. {
  3477. if (attackbuff != 0 || hpbuff != 0)
  3478. {
  3479. minionGetBuffed(m, attackbuff, hpbuff, true);
  3480. }
  3481. if (damage != 0 || heal != 0)
  3482. {
  3483. minionGetDamagedOrHealed(m, damage, heal, true);
  3484. }
  3485. if (spott) m.taunt = true;
  3486. if (windfury) minionGetWindfurry(m);
  3487. if (divineshild) m.divineshild = true;
  3488. if (destroy) minionGetDestroyed(m, true);
  3489. if (frozen) m.frozen = true;
  3490. if (stealth) m.stealth = true;
  3491. if (backtohand) minionReturnToHand(m, true);
  3492. if (silence) minionGetSilenced(m, true);
  3493. }
  3494. //enemyminion
  3495. if (target >= 10 && target < 20)
  3496. {
  3497. if (attackbuff != 0 || hpbuff != 0)
  3498. {
  3499. minionGetBuffed(m, attackbuff, hpbuff, false);
  3500. }
  3501. if (damage != 0 || heal != 0)
  3502. {
  3503. minionGetDamagedOrHealed(m, damage, heal, false);
  3504. }
  3505. if (spott) m.taunt = true;
  3506. if (windfury) minionGetWindfurry(m);
  3507. if (divineshild) m.divineshild = true;
  3508. if (destroy) minionGetDestroyed(m, false);
  3509. if (frozen) m.frozen = true;
  3510. if (stealth) m.stealth = true;
  3511. if (backtohand) minionReturnToHand(m, false);
  3512. if (silence) minionGetSilenced(m, false);
  3513. }
  3514. if (target == 100)
  3515. {
  3516. if (frozen) this.ownHeroFrozen = true;
  3517. if (damage >= 1) attackOrHealHero(damage, true);
  3518. if (heal >= 1) attackOrHealHero(-heal, true);
  3519. }
  3520. if (target == 200)
  3521. {
  3522. if (frozen) this.enemyHeroFrozen = true;
  3523. if (damage >= 1) attackOrHealHero(damage, false);
  3524. if (heal >= 1) attackOrHealHero(-heal, false);
  3525. }
  3526. }
  3527. private void doBattleCryWithoutTargeting(Minion c, int position, bool own, int choice)
  3528. {
  3529. //only nontargetable battlecrys!
  3530. //druid choices
  3531. //urtum des krieges:
  3532. if (c.name == "ancientofwar")
  3533. {
  3534. if (choice == 1)
  3535. {
  3536. minionGetBuffed(c, 5, 0, true);
  3537. }
  3538. if (choice == 2)
  3539. {
  3540. minionGetBuffed(c, 0, 5, true);
  3541. c.taunt = true;
  3542. }
  3543. }
  3544. if (c.name == "ancientoflore")
  3545. {
  3546. if (choice == 1)
  3547. {
  3548. this.owncarddraw += 2;
  3549. this.drawACard("");
  3550. this.drawACard("");
  3551. }
  3552. }
  3553. if (c.name == "druidoftheclaw")
  3554. {
  3555. if (choice == 1)
  3556. {
  3557. minionGetCharge(c);
  3558. }
  3559. if (choice == 2)
  3560. {
  3561. minionGetBuffed(c, 0, 2, true);
  3562. c.taunt = true;
  3563. }
  3564. }
  3565. if (c.name == "cenarius")
  3566. {
  3567. if (choice == 1)
  3568. {
  3569. foreach (Minion m in this.ownMinions)
  3570. {
  3571. minionGetBuffed(m, 2, 2, true);
  3572. }
  3573. }
  3574. //choice 2 = spawn 2 kids
  3575. }
  3576. //normal ones
  3577. if (c.name == "mindcontroltech")
  3578. {
  3579. if (this.enemyMinions.Count >= 4)
  3580. {
  3581. List<Minion> temp = new List<Minion>();
  3582. List<Minion> temp2 = new List<Minion>(this.enemyMinions);
  3583. temp2.Sort((a, b) => a.Angr.CompareTo(b.Angr));//we take the weekest
  3584. temp.AddRange(Helpfunctions.TakeList(temp2, 2));
  3585. Minion target = new Minion();
  3586. target = temp[0];
  3587. if (target.taunt && !temp[1].taunt) target = temp[1];
  3588. minionGetControlled(target, true, false);
  3589. }
  3590. }
  3591. if (c.name == "felguard")
  3592. {
  3593. this.ownMaxMana--;
  3594. }
  3595. if (c.name == "arcanegolem")
  3596. {
  3597. this.enemyMaxMana++;
  3598. }
  3599. if (c.name == "edwinvancleef" && this.cardsPlayedThisTurn >= 1)
  3600. {
  3601. minionGetBuffed(c, this.cardsPlayedThisTurn * 2, this.cardsPlayedThisTurn * 2, own);
  3602. }
  3603. if (c.name == "doomguard")
  3604. {
  3605. this.owncarddraw -= Math.Min(2, this.owncards.Count);
  3606. this.owncards.RemoveRange(0, Math.Min(2, this.owncards.Count));
  3607. }
  3608. if (c.name == "succubus")
  3609. {
  3610. this.owncarddraw -= Math.Min(1, this.owncards.Count);
  3611. this.owncards.RemoveRange(0, Math.Min(1, this.owncards.Count));
  3612. }
  3613. if (c.name == "lordjaraxxus")
  3614. {
  3615. this.ownHeroAblility = CardDB.Instance.getCardDataFromID("EX1_tk33");
  3616. this.ownHeroName = "lordjaraxxus";
  3617. this.ownHeroHp = c.Hp;
  3618. }
  3619. if (c.name == "flameimp")
  3620. {
  3621. attackOrHealHero(3, own);
  3622. }
  3623. if (c.name == "pitlord")
  3624. {
  3625. attackOrHealHero(5, own);
  3626. }
  3627. if (c.name == "voidterror")
  3628. {
  3629. List<Minion> temp = new List<Minion>();
  3630. if (own)
  3631. {
  3632. temp.AddRange(this.ownMinions);
  3633. }
  3634. else
  3635. {
  3636. temp.AddRange(this.enemyMinions);
  3637. }
  3638. int angr = 0;
  3639. int hp = 0;
  3640. foreach (Minion m in temp)
  3641. {
  3642. if (m.id == position || m.id == position - 1)
  3643. {
  3644. angr += m.Angr;
  3645. hp += m.Hp;
  3646. }
  3647. }
  3648. foreach (Minion m in temp)
  3649. {
  3650. if (m.id == position || m.id == position - 1)
  3651. {
  3652. minionGetDestroyed(m, own);
  3653. }
  3654. }
  3655. minionGetBuffed(c, angr, hp, own);
  3656. }
  3657. if (c.name == "frostwolfwarlord")
  3658. {
  3659. minionGetBuffed(c, this.ownMinions.Count, this.ownMinions.Count, own);
  3660. }
  3661. if (c.name == "bloodsailraider")
  3662. {
  3663. c.Angr += this.ownWeaponAttack;
  3664. }
  3665. if (c.name == "southseadeckhand" && this.ownWeaponDurability >= 1)
  3666. {
  3667. minionGetCharge(c);
  3668. }
  3669. if (c.name == "bloodknight")
  3670. {
  3671. int shilds = 0;
  3672. foreach (Minion m in this.ownMinions)
  3673. {
  3674. if (m.divineshild)
  3675. {
  3676. m.divineshild = false;
  3677. shilds++;
  3678. }
  3679. }
  3680. foreach (Minion m in this.enemyMinions)
  3681. {
  3682. if (m.divineshild)
  3683. {
  3684. m.divineshild = false;
  3685. shilds++;
  3686. }
  3687. }
  3688. minionGetBuffed(c, 3 * shilds, 3 * shilds, own);
  3689. }
  3690. if (c.name == "kingmukla")
  3691. {
  3692. this.enemycarddraw += 2;
  3693. }
  3694. if (c.name == "coldlightoracle")
  3695. {
  3696. this.enemycarddraw += 2;
  3697. this.owncarddraw += 2;
  3698. drawACard("");
  3699. drawACard("");
  3700. }
  3701. if (c.name == "arathiweaponsmith")
  3702. {
  3703. CardDB.Card wcard = CardDB.Instance.getCardData("battleaxe");
  3704. this.equipWeapon(wcard);
  3705. }
  3706. if (c.name == "bloodsailcorsair")
  3707. {
  3708. this.lowerWeaponDurability(1, false);
  3709. }
  3710. if (c.name == "acidicswampooze")
  3711. {
  3712. this.lowerWeaponDurability(1000, false);
  3713. }
  3714. if (c.name == "noviceengineer")
  3715. {
  3716. this.owncarddraw++;
  3717. drawACard("");
  3718. }
  3719. if (c.name == "gnomishinventor")
  3720. {
  3721. this.owncarddraw++;
  3722. drawACard("");
  3723. }
  3724. if (c.name == "darkscalehealer")
  3725. {
  3726. List<Minion> temp = new List<Minion>(this.ownMinions);
  3727. foreach (Minion m in temp)
  3728. {
  3729. minionGetDamagedOrHealed(m, 0, 2, true);
  3730. }
  3731. attackOrHealHero(-2, true);
  3732. }
  3733. if (c.name == "nightblade")
  3734. {
  3735. attackOrHealHero(3, !own);
  3736. }
  3737. if (c.name == "twilightdrake")
  3738. {
  3739. minionGetBuffed(c, 0, this.owncards.Count, true);
  3740. }
  3741. if (c.name == "azuredrake")
  3742. {
  3743. this.owncarddraw++;
  3744. drawACard("");
  3745. }
  3746. if (c.name == "harrisonjones")
  3747. {
  3748. this.enemyWeaponAttack = 0;
  3749. this.owncarddraw += enemyWeaponDurability;
  3750. for (int i = 0; i < enemyWeaponDurability; i++)
  3751. {
  3752. drawACard("");
  3753. }
  3754. this.enemyWeaponDurability = 0;
  3755. }
  3756. if (c.name == "guardianofkings")
  3757. {
  3758. attackOrHealHero(-6, true);
  3759. }
  3760. if (c.name == "captaingreenskin")
  3761. {
  3762. if (this.ownWeaponName != "")
  3763. {
  3764. this.ownheroAngr += 1;
  3765. this.ownWeaponAttack++;
  3766. this.ownWeaponDurability++;
  3767. }
  3768. }
  3769. if (c.name == "priestessofelune")
  3770. {
  3771. attackOrHealHero(-4, true);
  3772. }
  3773. if (c.name == "injuredblademaster")
  3774. {
  3775. minionGetDamagedOrHealed(c, 4, 0, true);
  3776. }
  3777. if (c.name == "dreadinfernal")
  3778. {
  3779. List<Minion> temp = new List<Minion>(this.ownMinions);
  3780. foreach (Minion m in temp)
  3781. {
  3782. minionGetDamagedOrHealed(m, 1, 0, true);
  3783. }
  3784. temp.Clear();
  3785. temp.AddRange(this.enemyMinions);
  3786. foreach (Minion m in temp)
  3787. {
  3788. minionGetDamagedOrHealed(m, 1, 0, false);
  3789. }
  3790. attackOrHealHero(1, false);
  3791. attackOrHealHero(1, true);
  3792. }
  3793. if (c.name == "tundrarhino")
  3794. {
  3795. minionGetCharge(c);
  3796. List<Minion> temp = new List<Minion>(this.ownMinions);
  3797. foreach (Minion m in temp)
  3798. {
  3799. if ((TAG_RACE)m.card.race == TAG_RACE.PET)
  3800. {
  3801. minionGetCharge(m);
  3802. }
  3803. }
  3804. }
  3805. if (c.name == "stampedingkodo")
  3806. {
  3807. List<Minion> temp = new List<Minion>();
  3808. List<Minion> temp2 = new List<Minion>(this.enemyMinions);
  3809. temp2.Sort((a, b) => a.Hp.CompareTo(b.Hp));//destroys the weakest
  3810. temp.AddRange(temp2);
  3811. foreach (Minion enemy in temp)
  3812. {
  3813. if (enemy.Angr <= 2)
  3814. {
  3815. minionGetDestroyed(enemy, false);
  3816. break;
  3817. }
  3818. }
  3819. }
  3820. if (c.name == "sunfuryprotector")
  3821. {
  3822. List<Minion> temp = new List<Minion>(this.ownMinions);
  3823. foreach (Minion m in temp)
  3824. {
  3825. if (m.id == position - 1 || m.id == position)
  3826. {
  3827. m.taunt = true;
  3828. }
  3829. }
  3830. }
  3831. if (c.name == "ancientmage")
  3832. {
  3833. List<Minion> temp = new List<Minion>(this.ownMinions);
  3834. foreach (Minion m in temp)
  3835. {
  3836. if (m.id == position - 1 || m.id == position)
  3837. {
  3838. m.card.spellpowervalue++;
  3839. }
  3840. }
  3841. }
  3842. if (c.name == "defenderofargus")
  3843. {
  3844. List<Minion> temp = new List<Minion>(this.ownMinions);
  3845. foreach (Minion m in temp)
  3846. {
  3847. if (m.id == position - 1 || m.id == position)//position and position -1 because its not placed jet
  3848. {
  3849. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_093e");
  3850. e.creator = c.entitiyID;
  3851. e.controllerOfCreator = this.ownController;
  3852. addEffectToMinionNoDoubles(m, e, own);
  3853. }
  3854. }
  3855. }
  3856. if (c.name == "coldlightseer")
  3857. {
  3858. List<Minion> temp = new List<Minion>(this.ownMinions);
  3859. foreach (Minion m in temp)
  3860. {
  3861. if ((TAG_RACE)m.card.race == TAG_RACE.MURLOC)
  3862. {
  3863. minionGetBuffed(m, 0, 2, true);
  3864. }
  3865. }
  3866. temp.Clear();
  3867. temp.AddRange(this.enemyMinions);
  3868. foreach (Minion m in temp)
  3869. {
  3870. if ((TAG_RACE)m.card.race == TAG_RACE.MURLOC)
  3871. {
  3872. minionGetBuffed(m, 0, 2, false);
  3873. }
  3874. }
  3875. }
  3876. if (c.name == "deathwing")
  3877. {
  3878. List<Minion> temp = new List<Minion>(this.ownMinions);
  3879. foreach (Minion enemy in temp)
  3880. {
  3881. minionGetDestroyed(enemy, true);
  3882. }
  3883. temp.Clear();
  3884. temp.AddRange(this.enemyMinions);
  3885. foreach (Minion enemy in temp)
  3886. {
  3887. minionGetDestroyed(enemy, false);
  3888. }
  3889. this.owncards.Clear();
  3890. }
  3891. if (c.name == "captainsparrot")
  3892. {
  3893. this.owncarddraw++;
  3894. this.drawACard("");
  3895. }
  3896. }
  3897. private int spawnKids(CardDB.Card c, int position, bool own, int choice)
  3898. {
  3899. int kids = 0;
  3900. if (c.name == "murloctidehunter")
  3901. {
  3902. kids = 1;
  3903. CardDB.Card kid = CardDB.Instance.getCardData("murlocscout");
  3904. callKid(kid, position, own);
  3905. }
  3906. if (c.name == "razorfenhunter")
  3907. {
  3908. kids = 1;
  3909. CardDB.Card kid = CardDB.Instance.getCardData("boar");
  3910. callKid(kid, position, own);
  3911. }
  3912. if (c.name == "dragonlingmechanic")
  3913. {
  3914. kids = 1;
  3915. CardDB.Card kid = CardDB.Instance.getCardData("mechanicaldragonling");
  3916. callKid(kid, position, own);
  3917. }
  3918. if (c.name == "leeroyjenkins")
  3919. {
  3920. kids = 2;
  3921. CardDB.Card kid = CardDB.Instance.getCardData("whelp");
  3922. int pos = this.ownMinions.Count - 1;
  3923. if (own) pos = this.enemyMinions.Count - 1;
  3924. callKid(kid, pos, !own);
  3925. callKid(kid, pos, !own);
  3926. }
  3927. if (c.name == "cenarius" && choice == 2)
  3928. {
  3929. kids = 2;
  3930. CardDB.Card kid = CardDB.Instance.getCardDataFromID("EX1_573t"); //special treant
  3931. int pos = this.ownMinions.Count - 1;
  3932. if (!own) pos = this.enemyMinions.Count - 1;
  3933. callKid(kid, pos, own);
  3934. callKid(kid, pos, own);
  3935. }
  3936. if (c.name == "silverhandknight")
  3937. {
  3938. kids = 1;
  3939. CardDB.Card kid = CardDB.Instance.getCardData("squire");
  3940. callKid(kid, position, own);
  3941. }
  3942. if (c.name == "gelbinmekkatorque")
  3943. {
  3944. kids = 1;
  3945. CardDB.Card kid = CardDB.Instance.getCardData("homingchicken");
  3946. callKid(kid, position, own);
  3947. }
  3948. if (c.name == "defiasringleader" && this.cardsPlayedThisTurn >= 1) //needs combo for spawn
  3949. {
  3950. kids = 1;
  3951. CardDB.Card kid = CardDB.Instance.getCardData("defiasbandit");
  3952. callKid(kid, position, own);
  3953. }
  3954. if (c.name == "onyxia")
  3955. {
  3956. kids = 7 - this.ownMinions.Count;
  3957. CardDB.Card kid = CardDB.Instance.getCardData("whelp");
  3958. for (int i = 0; i < kids; i++)
  3959. {
  3960. callKid(kid, position, own);
  3961. }
  3962. }
  3963. return kids;
  3964. }
  3965. private void callKid(CardDB.Card c, int placeoffather, bool own)
  3966. {
  3967. if (own && this.ownMinions.Count >= 7) return;
  3968. if (!own && this.enemyMinions.Count >= 7) return;
  3969. int mobplace = placeoffather + 1;
  3970. /*if (own && this.ownMinions.Count >= 1)
  3971. {
  3972. retval.X = ownMinions[mobplace - 1].Posix + 85;
  3973. retval.Y = ownMinions[mobplace - 1].Posiy;
  3974. }
  3975. if (!own && this.enemyMinions.Count >= 1)
  3976. {
  3977. retval.X = enemyMinions[mobplace - 1].Posix + 85;
  3978. retval.Y = enemyMinions[mobplace - 1].Posiy;
  3979. }*/
  3980. Minion m = createNewMinion(c, mobplace, own);
  3981. if (own)
  3982. {
  3983. addMiniontoList(m, this.ownMinions, mobplace, own);// additional minions span next to it!
  3984. }
  3985. else
  3986. {
  3987. addMiniontoList(m, this.enemyMinions, mobplace, own);// additional minions span next to it!
  3988. }
  3989. }
  3990. private Action placeAmobSomewhere(CardDB.Card c, int cardpos, int target, int choice, int placepos)
  3991. {
  3992. Action a = new Action();
  3993. a.cardplay = true;
  3994. a.card = new CardDB.Card(c);
  3995. a.numEnemysBeforePlayed = this.enemyMinions.Count;
  3996. a.comboBeforePlayed = (this.cardsPlayedThisTurn >= 1) ? true : false;
  3997. //we place him on the right!
  3998. int mobplace = placepos;
  3999. //create the minion out of the card + effects from other minions, which higher his hp/angr
  4000. // but before additional minions span next to it! (because we buff the minion in createNewMinion and swordofjustice gives summeond minons his buff first!
  4001. int spawnkids = spawnKids(c, mobplace - 1, true, choice); // if a mob targets something, it doesnt spawn minions!?
  4002. //create the new minion
  4003. Minion m = createNewMinion(c, mobplace, true);
  4004. //do the battlecry (where you dont need a target)
  4005. doBattleCryWithoutTargeting(m, mobplace, true, choice);
  4006. if (target >= 0)
  4007. {
  4008. doBattleCryWithTargeting(m, target, choice);
  4009. }
  4010. addMiniontoList(m, this.ownMinions, mobplace, true);
  4011. if (logging) help.logg("added " + m.card.name);
  4012. //only for fun :D
  4013. if (target >= 0)
  4014. {
  4015. // the OWNtargets right of the placed mobs are going up :D
  4016. if (target < 10 && target > mobplace + spawnkids) target++;
  4017. }
  4018. a.enemytarget = target;
  4019. a.owntarget = mobplace + 1; //1==before the 1.minion on board , 2 ==before the 2. minion o board (from left)
  4020. return a;
  4021. }
  4022. private void lowerWeaponDurability(int value, bool own)
  4023. {
  4024. if (own)
  4025. {
  4026. this.ownWeaponDurability -= value;
  4027. if (this.ownWeaponDurability <= 0)
  4028. {
  4029. this.ownheroAngr -= this.ownWeaponAttack;
  4030. this.ownWeaponDurability = 0;
  4031. this.ownWeaponAttack = 0;
  4032. this.ownWeaponName = "";
  4033. }
  4034. }
  4035. else
  4036. {
  4037. this.enemyWeaponDurability -= value;
  4038. if (this.enemyWeaponDurability <= 0)
  4039. {
  4040. this.enemyWeaponDurability = 0;
  4041. this.enemyWeaponAttack = 0;
  4042. }
  4043. }
  4044. }
  4045. private void equipWeapon(CardDB.Card c)
  4046. {
  4047. if (this.ownWeaponDurability >= 1) this.lostWeaponDamage += this.ownWeaponDurability * this.ownWeaponAttack;
  4048. this.ownheroAngr = c.Attack;
  4049. this.ownWeaponAttack = c.Attack;
  4050. this.ownWeaponDurability = c.Durability;
  4051. if (c.name == "doomhammer")
  4052. {
  4053. this.ownHeroWindfury = true;
  4054. }
  4055. else
  4056. {
  4057. this.ownHeroWindfury = false;
  4058. }
  4059. if ((this.ownHeroNumAttackThisTurn == 0 || (this.ownHeroWindfury && this.ownHeroNumAttackThisTurn == 1)) && !this.ownHeroFrozen)
  4060. {
  4061. this.ownHeroReady = true;
  4062. }
  4063. if (c.name == "gladiatorslongbow")
  4064. {
  4065. this.heroImmuneWhileAttacking = true;
  4066. }
  4067. else
  4068. {
  4069. this.heroImmuneWhileAttacking = false;
  4070. }
  4071. foreach (Minion m in this.ownMinions)
  4072. {
  4073. if (m.name == "southseadeckhand")
  4074. {
  4075. minionGetCharge(m);
  4076. }
  4077. }
  4078. }
  4079. private void playCardWithTarget(CardDB.Card c, int target, int choice)
  4080. {
  4081. //play card with target
  4082. int attackbuff = 0;
  4083. int hpbuff = 0;
  4084. int heal = 0;
  4085. int damage = 0;
  4086. bool spott = false;
  4087. bool divineshild = false;
  4088. bool windfury = false;
  4089. bool silence = false;
  4090. bool destroy = false;
  4091. bool frozen = false;
  4092. bool stealth = false;
  4093. bool backtohand = false;
  4094. bool charge = false;
  4095. bool setHPtoONE = false;
  4096. bool immune = false;
  4097. int adjacentDamage = 0;
  4098. bool sheep = false;
  4099. bool frogg = false;
  4100. //special
  4101. bool geistderahnen = false;
  4102. bool ueberwaeltigendemacht = false;
  4103. bool own = true;
  4104. if (target >= 10 && target < 20)
  4105. {
  4106. own = false;
  4107. }
  4108. Minion m = new Minion();
  4109. if (target < 10)
  4110. {
  4111. m = this.ownMinions[target];
  4112. }
  4113. if (target >= 10 && target < 20)
  4114. {
  4115. m = this.enemyMinions[target - 10];
  4116. }
  4117. //warrior###########################################################################
  4118. if (c.name == "execute")
  4119. {
  4120. destroy = true;
  4121. }
  4122. if (c.name == "innerrage")
  4123. {
  4124. damage = 1;
  4125. attackbuff = 2;
  4126. }
  4127. if (c.name == "slam")
  4128. {
  4129. damage = 2;
  4130. if (m.Hp >= 3)
  4131. {
  4132. this.owncarddraw++;
  4133. this.drawACard("");
  4134. }
  4135. }
  4136. if (c.name == "mortalstrike")
  4137. {
  4138. damage = 4;
  4139. if (ownHeroHp <= 12) damage = 6;
  4140. }
  4141. if (c.name == "shieldslam")
  4142. {
  4143. damage = this.ownHeroDefence;
  4144. }
  4145. if (c.name == "charge")
  4146. {
  4147. charge = true;
  4148. attackbuff = 2;
  4149. }
  4150. if (c.name == "rampage")
  4151. {
  4152. attackbuff = 3;
  4153. hpbuff = 3;
  4154. }
  4155. //hunter#################################################################################
  4156. if (c.name == "huntersmark")
  4157. {
  4158. setHPtoONE = true;
  4159. }
  4160. if (c.name == "arcaneshot")
  4161. {
  4162. damage = 2;
  4163. }
  4164. if (c.name == "killcommand")
  4165. {
  4166. damage = 3;
  4167. foreach (Minion mnn in this.ownMinions)
  4168. {
  4169. if ((TAG_RACE)mnn.card.race == TAG_RACE.PET)
  4170. {
  4171. damage = 5;
  4172. }
  4173. }
  4174. }
  4175. if (c.name == "bestialwrath")
  4176. {
  4177. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_549o");
  4178. e.creator = c.entityID;
  4179. e.controllerOfCreator = this.ownController;
  4180. addEffectToMinionNoDoubles(m, e, own);
  4181. }
  4182. if (c.name == "explosiveshot")
  4183. {
  4184. damage = 5;
  4185. adjacentDamage = 1;
  4186. }
  4187. //mage###############################################################################
  4188. if (c.name == "icelance")
  4189. {
  4190. if (target >= 0 && target <= 19)
  4191. {
  4192. if (m.frozen)
  4193. {
  4194. damage = 4;
  4195. }
  4196. else { frozen = true; }
  4197. }
  4198. else
  4199. {
  4200. if (target == 100)
  4201. {
  4202. if (this.ownHeroFrozen)
  4203. {
  4204. damage = 4;
  4205. }
  4206. else
  4207. {
  4208. frozen = true;
  4209. }
  4210. }
  4211. if (target == 200)
  4212. {
  4213. if (this.enemyHeroFrozen)
  4214. {
  4215. damage = 4;
  4216. }
  4217. else
  4218. {
  4219. frozen = true;
  4220. }
  4221. }
  4222. }
  4223. }
  4224. if (c.name == "coneofcold")
  4225. {
  4226. damage = 1;
  4227. adjacentDamage = 1;
  4228. frozen = true;
  4229. }
  4230. if (c.name == "fireball")
  4231. {
  4232. damage = 6;
  4233. }
  4234. if (c.name == "polymorph")
  4235. {
  4236. sheep = true;
  4237. }
  4238. if (c.name == "pyroblast")
  4239. {
  4240. damage = 10;
  4241. }
  4242. if (c.name == "frostbolt")
  4243. {
  4244. damage = 3;
  4245. frozen = true;
  4246. }
  4247. //pala######################################################################
  4248. if (c.name == "humility")
  4249. {
  4250. m.Angr = 1;
  4251. }
  4252. if (c.name == "handofprotection")
  4253. {
  4254. divineshild = true;
  4255. }
  4256. if (c.name == "blessingofmight")
  4257. {
  4258. attackbuff = 3;
  4259. }
  4260. if (c.name == "holylight")
  4261. {
  4262. heal = 6;
  4263. }
  4264. if (c.name == "hammerofwrath")
  4265. {
  4266. damage = 3;
  4267. this.owncarddraw++;
  4268. drawACard("");
  4269. }
  4270. if (c.name == "blessingofkings")
  4271. {
  4272. attackbuff = 4;
  4273. hpbuff = 4;
  4274. }
  4275. if (c.name == "blessingofwisdom")
  4276. {
  4277. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_363e2");
  4278. e.creator = c.entityID;
  4279. e.controllerOfCreator = this.ownController;
  4280. m.enchantments.Add(e);
  4281. }
  4282. if (c.name == "blessedchampion")
  4283. {
  4284. m.Angr *= 2;
  4285. }
  4286. if (c.name == "holywrath")
  4287. {
  4288. damage = 2;
  4289. this.owncarddraw++;
  4290. drawACard("");
  4291. }
  4292. if (c.name == "layonhands")
  4293. {
  4294. for (int i = 0; i < 3; i++)
  4295. {
  4296. this.owncarddraw++;
  4297. this.drawACard("");
  4298. }
  4299. heal = 8;
  4300. }
  4301. //priest ##########################################
  4302. if (c.name == "shadowmadness")
  4303. {
  4304. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_334e");
  4305. e.creator = c.entityID;
  4306. e.controllerOfCreator = this.ownController;
  4307. addEffectToMinionNoDoubles(m, e, own);
  4308. this.minionGetControlled(m, true, true);
  4309. }
  4310. if (c.name == "mindcontrol")
  4311. {
  4312. this.minionGetControlled(m, true, false);
  4313. }
  4314. if (c.name == "holysmite")
  4315. {
  4316. damage = 2;
  4317. }
  4318. if (c.name == "powerwordshield")
  4319. {
  4320. hpbuff = 2;
  4321. this.owncarddraw++;
  4322. this.drawACard("");
  4323. }
  4324. if (c.name == "silence")
  4325. {
  4326. silence = true;
  4327. }
  4328. if (c.name == "divinespirit")
  4329. {
  4330. hpbuff = m.Hp;
  4331. }
  4332. if (c.name == "innerfire")
  4333. {
  4334. m.Angr = m.Hp;
  4335. }
  4336. if (c.name == "holyfire")
  4337. {
  4338. damage = 5;
  4339. int ownheal = getSpellHeal(5);
  4340. attackOrHealHero(-ownheal, true);
  4341. }
  4342. if (c.name == "shadowwordpain")
  4343. {
  4344. destroy = true;
  4345. }
  4346. if (c.name == "shadowworddeath")
  4347. {
  4348. destroy = true;
  4349. }
  4350. //rogue ##########################################
  4351. if (c.name == "shadowstep")
  4352. {
  4353. backtohand = true;
  4354. m.card.cost = Math.Max(0, m.card.cost -= 2);
  4355. }
  4356. if (c.name == "sap")
  4357. {
  4358. backtohand = true;
  4359. }
  4360. if (c.name == "shiv")
  4361. {
  4362. damage = 1;
  4363. this.owncarddraw++;
  4364. this.drawACard("");
  4365. }
  4366. if (c.name == "coldblood")
  4367. {
  4368. attackbuff = 2;
  4369. if (this.cardsPlayedThisTurn >= 1) attackbuff = 4;
  4370. }
  4371. if (c.name == "conceal")
  4372. {
  4373. stealth = true;
  4374. }
  4375. if (c.name == "eviscerate")
  4376. {
  4377. damage = 2;
  4378. if (this.cardsPlayedThisTurn >= 1) damage = 4;
  4379. }
  4380. if (c.name == "betrayal")
  4381. {
  4382. //attack right neightbor
  4383. if (target >= 10 && target < 20 && target < this.enemyMinions.Count + 10 - 1)
  4384. {
  4385. attack(target, target + 1, true);
  4386. }
  4387. if (target < 10 && target < this.ownMinions.Count - 1)
  4388. {
  4389. attack(target, target + 1, true);
  4390. }
  4391. //attack left neightbor
  4392. if (target >= 11 || (target < 10 && target >= 1))
  4393. {
  4394. attack(target, target - 1, true);
  4395. }
  4396. }
  4397. if (c.name == "perditionsblade")
  4398. {
  4399. damage = 1;
  4400. if (this.cardsPlayedThisTurn >= 1) damage = 2;
  4401. }
  4402. if (c.name == "backstab")
  4403. {
  4404. damage = 2;
  4405. }
  4406. if (c.name == "assassinate")
  4407. {
  4408. destroy = true;
  4409. }
  4410. //shaman ##########################################
  4411. if (c.name == "lightningbolt")
  4412. {
  4413. damage = 3;
  4414. }
  4415. if (c.name == "frostshock")
  4416. {
  4417. frozen = true;
  4418. damage = 1;
  4419. }
  4420. if (c.name == "rockbiterweapon")
  4421. {
  4422. if (target <= 20)
  4423. {
  4424. Enchantment e = CardDB.getEnchantmentFromCardID("CS2_045e");
  4425. e.creator = c.entityID;
  4426. e.controllerOfCreator = this.ownController;
  4427. addEffectToMinionNoDoubles(m, e, own);
  4428. }
  4429. else
  4430. {
  4431. if (target == 100)
  4432. {
  4433. this.ownheroAngr += 3;
  4434. if ((this.ownHeroNumAttackThisTurn == 0 || (this.ownHeroWindfury && this.ownHeroNumAttackThisTurn == 1)) && !this.ownHeroFrozen)
  4435. {
  4436. this.ownHeroReady = true;
  4437. }
  4438. }
  4439. }
  4440. }
  4441. if (c.name == "windfury")
  4442. {
  4443. windfury = true;
  4444. }
  4445. if (c.name == "hex")
  4446. {
  4447. frogg = true;
  4448. }
  4449. if (c.name == "earthshock")
  4450. {
  4451. silence = true;
  4452. damage = 1;
  4453. }
  4454. if (c.name == "ancestralspirit")
  4455. {
  4456. geistderahnen = true;
  4457. }
  4458. if (c.name == "lavaburst")
  4459. {
  4460. damage = 5;
  4461. }
  4462. if (c.name == "ancestralhealing")
  4463. {
  4464. heal = 1000;
  4465. spott = true;
  4466. }
  4467. //hexenmeister ##########################################
  4468. if (c.name == "sacrificialpact")
  4469. {
  4470. destroy = true;
  4471. this.attackOrHealHero(getSpellHeal(5), true); // heal own hero
  4472. }
  4473. if (c.name == "soulfire")
  4474. {
  4475. damage = 4;
  4476. this.owncarddraw--;
  4477. this.owncards.RemoveRange(0, Math.Min(1, this.owncards.Count));
  4478. }
  4479. if (c.name == "poweroverwhelming")
  4480. {
  4481. //only to own mininos
  4482. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_316e");
  4483. e.creator = c.entityID;
  4484. e.controllerOfCreator = this.ownController;
  4485. addEffectToMinionNoDoubles(m, e, true);
  4486. }
  4487. if (c.name == "corruption")
  4488. {
  4489. //only to enemy mininos
  4490. Enchantment e = CardDB.getEnchantmentFromCardID("CS2_063e");
  4491. e.creator = c.entityID;
  4492. e.controllerOfCreator = this.ownController;
  4493. addEffectToMinionNoDoubles(m, e, false);
  4494. }
  4495. if (c.name == "mortalcoil")
  4496. {
  4497. damage = 1;
  4498. if (getSpellDamageDamage(1) >= m.Hp && !m.divineshild && !m.immune)
  4499. {
  4500. this.owncarddraw++;
  4501. this.drawACard("");
  4502. }
  4503. }
  4504. if (c.name == "drainlife")
  4505. {
  4506. damage = 2;
  4507. attackOrHealHero(2, true);
  4508. }
  4509. if (c.name == "shadowbolt")
  4510. {
  4511. damage = 4;
  4512. }
  4513. if (c.name == "shadowflame")
  4514. {
  4515. int damage1 = getSpellDamageDamage(m.Angr);
  4516. List<Minion> temp = new List<Minion>(this.enemyMinions);
  4517. foreach (Minion mnn in temp)
  4518. {
  4519. minionGetDamagedOrHealed(mnn, damage1, 0, false);
  4520. }
  4521. //destroy own mininon
  4522. destroy = true;
  4523. }
  4524. if (c.name == "demonfire")
  4525. {
  4526. if (m.card.race == 15 && own)
  4527. {
  4528. attackbuff = 2;
  4529. hpbuff = 2;
  4530. }
  4531. else
  4532. {
  4533. damage = 2;
  4534. }
  4535. }
  4536. if (c.name == "baneofdoom")
  4537. {
  4538. damage = 2;
  4539. if (getSpellDamageDamage(2) >= m.Hp && !m.divineshild && !m.immune)
  4540. {
  4541. int posi = this.ownMinions.Count - 1;
  4542. CardDB.Card kid = CardDB.Instance.getCardData("bloodimp");
  4543. callKid(kid, posi, true);
  4544. }
  4545. }
  4546. if (c.name == "siphonsoul")
  4547. {
  4548. destroy = true;
  4549. attackOrHealHero(3, true);
  4550. }
  4551. //druid #######################################################################
  4552. if (c.name == "moonfire" && c.CardID == "CS2_008")// nicht zu verwechseln mit cenarius choice nummer 1
  4553. {
  4554. damage = 1;
  4555. }
  4556. if (c.name == "markofthewild")
  4557. {
  4558. spott = true;
  4559. attackbuff = 2;
  4560. hpbuff = 2;
  4561. }
  4562. if (c.name == "healingtouch")
  4563. {
  4564. heal = 8;
  4565. }
  4566. if (c.name == "starfire")
  4567. {
  4568. damage = 5;
  4569. this.owncarddraw++;
  4570. this.drawACard("");
  4571. }
  4572. if (c.name == "naturalize")
  4573. {
  4574. destroy = true;
  4575. this.enemycarddraw += 2;
  4576. }
  4577. if (c.name == "savagery")
  4578. {
  4579. damage = this.ownheroAngr;
  4580. }
  4581. if (c.name == "swipe")
  4582. {
  4583. damage = 4;
  4584. // all others get 1 spelldamage
  4585. int damage1 = getSpellDamageDamage(1);
  4586. if (target != 200)
  4587. {
  4588. attackOrHealHero(damage1, false);
  4589. }
  4590. List<Minion> temp = new List<Minion>(this.enemyMinions);
  4591. foreach (Minion mnn in temp)
  4592. {
  4593. if (mnn.id + 10 != target)
  4594. {
  4595. minionGetDamagedOrHealed(mnn, damage1, 0, false);
  4596. }
  4597. }
  4598. }
  4599. //druid choices##################################################################################
  4600. if (c.name == "wrath")
  4601. {
  4602. if (choice == 1)
  4603. {
  4604. damage = 3;
  4605. }
  4606. if (choice == 2)
  4607. {
  4608. damage = 1;
  4609. this.owncarddraw++;
  4610. this.drawACard("");
  4611. }
  4612. }
  4613. if (c.name == "markofnature")
  4614. {
  4615. if (choice == 1)
  4616. {
  4617. attackbuff = 4;
  4618. }
  4619. if (choice == 2)
  4620. {
  4621. spott = true;
  4622. hpbuff = 4;
  4623. }
  4624. }
  4625. if (c.name == "starfall")
  4626. {
  4627. if (choice == 1)
  4628. {
  4629. damage = 5;
  4630. }
  4631. }
  4632. //special cards#########################################################################################
  4633. if (c.name == "nightmare")
  4634. {
  4635. //only to own mininos
  4636. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_316e");
  4637. e.creator = c.entityID;
  4638. e.controllerOfCreator = this.ownController;
  4639. addEffectToMinionNoDoubles(m, e, true);
  4640. }
  4641. if (c.name == "dream")
  4642. {
  4643. backtohand = true;
  4644. }
  4645. if (c.name == "bananas")
  4646. {
  4647. attackbuff = 1;
  4648. hpbuff = 1;
  4649. }
  4650. if (c.name == "barreltoss")
  4651. {
  4652. damage = 2;
  4653. }
  4654. if (c.CardID == "PRO_001b")// i am murloc
  4655. {
  4656. damage = 4;
  4657. this.owncarddraw++;
  4658. this.drawACard("");
  4659. } if (c.name == "willofmukla")
  4660. {
  4661. heal = 6;
  4662. }
  4663. //make effect on target
  4664. //ownminion
  4665. if (damage >= 1) damage = getSpellDamageDamage(damage);
  4666. if (adjacentDamage >= 1) adjacentDamage = getSpellDamageDamage(adjacentDamage);
  4667. if (heal >= 1 && heal < 1000) heal = getSpellHeal(heal);
  4668. if (target < 10)
  4669. {
  4670. if (silence) minionGetSilenced(m, true);
  4671. minionGetBuffed(m, attackbuff, hpbuff, true);
  4672. minionGetDamagedOrHealed(m, damage, heal, true);
  4673. if (spott) m.taunt = true;
  4674. if (charge) minionGetCharge(m);
  4675. if (windfury) minionGetWindfurry(m);
  4676. if (divineshild) m.divineshild = true;
  4677. if (destroy) minionGetDestroyed(m, true);
  4678. if (frozen) m.frozen = true;
  4679. if (stealth) m.stealth = true;
  4680. if (backtohand) minionReturnToHand(m, true);
  4681. if (immune) m.immune = true;
  4682. if (adjacentDamage >= 1)
  4683. {
  4684. List<Minion> tempolist = new List<Minion>(this.ownMinions);
  4685. foreach (Minion mnn in tempolist)
  4686. {
  4687. if (mnn.id == target + 1 || mnn.id == target - 1)
  4688. {
  4689. minionGetDamagedOrHealed(m, adjacentDamage, 0, own);
  4690. if (frozen) mnn.frozen = true;
  4691. }
  4692. }
  4693. }
  4694. if (sheep) minionTransform(m, CardDB.Instance.getCardDataFromID("CS2_tk1"), own);
  4695. if (frogg) minionTransform(m, CardDB.Instance.getCardDataFromID("hexfrog"), own);
  4696. if (setHPtoONE)
  4697. {
  4698. m.Hp = 1; m.maxHp = 1;
  4699. }
  4700. if (geistderahnen)
  4701. {
  4702. Enchantment e = CardDB.getEnchantmentFromCardID("CS2_038e");
  4703. e.creator = c.entityID;
  4704. e.controllerOfCreator = this.ownController;
  4705. addEffectToMinionNoDoubles(m, e, true);
  4706. }
  4707. }
  4708. //enemyminion
  4709. if (target >= 10 && target < 20)
  4710. {
  4711. if (silence) minionGetSilenced(m, false);
  4712. minionGetBuffed(m, attackbuff, hpbuff, false);
  4713. minionGetDamagedOrHealed(m, damage, heal, false);
  4714. if (spott) m.taunt = true;
  4715. if (charge) minionGetCharge(m);
  4716. if (windfury) minionGetWindfurry(m);
  4717. if (divineshild) m.divineshild = true;
  4718. if (destroy) minionGetDestroyed(m, false);
  4719. if (frozen) m.frozen = true;
  4720. if (stealth) m.stealth = true;
  4721. if (backtohand) minionReturnToHand(m, false);
  4722. if (immune) m.immune = true;
  4723. if (adjacentDamage >= 1)
  4724. {
  4725. List<Minion> tempolist = new List<Minion>(this.enemyMinions);
  4726. foreach (Minion mnn in tempolist)
  4727. {
  4728. if (mnn.id + 10 == target + 1 || mnn.id + 10 == target - 1)
  4729. {
  4730. minionGetDamagedOrHealed(m, adjacentDamage, 0, own);
  4731. if (frozen) mnn.frozen = true;
  4732. }
  4733. }
  4734. }
  4735. if (sheep) minionTransform(m, CardDB.Instance.getCardDataFromID("CS2_tk1"), own);
  4736. if (frogg) minionTransform(m, CardDB.Instance.getCardDataFromID("hexfrog"), own);
  4737. if (setHPtoONE)
  4738. {
  4739. m.Hp = 1; m.maxHp = 1;
  4740. }
  4741. if (geistderahnen)
  4742. {
  4743. Enchantment e = CardDB.getEnchantmentFromCardID("CS2_038e");
  4744. e.creator = c.entityID;
  4745. e.controllerOfCreator = this.ownController;
  4746. addEffectToMinionNoDoubles(m, e, false);
  4747. }
  4748. }
  4749. if (target == 100)
  4750. {
  4751. if (frozen) this.ownHeroFrozen = true;
  4752. if (damage >= 1) attackOrHealHero(damage, true);
  4753. if (heal >= 1) attackOrHealHero(-heal, true);
  4754. }
  4755. if (target == 200)
  4756. {
  4757. if (frozen) this.enemyHeroFrozen = true;
  4758. if (damage >= 1) attackOrHealHero(damage, false);
  4759. if (heal >= 1) attackOrHealHero(-heal, false);
  4760. }
  4761. }
  4762. private void playCardWithoutTarget(CardDB.Card c, int choice)
  4763. {
  4764. //todo faehrtenlesen!
  4765. //play card without target
  4766. if (c.name == "thecoin")
  4767. {
  4768. this.mana++;
  4769. }
  4770. //hunter#########################################################################
  4771. if (c.name == "multi-shot" && this.enemyMinions.Count >= 2)
  4772. {
  4773. List<Minion> temp = new List<Minion>();
  4774. int damage = getSpellDamageDamage(3);
  4775. List<Minion> temp2 = new List<Minion>(this.enemyMinions);
  4776. temp2.Sort((a, b) => -a.Hp.CompareTo(b.Hp));//damage the strongest
  4777. temp.AddRange(Helpfunctions.TakeList(temp2, 2));
  4778. foreach (Minion enemy in temp)
  4779. {
  4780. minionGetDamagedOrHealed(enemy, damage, 0, false);
  4781. }
  4782. }
  4783. if (c.name == "animalcompanion")
  4784. {
  4785. CardDB.Card c2 = CardDB.Instance.getCardData("misha");
  4786. int placeoffather = this.ownMinions.Count - 1;
  4787. callKid(c2, placeoffather, true);
  4788. }
  4789. if (c.name == "flare")
  4790. {
  4791. foreach (Minion m in this.ownMinions)
  4792. {
  4793. m.stealth = false;
  4794. }
  4795. foreach (Minion m in this.enemyMinions)
  4796. {
  4797. m.stealth = false;
  4798. }
  4799. this.owncarddraw++;
  4800. this.drawACard("");
  4801. this.enemySecretCount = 0;
  4802. }
  4803. if (c.name == "unleashthehounds")
  4804. {
  4805. int anz = this.enemyMinions.Count;
  4806. int posi = this.ownMinions.Count - 1;
  4807. CardDB.Card kid = CardDB.Instance.getCardData("hound");
  4808. for (int i = 0; i < anz; i++)
  4809. {
  4810. callKid(kid, posi, true);
  4811. }
  4812. }
  4813. if (c.name == "deadlyshot" && this.enemyMinions.Count >= 1)
  4814. {
  4815. List<Minion> temp = new List<Minion>();
  4816. List<Minion> temp2 = new List<Minion>(this.enemyMinions);
  4817. temp2.Sort((a, b) => a.Hp.CompareTo(b.Hp));
  4818. temp.AddRange(Helpfunctions.TakeList(temp2, 1));
  4819. foreach (Minion enemy in temp)
  4820. {
  4821. minionGetDestroyed(enemy, false);
  4822. }
  4823. }
  4824. //warrior#########################################################################
  4825. if (c.name == "commandingshout")
  4826. {
  4827. List<Minion> temp = new List<Minion>(this.ownMinions);
  4828. Enchantment e1 = CardDB.getEnchantmentFromCardID("NEW1_036e");
  4829. e1.creator = c.entityID;
  4830. e1.controllerOfCreator = this.ownController;
  4831. Enchantment e2 = CardDB.getEnchantmentFromCardID("NEW1_036e2");
  4832. e2.creator = c.entityID;
  4833. e2.controllerOfCreator = this.ownController;
  4834. foreach (Minion mnn in temp)
  4835. {//cantLowerHPbelowONE
  4836. addEffectToMinionNoDoubles(mnn, e1, true);
  4837. addEffectToMinionNoDoubles(mnn, e2, true);
  4838. mnn.cantLowerHPbelowONE = true;
  4839. }
  4840. }
  4841. if (c.name == "battlerage")
  4842. {
  4843. foreach (Minion mnn in this.ownMinions)
  4844. {
  4845. if (mnn.wounded)
  4846. {
  4847. this.owncarddraw++;
  4848. this.drawACard("");
  4849. }
  4850. }
  4851. }
  4852. if (c.name == "brawl")
  4853. {
  4854. List<Minion> temp = new List<Minion>(this.ownMinions);
  4855. foreach (Minion mnn in temp)
  4856. {
  4857. minionGetDestroyed(mnn, true);
  4858. }
  4859. temp.Clear();
  4860. temp.AddRange(this.enemyMinions);
  4861. foreach (Minion mnn in temp)
  4862. {
  4863. minionGetDestroyed(mnn, false);
  4864. }
  4865. }
  4866. if (c.name == "cleave" && this.enemyMinions.Count >= 2)
  4867. {
  4868. List<Minion> temp = new List<Minion>();
  4869. int damage = getSpellDamageDamage(2);
  4870. List<Minion> temp2 = new List<Minion>(this.enemyMinions);
  4871. temp2.Sort((a, b) => -a.Hp.CompareTo(b.Hp));
  4872. temp.AddRange(Helpfunctions.TakeList(temp2, 2));
  4873. foreach (Minion enemy in temp)
  4874. {
  4875. minionGetDamagedOrHealed(enemy, damage, 0, false);
  4876. }
  4877. }
  4878. if (c.name == "upgrade")
  4879. {
  4880. if (this.ownWeaponName != "")
  4881. {
  4882. this.ownWeaponAttack++;
  4883. this.ownheroAngr++;
  4884. this.ownWeaponDurability++;
  4885. }
  4886. else
  4887. {
  4888. CardDB.Card wcard = CardDB.Instance.getCardData("heavyaxe");
  4889. this.equipWeapon(wcard);
  4890. }
  4891. }
  4892. if (c.name == "whirlwind")
  4893. {
  4894. List<Minion> temp = new List<Minion>(this.enemyMinions);
  4895. int damage = getSpellDamageDamage(1);
  4896. foreach (Minion enemy in temp)
  4897. {
  4898. minionGetDamagedOrHealed(enemy, damage, 0, false);
  4899. }
  4900. temp.Clear();
  4901. temp = new List<Minion>(this.ownMinions);
  4902. foreach (Minion enemy in temp)
  4903. {
  4904. minionGetDamagedOrHealed(enemy, damage, 0, true);
  4905. }
  4906. }
  4907. if (c.name == "heroicstrike")
  4908. {
  4909. this.ownheroAngr = this.ownheroAngr + 4;
  4910. if ((this.ownHeroNumAttackThisTurn == 0 || (this.ownHeroWindfury && this.ownHeroNumAttackThisTurn == 1)) && !this.ownHeroFrozen)
  4911. {
  4912. this.ownHeroReady = true;
  4913. }
  4914. }
  4915. if (c.name == "shieldblock")
  4916. {
  4917. this.ownHeroDefence = this.ownHeroDefence + 5;
  4918. this.owncarddraw++;
  4919. drawACard("");
  4920. }
  4921. //mage#########################################################################################
  4922. if (c.name == "blizzard")
  4923. {
  4924. int damage = getSpellDamageDamage(2);
  4925. List<Minion> temp = new List<Minion>(this.enemyMinions);
  4926. int maxHp = 0;
  4927. foreach (Minion enemy in temp)
  4928. {
  4929. enemy.frozen = true;
  4930. if (maxHp < enemy.Hp) maxHp = enemy.Hp;
  4931. minionGetDamagedOrHealed(enemy, damage, 0, false, true);
  4932. }
  4933. this.lostDamage += Math.Max(0, damage - maxHp);
  4934. }
  4935. if (c.name == "arcanemissiles")
  4936. {
  4937. List<Minion> temp = new List<Minion>(this.enemyMinions);
  4938. temp.Sort((a, b) => -a.Hp.CompareTo(b.Hp));
  4939. int damage = 1;
  4940. int ammount = getSpellDamageDamage(3);
  4941. int i = 0;
  4942. int hp = 0;
  4943. foreach (Minion enemy in temp)
  4944. {
  4945. if (enemy.Hp >= 2)
  4946. {
  4947. minionGetDamagedOrHealed(enemy, damage, 0, false);
  4948. i++;
  4949. hp += enemy.Hp;
  4950. if (i == ammount) break;
  4951. }
  4952. }
  4953. if (i < ammount) attackOrHealHero(ammount - i, false);
  4954. }
  4955. if (c.name == "arcaneintellect")
  4956. {
  4957. this.owncarddraw++;
  4958. this.drawACard("");
  4959. this.drawACard("");
  4960. }
  4961. if (c.name == "mirrorimage")
  4962. {
  4963. int posi = this.ownMinions.Count - 1;
  4964. CardDB.Card kid = CardDB.Instance.getCardDataFromID("CS2_mirror");
  4965. callKid(kid, posi, true);
  4966. callKid(kid, posi, true);
  4967. }
  4968. if (c.name == "arcaneexplosion")
  4969. {
  4970. List<Minion> temp = new List<Minion>(this.enemyMinions);
  4971. int damage = getSpellDamageDamage(1);
  4972. foreach (Minion enemy in temp)
  4973. {
  4974. minionGetDamagedOrHealed(enemy, damage, 0, false);
  4975. }
  4976. }
  4977. if (c.name == "frostnova")
  4978. {
  4979. List<Minion> temp = new List<Minion>(this.enemyMinions);
  4980. foreach (Minion enemy in temp)
  4981. {
  4982. enemy.frozen = true;
  4983. }
  4984. }
  4985. if (c.name == "flamestrike")
  4986. {
  4987. List<Minion> temp = new List<Minion>(this.enemyMinions);
  4988. int damage = getSpellDamageDamage(4);
  4989. int maxHp = 0;
  4990. foreach (Minion enemy in temp)
  4991. {
  4992. if (maxHp < enemy.Hp) maxHp = enemy.Hp;
  4993. minionGetDamagedOrHealed(enemy, damage, 0, false, true);
  4994. }
  4995. this.lostDamage += Math.Max(0, damage - maxHp);
  4996. }
  4997. //pala#################################################################
  4998. if (c.name == "consecration")
  4999. {
  5000. List<Minion> temp = new List<Minion>(this.enemyMinions);
  5001. int damage = getSpellDamageDamage(2);
  5002. foreach (Minion enemy in temp)
  5003. {
  5004. minionGetDamagedOrHealed(enemy, damage, 0, false);
  5005. }
  5006. attackOrHealHero(damage, false);
  5007. }
  5008. if (c.name == "equality")
  5009. {
  5010. foreach (Minion m in this.ownMinions)
  5011. {
  5012. m.Hp = 1;
  5013. m.maxHp = 1;
  5014. }
  5015. foreach (Minion m in this.enemyMinions)
  5016. {
  5017. m.Hp = 1;
  5018. m.maxHp = 1;
  5019. }
  5020. }
  5021. if (c.name == "divinefavor")
  5022. {
  5023. int enemcardsanz = this.enemyAnzCards + this.enemycarddraw;
  5024. int diff = enemcardsanz - this.owncards.Count;
  5025. if (diff >= 1)
  5026. {
  5027. for (int i = 0; i < diff; i++)
  5028. {
  5029. this.owncarddraw++;
  5030. this.drawACard("");
  5031. }
  5032. }
  5033. }
  5034. if (c.name == "avengingwrath")
  5035. {
  5036. List<Minion> temp = new List<Minion>(this.enemyMinions);
  5037. int damage = 1;
  5038. int i = 0;
  5039. if (temp.Count >= 1)
  5040. {
  5041. foreach (Minion enemy in temp)
  5042. {
  5043. minionGetDamagedOrHealed(enemy, damage, 0, false);
  5044. i++;
  5045. if (i == 8) break;
  5046. }
  5047. }
  5048. else
  5049. {
  5050. damage = getSpellDamageDamage(8);
  5051. attackOrHealHero(damage, false);
  5052. }
  5053. }
  5054. //priest ####################################################
  5055. if (c.name == "circleofhealing")
  5056. {
  5057. List<Minion> temp = new List<Minion>(this.enemyMinions);
  5058. int heal = getSpellHeal(4);
  5059. foreach (Minion enemy in temp)
  5060. {
  5061. minionGetDamagedOrHealed(enemy, 0, heal, false);
  5062. }
  5063. temp.Clear();
  5064. temp.AddRange(this.ownMinions);
  5065. foreach (Minion enemy in temp)
  5066. {
  5067. minionGetDamagedOrHealed(enemy, 0, heal, true);
  5068. }
  5069. }
  5070. if (c.name == "thoughtsteal")
  5071. {
  5072. this.owncarddraw++;
  5073. this.drawACard("enemycard");
  5074. this.owncarddraw++;
  5075. this.drawACard("enemycard");
  5076. }
  5077. if (c.name == "mindvision")
  5078. {
  5079. if (this.enemyAnzCards >= 1)
  5080. {
  5081. this.owncarddraw++;
  5082. this.drawACard("enemycard");
  5083. }
  5084. }
  5085. if (c.name == "shadowform")
  5086. {
  5087. if (this.ownHeroAblility.CardID == "CS1h_001") // lesser heal becomes mind spike
  5088. {
  5089. this.ownHeroAblility = CardDB.Instance.getCardDataFromID("EX1_625t");
  5090. }
  5091. else
  5092. {
  5093. this.ownHeroAblility = CardDB.Instance.getCardDataFromID("EX1_625t2"); // mindspike becomes mind shatter
  5094. }
  5095. }
  5096. if (c.name == "mindgames")
  5097. {
  5098. CardDB.Card copymin = CardDB.Instance.getCardDataFromID("CS2_152"); //we draw a knappe :D (worst case)
  5099. callKid(copymin, this.ownMinions.Count - 1, true);
  5100. }
  5101. if (c.name == "massdispel")
  5102. {
  5103. foreach (Minion m in this.enemyMinions)
  5104. {
  5105. minionGetSilenced(m, false);
  5106. }
  5107. }
  5108. if (c.name == "mindblast")
  5109. {
  5110. int damage = getSpellDamageDamage(5);
  5111. attackOrHealHero(damage, false);
  5112. }
  5113. if (c.name == "holynova")
  5114. {
  5115. List<Minion> temp = new List<Minion>(this.ownMinions);
  5116. int heal = getSpellHeal(2);
  5117. int damage = getSpellDamageDamage(2);
  5118. foreach (Minion enemy in temp)
  5119. {
  5120. minionGetDamagedOrHealed(enemy, 0, heal, true, true);
  5121. }
  5122. attackOrHealHero(-heal, true);
  5123. temp.Clear();
  5124. temp.AddRange(this.enemyMinions);
  5125. foreach (Minion enemy in temp)
  5126. {
  5127. minionGetDamagedOrHealed(enemy, damage, 0, false, true);
  5128. }
  5129. attackOrHealHero(damage, false);
  5130. }
  5131. //rogue #################################################
  5132. if (c.name == "preparation")
  5133. {
  5134. this.playedPreparation = true;
  5135. }
  5136. if (c.name == "bladeflurry")
  5137. {
  5138. List<Minion> temp = new List<Minion>(this.enemyMinions);
  5139. int damage = this.getSpellDamageDamage(this.ownWeaponAttack);
  5140. foreach (Minion enemy in temp)
  5141. {
  5142. minionGetDamagedOrHealed(enemy, damage, 0, false);
  5143. }
  5144. attackOrHealHero(damage, false);
  5145. //destroy own weapon
  5146. this.lowerWeaponDurability(1000, true);
  5147. }
  5148. if (c.name == "headcrack")
  5149. {
  5150. int damage = getSpellDamageDamage(2);
  5151. attackOrHealHero(damage, false);
  5152. if (this.cardsPlayedThisTurn >= 1) this.owncarddraw++; // DONT DRAW A CARD WITH (drawAcard()) because we get this NEXT turn
  5153. }
  5154. if (c.name == "sinisterstrike")
  5155. {
  5156. int damage = getSpellDamageDamage(3);
  5157. attackOrHealHero(damage, false);
  5158. }
  5159. if (c.name == "deadlypoison")
  5160. {
  5161. if (this.ownWeaponName != "")
  5162. {
  5163. this.ownWeaponAttack += 2;
  5164. this.ownheroAngr += 2;
  5165. }
  5166. }
  5167. if (c.name == "fanofknives")
  5168. {
  5169. List<Minion> temp = new List<Minion>(this.enemyMinions);
  5170. int damage = getSpellDamageDamage(1);
  5171. foreach (Minion enemy in temp)
  5172. {
  5173. minionGetDamagedOrHealed(enemy, damage, 0, false);
  5174. }
  5175. }
  5176. if (c.name == "sprint")
  5177. {
  5178. for (int i = 0; i < 4; i++)
  5179. {
  5180. this.owncarddraw++;
  5181. this.drawACard("");
  5182. }
  5183. }
  5184. if (c.name == "vanish")
  5185. {
  5186. List<Minion> temp = new List<Minion>(this.enemyMinions);
  5187. int heal = getSpellHeal(4);
  5188. foreach (Minion enemy in temp)
  5189. {
  5190. minionReturnToHand(enemy, false);
  5191. }
  5192. temp.Clear();
  5193. temp.AddRange(this.ownMinions);
  5194. foreach (Minion enemy in temp)
  5195. {
  5196. minionReturnToHand(enemy, true);
  5197. }
  5198. }
  5199. //shaman #################################################
  5200. if (c.name == "forkedlightning" && this.enemyMinions.Count >= 2)
  5201. {
  5202. List<Minion> temp = new List<Minion>();
  5203. int damage = getSpellDamageDamage(2);
  5204. List<Minion> temp2 = new List<Minion>(this.enemyMinions);
  5205. temp2.Sort((a, b) => -a.Hp.CompareTo(b.Hp));
  5206. temp.AddRange(Helpfunctions.TakeList(temp2, 2));
  5207. foreach (Minion enemy in temp)
  5208. {
  5209. minionGetDamagedOrHealed(enemy, damage, 0, false);
  5210. }
  5211. }
  5212. if (c.name == "farsight")
  5213. {
  5214. this.owncarddraw++;
  5215. this.drawACard("");
  5216. }
  5217. if (c.name == "lightningstorm")
  5218. {
  5219. List<Minion> temp = new List<Minion>(this.enemyMinions);
  5220. int damage = getSpellDamageDamage(2);
  5221. int maxHp = 0;
  5222. foreach (Minion enemy in temp)
  5223. {
  5224. if (maxHp < enemy.Hp) maxHp = enemy.Hp;
  5225. minionGetDamagedOrHealed(enemy, damage, 0, false, true);
  5226. }
  5227. this.lostDamage += Math.Max(0, damage - maxHp);
  5228. }
  5229. if (c.name == "feralspirit")
  5230. {
  5231. int posi = this.ownMinions.Count - 1;
  5232. CardDB.Card kid = CardDB.Instance.getCardData("spiritwolf");
  5233. callKid(kid, posi, true);
  5234. callKid(kid, posi, true);
  5235. }
  5236. if (c.name == "totemicmight")
  5237. {
  5238. List<Minion> temp = new List<Minion>(this.ownMinions);
  5239. foreach (Minion m in temp)
  5240. {
  5241. if (m.card.race == 21) // if minion is a totem, buff it
  5242. {
  5243. minionGetBuffed(m, 0, 2, true);
  5244. }
  5245. }
  5246. }
  5247. if (c.name == "bloodlust")
  5248. {
  5249. List<Minion> temp = new List<Minion>(this.ownMinions);
  5250. foreach (Minion m in temp)
  5251. {
  5252. Enchantment e = CardDB.getEnchantmentFromCardID("CS2_046e");
  5253. e.creator = this.ownController;
  5254. e.controllerOfCreator = this.ownController;
  5255. addEffectToMinionNoDoubles(m, e, true);
  5256. }
  5257. }
  5258. //hexenmeister #################################################
  5259. if (c.name == "sensedemons")
  5260. {
  5261. this.owncarddraw += 2;
  5262. this.drawACard("");
  5263. this.drawACard("");
  5264. }
  5265. if (c.name == "twistingnether")
  5266. {
  5267. List<Minion> temp = new List<Minion>(this.enemyMinions);
  5268. foreach (Minion enemy in temp)
  5269. {
  5270. minionGetDestroyed(enemy, false);
  5271. }
  5272. temp.Clear();
  5273. temp.AddRange(this.ownMinions);
  5274. foreach (Minion enemy in temp)
  5275. {
  5276. minionGetDestroyed(enemy, true);
  5277. }
  5278. }
  5279. if (c.name == "hellfire")
  5280. {
  5281. List<Minion> temp = new List<Minion>(this.enemyMinions);
  5282. int damage = getSpellDamageDamage(3);
  5283. foreach (Minion enemy in temp)
  5284. {
  5285. minionGetDamagedOrHealed(enemy, damage, 0, false);
  5286. }
  5287. temp.Clear();
  5288. temp.AddRange(this.ownMinions);
  5289. foreach (Minion enemy in temp)
  5290. {
  5291. minionGetDamagedOrHealed(enemy, damage, 0, true);
  5292. }
  5293. attackOrHealHero(damage, true);
  5294. attackOrHealHero(damage, false);
  5295. }
  5296. //druid #################################################
  5297. if (c.name == "souloftheforest")
  5298. {
  5299. List<Minion> temp = new List<Minion>(this.ownMinions);
  5300. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_158e");
  5301. e.creator = c.entityID;
  5302. e.controllerOfCreator = this.ownController;
  5303. foreach (Minion enemy in temp)
  5304. {
  5305. addEffectToMinionNoDoubles(enemy, e, true);
  5306. }
  5307. }
  5308. if (c.name == "innervate")
  5309. {
  5310. this.mana = Math.Min(this.mana + 2, 10);
  5311. }
  5312. if (c.name == "bite")
  5313. {
  5314. this.ownheroAngr += 4;
  5315. this.ownHeroDefence += 4;
  5316. if ((this.ownHeroNumAttackThisTurn == 0 || (this.ownHeroWindfury && this.ownHeroNumAttackThisTurn == 1)) && !this.ownHeroFrozen)
  5317. {
  5318. this.ownHeroReady = true;
  5319. }
  5320. }
  5321. if (c.name == "claw")
  5322. {
  5323. this.ownheroAngr += 2;
  5324. this.ownHeroDefence += 2;
  5325. if ((this.ownHeroNumAttackThisTurn == 0 || (this.ownHeroWindfury && this.ownHeroNumAttackThisTurn == 1)) && !this.ownHeroFrozen)
  5326. {
  5327. this.ownHeroReady = true;
  5328. }
  5329. }
  5330. if (c.name == "forceofnature")
  5331. {
  5332. int posi = this.ownMinions.Count - 1;
  5333. CardDB.Card kid = CardDB.Instance.getCardDataFromID("EX1_tk9");//Treant
  5334. callKid(kid, posi, true);
  5335. callKid(kid, posi, true);
  5336. callKid(kid, posi, true);
  5337. }
  5338. if (c.name == "powerofthewild")// macht der wildnis with summoning
  5339. {
  5340. if (choice == 1)
  5341. {
  5342. foreach (Minion m in this.ownMinions)
  5343. {
  5344. minionGetBuffed(m, 1, 1, true);
  5345. }
  5346. }
  5347. if (choice == 2)
  5348. {
  5349. int posi = this.ownMinions.Count - 1;
  5350. CardDB.Card kid = CardDB.Instance.getCardDataFromID("EX1_160t");//panther
  5351. callKid(kid, posi, true);
  5352. }
  5353. }
  5354. if (c.name == "starfall")
  5355. {
  5356. if (choice == 2)
  5357. {
  5358. List<Minion> temp = new List<Minion>(this.enemyMinions);
  5359. int damage = getSpellDamageDamage(2);
  5360. foreach (Minion enemy in temp)
  5361. {
  5362. minionGetDamagedOrHealed(enemy, damage, 0, false);
  5363. }
  5364. }
  5365. }
  5366. if (c.name == "nourish")
  5367. {
  5368. if (choice == 1)
  5369. {
  5370. if (this.ownMaxMana == 10)
  5371. {
  5372. this.owncarddraw++;
  5373. this.drawACard("excessmana");
  5374. }
  5375. else
  5376. {
  5377. this.ownMaxMana++;
  5378. this.mana++;
  5379. }
  5380. if (this.ownMaxMana == 10)
  5381. {
  5382. this.owncarddraw++;
  5383. this.drawACard("excessmana");
  5384. }
  5385. else
  5386. {
  5387. this.ownMaxMana++;
  5388. this.mana++;
  5389. }
  5390. }
  5391. if (choice == 2)
  5392. {
  5393. this.owncarddraw += 3;
  5394. this.drawACard("");
  5395. this.drawACard("");
  5396. this.drawACard("");
  5397. }
  5398. }
  5399. //special cards#######################
  5400. if (c.CardID == "PRO_001a")// i am murloc
  5401. {
  5402. int posi = this.ownMinions.Count - 1;
  5403. CardDB.Card kid = CardDB.Instance.getCardDataFromID("PRO_001at");//panther
  5404. callKid(kid, posi, true);
  5405. callKid(kid, posi, true);
  5406. callKid(kid, posi, true);
  5407. }
  5408. if (c.CardID == "PRO_001c")// i am murloc
  5409. {
  5410. int posi = this.ownMinions.Count - 1;
  5411. CardDB.Card kid = CardDB.Instance.getCardDataFromID("EX1_021");//scharfseher
  5412. callKid(kid, posi, true);
  5413. }
  5414. if (c.name == "wildgrowth")
  5415. {
  5416. if (this.ownMaxMana == 10)
  5417. {
  5418. this.owncarddraw++;
  5419. this.drawACard("excessmana");
  5420. }
  5421. else
  5422. {
  5423. this.ownMaxMana++;
  5424. }
  5425. }
  5426. if (c.name == "excessmana")
  5427. {
  5428. this.owncarddraw++;
  5429. this.drawACard("");
  5430. }
  5431. if (c.name == "yseraawakens")
  5432. {
  5433. List<Minion> temp = new List<Minion>(this.enemyMinions);
  5434. int damage = getSpellDamageDamage(5);
  5435. foreach (Minion enemy in temp)
  5436. {
  5437. if (enemy.name != "ysera")// dont attack ysera
  5438. {
  5439. minionGetDamagedOrHealed(enemy, damage, 0, false);
  5440. }
  5441. }
  5442. temp.Clear();
  5443. temp.AddRange(this.ownMinions);
  5444. foreach (Minion enemy in temp)
  5445. {
  5446. if (enemy.name != "ysera")//dont attack ysera
  5447. {
  5448. minionGetDamagedOrHealed(enemy, damage, 0, false);
  5449. }
  5450. }
  5451. attackOrHealHero(damage, true);
  5452. attackOrHealHero(damage, false);
  5453. }
  5454. if (c.name == "stomp")
  5455. {
  5456. List<Minion> temp = new List<Minion>(this.enemyMinions);
  5457. int damage = getSpellDamageDamage(2);
  5458. foreach (Minion enemy in temp)
  5459. {
  5460. minionGetDamagedOrHealed(enemy, damage, 0, false);
  5461. }
  5462. }
  5463. }
  5464. private void drawACard(string ss)
  5465. {
  5466. string s = ss;
  5467. if (s == "") s = "unknown";
  5468. if (s == "enemycard") s = "unknown"; // NO PENALITY FOR DRAWING TO MUCH CARDS
  5469. if (this.owncards.Count >= 10) return; // cant hold more than 10 cards
  5470. if (s == "unknown")
  5471. {
  5472. CardDB.Card plchldr = new CardDB.Card();
  5473. plchldr.name = "unknown";
  5474. plchldr.cost = 1000;
  5475. Handmanager.Handcard hc = new Handmanager.Handcard();
  5476. hc.card = plchldr;
  5477. hc.position = this.owncards.Count + 1;
  5478. this.owncards.Add(hc);
  5479. }
  5480. if (s == "fireball")
  5481. {
  5482. CardDB.Card c = CardDB.Instance.getCardData("fireball");
  5483. Handmanager.Handcard hc = new Handmanager.Handcard();
  5484. hc.card = c;
  5485. hc.position = this.owncards.Count + 1;
  5486. this.owncards.Add(hc);
  5487. }
  5488. }
  5489. private void triggerPlayedAMinion(CardDB.Card c, bool own)
  5490. {
  5491. if (own) // effects only for OWN minons
  5492. {
  5493. List<Minion> tempo = new List<Minion>(this.ownMinions);
  5494. foreach (Minion m in tempo)
  5495. {
  5496. if (m.silenced) continue;
  5497. if (m.name == "knifejuggler")
  5498. {
  5499. if (this.enemyMinions.Count >= 1)
  5500. {
  5501. List<Minion> temp = new List<Minion>();
  5502. int damage = 1;
  5503. List<Minion> temp2 = new List<Minion>(this.enemyMinions);
  5504. temp2.Sort((a, b) => -a.Hp.CompareTo(b.Hp));
  5505. temp.AddRange(Helpfunctions.TakeList(temp2, 1));
  5506. foreach (Minion enemy in temp)
  5507. {
  5508. minionGetDamagedOrHealed(enemy, damage, 0, false);
  5509. }
  5510. }
  5511. else
  5512. {
  5513. this.attackOrHealHero(1, false);
  5514. }
  5515. }
  5516. if (own && m.name == "starvingbuzzard" && (TAG_RACE)c.race == TAG_RACE.PET)
  5517. {
  5518. this.owncarddraw++;
  5519. this.drawACard("");
  5520. }
  5521. }
  5522. }
  5523. //effects for ALL minons
  5524. List<Minion> tempoo = new List<Minion>(this.ownMinions);
  5525. foreach (Minion m in tempoo)
  5526. {
  5527. if (m.silenced) continue;
  5528. if (m.name == "murloctidecaller" && c.race == 14 && m.entitiyID != c.entityID)
  5529. {
  5530. minionGetBuffed(m, 1, 0, true);
  5531. }
  5532. if (m.name == "oldmurk-eye" && c.race == 14 && m.entitiyID != c.entityID)
  5533. {
  5534. minionGetBuffed(m, 1, 0, true);
  5535. }
  5536. }
  5537. tempoo.Clear();
  5538. tempoo.AddRange(this.enemyMinions);
  5539. foreach (Minion m in tempoo)
  5540. {
  5541. if (m.silenced) continue;
  5542. //truebaugederalte
  5543. if (m.name == "murloctidecaller" && c.race == 14 && m.entitiyID != c.entityID)
  5544. {
  5545. minionGetBuffed(m, 1, 0, false);
  5546. }
  5547. if (m.name == "oldmurk-eye" && c.race == 14 && m.entitiyID != c.entityID)
  5548. {
  5549. minionGetBuffed(m, 1, 0, false);
  5550. }
  5551. }
  5552. }
  5553. private void triggerPlayedASpell(CardDB.Card c)
  5554. {
  5555. bool wilderpyro = false;
  5556. foreach (Minion m in this.ownMinions)
  5557. {
  5558. if (m.silenced) continue;
  5559. if (m.name == "manawyrm")
  5560. {
  5561. minionGetBuffed(m, 1, 0, true);
  5562. }
  5563. if (m.name == "manaaddict")
  5564. {
  5565. Enchantment e = CardDB.getEnchantmentFromCardID("EX1_055o");
  5566. e.creator = m.entitiyID;
  5567. e.controllerOfCreator = this.ownController;
  5568. addEffectToMinionNoDoubles(m, e, true);
  5569. }
  5570. if (m.name == "secretkeeper" && c.Secret)
  5571. {
  5572. minionGetBuffed(m, 1, 1, true);
  5573. }
  5574. if (m.name == "archmageantonidas")
  5575. {
  5576. drawACard("fireball");
  5577. }
  5578. if (m.name == "violetteacher")
  5579. {
  5580. CardDB.Card d = CardDB.Instance.getCardData("violetapprentice");
  5581. callKid(d, m.id, true);
  5582. }
  5583. if (m.name == "gadgetzanauctioneer")
  5584. {
  5585. this.owncarddraw++;
  5586. drawACard("");
  5587. }
  5588. if (m.name == "wildpyromancer")
  5589. {
  5590. wilderpyro = true;
  5591. }
  5592. }
  5593. foreach (Minion m in this.enemyMinions)
  5594. {
  5595. if (m.name == "secretkeeper" && c.Secret)
  5596. {
  5597. minionGetBuffed(m, 1, 1, true);
  5598. }
  5599. }
  5600. if (wilderpyro)
  5601. {
  5602. List<Minion> temp = new List<Minion>(this.ownMinions);
  5603. foreach (Minion m in temp)
  5604. {
  5605. if (m.silenced) continue;
  5606. if (m.name == "wildpyromancer")
  5607. {
  5608. List<Minion> temp2 = new List<Minion>(this.ownMinions);
  5609. foreach (Minion mnn in temp2)
  5610. {
  5611. minionGetDamagedOrHealed(mnn, 1, 0, true);
  5612. }
  5613. temp2.Clear();
  5614. temp2.AddRange(this.enemyMinions);
  5615. foreach (Minion mnn in temp2)
  5616. {
  5617. minionGetDamagedOrHealed(mnn, 1, 0, false);
  5618. }
  5619. }
  5620. }
  5621. }
  5622. }
  5623. public void removeCard(CardDB.Card c)
  5624. {
  5625. this.owncards.RemoveAll(x => x.entity == c.entityID);
  5626. int i = 1;
  5627. foreach (Handmanager.Handcard hc in this.owncards)
  5628. {
  5629. hc.position = i;
  5630. i++;
  5631. }
  5632. }
  5633. public void playCard(CardDB.Card c, int cardpos, int cardEntity, int target, int targetEntity, int choice, int placepos, int penality)
  5634. {
  5635. this.evaluatePenality += penality;
  5636. // lock at frostnova (click) / frostblitz (no click)
  5637. this.mana = this.mana - c.getManaCost(this);
  5638. removeCard(c);// remove card
  5639. if (c.Secret)
  5640. {
  5641. this.ownSecretsIDList.Add(c.CardID);
  5642. this.playedmagierinderkirintor = false;
  5643. }
  5644. if (c.type == CardDB.cardtype.SPELL) this.playedPreparation = false;
  5645. if (logging) help.logg("play crd " + c.name + " entitiy# " + cardEntity + " mana " + c.getManaCost(this) + " trgt " + target);
  5646. if (c.type == CardDB.cardtype.MOB)
  5647. {
  5648. Action b = this.placeAmobSomewhere(c, cardpos, target, choice, placepos);
  5649. b.druidchoice = choice;
  5650. b.owntarget = placepos;
  5651. b.enemyEntitiy = targetEntity;
  5652. b.cardEntitiy = cardEntity;
  5653. this.playactions.Add(b);
  5654. this.mobsplayedThisTurn++;
  5655. if (c.name == "kirintormage") this.playedmagierinderkirintor = true;
  5656. }
  5657. else
  5658. {
  5659. Action a = new Action();
  5660. a.cardplay = true;
  5661. a.card = new CardDB.Card(c);
  5662. a.cardEntitiy = cardEntity;
  5663. a.numEnemysBeforePlayed = this.enemyMinions.Count;
  5664. a.comboBeforePlayed = (this.cardsPlayedThisTurn >= 1) ? true : false;
  5665. a.owntarget = 0;
  5666. if (target >= 0)
  5667. {
  5668. a.owntarget = -1;
  5669. }
  5670. a.enemytarget = target;
  5671. a.enemyEntitiy = targetEntity;
  5672. a.druidchoice = choice;
  5673. if (target == -1)
  5674. {
  5675. //card with no target
  5676. if (c.type == CardDB.cardtype.WEAPON)
  5677. {
  5678. equipWeapon(c);
  5679. }
  5680. playCardWithoutTarget(c, choice);
  5681. }
  5682. else //before : if(target >=0 && target < 20)
  5683. {
  5684. if (c.type == CardDB.cardtype.WEAPON)
  5685. {
  5686. equipWeapon(c);
  5687. }
  5688. playCardWithTarget(c, target, choice);
  5689. }
  5690. this.playactions.Add(a);
  5691. if (c.type == CardDB.cardtype.SPELL)
  5692. {
  5693. this.triggerPlayedASpell(c);
  5694. }
  5695. }
  5696. triggerACardGetPlayed(c);
  5697. this.ueberladung += c.recallValue;
  5698. this.cardsPlayedThisTurn++;
  5699. }
  5700. private void triggerACardGetPlayed(CardDB.Card c)
  5701. {
  5702. List<Minion> temp = new List<Minion>(this.ownMinions);
  5703. foreach (Minion mnn in temp)
  5704. {
  5705. if (mnn.silenced) continue;
  5706. if (mnn.name == "illidanstormrage")
  5707. {
  5708. CardDB.Card d = CardDB.Instance.getCardData("flameofazzinoth");
  5709. callKid(d, mnn.id, true);
  5710. }
  5711. if (mnn.name == "questingadventurer")
  5712. {
  5713. minionGetBuffed(mnn, 1, 1, true);
  5714. }
  5715. if (mnn.name == "unboundelemental" && c.recallValue >= 1)
  5716. {
  5717. minionGetBuffed(mnn, 1, 1, true);
  5718. }
  5719. }
  5720. }
  5721. public void attackWithWeapon(int target, int targetEntity, int penality)
  5722. {
  5723. //this.ownHeroAttackedInRound = true;
  5724. this.ownHeroNumAttackThisTurn++;
  5725. if ((this.ownHeroWindfury && this.ownHeroNumAttackThisTurn == 2) || (!this.ownHeroWindfury && this.ownHeroNumAttackThisTurn == 1))
  5726. {
  5727. this.ownHeroReady = false;
  5728. }
  5729. Action a = new Action();
  5730. a.heroattack = true;
  5731. a.enemytarget = target;
  5732. a.enemyEntitiy = targetEntity;
  5733. a.owntarget = 100;
  5734. a.ownEntitiy = this.ownHeroEntity;
  5735. a.numEnemysBeforePlayed = this.enemyMinions.Count;
  5736. a.comboBeforePlayed = (this.cardsPlayedThisTurn >= 1) ? true : false;
  5737. this.playactions.Add(a);
  5738. if (this.ownWeaponName == "truesilverchampion")
  5739. {
  5740. this.attackOrHealHero(-2, true);
  5741. }
  5742. if (logging) help.logg("attck with weapon " + a.owntarget + " " + a.ownEntitiy + " trgt: " + a.enemytarget + " " + a.enemyEntitiy);
  5743. if (target == 200)
  5744. {
  5745. attackOrHealHero(this.ownheroAngr, false);
  5746. }
  5747. else
  5748. {
  5749. Minion enemy = this.enemyMinions[target - 10];
  5750. minionGetDamagedOrHealed(enemy, this.ownheroAngr, 0, false);
  5751. if (!this.heroImmuneWhileAttacking)
  5752. {
  5753. attackOrHealHero(enemy.Angr, true);
  5754. if (enemy.name == "waterelemental")
  5755. {
  5756. this.ownHeroFrozen = true;
  5757. }
  5758. }
  5759. }
  5760. //todo
  5761. if (ownWeaponName == "gorehowl")
  5762. {
  5763. this.ownWeaponAttack--;
  5764. this.ownheroAngr--;
  5765. }
  5766. else
  5767. {
  5768. this.lowerWeaponDurability(1, true);
  5769. }
  5770. }
  5771. public void activateAbility(CardDB.Card c, int target, int targetEntity, int penality)
  5772. {
  5773. this.evaluatePenality += penality;
  5774. string heroname = this.ownHeroName;
  5775. this.ownAbilityReady = false;
  5776. this.mana -= 2;
  5777. Action a = new Action();
  5778. a.useability = true;
  5779. a.card = c;
  5780. a.enemytarget = target;
  5781. a.enemyEntitiy = targetEntity;
  5782. a.numEnemysBeforePlayed = this.enemyMinions.Count;
  5783. a.comboBeforePlayed = (this.cardsPlayedThisTurn >= 1) ? true : false;
  5784. this.playactions.Add(a);
  5785. if (logging) help.logg("play ability on target " + target);
  5786. if (heroname == "mage")
  5787. {
  5788. int damage = 1;
  5789. if (target == 100)
  5790. {
  5791. attackOrHealHero(damage, true);
  5792. }
  5793. else
  5794. {
  5795. if (target == 200)
  5796. {
  5797. attackOrHealHero(damage, false);
  5798. }
  5799. else
  5800. {
  5801. if (target < 10)
  5802. {
  5803. Minion m = this.ownMinions[target];
  5804. this.minionGetDamagedOrHealed(m, damage, 0, true);
  5805. }
  5806. if (target >= 10 && target < 20)
  5807. {
  5808. Minion m = this.enemyMinions[target - 10];
  5809. this.minionGetDamagedOrHealed(m, damage, 0, false);
  5810. }
  5811. }
  5812. }
  5813. }
  5814. if (heroname == "priest")
  5815. {
  5816. int heal = 2;
  5817. if (this.auchenaiseelenpriesterin) heal = -2;
  5818. if (c.name == "mindspike")
  5819. {
  5820. heal = -1 * 2;
  5821. }
  5822. if (c.name == "mindshatter")
  5823. {
  5824. heal = -1 * 3;
  5825. }
  5826. if (target == 100)
  5827. {
  5828. attackOrHealHero(-1 * heal, true);
  5829. }
  5830. else
  5831. {
  5832. if (target == 200)
  5833. {
  5834. attackOrHealHero(-1 * heal, false);
  5835. }
  5836. else
  5837. {
  5838. if (target < 10)
  5839. {
  5840. Minion m = this.ownMinions[target];
  5841. this.minionGetDamagedOrHealed(m, 0, heal, true);
  5842. }
  5843. if (target >= 10 && target < 20)
  5844. {
  5845. Minion m = this.enemyMinions[target - 10];
  5846. this.minionGetDamagedOrHealed(m, 0, heal, false);
  5847. }
  5848. }
  5849. }
  5850. }
  5851. if (heroname == "warrior")
  5852. {
  5853. this.ownHeroDefence += 2;
  5854. }
  5855. if (heroname == "warlock")
  5856. {
  5857. this.owncarddraw++;
  5858. drawACard("");
  5859. this.attackOrHealHero(2, true);
  5860. }
  5861. if (heroname == "thief")
  5862. {
  5863. CardDB.Card wcard = CardDB.Instance.getCardData("wickedknife");
  5864. this.equipWeapon(wcard);
  5865. }
  5866. if (heroname == "druid")
  5867. {
  5868. this.ownheroAngr += 1;
  5869. if ((this.ownHeroNumAttackThisTurn == 0 || (this.ownHeroWindfury && this.ownHeroNumAttackThisTurn == 1)) && !this.ownHeroFrozen)
  5870. {
  5871. this.ownHeroReady = true;
  5872. }
  5873. this.ownHeroDefence += 1;
  5874. }
  5875. if (heroname == "hunter")
  5876. {
  5877. this.attackOrHealHero(2, false);
  5878. }
  5879. if (heroname == "pala")
  5880. {
  5881. int posi = this.ownMinions.Count - 1;
  5882. CardDB.Card kid = CardDB.Instance.getCardData("silverhandrecruit");
  5883. callKid(kid, posi, true);
  5884. }
  5885. if (heroname == "shaman")
  5886. {
  5887. int posi = this.ownMinions.Count - 1;
  5888. CardDB.Card kid = CardDB.Instance.getCardData("healingtotem");
  5889. callKid(kid, posi, true);
  5890. }
  5891. if (heroname == "lordjaraxxus")
  5892. {
  5893. int posi = this.ownMinions.Count - 1;
  5894. CardDB.Card kid = CardDB.Instance.getCardData("infernal");
  5895. callKid(kid, posi, true);
  5896. }
  5897. }
  5898. public void doAction()
  5899. {
  5900. /*if (this.playactions.Count >= 1)
  5901. {
  5902. Action a = this.playactions[0];
  5903. if (a.cardplay)
  5904. {
  5905. if (logging) help.logg("play " + a.card.name);
  5906. if (logging) help.logg("with position " + a.cardplace.X + "," + a.cardplace.Y);
  5907. help.clicklauf(a.cardplace.X, a.cardplace.Y);
  5908. if (a.owntarget >= 0)
  5909. {
  5910. if (logging) help.logg("on position " + a.ownplace.X + "," + a.ownplace.Y);
  5911. help.clicklauf(a.ownplace.X, a.ownplace.Y);
  5912. }
  5913. if (a.enemytarget >= 0)
  5914. {
  5915. if (logging) help.logg("and target to " + a.enemytarget + ": on " + a.targetplace.X + ", " + a.targetplace.Y);
  5916. help.clicklauf(a.targetplace.X, a.targetplace.Y);
  5917. }
  5918. }
  5919. if (a.minionplay)
  5920. {
  5921. if (logging) help.logg("attacker: " + a.owntarget + " enemy: " + a.enemytarget);
  5922. help.clicklauf(a.ownplace.X, a.ownplace.Y);
  5923. System.Threading.Thread.Sleep(500);
  5924. if (logging) help.logg("targetplace " + a.targetplace.X + ", " + a.targetplace.Y);
  5925. help.clicklauf(a.targetplace.X, a.targetplace.Y);
  5926. }
  5927. if (a.heroattack)
  5928. {
  5929. if (logging) help.logg("attack with hero, enemy: " + a.enemytarget);
  5930. help.clicklauf(a.ownplace.X, a.ownplace.Y);
  5931. if (logging) help.logg("targetplace " + a.targetplace.X + ", " + a.targetplace.Y);
  5932. help.clicklauf(a.targetplace.X, a.targetplace.Y);
  5933. }
  5934. if (a.useability)
  5935. {
  5936. if (logging) help.logg("useability ");
  5937. help.clicklauf(a.ownplace.X, a.ownplace.Y);
  5938. if (a.enemytarget >= 0)
  5939. {
  5940. if (logging) help.logg("on enemy: " + a.enemytarget + "targetplace " + a.targetplace.X + ", " + a.targetplace.Y);
  5941. help.clicklauf(a.targetplace.X, a.targetplace.Y);
  5942. }
  5943. }
  5944. }
  5945. else
  5946. {
  5947. // click endturnbutton
  5948. help.clicklauf(939, 353);
  5949. }
  5950. help.laufmaus(915, 400, 6);
  5951. */
  5952. }
  5953. private void debugMinions()
  5954. {
  5955. help.logg("OWN MINIONS################");
  5956. foreach (Minion m in this.ownMinions)
  5957. {
  5958. help.logg("name,ang, hp, maxhp: " + m.name + ", " + m.Angr + ", " + m.Hp + ", " + m.maxHp);
  5959. foreach (Enchantment e in m.enchantments)
  5960. {
  5961. help.logg("enchment: " + e.CARDID + " " + e.creator + " " + e.controllerOfCreator);
  5962. }
  5963. }
  5964. help.logg("ENEMY MINIONS############");
  5965. foreach (Minion m in this.enemyMinions)
  5966. {
  5967. help.logg("name,ang, hp: " + m.name + ", " + m.Angr + ", " + m.Hp);
  5968. }
  5969. }
  5970. public void printBoard()
  5971. {
  5972. help.logg("board: " + value);
  5973. help.logg("cardsplayed: " + this.cardsPlayedThisTurn + " handsize: " + this.owncards.Count);
  5974. help.logg("ownhero: ");
  5975. help.logg("ownherohp: " + this.ownHeroHp + " + " + this.ownHeroDefence);
  5976. help.logg("ownheroattac: " + this.ownheroAngr);
  5977. help.logg("ownheroweapon: " + this.ownWeaponAttack + " " + this.ownWeaponDurability + " " + this.ownWeaponName);
  5978. help.logg("ownherostatus: frozen" + this.ownHeroFrozen + " ");
  5979. help.logg("enemyherohp: " + this.enemyHeroHp + " + " + this.enemyHeroDefence);
  5980. help.logg("OWN MINIONS################");
  5981. foreach (Minion m in this.ownMinions)
  5982. {
  5983. help.logg("name,ang, hp: " + m.name + ", " + m.Angr + ", " + m.Hp);
  5984. foreach (Enchantment e in m.enchantments)
  5985. {
  5986. help.logg("enchment " + e.CARDID + " " + e.creator + " " + e.controllerOfCreator);
  5987. }
  5988. }
  5989. help.logg("ENEMY MINIONS############");
  5990. foreach (Minion m in this.enemyMinions)
  5991. {
  5992. help.logg("name,ang, hp: " + m.name + ", " + m.Angr + ", " + m.Hp);
  5993. }
  5994. help.logg("");
  5995. }
  5996. public Action getNextAction()
  5997. {
  5998. if (this.playactions.Count >= 1) return this.playactions[0];
  5999. return null;
  6000. }
  6001. public void printActions()
  6002. {
  6003. foreach (Action a in this.playactions)
  6004. {
  6005. if (a.cardplay)
  6006. {
  6007. help.logg("play " + a.card.name);
  6008. if (a.druidchoice >= 1) help.logg("choose choise " + a.druidchoice);
  6009. help.logg("with position " + a.cardEntitiy);
  6010. if (a.owntarget >= 0)
  6011. {
  6012. help.logg("on position " + a.ownEntitiy);
  6013. }
  6014. if (a.enemytarget >= 0)
  6015. {
  6016. help.logg("and target to " + a.enemytarget + " " + a.enemyEntitiy);
  6017. }
  6018. }
  6019. if (a.minionplay)
  6020. {
  6021. help.logg("attacker: " + a.owntarget + " enemy: " + a.enemytarget);
  6022. help.logg("targetplace " + a.enemyEntitiy);
  6023. }
  6024. if (a.heroattack)
  6025. {
  6026. help.logg("attack with hero, enemy: " + a.enemytarget);
  6027. help.logg("targetplace " + a.enemyEntitiy);
  6028. }
  6029. if (a.useability)
  6030. {
  6031. help.logg("useability ");
  6032. if (a.enemytarget >= 0)
  6033. {
  6034. help.logg("on enemy: " + a.enemytarget + "targetplace " + a.enemyEntitiy);
  6035. }
  6036. }
  6037. help.logg("");
  6038. }
  6039. }
  6040. }
  6041. public class Ai
  6042. {
  6043. private int maxdeep = 12;
  6044. private int maxwide = 7000;
  6045. private bool usePenalityManager = true;
  6046. private bool useCutingTargets = true;
  6047. private bool dontRecalc = true;
  6048. private bool useLethalCheck = true;
  6049. private bool useThreads = true;
  6050. private int numberOfThreads = 8;
  6051. public class aitask
  6052. {
  6053. public bool havedonesomething = false;
  6054. public List<Playfield> finishedStuff = new List<Playfield>();
  6055. public Playfield bestbard = null;
  6056. public int finishedValue = -1000000;
  6057. public List<Playfield> newStuff = new List<Playfield>();
  6058. }
  6059. public class threadobject
  6060. {
  6061. public bool test = false;
  6062. public Bot botBase = null;
  6063. public bool isLethalCheck = false;
  6064. public List<Playfield> playfieldsTasklist = new List<Playfield>();
  6065. public int threadnumber = 0;
  6066. public threadobject(bool test, Bot botBase, bool isLethalCheck, List<Playfield> playfieldsTasklist, int threadnumber)
  6067. {
  6068. this.test = test;
  6069. this.botBase = botBase;
  6070. this.isLethalCheck = isLethalCheck;
  6071. this.playfieldsTasklist.AddRange(playfieldsTasklist);
  6072. this.threadnumber = threadnumber;
  6073. }
  6074. }
  6075. private List<aitask> threadResults = new List<aitask>();
  6076. private List<int> threadnumbers = new List<int>();
  6077. PenalityManager penman = PenalityManager.Instance;
  6078. List<Playfield> posmoves = new List<Playfield>();
  6079. Hrtprozis hp = Hrtprozis.Instance;
  6080. Handmanager hm = Handmanager.Instance;
  6081. Helpfunctions help = Helpfunctions.Instance;
  6082. public Action bestmove = new Action();
  6083. public int bestmoveValue = 0;
  6084. Playfield bestboard = new Playfield();
  6085. Playfield nextMoveGuess = new Playfield();
  6086. private static Ai instance;
  6087. public static Ai Instance
  6088. {
  6089. get
  6090. {
  6091. if (instance == null)
  6092. {
  6093. instance = new Ai();
  6094. }
  6095. return instance;
  6096. }
  6097. }
  6098. private Ai()
  6099. {
  6100. this.nextMoveGuess = new Playfield();
  6101. this.nextMoveGuess.mana = -1;
  6102. }
  6103. private bool doAllChoices(CardDB.Card card, Playfield p, Handmanager.Handcard hc)
  6104. {
  6105. bool havedonesomething = false;
  6106. for (int i = 1; i < 3; i++)
  6107. {
  6108. CardDB.Card c = card;
  6109. if (card.name == "starfall")
  6110. {
  6111. if (i == 1)
  6112. {
  6113. c = CardDB.Instance.getCardDataFromID("NEW1_007b");
  6114. }
  6115. if (i == 2)
  6116. {
  6117. c = CardDB.Instance.getCardDataFromID("NEW1_007a");
  6118. }
  6119. }
  6120. if (card.name == "ancientoflore")
  6121. {
  6122. if (i == 1)
  6123. {
  6124. c = CardDB.Instance.getCardDataFromID("NEW1_008a");
  6125. }
  6126. if (i == 2)
  6127. {
  6128. c = CardDB.Instance.getCardDataFromID("NEW1_008b");
  6129. }
  6130. }
  6131. if (c.canplayCard(p))
  6132. {
  6133. havedonesomething = true;
  6134. int bestplace = p.getBestPlace(c);
  6135. List<targett> trgts = c.getTargetsForCard(p);
  6136. int cardplayPenality = 0;
  6137. if (trgts.Count == 0)
  6138. {
  6139. Playfield pf = new Playfield(p);
  6140. if (usePenalityManager)
  6141. {
  6142. cardplayPenality = penman.getPlayCardPenality(c, -1, pf, i);
  6143. if (cardplayPenality <= 499)
  6144. {
  6145. pf.playCard(card, hc.position - 1, hc.entity, -1, -1, i, bestplace, cardplayPenality);
  6146. this.posmoves.Add(pf);
  6147. }
  6148. }
  6149. else
  6150. {
  6151. pf.playCard(card, hc.position - 1, hc.entity, -1, -1, i, bestplace, cardplayPenality);
  6152. this.posmoves.Add(pf);
  6153. }
  6154. }
  6155. else
  6156. {
  6157. foreach (targett trgt in trgts)
  6158. {
  6159. Playfield pf = new Playfield(p);
  6160. if (usePenalityManager)
  6161. {
  6162. cardplayPenality = penman.getPlayCardPenality(c, -1, pf, i);
  6163. if (cardplayPenality <= 499)
  6164. {
  6165. pf.playCard(card, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, i, bestplace, cardplayPenality);
  6166. this.posmoves.Add(pf);
  6167. }
  6168. }
  6169. else
  6170. {
  6171. pf.playCard(card, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, i, bestplace, cardplayPenality);
  6172. this.posmoves.Add(pf);
  6173. }
  6174. }
  6175. }
  6176. }
  6177. }
  6178. return havedonesomething;
  6179. }
  6180. private void doallmoves(bool test, Bot botBase, bool isLethalCheck)
  6181. {
  6182. bool havedonesomething = true;
  6183. List<Playfield> temp = new List<Playfield>();
  6184. int deep = 0;
  6185. while (havedonesomething)
  6186. {
  6187. help.logg("ailoop");
  6188. GC.Collect();
  6189. temp.Clear();
  6190. temp.AddRange(this.posmoves);
  6191. havedonesomething = false;
  6192. Playfield bestold = null;
  6193. int bestoldval = -20000000;
  6194. foreach (Playfield p in temp)
  6195. {
  6196. if (p.complete)
  6197. {
  6198. continue;
  6199. }
  6200. //take a card and play it
  6201. List<string> playedcards = new List<string>();
  6202. foreach (Handmanager.Handcard hc in p.owncards)
  6203. {
  6204. CardDB.Card c = hc.card;
  6205. //help.logg("try play crd" + c.name + " " + c.getManaCost(p) + " " + c.canplayCard(p));
  6206. if (playedcards.Contains(c.name)) continue; // dont play the same card in one loop
  6207. playedcards.Add(c.name);
  6208. if (c.choice)
  6209. {
  6210. if (doAllChoices(c, p, hc))
  6211. {
  6212. havedonesomething = true;
  6213. }
  6214. }
  6215. else
  6216. {
  6217. int bestplace = p.getBestPlace(c);
  6218. if (c.canplayCard(p))
  6219. {
  6220. havedonesomething = true;
  6221. List<targett> trgts = c.getTargetsForCard(p);
  6222. if (isLethalCheck && (penman.DamageTargetDatabase.ContainsKey(c.name) || penman.DamageTargetSpecialDatabase.ContainsKey(c.name)))// only target enemy hero during Lethal check!
  6223. {
  6224. targett trg = trgts.Find(x => x.target == 200);
  6225. if (trg != null)
  6226. {
  6227. trgts.Clear();
  6228. trgts.Add(trg);
  6229. }
  6230. else
  6231. {
  6232. // no enemy hero -> enemy have taunts ->kill the taunts from left to right
  6233. if (trgts.Count >= 1)
  6234. {
  6235. trg = trgts[0];
  6236. trgts.Clear();
  6237. trgts.Add(trg);
  6238. }
  6239. }
  6240. }
  6241. int cardplayPenality = 0;
  6242. if (trgts.Count == 0)
  6243. {
  6244. Playfield pf = new Playfield(p);
  6245. if (usePenalityManager)
  6246. {
  6247. cardplayPenality = penman.getPlayCardPenality(c, -1, pf, 0);
  6248. if (cardplayPenality <= 499)
  6249. {
  6250. havedonesomething = true;
  6251. pf.playCard(c, hc.position - 1, hc.entity, -1, -1, 0, bestplace, cardplayPenality);
  6252. this.posmoves.Add(pf);
  6253. }
  6254. }
  6255. else
  6256. {
  6257. havedonesomething = true;
  6258. pf.playCard(c, hc.position - 1, hc.entity, -1, -1, 0, bestplace, cardplayPenality);
  6259. this.posmoves.Add(pf);
  6260. }
  6261. }
  6262. else
  6263. {
  6264. if (isLethalCheck)// only target enemy hero during Lethal check!
  6265. {
  6266. targett trg = trgts.Find(x => x.target == 200);
  6267. if (trg != null)
  6268. {
  6269. trgts.Clear();
  6270. trgts.Add(trg);
  6271. }
  6272. }
  6273. foreach (targett trgt in trgts)
  6274. {
  6275. Playfield pf = new Playfield(p);
  6276. if (usePenalityManager)
  6277. {
  6278. cardplayPenality = penman.getPlayCardPenality(c, trgt.target, pf, 0);
  6279. if (cardplayPenality <= 499)
  6280. {
  6281. havedonesomething = true;
  6282. pf.playCard(c, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0, bestplace, cardplayPenality);
  6283. this.posmoves.Add(pf);
  6284. }
  6285. }
  6286. else
  6287. {
  6288. havedonesomething = true;
  6289. pf.playCard(c, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0, bestplace, cardplayPenality);
  6290. this.posmoves.Add(pf);
  6291. }
  6292. }
  6293. }
  6294. }
  6295. }
  6296. }
  6297. //attack with a minion
  6298. List<Minion> playedMinions = new List<Minion>(8);
  6299. foreach (Minion m in p.ownMinions)
  6300. {
  6301. if (m.Ready && m.Angr >= 1 && !m.frozen)
  6302. {
  6303. //BEGIN:cut (double/similar) attacking minions out#####################################
  6304. // DONT LET SIMMILAR MINIONS ATTACK IN ONE TURN (example 3 unlesh the hounds-hounds doesnt need to simulated hole)
  6305. List<Minion> tempoo = new List<Minion>(playedMinions);
  6306. bool dontattacked = true;
  6307. bool isSpecial = penman.specialMinions.ContainsKey(m.name);
  6308. foreach (Minion mnn in tempoo)
  6309. {
  6310. // special minions are allowed to attack in silended and unsilenced state!
  6311. //help.logg(mnn.silenced + " " + m.silenced + " " + mnn.name + " " + m.name + " " + penman.specialMinions.ContainsKey(m.name));
  6312. bool otherisSpecial = penman.specialMinions.ContainsKey(mnn.name);
  6313. if ((!isSpecial || (isSpecial && m.silenced)) && (!otherisSpecial || (otherisSpecial && mnn.silenced))) // both are not special, if they are the same, dont add
  6314. {
  6315. if (mnn.Angr == m.Angr && mnn.Hp == m.Hp && mnn.divineshild == m.divineshild && mnn.taunt == m.taunt && mnn.poisonous == m.poisonous) dontattacked = false;
  6316. continue;
  6317. }
  6318. if (isSpecial == otherisSpecial && !m.silenced && !mnn.silenced) // same are special
  6319. {
  6320. if (m.name != mnn.name) // different name -> take it
  6321. {
  6322. continue;
  6323. }
  6324. // same name -> test whether they are equal
  6325. if (mnn.Angr == m.Angr && mnn.Hp == m.Hp && mnn.divineshild == m.divineshild && mnn.taunt == m.taunt && mnn.poisonous == m.poisonous) dontattacked = false;
  6326. continue;
  6327. }
  6328. }
  6329. if (dontattacked)
  6330. {
  6331. playedMinions.Add(m);
  6332. }
  6333. else
  6334. {
  6335. //help.logg(m.name + " doesnt need to attack!");
  6336. continue;
  6337. }
  6338. //END: cut (double/similar) attacking minions out#####################################
  6339. //help.logg(m.name + " is going to attack!");
  6340. List<targett> trgts = p.getAttackTargets();
  6341. if (isLethalCheck)// only target enemy hero during Lethal check!
  6342. {
  6343. targett trg = trgts.Find(x => x.target == 200);
  6344. if (trg != null)
  6345. {
  6346. trgts.Clear();
  6347. trgts.Add(trg);
  6348. }
  6349. else
  6350. {
  6351. // no enemy hero -> enemy have taunts ->kill the taunts from left to right
  6352. if (trgts.Count >= 1)
  6353. {
  6354. trg = trgts[0];
  6355. trgts.Clear();
  6356. trgts.Add(trg);
  6357. }
  6358. }
  6359. }
  6360. else
  6361. {
  6362. if (this.useCutingTargets) trgts = this.cutAttackTargets(trgts, p);
  6363. }
  6364. foreach (targett trgt in trgts)
  6365. {
  6366. Playfield pf = new Playfield(p);
  6367. int attackPenality = 0;
  6368. if (usePenalityManager)
  6369. {
  6370. attackPenality = penman.getAttackWithMininonPenality(m, pf, trgt.target);
  6371. if (attackPenality <= 499)
  6372. {
  6373. havedonesomething = true;
  6374. pf.attackWithMinion(m, trgt.target, trgt.targetEntity, attackPenality);
  6375. this.posmoves.Add(pf);
  6376. }
  6377. }
  6378. else
  6379. {
  6380. havedonesomething = true;
  6381. pf.attackWithMinion(m, trgt.target, trgt.targetEntity, attackPenality);
  6382. this.posmoves.Add(pf);
  6383. }
  6384. }
  6385. if (trgts.Count == 1 && trgts[0].target == 200)//only enemy hero is available als attack
  6386. {
  6387. break;
  6388. }
  6389. }
  6390. }
  6391. // attack with hero
  6392. if (p.ownHeroReady)
  6393. {
  6394. List<targett> trgts = p.getAttackTargets();
  6395. havedonesomething = true;
  6396. if (isLethalCheck)// only target enemy hero during Lethal check!
  6397. {
  6398. targett trg = trgts.Find(x => x.target == 200);
  6399. if (trg != null)
  6400. {
  6401. trgts.Clear();
  6402. trgts.Add(trg);
  6403. }
  6404. else
  6405. {
  6406. // no enemy hero -> enemy have taunts ->kill the taunts from left to right
  6407. if (trgts.Count >= 1)
  6408. {
  6409. trg = trgts[0];
  6410. trgts.Clear();
  6411. trgts.Add(trg);
  6412. }
  6413. }
  6414. }
  6415. else
  6416. {
  6417. if (this.useCutingTargets) trgts = this.cutAttackTargets(trgts, p);
  6418. }
  6419. foreach (targett trgt in trgts)
  6420. {
  6421. Playfield pf = new Playfield(p);
  6422. int heroAttackPen = 0;
  6423. if (usePenalityManager)
  6424. {
  6425. heroAttackPen = penman.getAttackWithHeroPenality(trgt.target, p);
  6426. }
  6427. pf.attackWithWeapon(trgt.target, trgt.targetEntity, heroAttackPen);
  6428. this.posmoves.Add(pf);
  6429. }
  6430. }
  6431. // use ability
  6432. /// TODO check if ready after manaup
  6433. if (p.ownAbilityReady && p.mana >= 2 && p.ownHeroAblility.canplayCard(p))
  6434. {
  6435. int abilityPenality = 0;
  6436. havedonesomething = true;
  6437. // if we have mage or priest, we have to target something####################################################
  6438. if (this.hp.heroname == "mage" || this.hp.heroname == "priest")
  6439. {
  6440. List<targett> trgts = p.ownHeroAblility.getTargetsForCard(p);
  6441. if (isLethalCheck && (this.hp.heroname == "mage" || (this.hp.heroname == "priest" && p.ownHeroAblility.name != "lesserheal")))// only target enemy hero during Lethal check!
  6442. {
  6443. targett trg = trgts.Find(x => x.target == 200);
  6444. if (trg != null)
  6445. {
  6446. trgts.Clear();
  6447. trgts.Add(trg);
  6448. }
  6449. else
  6450. {
  6451. // no enemy hero -> enemy have taunts ->kill the taunts from left to right
  6452. if (trgts.Count >= 1)
  6453. {
  6454. trg = trgts[0];
  6455. trgts.Clear();
  6456. trgts.Add(trg);
  6457. }
  6458. }
  6459. }
  6460. foreach (targett trgt in trgts)
  6461. {
  6462. Playfield pf = new Playfield(p);
  6463. if (usePenalityManager)
  6464. {
  6465. abilityPenality = penman.getPlayCardPenality(p.ownHeroAblility, trgt.target, pf, 0);
  6466. if (abilityPenality <= 499)
  6467. {
  6468. havedonesomething = true;
  6469. pf.activateAbility(p.ownHeroAblility, trgt.target, trgt.targetEntity, abilityPenality);
  6470. this.posmoves.Add(pf);
  6471. }
  6472. }
  6473. else
  6474. {
  6475. havedonesomething = true;
  6476. pf.activateAbility(p.ownHeroAblility, trgt.target, trgt.targetEntity, abilityPenality);
  6477. this.posmoves.Add(pf);
  6478. }
  6479. }
  6480. }
  6481. else
  6482. {
  6483. // the other classes dont have to target####################################################
  6484. Playfield pf = new Playfield(p);
  6485. if (usePenalityManager)
  6486. {
  6487. abilityPenality = penman.getPlayCardPenality(p.ownHeroAblility, -1, pf, 0);
  6488. if (abilityPenality <= 499)
  6489. {
  6490. havedonesomething = true;
  6491. pf.activateAbility(p.ownHeroAblility, -1, -1, abilityPenality);
  6492. this.posmoves.Add(pf);
  6493. }
  6494. }
  6495. else
  6496. {
  6497. havedonesomething = true;
  6498. pf.activateAbility(p.ownHeroAblility, -1, -1, abilityPenality);
  6499. this.posmoves.Add(pf);
  6500. }
  6501. }
  6502. }
  6503. p.endTurn();
  6504. //sort stupid stuff ouf
  6505. if (botBase.getPlayfieldValue(p) > bestoldval)
  6506. {
  6507. bestoldval = botBase.getPlayfieldValue(p);
  6508. bestold = p;
  6509. }
  6510. if (!test)
  6511. {
  6512. posmoves.Remove(p);
  6513. }
  6514. }
  6515. if (!test && bestoldval >= -10000 && bestold != null)
  6516. {
  6517. this.posmoves.Add(bestold);
  6518. }
  6519. help.loggonoff(true);
  6520. int donec = 0;
  6521. foreach (Playfield p in posmoves)
  6522. {
  6523. if (p.complete) donec++;
  6524. }
  6525. help.logg("deep " + deep + " len " + this.posmoves.Count + " dones " + donec);
  6526. if (!test)
  6527. {
  6528. cuttingposibilities(botBase);
  6529. }
  6530. help.logg("cut to len " + this.posmoves.Count);
  6531. help.loggonoff(false);
  6532. deep++;
  6533. if (deep >= this.maxdeep) break;//remove this?
  6534. }
  6535. int bestval = int.MinValue;
  6536. int bestanzactions = 1000;
  6537. Playfield bestplay = temp[0];
  6538. foreach (Playfield p in temp)
  6539. {
  6540. int val = botBase.getPlayfieldValue(p);
  6541. if (bestval <= val)
  6542. {
  6543. if (bestval == val && bestanzactions < p.playactions.Count) continue;
  6544. bestplay = p;
  6545. bestval = val;
  6546. bestanzactions = p.playactions.Count;
  6547. }
  6548. }
  6549. help.loggonoff(true);
  6550. help.logg("-------------------------------------");
  6551. help.logg("bestPlayvalue " + bestval);
  6552. bestplay.printActions();
  6553. this.bestmove = bestplay.getNextAction();
  6554. this.bestmoveValue = bestval;
  6555. this.bestboard = new Playfield(bestplay);
  6556. /*if (bestmove != null && bestmove.cardplay && bestmove.card.type == CardDB.cardtype.MOB)
  6557. {
  6558. Playfield pf = new Playfield();
  6559. help.logg("bestplaces:");
  6560. pf.getBestPlacePrint(bestmove.card);
  6561. }*/
  6562. if (bestmove != null) // save the guessed move, so we doesnt need to recalc!
  6563. {
  6564. this.nextMoveGuess = new Playfield();
  6565. if (bestmove.cardplay)
  6566. {
  6567. //pf.playCard(c, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0, bestplace, cardplayPenality);
  6568. Handmanager.Handcard hc = this.nextMoveGuess.owncards.Find(x => x.entity == bestmove.cardEntitiy);
  6569. this.nextMoveGuess.playCard(bestmove.card, hc.position - 1, hc.entity, bestmove.enemytarget, bestmove.enemyEntitiy, bestmove.druidchoice, bestmove.owntarget, 0);
  6570. }
  6571. if (bestmove.minionplay)
  6572. {
  6573. //.attackWithMinion(m, trgt.target, trgt.targetEntity, attackPenality);
  6574. Minion m = this.nextMoveGuess.ownMinions.Find(x => x.entitiyID == bestmove.ownEntitiy);
  6575. this.nextMoveGuess.attackWithMinion(m, bestmove.enemytarget, bestmove.enemyEntitiy, 0);
  6576. }
  6577. if (bestmove.heroattack)
  6578. {
  6579. this.nextMoveGuess.attackWithWeapon(bestmove.enemytarget, bestmove.enemyEntitiy, 0);
  6580. }
  6581. if (bestmove.useability)
  6582. {
  6583. //.activateAbility(p.ownHeroAblility, trgt.target, trgt.targetEntity, abilityPenality);
  6584. this.nextMoveGuess.activateAbility(this.nextMoveGuess.ownHeroAblility, bestmove.enemytarget, bestmove.enemyEntitiy, 0);
  6585. }
  6586. this.bestboard.playactions.RemoveAt(0);
  6587. }
  6588. else
  6589. {
  6590. nextMoveGuess.mana = -1;
  6591. }
  6592. }
  6593. private void Workthread(object to)
  6594. {
  6595. threadobject trob = (threadobject)to;
  6596. bool test = trob.test;
  6597. Bot botBase = trob.botBase;
  6598. bool isLethalCheck = trob.isLethalCheck;
  6599. List<Playfield> tasks = trob.playfieldsTasklist;
  6600. int threadNumber = trob.threadnumber;
  6601. aitask retval = new aitask();
  6602. //help.logg("hello im " + threadNumber);
  6603. bool havedonesomething = false;
  6604. Playfield bestold = null;
  6605. int bestoldval = -20000000;
  6606. foreach (Playfield p in tasks)
  6607. {
  6608. if (p.complete)
  6609. {
  6610. /*if (botBase.getPlayfieldValue(p) > bestoldval)
  6611. {
  6612. bestoldval = botBase.getPlayfieldValue(p);
  6613. bestold = p;
  6614. }*/
  6615. retval.finishedStuff.Add(p);
  6616. continue;
  6617. }
  6618. //take a card and play it
  6619. List<string> playedcards = new List<string>();
  6620. foreach (Handmanager.Handcard hc in p.owncards)
  6621. {
  6622. CardDB.Card c = hc.card;
  6623. //help.logg("try play crd" + c.name + " " + c.getManaCost(p) + " " + c.canplayCard(p));
  6624. if (playedcards.Contains(c.name)) continue; // dont play the same card in one loop
  6625. playedcards.Add(c.name);
  6626. if (c.choice)
  6627. {
  6628. if (doAllChoices(c, p, hc))
  6629. {
  6630. havedonesomething = true;
  6631. }
  6632. }
  6633. else
  6634. {
  6635. int bestplace = p.getBestPlace(c);
  6636. if (c.canplayCard(p))
  6637. {
  6638. havedonesomething = true;
  6639. List<targett> trgts = c.getTargetsForCard(p);
  6640. if (isLethalCheck && (penman.DamageTargetDatabase.ContainsKey(c.name) || penman.DamageTargetSpecialDatabase.ContainsKey(c.name)))// only target enemy hero during Lethal check!
  6641. {
  6642. targett trg = trgts.Find(x => x.target == 200);
  6643. if (trg != null)
  6644. {
  6645. trgts.Clear();
  6646. trgts.Add(trg);
  6647. }
  6648. else
  6649. {
  6650. // no enemy hero -> enemy have taunts ->kill the taunts from left to right
  6651. if (trgts.Count >= 1)
  6652. {
  6653. trg = trgts[0];
  6654. trgts.Clear();
  6655. trgts.Add(trg);
  6656. }
  6657. }
  6658. }
  6659. int cardplayPenality = 0;
  6660. if (trgts.Count == 0)
  6661. {
  6662. Playfield pf = new Playfield(p);
  6663. if (usePenalityManager)
  6664. {
  6665. cardplayPenality = penman.getPlayCardPenality(c, -1, pf, 0);
  6666. if (cardplayPenality <= 499)
  6667. {
  6668. havedonesomething = true;
  6669. pf.playCard(c, hc.position - 1, hc.entity, -1, -1, 0, bestplace, cardplayPenality);
  6670. retval.newStuff.Add(pf);
  6671. }
  6672. }
  6673. else
  6674. {
  6675. havedonesomething = true;
  6676. pf.playCard(c, hc.position - 1, hc.entity, -1, -1, 0, bestplace, cardplayPenality);
  6677. retval.newStuff.Add(pf);
  6678. }
  6679. }
  6680. else
  6681. {
  6682. if (isLethalCheck)// only target enemy hero during Lethal check!
  6683. {
  6684. targett trg = trgts.Find(x => x.target == 200);
  6685. if (trg != null)
  6686. {
  6687. trgts.Clear();
  6688. trgts.Add(trg);
  6689. }
  6690. }
  6691. foreach (targett trgt in trgts)
  6692. {
  6693. Playfield pf = new Playfield(p);
  6694. if (usePenalityManager)
  6695. {
  6696. cardplayPenality = penman.getPlayCardPenality(c, trgt.target, pf, 0);
  6697. if (cardplayPenality <= 499)
  6698. {
  6699. havedonesomething = true;
  6700. pf.playCard(c, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0, bestplace, cardplayPenality);
  6701. retval.newStuff.Add(pf);
  6702. }
  6703. }
  6704. else
  6705. {
  6706. havedonesomething = true;
  6707. pf.playCard(c, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0, bestplace, cardplayPenality);
  6708. retval.newStuff.Add(pf);
  6709. }
  6710. }
  6711. }
  6712. }
  6713. }
  6714. }
  6715. //attack with a minion
  6716. List<Minion> playedMinions = new List<Minion>(8);
  6717. foreach (Minion m in p.ownMinions)
  6718. {
  6719. if (m.Ready && m.Angr >= 1 && !m.frozen)
  6720. {
  6721. //BEGIN:cut (double/similar) attacking minions out#####################################
  6722. // DONT LET SIMMILAR MINIONS ATTACK IN ONE TURN (example 3 unlesh the hounds-hounds doesnt need to simulated hole)
  6723. List<Minion> tempoo = new List<Minion>(playedMinions);
  6724. bool dontattacked = true;
  6725. bool isSpecial = penman.specialMinions.ContainsKey(m.name);
  6726. foreach (Minion mnn in tempoo)
  6727. {
  6728. // special minions are allowed to attack in silended and unsilenced state!
  6729. //help.logg(mnn.silenced + " " + m.silenced + " " + mnn.name + " " + m.name + " " + penman.specialMinions.ContainsKey(m.name));
  6730. bool otherisSpecial = penman.specialMinions.ContainsKey(mnn.name);
  6731. if ((!isSpecial || (isSpecial && m.silenced)) && (!otherisSpecial || (otherisSpecial && mnn.silenced))) // both are not special, if they are the same, dont add
  6732. {
  6733. if (mnn.Angr == m.Angr && mnn.Hp == m.Hp && mnn.divineshild == m.divineshild && mnn.taunt == m.taunt && mnn.poisonous == m.poisonous) dontattacked = false;
  6734. continue;
  6735. }
  6736. if (isSpecial == otherisSpecial && !m.silenced && !mnn.silenced) // same are special
  6737. {
  6738. if (m.name != mnn.name) // different name -> take it
  6739. {
  6740. continue;
  6741. }
  6742. // same name -> test whether they are equal
  6743. if (mnn.Angr == m.Angr && mnn.Hp == m.Hp && mnn.divineshild == m.divineshild && mnn.taunt == m.taunt && mnn.poisonous == m.poisonous) dontattacked = false;
  6744. continue;
  6745. }
  6746. }
  6747. if (dontattacked)
  6748. {
  6749. playedMinions.Add(m);
  6750. }
  6751. else
  6752. {
  6753. //help.logg(m.name + " doesnt need to attack!");
  6754. continue;
  6755. }
  6756. //END: cut (double/similar) attacking minions out#####################################
  6757. //help.logg(m.name + " is going to attack!");
  6758. List<targett> trgts = p.getAttackTargets();
  6759. if (isLethalCheck)// only target enemy hero during Lethal check!
  6760. {
  6761. targett trg = trgts.Find(x => x.target == 200);
  6762. if (trg != null)
  6763. {
  6764. trgts.Clear();
  6765. trgts.Add(trg);
  6766. }
  6767. else
  6768. {
  6769. // no enemy hero -> enemy have taunts ->kill the taunts from left to right
  6770. if (trgts.Count >= 1)
  6771. {
  6772. trg = trgts[0];
  6773. trgts.Clear();
  6774. trgts.Add(trg);
  6775. }
  6776. }
  6777. }
  6778. else
  6779. {
  6780. if (this.useCutingTargets) trgts = this.cutAttackTargets(trgts, p);
  6781. }
  6782. foreach (targett trgt in trgts)
  6783. {
  6784. Playfield pf = new Playfield(p);
  6785. int attackPenality = 0;
  6786. if (usePenalityManager)
  6787. {
  6788. attackPenality = penman.getAttackWithMininonPenality(m, pf, trgt.target);
  6789. if (attackPenality <= 499)
  6790. {
  6791. havedonesomething = true;
  6792. pf.attackWithMinion(m, trgt.target, trgt.targetEntity, attackPenality);
  6793. retval.newStuff.Add(pf);
  6794. }
  6795. }
  6796. else
  6797. {
  6798. havedonesomething = true;
  6799. pf.attackWithMinion(m, trgt.target, trgt.targetEntity, attackPenality);
  6800. retval.newStuff.Add(pf);
  6801. }
  6802. }
  6803. if (trgts.Count == 1 && trgts[0].target == 200)//only enemy hero is available als attack
  6804. {
  6805. break;
  6806. }
  6807. }
  6808. }
  6809. // attack with hero
  6810. if (p.ownHeroReady)
  6811. {
  6812. List<targett> trgts = p.getAttackTargets();
  6813. havedonesomething = true;
  6814. if (isLethalCheck)// only target enemy hero during Lethal check!
  6815. {
  6816. targett trg = trgts.Find(x => x.target == 200);
  6817. if (trg != null)
  6818. {
  6819. trgts.Clear();
  6820. trgts.Add(trg);
  6821. }
  6822. else
  6823. {
  6824. // no enemy hero -> enemy have taunts ->kill the taunts from left to right
  6825. if (trgts.Count >= 1)
  6826. {
  6827. trg = trgts[0];
  6828. trgts.Clear();
  6829. trgts.Add(trg);
  6830. }
  6831. }
  6832. }
  6833. else
  6834. {
  6835. if (this.useCutingTargets) trgts = this.cutAttackTargets(trgts, p);
  6836. }
  6837. foreach (targett trgt in trgts)
  6838. {
  6839. Playfield pf = new Playfield(p);
  6840. int heroAttackPen = 0;
  6841. if (usePenalityManager)
  6842. {
  6843. heroAttackPen = penman.getAttackWithHeroPenality(trgt.target, p);
  6844. }
  6845. pf.attackWithWeapon(trgt.target, trgt.targetEntity, heroAttackPen);
  6846. retval.newStuff.Add(pf);
  6847. }
  6848. }
  6849. // use ability
  6850. /// TODO check if ready after manaup
  6851. if (p.ownAbilityReady && p.mana >= 2 && p.ownHeroAblility.canplayCard(p))
  6852. {
  6853. int abilityPenality = 0;
  6854. havedonesomething = true;
  6855. // if we have mage or priest, we have to target something####################################################
  6856. if (this.hp.heroname == "mage" || this.hp.heroname == "priest")
  6857. {
  6858. List<targett> trgts = p.ownHeroAblility.getTargetsForCard(p);
  6859. if (isLethalCheck && (this.hp.heroname == "mage" || (this.hp.heroname == "priest" && p.ownHeroAblility.name != "lesserheal")))// only target enemy hero during Lethal check!
  6860. {
  6861. targett trg = trgts.Find(x => x.target == 200);
  6862. if (trg != null)
  6863. {
  6864. trgts.Clear();
  6865. trgts.Add(trg);
  6866. }
  6867. else
  6868. {
  6869. // no enemy hero -> enemy have taunts ->kill the taunts from left to right
  6870. if (trgts.Count >= 1)
  6871. {
  6872. trg = trgts[0];
  6873. trgts.Clear();
  6874. trgts.Add(trg);
  6875. }
  6876. }
  6877. }
  6878. foreach (targett trgt in trgts)
  6879. {
  6880. Playfield pf = new Playfield(p);
  6881. if (usePenalityManager)
  6882. {
  6883. abilityPenality = penman.getPlayCardPenality(p.ownHeroAblility, trgt.target, pf, 0);
  6884. if (abilityPenality <= 499)
  6885. {
  6886. havedonesomething = true;
  6887. pf.activateAbility(p.ownHeroAblility, trgt.target, trgt.targetEntity, abilityPenality);
  6888. retval.newStuff.Add(pf);
  6889. }
  6890. }
  6891. else
  6892. {
  6893. havedonesomething = true;
  6894. pf.activateAbility(p.ownHeroAblility, trgt.target, trgt.targetEntity, abilityPenality);
  6895. retval.newStuff.Add(pf);
  6896. }
  6897. }
  6898. }
  6899. else
  6900. {
  6901. // the other classes dont have to target####################################################
  6902. Playfield pf = new Playfield(p);
  6903. if (usePenalityManager)
  6904. {
  6905. abilityPenality = penman.getPlayCardPenality(p.ownHeroAblility, -1, pf, 0);
  6906. if (abilityPenality <= 499)
  6907. {
  6908. havedonesomething = true;
  6909. pf.activateAbility(p.ownHeroAblility, -1, -1, abilityPenality);
  6910. retval.newStuff.Add(pf);
  6911. }
  6912. }
  6913. else
  6914. {
  6915. havedonesomething = true;
  6916. pf.activateAbility(p.ownHeroAblility, -1, -1, abilityPenality);
  6917. retval.newStuff.Add(pf);
  6918. }
  6919. }
  6920. }
  6921. p.endTurn();
  6922. //sort stupid stuff ouf
  6923. if (botBase.getPlayfieldValue(p) > bestoldval)
  6924. {
  6925. bestoldval = botBase.getPlayfieldValue(p);
  6926. bestold = p;
  6927. }
  6928. }
  6929. retval.bestbard = bestold;
  6930. retval.finishedValue = bestoldval;
  6931. retval.havedonesomething = havedonesomething;
  6932. this.threadResults[threadNumber] = retval;
  6933. }
  6934. private void doallmovesParallel(bool test, Bot botBase, bool isLethalCheck)
  6935. {
  6936. bool havedonesomething = true;
  6937. List<Playfield> temp = new List<Playfield>();
  6938. int deep = 0;
  6939. while (havedonesomething)
  6940. {
  6941. help.logg("ailoop");
  6942. GC.Collect();
  6943. temp.Clear();
  6944. temp.AddRange(this.posmoves);
  6945. havedonesomething = false;
  6946. Playfield bestold = null;
  6947. int bestoldval = -20000000;
  6948. //help.logg("create taskts");
  6949. List<System.Threading.Thread> tasks = new List<System.Threading.Thread>(this.numberOfThreads);
  6950. List<List<Playfield>> playfieldsTasklist = new List<List<Playfield>>(this.numberOfThreads);
  6951. this.threadResults.Clear();
  6952. for (int j = 0; j < this.numberOfThreads; j++)
  6953. {
  6954. this.threadResults.Add(new aitask());
  6955. this.threadnumbers.Add(j);
  6956. playfieldsTasklist.Add(new List<Playfield>());
  6957. }
  6958. int i = 0;
  6959. // distribute playfields
  6960. //help.logg("distribute boards");
  6961. foreach (Playfield p in temp)
  6962. {
  6963. int targetP = (i % this.numberOfThreads);
  6964. playfieldsTasklist[targetP].Add(p);
  6965. i++;
  6966. }
  6967. // start taskts
  6968. //help.logg("create taskts");
  6969. int k = 0;
  6970. for (k = 0; k < this.numberOfThreads; k++)
  6971. {
  6972. //System.Threading.Thread threadl = new System.Threading.Thread(() => this.Workthread(test, botBase, isLethalCheck, playfieldsTasklist[k], threadnumbers[k]));
  6973. System.Threading.Thread threadl = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(this.Workthread));
  6974. threadl.Start((object)new threadobject(test, botBase, isLethalCheck, playfieldsTasklist[k], threadnumbers[k]));
  6975. tasks.Add(threadl);
  6976. }
  6977. this.posmoves.Clear();
  6978. // collect results
  6979. System.Threading.Thread.Sleep(1);
  6980. for (int j = 0; j < this.numberOfThreads; j++)
  6981. {
  6982. tasks[j].Join();
  6983. aitask at = this.threadResults[j];
  6984. if (at.havedonesomething) havedonesomething = true;
  6985. posmoves.AddRange(at.newStuff);
  6986. this.posmoves.AddRange(at.finishedStuff);
  6987. if (at.bestbard != null && at.finishedValue > bestoldval)
  6988. {
  6989. help.logg("change bestboard");
  6990. bestoldval = at.finishedValue;
  6991. bestold = at.bestbard;
  6992. }
  6993. }
  6994. if (!test && bestoldval >= -10000 && bestold != null)
  6995. {
  6996. this.posmoves.Add(bestold);
  6997. }
  6998. help.loggonoff(true);
  6999. int donec = 0;
  7000. foreach (Playfield p in posmoves)
  7001. {
  7002. if (p.complete) donec++;
  7003. }
  7004. help.logg("deep " + deep + " len " + this.posmoves.Count + " dones " + donec);
  7005. if (!test)
  7006. {
  7007. cuttingposibilities(botBase);
  7008. }
  7009. help.logg("cut to len " + this.posmoves.Count);
  7010. help.loggonoff(false);
  7011. deep++;
  7012. if (deep >= this.maxdeep) break;//remove this?
  7013. }
  7014. int bestval = int.MinValue;
  7015. int bestanzactions = 1000;
  7016. Playfield bestplay = temp[0];
  7017. foreach (Playfield p in temp)
  7018. {
  7019. int val = botBase.getPlayfieldValue(p);
  7020. if (bestval <= val)
  7021. {
  7022. if (bestval == val && bestanzactions < p.playactions.Count) continue;
  7023. bestplay = p;
  7024. bestval = val;
  7025. bestanzactions = p.playactions.Count;
  7026. }
  7027. }
  7028. help.loggonoff(true);
  7029. help.logg("-------------------------------------");
  7030. help.logg("bestPlayvalue " + bestval);
  7031. bestplay.printActions();
  7032. this.bestmove = bestplay.getNextAction();
  7033. this.bestmoveValue = bestval;
  7034. this.bestboard = new Playfield(bestplay);
  7035. /*if (bestmove != null && bestmove.cardplay && bestmove.card.type == CardDB.cardtype.MOB)
  7036. {
  7037. Playfield pf = new Playfield();
  7038. help.logg("bestplaces:");
  7039. pf.getBestPlacePrint(bestmove.card);
  7040. }*/
  7041. if (bestmove != null) // save the guessed move, so we doesnt need to recalc!
  7042. {
  7043. this.nextMoveGuess = new Playfield();
  7044. if (bestmove.cardplay)
  7045. {
  7046. //pf.playCard(c, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0, bestplace, cardplayPenality);
  7047. Handmanager.Handcard hc = this.nextMoveGuess.owncards.Find(x => x.entity == bestmove.cardEntitiy);
  7048. this.nextMoveGuess.playCard(bestmove.card, hc.position - 1, hc.entity, bestmove.enemytarget, bestmove.enemyEntitiy, bestmove.druidchoice, bestmove.owntarget, 0);
  7049. }
  7050. if (bestmove.minionplay)
  7051. {
  7052. //.attackWithMinion(m, trgt.target, trgt.targetEntity, attackPenality);
  7053. Minion m = this.nextMoveGuess.ownMinions.Find(x => x.entitiyID == bestmove.ownEntitiy);
  7054. this.nextMoveGuess.attackWithMinion(m, bestmove.enemytarget, bestmove.enemyEntitiy, 0);
  7055. }
  7056. if (bestmove.heroattack)
  7057. {
  7058. this.nextMoveGuess.attackWithWeapon(bestmove.enemytarget, bestmove.enemyEntitiy, 0);
  7059. }
  7060. if (bestmove.useability)
  7061. {
  7062. //.activateAbility(p.ownHeroAblility, trgt.target, trgt.targetEntity, abilityPenality);
  7063. this.nextMoveGuess.activateAbility(this.nextMoveGuess.ownHeroAblility, bestmove.enemytarget, bestmove.enemyEntitiy, 0);
  7064. }
  7065. this.bestboard.playactions.RemoveAt(0);
  7066. }
  7067. else
  7068. {
  7069. nextMoveGuess.mana = -1;
  7070. }
  7071. }
  7072. private void cuttingposibilities(Bot botBase)
  7073. {
  7074. // take the x best values
  7075. int takenumber = this.maxwide;
  7076. List<Playfield> temp = new List<Playfield>();
  7077. posmoves.Sort((a, b) => -(botBase.getPlayfieldValue(a)).CompareTo(botBase.getPlayfieldValue(b)));//want to keep the best
  7078. temp.AddRange(posmoves);
  7079. posmoves.Clear();
  7080. posmoves.AddRange(Helpfunctions.TakeList(temp, takenumber));
  7081. }
  7082. private List<targett> cutAttackTargets(List<targett> oldlist, Playfield p)
  7083. {
  7084. List<targett> retvalues = new List<targett>();
  7085. List<Minion> addedmins = new List<Minion>(8);
  7086. bool priomins = false;
  7087. List<targett> retvaluesPrio = new List<targett>();
  7088. foreach (targett t in oldlist)
  7089. {
  7090. if (t.target == 200)
  7091. {
  7092. retvalues.Add(t);
  7093. continue;
  7094. }
  7095. if (t.target >= 10 && t.target <= 20)
  7096. {
  7097. Minion m = p.enemyMinions[t.target - 10];
  7098. if (penman.priorityDatabase.ContainsKey(m.name))
  7099. {
  7100. retvaluesPrio.Add(t);
  7101. priomins = true;
  7102. //help.logg(m.name + " is added to targetlist");
  7103. continue;
  7104. }
  7105. bool goingtoadd = true;
  7106. List<Minion> temp = new List<Minion>(addedmins);
  7107. bool isSpecial = penman.specialMinions.ContainsKey(m.name);
  7108. foreach (Minion mnn in temp)
  7109. {
  7110. // special minions are allowed to attack in silended and unsilenced state!
  7111. //help.logg(mnn.silenced + " " + m.silenced + " " + mnn.name + " " + m.name + " " + penman.specialMinions.ContainsKey(m.name));
  7112. bool otherisSpecial = penman.specialMinions.ContainsKey(mnn.name);
  7113. if ((!isSpecial || (isSpecial && m.silenced)) && (!otherisSpecial || (otherisSpecial && mnn.silenced))) // both are not special, if they are the same, dont add
  7114. {
  7115. if (mnn.Angr == m.Angr && mnn.Hp == m.Hp && mnn.divineshild == m.divineshild && mnn.taunt == m.taunt && mnn.poisonous == m.poisonous) goingtoadd = false;
  7116. continue;
  7117. }
  7118. if (isSpecial == otherisSpecial && !m.silenced && !mnn.silenced) // same are special
  7119. {
  7120. if (m.name != mnn.name) // different name -> take it
  7121. {
  7122. continue;
  7123. }
  7124. // same name -> test whether they are equal
  7125. if (mnn.Angr == m.Angr && mnn.Hp == m.Hp && mnn.divineshild == m.divineshild && mnn.taunt == m.taunt && mnn.poisonous == m.poisonous) goingtoadd = false;
  7126. continue;
  7127. }
  7128. }
  7129. if (goingtoadd)
  7130. {
  7131. addedmins.Add(m);
  7132. retvalues.Add(t);
  7133. //help.logg(m.name + " " + m.id +" is added to targetlist");
  7134. }
  7135. else
  7136. {
  7137. //help.logg(m.name + " is not needed to attack");
  7138. continue;
  7139. }
  7140. }
  7141. }
  7142. //help.logg("end targetcutting");
  7143. if (priomins) return retvaluesPrio;
  7144. return retvalues;
  7145. }
  7146. private void doNextCalcedMove()
  7147. {
  7148. help.logg("noRecalcNeeded!!!-----------------------------------");
  7149. this.bestboard.printActions();
  7150. this.bestmove = this.bestboard.getNextAction();
  7151. if (bestmove != null) // save the guessed move, so we doesnt need to recalc!
  7152. {
  7153. this.nextMoveGuess = new Playfield();
  7154. if (bestmove.cardplay)
  7155. {
  7156. //pf.playCard(c, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0, bestplace, cardplayPenality);
  7157. Handmanager.Handcard hc = this.nextMoveGuess.owncards.Find(x => x.entity == bestmove.cardEntitiy);
  7158. if (bestmove.owntarget >= 0 && bestmove.enemytarget >= 0 && bestmove.enemytarget <= 9 && bestmove.owntarget < bestmove.enemytarget)
  7159. {
  7160. this.nextMoveGuess.playCard(bestmove.card, hc.position - 1, hc.entity, bestmove.enemytarget - 1, bestmove.enemyEntitiy, bestmove.druidchoice, bestmove.owntarget, 0);
  7161. }
  7162. else
  7163. {
  7164. this.nextMoveGuess.playCard(bestmove.card, hc.position - 1, hc.entity, bestmove.enemytarget, bestmove.enemyEntitiy, bestmove.druidchoice, bestmove.owntarget, 0);
  7165. }
  7166. }
  7167. if (bestmove.minionplay)
  7168. {
  7169. //.attackWithMinion(m, trgt.target, trgt.targetEntity, attackPenality);
  7170. Minion m = this.nextMoveGuess.ownMinions.Find(x => x.entitiyID == bestmove.ownEntitiy);
  7171. this.nextMoveGuess.attackWithMinion(m, bestmove.enemytarget, bestmove.enemyEntitiy, 0);
  7172. }
  7173. if (bestmove.heroattack)
  7174. {
  7175. this.nextMoveGuess.attackWithWeapon(bestmove.enemytarget, bestmove.enemyEntitiy, 0);
  7176. }
  7177. if (bestmove.useability)
  7178. {
  7179. //.activateAbility(p.ownHeroAblility, trgt.target, trgt.targetEntity, abilityPenality);
  7180. this.nextMoveGuess.activateAbility(this.nextMoveGuess.ownHeroAblility, bestmove.enemytarget, bestmove.enemyEntitiy, 0);
  7181. }
  7182. this.bestboard.playactions.RemoveAt(0);
  7183. }
  7184. else
  7185. {
  7186. nextMoveGuess.mana = -1;
  7187. }
  7188. }
  7189. public void dosomethingclever(Bot botbase)
  7190. {
  7191. //return;
  7192. //turncheck
  7193. //help.moveMouse(950,750);
  7194. //help.Screenshot();
  7195. hp.updatePositions();
  7196. posmoves.Clear();
  7197. posmoves.Add(new Playfield());
  7198. /* foreach (var item in this.posmoves[0].owncards)
  7199. {
  7200. help.logg("card " + item.card.name + " is playable :" + item.card.canplayCard(posmoves[0]) + " cost/mana: " + item.card.cost + "/" + posmoves[0].mana);
  7201. }
  7202. */
  7203. //help.logg("is hero ready?" + posmoves[0].ownHeroReady);
  7204. help.loggonoff(false);
  7205. //do we need to recalc?
  7206. help.logg("recalc-check###########");
  7207. if (this.dontRecalc && posmoves[0].isEqual(this.nextMoveGuess))
  7208. {
  7209. doNextCalcedMove();
  7210. }
  7211. else
  7212. {
  7213. help.logg("Leathal-check###########");
  7214. bestmoveValue = -1000000;
  7215. if (useThreads)
  7216. {
  7217. if (useLethalCheck) doallmovesParallel(false, botbase, true);
  7218. }
  7219. else
  7220. {
  7221. if (useLethalCheck) doallmoves(false, botbase, true);
  7222. }
  7223. if (bestmoveValue < 10000)
  7224. {
  7225. posmoves.Clear();
  7226. posmoves.Add(new Playfield());
  7227. help.logg("no lethal, do something random######");
  7228. if (useThreads)
  7229. {
  7230. doallmovesParallel(false, botbase, false);
  7231. }
  7232. else
  7233. {
  7234. doallmoves(false, botbase, false);
  7235. }
  7236. }
  7237. }
  7238. //help.logging(true);
  7239. }
  7240. public void doBenchmark(Bot botbase)
  7241. {
  7242. help.logg("do benchmark, dont cry");
  7243. //setup cards in hand
  7244. this.hm.loadPreparedBattlefield(10);
  7245. this.hp.loadPreparedHeros(0);//setup hero hp, weapons and stuff
  7246. //setup minions on field
  7247. this.hp.loadPreparedBattlefield(10);
  7248. //calculate the stuff
  7249. posmoves.Clear();
  7250. posmoves.Add(new Playfield());
  7251. foreach (Playfield p in this.posmoves)
  7252. {
  7253. p.printBoard();
  7254. }
  7255. help.logg("ownminionscount " + posmoves[0].ownMinions.Count);
  7256. help.logg("owncardscount " + posmoves[0].owncards.Count);
  7257. foreach (var item in this.posmoves[0].owncards)
  7258. {
  7259. help.logg("card " + item.card.name + " is playable :" + item.card.canplayCard(posmoves[0]) + " cost/mana: " + item.card.cost + "/" + posmoves[0].mana);
  7260. }
  7261. doallmoves(true, botbase, false);
  7262. }
  7263. public void simulatorTester(Bot botbase)
  7264. {
  7265. help.logg("simulating board ");
  7266. //setup cards in hand
  7267. this.hm.loadPreparedBattlefield(5);
  7268. this.hp.loadPreparedHeros(0);//setup hero hp, weapons and stuff
  7269. //setup minions on field
  7270. this.hp.loadPreparedBattlefield(5);
  7271. //calculate the stuff
  7272. posmoves.Clear();
  7273. posmoves.Add(new Playfield());
  7274. foreach (Playfield p in this.posmoves)
  7275. {
  7276. p.printBoard();
  7277. }
  7278. help.logg("ownminionscount " + posmoves[0].ownMinions.Count);
  7279. help.logg("owncardscount " + posmoves[0].owncards.Count);
  7280. foreach (var item in this.posmoves[0].owncards)
  7281. {
  7282. help.logg("card " + item.card.name + " is playable :" + item.card.canplayCard(posmoves[0]) + " cost/mana: " + item.card.cost + "/" + posmoves[0].mana);
  7283. }
  7284. doallmoves(true, botbase, false);
  7285. foreach (Playfield p in this.posmoves)
  7286. {
  7287. p.printBoard();
  7288. }
  7289. }
  7290. public void autoTester(Bot botbase)
  7291. {
  7292. help.logg("simulating board ");
  7293. BoardTester bt = new BoardTester();
  7294. hp.printHero();
  7295. hp.printOwnMinions();
  7296. hp.printEnemyMinions();
  7297. hm.printcards();
  7298. //calculate the stuff
  7299. posmoves.Clear();
  7300. posmoves.Add(new Playfield());
  7301. foreach (Playfield p in this.posmoves)
  7302. {
  7303. p.printBoard();
  7304. }
  7305. help.logg("ownminionscount " + posmoves[0].ownMinions.Count);
  7306. help.logg("owncardscount " + posmoves[0].owncards.Count);
  7307. foreach (var item in this.posmoves[0].owncards)
  7308. {
  7309. help.logg("card " + item.card.name + " is playable :" + item.card.canplayCard(posmoves[0]) + " cost/mana: " + item.card.cost + "/" + posmoves[0].mana);
  7310. }
  7311. help.logg("ability " + posmoves[0].ownHeroAblility.name + " is playable :" + posmoves[0].ownHeroAblility.canplayCard(posmoves[0]) + " cost/mana: " + posmoves[0].ownHeroAblility.cost + "/" + posmoves[0].mana);
  7312. // lethalcheck + normal
  7313. doallmoves(false, botbase, true);
  7314. if (bestmoveValue < 10000)
  7315. {
  7316. posmoves.Clear();
  7317. posmoves.Add(new Playfield());
  7318. doallmoves(false, botbase, false);
  7319. }
  7320. foreach (Playfield p in this.posmoves)
  7321. {
  7322. p.printBoard();
  7323. }
  7324. help.logg("bestfield");
  7325. bestboard.printBoard();
  7326. //simmulateWholeTurn();
  7327. }
  7328. public void autoTesterParallel(Bot botbase)
  7329. {
  7330. help.logg("simulating board ");
  7331. BoardTester bt = new BoardTester();
  7332. hp.printHero();
  7333. hp.printOwnMinions();
  7334. hp.printEnemyMinions();
  7335. hm.printcards();
  7336. //calculate the stuff
  7337. posmoves.Clear();
  7338. posmoves.Add(new Playfield());
  7339. foreach (Playfield p in this.posmoves)
  7340. {
  7341. p.printBoard();
  7342. }
  7343. help.logg("ownminionscount " + posmoves[0].ownMinions.Count);
  7344. help.logg("owncardscount " + posmoves[0].owncards.Count);
  7345. foreach (var item in this.posmoves[0].owncards)
  7346. {
  7347. help.logg("card " + item.card.name + " is playable :" + item.card.canplayCard(posmoves[0]) + " cost/mana: " + item.card.cost + "/" + posmoves[0].mana);
  7348. }
  7349. help.logg("ability " + posmoves[0].ownHeroAblility.name + " is playable :" + posmoves[0].ownHeroAblility.canplayCard(posmoves[0]) + " cost/mana: " + posmoves[0].ownHeroAblility.cost + "/" + posmoves[0].mana);
  7350. // lethalcheck + normal
  7351. help.logg(DateTime.Now.ToString("hh:mm:ss.fff"));
  7352. doallmovesParallel(false, botbase, true);
  7353. help.logg(DateTime.Now.ToString("hh:mm:ss.fff"));
  7354. if (bestmoveValue < 10000)
  7355. {
  7356. posmoves.Clear();
  7357. posmoves.Add(new Playfield());
  7358. help.logg(DateTime.Now.ToString("hh:mm:ss.fff"));
  7359. doallmovesParallel(false, botbase, false);
  7360. help.logg(DateTime.Now.ToString("hh:mm:ss.fff"));
  7361. }
  7362. foreach (Playfield p in this.posmoves)
  7363. {
  7364. p.printBoard();
  7365. }
  7366. help.logg("bestfield");
  7367. bestboard.printBoard();
  7368. }
  7369. public void simmulateWholeTurn()
  7370. {
  7371. help.logg("simulate best board");
  7372. //this.bestboard.printActions();
  7373. Playfield tempbestboard = new Playfield();
  7374. if (bestmove != null) // save the guessed move, so we doesnt need to recalc!
  7375. {
  7376. bestmove.print();
  7377. if (bestmove.cardplay)
  7378. {
  7379. help.logg("card");
  7380. //pf.playCard(c, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0, bestplace, cardplayPenality);
  7381. Handmanager.Handcard hc = tempbestboard.owncards.Find(x => x.entity == bestmove.cardEntitiy);
  7382. if (bestmove.owntarget >= 0 && bestmove.enemytarget >= 0 && bestmove.enemytarget <= 9 && bestmove.owntarget < bestmove.enemytarget)
  7383. {
  7384. tempbestboard.playCard(bestmove.card, hc.position - 1, hc.entity, bestmove.enemytarget - 1, bestmove.enemyEntitiy, bestmove.druidchoice, bestmove.owntarget, 0);
  7385. }
  7386. else
  7387. {
  7388. tempbestboard.playCard(bestmove.card, hc.position - 1, hc.entity, bestmove.enemytarget, bestmove.enemyEntitiy, bestmove.druidchoice, bestmove.owntarget, 0);
  7389. }
  7390. }
  7391. if (bestmove.minionplay)
  7392. {
  7393. help.logg("min");
  7394. //.attackWithMinion(m, trgt.target, trgt.targetEntity, attackPenality);
  7395. Minion mm = tempbestboard.ownMinions.Find(x => x.entitiyID == bestmove.ownEntitiy);
  7396. help.logg("min");
  7397. tempbestboard.attackWithMinion(mm, bestmove.enemytarget, bestmove.enemyEntitiy, 0);
  7398. help.logg("min");
  7399. }
  7400. if (bestmove.heroattack)
  7401. {
  7402. help.logg("hero");
  7403. tempbestboard.attackWithWeapon(bestmove.enemytarget, bestmove.enemyEntitiy, 0);
  7404. }
  7405. if (bestmove.useability)
  7406. {
  7407. help.logg("abi");
  7408. //.activateAbility(p.ownHeroAblility, trgt.target, trgt.targetEntity, abilityPenality);
  7409. tempbestboard.activateAbility(this.nextMoveGuess.ownHeroAblility, bestmove.enemytarget, bestmove.enemyEntitiy, 0);
  7410. }
  7411. }
  7412. else
  7413. {
  7414. tempbestboard.mana = -1;
  7415. }
  7416. help.logg("-------------");
  7417. help.logg("OwnMinions:");
  7418. foreach (Minion m in tempbestboard.ownMinions)
  7419. {
  7420. help.logg(m.name + " id " + m.id + " zp " + m.zonepos + " " + " e:" + m.entitiyID + " " + " A:" + m.Angr + " H:" + m.Hp + " mH:" + m.maxHp + " rdy:" + m.Ready + " tnt:" + m.taunt + " frz:" + m.frozen + " silenced:" + m.silenced + " divshield:" + m.divineshild + " ptt:" + m.playedThisTurn + " wndfr:" + m.windfury + " natt:" + m.numAttacksThisTurn + " sil:" + m.silenced + " stl:" + m.stealth + " poi:" + m.poisonous + " imm:" + m.immune + " ex:" + m.exhausted + " chrg:" + m.charge);
  7421. foreach (Enchantment e in m.enchantments)
  7422. {
  7423. help.logg(e.CARDID + " " + e.creator + " " + e.controllerOfCreator);
  7424. }
  7425. }
  7426. help.logg("EnemyMinions:");
  7427. foreach (Minion m in tempbestboard.enemyMinions)
  7428. {
  7429. help.logg(m.name + " id " + m.id + " zp " + m.zonepos + " " + " e:" + m.entitiyID + " " + " A:" + m.Angr + " H:" + m.Hp + " mH:" + m.maxHp + " rdy:" + m.Ready + " tnt:" + m.taunt + " frz:" + m.frozen + " silenced:" + m.silenced + " divshield:" + m.divineshild + " wndfr:" + m.windfury + " sil:" + m.silenced + " stl:" + m.stealth + " poi:" + m.poisonous + " imm:" + m.immune + " ex:" + m.exhausted);
  7430. foreach (Enchantment e in m.enchantments)
  7431. {
  7432. help.logg(e.CARDID + " " + e.creator + " " + e.controllerOfCreator);
  7433. }
  7434. }
  7435. foreach (Action bestmovee in bestboard.playactions)
  7436. {
  7437. help.logg("stepp");
  7438. if (bestmovee != null) // save the guessed move, so we doesnt need to recalc!
  7439. {
  7440. bestmovee.print();
  7441. if (bestmovee.cardplay)
  7442. {
  7443. help.logg("card");
  7444. //pf.playCard(c, hc.position - 1, hc.entity, trgt.target, trgt.targetEntity, 0, bestplace, cardplayPenality);
  7445. Handmanager.Handcard hc = tempbestboard.owncards.Find(x => x.entity == bestmovee.cardEntitiy);
  7446. if (bestmovee.owntarget >= 0 && bestmovee.enemytarget >= 0 && bestmovee.enemytarget <= 9 && bestmovee.owntarget < bestmovee.enemytarget)
  7447. {
  7448. tempbestboard.playCard(bestmovee.card, hc.position - 1, hc.entity, bestmovee.enemytarget - 1, bestmovee.enemyEntitiy, bestmovee.druidchoice, bestmovee.owntarget, 0);
  7449. }
  7450. else
  7451. {
  7452. tempbestboard.playCard(bestmovee.card, hc.position - 1, hc.entity, bestmovee.enemytarget, bestmovee.enemyEntitiy, bestmovee.druidchoice, bestmovee.owntarget, 0);
  7453. }
  7454. }
  7455. if (bestmovee.minionplay)
  7456. {
  7457. help.logg("min");
  7458. //.attackWithMinion(m, trgt.target, trgt.targetEntity, attackPenality);
  7459. Minion mm = tempbestboard.ownMinions.Find(x => x.entitiyID == bestmovee.ownEntitiy);
  7460. help.logg("min");
  7461. tempbestboard.attackWithMinion(mm, bestmovee.enemytarget, bestmovee.enemyEntitiy, 0);
  7462. help.logg("min");
  7463. }
  7464. if (bestmovee.heroattack)
  7465. {
  7466. help.logg("hero");
  7467. tempbestboard.attackWithWeapon(bestmovee.enemytarget, bestmovee.enemyEntitiy, 0);
  7468. }
  7469. if (bestmovee.useability)
  7470. {
  7471. help.logg("abi");
  7472. //.activateAbility(p.ownHeroAblility, trgt.target, trgt.targetEntity, abilityPenality);
  7473. tempbestboard.activateAbility(this.nextMoveGuess.ownHeroAblility, bestmovee.enemytarget, bestmovee.enemyEntitiy, 0);
  7474. }
  7475. }
  7476. else
  7477. {
  7478. tempbestboard.mana = -1;
  7479. }
  7480. help.logg("-------------");
  7481. help.logg("OwnMinions:");
  7482. foreach (Minion m in tempbestboard.ownMinions)
  7483. {
  7484. help.logg(m.name + " id " + m.id + " zp " + m.zonepos + " " + " e:" + m.entitiyID + " " + " A:" + m.Angr + " H:" + m.Hp + " mH:" + m.maxHp + " rdy:" + m.Ready + " tnt:" + m.taunt + " frz:" + m.frozen + " silenced:" + m.silenced + " divshield:" + m.divineshild + " ptt:" + m.playedThisTurn + " wndfr:" + m.windfury + " natt:" + m.numAttacksThisTurn + " sil:" + m.silenced + " stl:" + m.stealth + " poi:" + m.poisonous + " imm:" + m.immune + " ex:" + m.exhausted + " chrg:" + m.charge);
  7485. foreach (Enchantment e in m.enchantments)
  7486. {
  7487. help.logg(e.CARDID + " " + e.creator + " " + e.controllerOfCreator);
  7488. }
  7489. }
  7490. help.logg("EnemyMinions:");
  7491. foreach (Minion m in tempbestboard.enemyMinions)
  7492. {
  7493. help.logg(m.name + " id " + m.id + " zp " + m.zonepos + " " + " e:" + m.entitiyID + " " + " A:" + m.Angr + " H:" + m.Hp + " mH:" + m.maxHp + " rdy:" + m.Ready + " tnt:" + m.taunt + " frz:" + m.frozen + " silenced:" + m.silenced + " divshield:" + m.divineshild + " wndfr:" + m.windfury + " sil:" + m.silenced + " stl:" + m.stealth + " poi:" + m.poisonous + " imm:" + m.immune + " ex:" + m.exhausted);
  7494. foreach (Enchantment e in m.enchantments)
  7495. {
  7496. help.logg(e.CARDID + " " + e.creator + " " + e.controllerOfCreator);
  7497. }
  7498. }
  7499. }
  7500. }
  7501. }
  7502. public class Handmanager
  7503. {
  7504. public class Cardsposi
  7505. {
  7506. public int Amount = 0;
  7507. public int DetectPosix = 0;
  7508. public int DetectPosiy = 0;
  7509. public int cardsHooverPosx = 0;
  7510. public int cardsHooverdiff = 0;
  7511. public int cardsBigPosx = 0;
  7512. public int cardsBigdiff = 0;
  7513. public int hoovery = 750;
  7514. public int bigreadydetecty = 510;
  7515. }
  7516. public class Handcard
  7517. {
  7518. public int position = 0;
  7519. public int entity = -1;
  7520. public CardDB.Card card = new CardDB.Card();
  7521. }
  7522. private BattleField bf = BattleField.Instance;
  7523. public List<Cardsposi> cardsdata = new List<Cardsposi>();
  7524. public List<Handcard> handCards = new List<Handcard>();
  7525. public int anzcards = 0;
  7526. public int enemyAnzCards = 0;
  7527. private int ownPlayerController = 0;
  7528. Helpfunctions help;
  7529. Cardsposi currentCarddata = new Cardsposi();
  7530. CardDB cdb = CardDB.Instance;
  7531. private static Handmanager instance;
  7532. public static Handmanager Instance
  7533. {
  7534. get
  7535. {
  7536. if (instance == null)
  7537. {
  7538. instance = new Handmanager();
  7539. }
  7540. return instance;
  7541. }
  7542. }
  7543. private Handmanager()
  7544. {
  7545. this.help = Helpfunctions.Instance;
  7546. int i = 0;
  7547. Cardsposi c = new Cardsposi();
  7548. c.Amount = 1;
  7549. c.DetectPosix = 450;
  7550. c.DetectPosiy = 675;
  7551. c.cardsHooverPosx = 490;
  7552. c.cardsHooverdiff = 1;
  7553. c.cardsBigPosx = 366;
  7554. c.cardsBigdiff = 1;
  7555. this.cardsdata.Add(c);
  7556. i = i + 1;
  7557. c = new Cardsposi();
  7558. c.Amount = 2;
  7559. c.DetectPosix = 403;
  7560. c.DetectPosiy = 674;
  7561. c.cardsHooverPosx = 438;
  7562. c.cardsHooverdiff = 100;
  7563. c.cardsBigPosx = 317;
  7564. c.cardsBigdiff = 99;
  7565. this.cardsdata.Add(c);
  7566. i = i + 1;
  7567. c = new Cardsposi();
  7568. c.Amount = 3;
  7569. c.DetectPosix = 356;
  7570. c.DetectPosiy = 675;
  7571. c.cardsHooverPosx = 390;
  7572. c.cardsHooverdiff = 100;
  7573. c.cardsBigPosx = 267;
  7574. c.cardsBigdiff = 99;
  7575. this.cardsdata.Add(c);
  7576. i = i + 1;
  7577. c = new Cardsposi();
  7578. c.Amount = 4;
  7579. c.DetectPosix = 291;
  7580. c.DetectPosiy = 715;
  7581. c.cardsHooverPosx = 350;
  7582. c.cardsHooverdiff = 90;
  7583. c.cardsBigPosx = 220;
  7584. c.cardsBigdiff = 97;
  7585. this.cardsdata.Add(c);
  7586. i = i + 1;
  7587. c = new Cardsposi();
  7588. c.Amount = 5;
  7589. c.DetectPosix = 280;
  7590. c.DetectPosiy = 712;
  7591. c.cardsHooverPosx = 340;
  7592. c.cardsHooverdiff = 75;
  7593. c.cardsBigPosx = 210;
  7594. c.cardsBigdiff = 78;
  7595. this.cardsdata.Add(c);
  7596. i = i + 1;
  7597. c = new Cardsposi();
  7598. c.Amount = 6;
  7599. c.DetectPosix = 273;
  7600. c.DetectPosiy = 726;
  7601. c.cardsHooverPosx = 323;
  7602. c.cardsHooverdiff = 65;
  7603. c.cardsBigPosx = 204;
  7604. c.cardsBigdiff = 65;
  7605. this.cardsdata.Add(c);
  7606. i = i + 1;
  7607. c = new Cardsposi();
  7608. c.Amount = 7;
  7609. c.DetectPosix = 267;
  7610. c.DetectPosiy = 724;
  7611. c.cardsHooverPosx = 314;
  7612. c.cardsHooverdiff = 56;
  7613. c.cardsBigPosx = 199;
  7614. c.cardsBigdiff = 56;
  7615. this.cardsdata.Add(c);
  7616. i = i + 1;
  7617. c = new Cardsposi();
  7618. c.Amount = 8;
  7619. c.DetectPosix = 262;
  7620. c.DetectPosiy = 740;
  7621. c.cardsHooverPosx = 300;
  7622. c.cardsHooverdiff = 47;
  7623. c.cardsBigPosx = 196;
  7624. c.cardsBigdiff = 49;
  7625. this.cardsdata.Add(c);
  7626. i = i + 1;
  7627. c = new Cardsposi();
  7628. c.Amount = 9;
  7629. c.DetectPosix = 260;
  7630. c.DetectPosiy = 738;
  7631. c.cardsHooverPosx = 295;
  7632. c.cardsHooverdiff = 42;
  7633. c.cardsBigPosx = 193;
  7634. c.cardsBigdiff = 43;
  7635. this.cardsdata.Add(c);
  7636. i = i + 1;
  7637. c = new Cardsposi();
  7638. c.Amount = 10;
  7639. c.DetectPosix = 257;
  7640. c.DetectPosiy = 752;
  7641. c.cardsHooverPosx = 286;
  7642. c.cardsHooverdiff = 38;
  7643. c.cardsBigPosx = 191;
  7644. c.cardsBigdiff = 39;
  7645. this.cardsdata.Add(c);
  7646. }
  7647. public void clearAll()
  7648. {
  7649. this.handCards.Clear();
  7650. this.anzcards = 0;
  7651. this.enemyAnzCards = 0;
  7652. this.ownPlayerController = 0;
  7653. }
  7654. public void setOwnPlayer(int player)
  7655. {
  7656. this.ownPlayerController = player;
  7657. }
  7658. public Cardsposi getCardposi(int anzcard)
  7659. {
  7660. if (anzcard == 0) return new Cardsposi();
  7661. int k = anzcard - 1;
  7662. Cardsposi returnval = new Cardsposi();
  7663. returnval.Amount = this.cardsdata[k].Amount;
  7664. returnval.cardsBigdiff = this.cardsdata[k].cardsBigdiff;
  7665. returnval.cardsBigPosx = this.cardsdata[k].cardsBigPosx;
  7666. returnval.cardsHooverdiff = this.cardsdata[k].cardsHooverdiff;
  7667. returnval.cardsHooverPosx = this.cardsdata[k].cardsHooverPosx;
  7668. returnval.DetectPosix = this.cardsdata[k].DetectPosix;
  7669. returnval.DetectPosiy = this.cardsdata[k].DetectPosiy;
  7670. return returnval;
  7671. }
  7672. public void setHandcards(List<Handcard> hc, int anzown, int anzenemy)
  7673. {
  7674. this.handCards.Clear();
  7675. foreach (Handcard h in hc)
  7676. {
  7677. Handcard h1 = new Handcard();
  7678. h1.card = new CardDB.Card(h.card);
  7679. h1.entity = h.entity;
  7680. h1.position = h.position;
  7681. h1.card.entityID = h.entity;
  7682. this.handCards.Add(h1);
  7683. }
  7684. //this.handCards.AddRange(hc);
  7685. this.handCards.Sort((a, b) => a.position.CompareTo(b.position));
  7686. this.anzcards = anzown;
  7687. this.enemyAnzCards = anzenemy;
  7688. this.currentCarddata = this.getCardposi(this.anzcards);
  7689. }
  7690. public void printcards()
  7691. {
  7692. help.logg("Own Handcards: ");
  7693. foreach (Handmanager.Handcard c in this.handCards)
  7694. {
  7695. help.logg("pos " + c.position + " " + c.card.name + " " + c.card.cost + " entity " + c.entity);
  7696. }
  7697. }
  7698. public void loadPreparedBattlefield(int bfield)
  7699. {
  7700. this.handCards.Clear();
  7701. if (bfield == 0)
  7702. {
  7703. enemyAnzCards = 0;
  7704. this.handCards.Clear();
  7705. Handcard hc1 = new Handcard();
  7706. hc1.position = 1;
  7707. hc1.card = cdb.getCardDataFromID("EX1_564");//gesichtsloser manipulator
  7708. this.handCards.Add(hc1);
  7709. }
  7710. if (bfield == 1)
  7711. {
  7712. enemyAnzCards = 0;
  7713. this.handCards.Clear();
  7714. Handcard hc1 = new Handcard();
  7715. hc1.position = 1;
  7716. //hc1.card = cdb.getCardDataFromID("CS2_029"); //feuerball
  7717. hc1.card = cdb.getCardDataFromID("NEW1_007"); //feuerball
  7718. this.handCards.Add(hc1);
  7719. }
  7720. if (bfield == 2)
  7721. {
  7722. enemyAnzCards = 0;
  7723. this.handCards.Clear();
  7724. Handcard hc1 = new Handcard();
  7725. hc1.position = 1;
  7726. hc1.card = cdb.getCardDataFromID("CS1_113"); //gedankenkontrolle
  7727. this.handCards.Add(hc1);
  7728. }
  7729. if (bfield == 3)
  7730. {
  7731. enemyAnzCards = 0;
  7732. this.handCards.Clear();
  7733. Handcard hc1 = new Handcard();
  7734. hc1.position = 1;
  7735. hc1.card = cdb.getCardDataFromID("CS2_122");//schlachtzugsleiter
  7736. this.handCards.Add(hc1);
  7737. }
  7738. if (bfield == 4)
  7739. {
  7740. enemyAnzCards = 0;
  7741. this.handCards.Clear();
  7742. Handcard hc1 = new Handcard();
  7743. hc1.position = 1;
  7744. hc1.card = cdb.getCardDataFromID("EX1_246");//frogg
  7745. this.handCards.Add(hc1);
  7746. }
  7747. if (bfield == 5)
  7748. {
  7749. // test silence
  7750. enemyAnzCards = 0;
  7751. this.handCards.Clear();
  7752. Handcard hc1 = new Handcard();
  7753. hc1.position = 1;
  7754. hc1.card = cdb.getCardData("ironbeakowl");
  7755. this.handCards.Add(hc1);
  7756. /*hc1 = new Handcard();
  7757. hc1.position = 2;
  7758. hc1.card = cdb.getCardData("frostblitz");
  7759. this.handCards.Add(hc1);*/
  7760. }
  7761. if (bfield == 6)
  7762. {
  7763. enemyAnzCards = 0;
  7764. this.handCards.Clear();
  7765. Handcard hc1 = new Handcard();
  7766. hc1.position = 1;
  7767. hc1.card = cdb.getCardData("azuredrake");
  7768. this.handCards.Add(hc1);
  7769. hc1 = new Handcard();
  7770. hc1.position = 2;
  7771. hc1.card = cdb.getCardData("gurubashiberserker");
  7772. this.handCards.Add(hc1);
  7773. hc1 = new Handcard();
  7774. hc1.position = 3;
  7775. hc1.card = cdb.getCardData("flamestrike");
  7776. this.handCards.Add(hc1);
  7777. }
  7778. if (bfield == 10)
  7779. {
  7780. enemyAnzCards = 0;
  7781. this.handCards.Clear();
  7782. Handcard hc1 = new Handcard();
  7783. hc1.position = 1;
  7784. hc1.card = cdb.getCardDataFromID("NEW1_036");//befehlsruf
  7785. this.handCards.Add(hc1);
  7786. hc1 = new Handcard();
  7787. hc1.position = 2;
  7788. hc1.card = cdb.getCardDataFromID("EX1_392");//kampfeswut
  7789. this.handCards.Add(hc1);
  7790. }
  7791. }
  7792. }
  7793. public class Hrtprozis
  7794. {
  7795. public int ownHeroFatigue = 0;
  7796. public int ownDeckSize = 0;
  7797. public int enemyDeckSize = 0;
  7798. public int enemyHeroFatigue = 0;
  7799. public int ownHeroEntity = -1;
  7800. public int enemyHeroEntitiy = -1;
  7801. public DateTime roundstart = DateTime.Now;
  7802. BattleField bf = BattleField.Instance;
  7803. bool tempwounded = false;
  7804. public int currentMana = 0;
  7805. public int heroHp = 30, enemyHp = 30;
  7806. public int heroAtk = 0, enemyAtk = 0;
  7807. public int heroDefence = 0, enemyDefence = 0;
  7808. public bool ownheroisread = false;
  7809. public bool ownAbilityisReady = false;
  7810. public int ownHeroNumAttacksThisTurn = 0;
  7811. public bool ownHeroWindfury = false;
  7812. public List<string> ownSecretList = new List<string>();
  7813. public int enemySecretCount = 0;
  7814. public string heroname = "druid", enemyHeroname = "druid";
  7815. public CardDB.Card heroAbility;
  7816. public int anzEnemys = 0;
  7817. public int anzOwn = 0;
  7818. public bool herofrozen = false;
  7819. public bool enemyfrozen = false;
  7820. public int numMinionsPlayedThisTurn = 0;
  7821. public int cardsPlayedThisTurn = 0;
  7822. public int ueberladung = 0;
  7823. public int ownMaxMana = 0;
  7824. public int enemyMaxMana = 0;
  7825. public int enemyWeaponDurability = 0;
  7826. public int enemyWeaponAttack = 0;
  7827. public string enemyHeroWeapon = "";
  7828. public int heroWeaponDurability = 0;
  7829. public int heroWeaponAttack = 0;
  7830. public string ownHeroWeapon = "";
  7831. public bool heroImmuneToDamageWhileAttacking = false;
  7832. public bool minionsFailure = false;
  7833. public List<Minion> ownMinions = new List<Minion>();
  7834. public List<Minion> enemyMinions = new List<Minion>();
  7835. int manadiff = 23;
  7836. int detectmin = 30, detectmax = 130;
  7837. Helpfunctions help = Helpfunctions.Instance;
  7838. //Imagecomparer icom = Imagecomparer.Instance;
  7839. //HrtNumbers hrtnumbers = HrtNumbers.Instance;
  7840. CardDB cdb = CardDB.Instance;
  7841. private int ownPlayerController = 0;
  7842. private static Hrtprozis instance;
  7843. public static Hrtprozis Instance
  7844. {
  7845. get
  7846. {
  7847. if (instance == null)
  7848. {
  7849. instance = new Hrtprozis();
  7850. }
  7851. return instance;
  7852. }
  7853. }
  7854. private Hrtprozis()
  7855. {
  7856. }
  7857. public void clearAll()
  7858. {
  7859. ownHeroEntity = -1;
  7860. enemyHeroEntitiy = -1;
  7861. tempwounded = false;
  7862. currentMana = 0;
  7863. heroHp = 30;
  7864. enemyHp = 30;
  7865. heroAtk = 0;
  7866. enemyAtk = 0;
  7867. heroDefence = 0; enemyDefence = 0;
  7868. ownheroisread = false;
  7869. ownAbilityisReady = false;
  7870. ownHeroNumAttacksThisTurn = 0;
  7871. ownHeroWindfury = false;
  7872. ownSecretList.Clear();
  7873. enemySecretCount = 0;
  7874. heroname = "druid";
  7875. enemyHeroname = "druid";
  7876. heroAbility = new CardDB.Card();
  7877. anzEnemys = 0;
  7878. anzOwn = 0;
  7879. herofrozen = false;
  7880. enemyfrozen = false;
  7881. numMinionsPlayedThisTurn = 0;
  7882. cardsPlayedThisTurn = 0;
  7883. ueberladung = 0;
  7884. ownMaxMana = 0;
  7885. enemyMaxMana = 0;
  7886. enemyWeaponDurability = 0;
  7887. enemyWeaponAttack = 0;
  7888. enemyHeroWeapon = "";
  7889. heroWeaponDurability = 0;
  7890. heroWeaponAttack = 0;
  7891. ownHeroWeapon = "";
  7892. heroImmuneToDamageWhileAttacking = false;
  7893. ownMinions.Clear();
  7894. enemyMinions.Clear();
  7895. }
  7896. public void setOwnPlayer(int player)
  7897. {
  7898. this.ownPlayerController = player;
  7899. }
  7900. public int getOwnController()
  7901. {
  7902. return this.ownPlayerController;
  7903. }
  7904. public string heroIDtoName(string s)
  7905. {
  7906. string retval = "druid";
  7907. if (s == "XXX_040")
  7908. {
  7909. retval = "hogger";
  7910. }
  7911. if (s == "HERO_05")
  7912. {
  7913. retval = "hunter";
  7914. }
  7915. if (s == "HERO_09")
  7916. {
  7917. retval = "priest";
  7918. }
  7919. if (s == "HERO_06")
  7920. {
  7921. retval = "druid";
  7922. }
  7923. if (s == "HERO_07")
  7924. {
  7925. retval = "warlock";
  7926. }
  7927. if (s == "HERO_03")
  7928. {
  7929. retval = "thief";
  7930. }
  7931. if (s == "HERO_04")
  7932. {
  7933. retval = "pala";
  7934. }
  7935. if (s == "HERO_01")
  7936. {
  7937. retval = "warrior";
  7938. }
  7939. if (s == "HERO_02")
  7940. {
  7941. retval = "shaman";
  7942. }
  7943. if (s == "HERO_08")
  7944. {
  7945. retval = "mage";
  7946. }
  7947. if (s == "EX1_323h")
  7948. {
  7949. retval = "lordjaraxxus";
  7950. }
  7951. return retval;
  7952. }
  7953. public void updateMinions(List<Minion> om, List<Minion> em)
  7954. {
  7955. this.ownMinions.Clear();
  7956. this.enemyMinions.Clear();
  7957. foreach (var item in om)
  7958. {
  7959. this.ownMinions.Add(new Minion(item));
  7960. }
  7961. //this.ownMinions.AddRange(om);
  7962. foreach (var item in em)
  7963. {
  7964. this.enemyMinions.Add(new Minion(item));
  7965. }
  7966. //this.enemyMinions.AddRange(em);
  7967. //sort them
  7968. updatePositions();
  7969. }
  7970. public void updateSecretStuff(List<string> ownsecs, int numEnemSec)
  7971. {
  7972. this.ownSecretList.Clear();
  7973. foreach (string s in ownsecs)
  7974. {
  7975. this.ownSecretList.Add(s);
  7976. }
  7977. this.enemySecretCount = numEnemSec;
  7978. }
  7979. public void updatePlayer(int maxmana, int currentmana, int cardsplayedthisturn, int numMinionsplayed, int recall, int heroentity, int enemyentity)
  7980. {
  7981. this.currentMana = currentmana;
  7982. this.ownMaxMana = maxmana;
  7983. this.cardsPlayedThisTurn = cardsplayedthisturn;
  7984. this.numMinionsPlayedThisTurn = numMinionsplayed;
  7985. this.ueberladung = recall;
  7986. this.ownHeroEntity = heroentity;
  7987. this.enemyHeroEntitiy = enemyentity;
  7988. }
  7989. public void updateOwnHero(string weapon, int watt, int wdur, bool heroimune, int heroatt, int herohp, int herodef, string heron, bool heroready, bool frozen, CardDB.Card hab, bool habrdy, int numAttacksTTurn, bool windfury)
  7990. {
  7991. this.ownHeroWeapon = weapon;
  7992. this.heroWeaponAttack = watt;
  7993. this.heroWeaponDurability = wdur;
  7994. this.heroImmuneToDamageWhileAttacking = heroimune;
  7995. this.heroAtk = heroatt;
  7996. this.heroHp = herohp;
  7997. this.heroDefence = herodef;
  7998. this.heroname = heron;
  7999. this.ownheroisread = heroready;
  8000. this.herofrozen = frozen;
  8001. this.heroAbility = hab;
  8002. this.ownAbilityisReady = habrdy;
  8003. this.ownHeroWindfury = windfury;
  8004. this.ownHeroNumAttacksThisTurn = numAttacksTTurn;
  8005. }
  8006. public void updateEnemyHero(string weapon, int watt, int wdur, int heroatt, int herohp, int herodef, string heron, bool frozen)
  8007. {
  8008. this.enemyHeroWeapon = weapon;
  8009. this.enemyWeaponAttack = watt;
  8010. this.enemyWeaponDurability = wdur;
  8011. this.enemyAtk = heroatt;
  8012. this.enemyHp = herohp;
  8013. this.enemyHeroname = heron;
  8014. this.enemyDefence = herodef;
  8015. this.enemyfrozen = frozen;
  8016. }
  8017. public void updateFatigueStats(int ods, int ohf, int eds, int ehf)
  8018. {
  8019. this.ownDeckSize = ods;
  8020. this.ownHeroFatigue = ohf;
  8021. this.enemyDeckSize = eds;
  8022. this.enemyHeroFatigue = ehf;
  8023. }
  8024. public void setEnchantments(List<BattleField.HrtUnit> enchantments)
  8025. {
  8026. foreach (BattleField.HrtUnit bhu in enchantments)
  8027. {
  8028. //create enchantment
  8029. Enchantment ench = CardDB.getEnchantmentFromCardID(bhu.CardID);
  8030. ench.creator = bhu.getTag(GAME_TAG.CREATOR);
  8031. ench.cantBeDispelled = false;
  8032. if (bhu.getTag(GAME_TAG.CANT_BE_DISPELLED) == 1) ench.cantBeDispelled = true;
  8033. foreach (Minion m in this.ownMinions)
  8034. {
  8035. if (m.entitiyID == bhu.getTag(GAME_TAG.ATTACHED))
  8036. {
  8037. m.enchantments.Add(ench);
  8038. }
  8039. }
  8040. foreach (Minion m in this.enemyMinions)
  8041. {
  8042. if (m.entitiyID == bhu.getTag(GAME_TAG.ATTACHED))
  8043. {
  8044. m.enchantments.Add(ench);
  8045. }
  8046. }
  8047. }
  8048. }
  8049. public void updatePositions()
  8050. {
  8051. this.ownMinions.Sort((a, b) => a.zonepos.CompareTo(b.zonepos));
  8052. this.enemyMinions.Sort((a, b) => a.zonepos.CompareTo(b.zonepos));
  8053. int i = 0;
  8054. foreach (Minion m in this.ownMinions)
  8055. {
  8056. m.id = i;
  8057. i++;
  8058. m.zonepos = i;
  8059. }
  8060. i = 0;
  8061. foreach (Minion m in this.enemyMinions)
  8062. {
  8063. m.id = i;
  8064. i++;
  8065. m.zonepos = i;
  8066. }
  8067. /*List<Minion> temp = new List<Minion>();
  8068. temp.AddRange(ownMinions);
  8069. this.ownMinions.Clear();
  8070. this.ownMinions.AddRange(temp.OrderBy(x => x.zonepos).ToList());
  8071. temp.Clear();
  8072. temp.AddRange(enemyMinions);
  8073. this.enemyMinions.Clear();
  8074. this.enemyMinions.AddRange(temp.OrderBy(x => x.zonepos).ToList());*/
  8075. }
  8076. private Minion createNewMinion(CardDB.Card c, int id)
  8077. {
  8078. Minion m = new Minion();
  8079. m.card = c;
  8080. m.id = id;
  8081. m.zonepos = id + 1;
  8082. m.entitiyID = c.entityID;
  8083. m.Posix = 0;
  8084. m.Posiy = 0;
  8085. m.Angr = c.Attack;
  8086. m.Hp = c.Health;
  8087. m.maxHp = c.Health;
  8088. m.name = c.name;
  8089. m.playedThisTurn = true;
  8090. m.numAttacksThisTurn = 0;
  8091. if (c.windfury) m.windfury = true;
  8092. if (c.tank) m.taunt = true;
  8093. if (c.Charge)
  8094. {
  8095. m.Ready = true;
  8096. m.charge = true;
  8097. }
  8098. if (c.poisionous) m.poisonous = true;
  8099. if (c.Stealth) m.stealth = true;
  8100. if (m.name == "lightspawn" && !m.silenced)
  8101. {
  8102. m.Angr = m.Hp;
  8103. }
  8104. return m;
  8105. }
  8106. public void printHero()
  8107. {
  8108. help.logg("player:");
  8109. help.logg(this.currentMana + " " + this.ownMaxMana + " " + this.numMinionsPlayedThisTurn + " " + this.cardsPlayedThisTurn + " " + this.ueberladung + " " + this.ownPlayerController);
  8110. help.logg("ownhero:");
  8111. help.logg(this.heroname + " " + heroHp + " " + heroDefence + " immn " + this.heroImmuneToDamageWhileAttacking);
  8112. help.logg("ready: " + this.ownheroisread + " alreadyattacked: " + this.ownHeroNumAttacksThisTurn + " frzn: " + this.herofrozen + " attack: " + heroAtk + " " + heroWeaponAttack + " " + heroWeaponDurability + " " + ownHeroWeapon);
  8113. help.logg("ability: " + this.ownAbilityisReady + " " + this.heroAbility.CardID);
  8114. string secs = "";
  8115. foreach (string sec in this.ownSecretList)
  8116. {
  8117. secs += sec + " ";
  8118. }
  8119. help.logg("osecrets: " + secs);
  8120. help.logg("enemyhero:");
  8121. help.logg(this.enemyHeroname + " " + enemyHp + " " + enemyDefence + " " + this.enemyfrozen);
  8122. help.logg(this.enemyWeaponAttack + " " + this.enemyWeaponDurability + " " + this.enemyHeroWeapon);
  8123. help.logg("fatigue: " + this.ownDeckSize + " " + this.ownHeroFatigue + " " + this.enemyDeckSize + " " + this.enemyHeroFatigue);
  8124. }
  8125. public void printOwnMinions()
  8126. {
  8127. help.logg("OwnMinions:");
  8128. foreach (Minion m in this.ownMinions)
  8129. {
  8130. help.logg(m.name + " id " + m.id + " zp " + m.zonepos + " " + " e:" + m.entitiyID + " " + " A:" + m.Angr + " H:" + m.Hp + " mH:" + m.maxHp + " rdy:" + m.Ready + " tnt:" + m.taunt + " frz:" + m.frozen + " silenced:" + m.silenced + " divshield:" + m.divineshild + " ptt:" + m.playedThisTurn + " wndfr:" + m.windfury + " natt:" + m.numAttacksThisTurn + " sil:" + m.silenced + " stl:" + m.stealth + " poi:" + m.poisonous + " imm:" + m.immune + " ex:" + m.exhausted + " chrg:" + m.charge);
  8131. foreach (Enchantment e in m.enchantments)
  8132. {
  8133. help.logg(e.CARDID + " " + e.creator + " " + e.controllerOfCreator);
  8134. }
  8135. }
  8136. }
  8137. public void printEnemyMinions()
  8138. {
  8139. help.logg("EnemyMinions:");
  8140. foreach (Minion m in this.enemyMinions)
  8141. {
  8142. help.logg(m.name + " id " + m.id + " zp " + m.zonepos + " " + " e:" + m.entitiyID + " " + " A:" + m.Angr + " H:" + m.Hp + " mH:" + m.maxHp + " rdy:" + m.Ready + " tnt:" + m.taunt + " frz:" + m.frozen + " silenced:" + m.silenced + " divshield:" + m.divineshild + " wndfr:" + m.windfury + " sil:" + m.silenced + " stl:" + m.stealth + " poi:" + m.poisonous + " imm:" + m.immune + " ex:" + m.exhausted);
  8143. foreach (Enchantment e in m.enchantments)
  8144. {
  8145. help.logg(e.CARDID + " " + e.creator + " " + e.controllerOfCreator);
  8146. }
  8147. }
  8148. }
  8149. public void loadPreparedHeros(int bfield)
  8150. {
  8151. if (bfield == 0)
  8152. {
  8153. currentMana = 5;
  8154. ownMaxMana = 7;
  8155. heroHp = 22;
  8156. enemyHp = 25;
  8157. heroAtk = 0;
  8158. enemyAtk = 0;
  8159. heroDefence = 0;
  8160. enemyDefence = 0;
  8161. ownheroisread = false;
  8162. ownAbilityisReady = true;
  8163. heroname = "mage";
  8164. enemyHeroname = "druid";
  8165. this.heroAbility = this.cdb.getCardDataFromID("CS2_034");
  8166. anzEnemys = 0;
  8167. anzOwn = 0;
  8168. herofrozen = false;
  8169. enemyfrozen = false;
  8170. numMinionsPlayedThisTurn = 0;
  8171. cardsPlayedThisTurn = 0;
  8172. ueberladung = 0;
  8173. ownMaxMana = 10;
  8174. enemyMaxMana = 10;
  8175. enemyWeaponDurability = 0;
  8176. enemyWeaponAttack = 0;
  8177. enemyHeroWeapon = "";
  8178. heroWeaponDurability = 0;
  8179. heroWeaponAttack = 0;
  8180. ownHeroWeapon = "";
  8181. heroImmuneToDamageWhileAttacking = false;
  8182. ownPlayerController = 1;
  8183. }
  8184. }
  8185. public void loadPreparedBattlefield(int bfield)
  8186. {
  8187. this.ownMinions.Clear();
  8188. this.enemyMinions.Clear();
  8189. if (bfield == 0)
  8190. {
  8191. Minion own1 = createNewMinion(cdb.getCardDataFromID("CS2_171"), 0); // steinhauereber
  8192. own1.Ready = true;
  8193. this.ownMinions.Add(own1);
  8194. Minion enemy1 = createNewMinion(cdb.getCardDataFromID("CS2_222"), 0);// champion von sturmwind
  8195. enemy1.Ready = true;
  8196. this.enemyMinions.Add(enemy1);
  8197. }
  8198. if (bfield == 1)
  8199. {
  8200. Minion enemy1 = createNewMinion(cdb.getCardDataFromID("CS2_152"), 0);
  8201. Minion enemy2 = createNewMinion(cdb.getCardDataFromID("CS2_152"), 1);
  8202. Minion enemy3 = createNewMinion(cdb.getCardDataFromID("EX1_097"), 2);
  8203. Minion enemy4 = createNewMinion(cdb.getCardDataFromID("CS2_152"), 3);
  8204. Minion enemy5 = createNewMinion(cdb.getCardDataFromID("EX1_097"), 4);
  8205. enemy1.stealth = true;
  8206. enemy2.stealth = true;
  8207. enemy4.stealth = true;
  8208. enemy5.stealth = true;
  8209. enemy5.Hp = 2; enemy5.maxHp = 4;
  8210. this.enemyMinions.Add(enemy1);
  8211. this.enemyMinions.Add(enemy2);
  8212. this.enemyMinions.Add(enemy3);
  8213. this.enemyMinions.Add(enemy4);
  8214. this.enemyMinions.Add(enemy5);
  8215. }
  8216. if (bfield == 2)
  8217. {
  8218. Minion enemy1 = createNewMinion(cdb.getCardDataFromID("NEW1_011"), 0);
  8219. Minion enemy2 = createNewMinion(cdb.getCardDataFromID("CS2_152"), 1);
  8220. enemy2.stealth = true;
  8221. this.enemyMinions.Add(enemy1);
  8222. this.enemyMinions.Add(enemy2);
  8223. }
  8224. if (bfield == 3)
  8225. {
  8226. //wichtelmeisterin
  8227. Minion own1 = createNewMinion(cdb.getCardDataFromID("EX1_597"), 0); // wichtelmeisterin
  8228. own1.Hp = 2;
  8229. own1.Angr = 6;
  8230. Enchantment e = CardDB.getEnchantmentFromCardID("CS2_046e");
  8231. e.creator = 1;
  8232. e.controllerOfCreator = 1;
  8233. own1.enchantments.Add(e);
  8234. own1.Ready = false;
  8235. this.ownMinions.Add(own1);
  8236. }
  8237. if (bfield == 6)
  8238. {
  8239. Minion own1 = createNewMinion(cdb.getCardData("abusivesergeant"), 0);
  8240. own1.Ready = true;
  8241. this.ownMinions.Add(own1);
  8242. own1 = createNewMinion(cdb.getCardData("knifejuggler"), 0);
  8243. this.ownMinions.Add(own1);
  8244. own1 = createNewMinion(cdb.getCardData("argentcommander"), 0);
  8245. own1.divineshild = false;
  8246. this.enemyMinions.Add(own1);
  8247. }
  8248. if (bfield == 10)
  8249. {// benchmark
  8250. Minion own1 = createNewMinion(cdb.getCardDataFromID("CS2_182"), 0); // jeti
  8251. own1.Hp = 3;
  8252. own1.maxHp = 3;
  8253. own1.windfury = true;
  8254. own1.Ready = true;
  8255. this.ownMinions.Add(own1);
  8256. own1 = createNewMinion(cdb.getCardDataFromID("CS2_182"), 1); // jeti
  8257. own1.Hp = 3;
  8258. own1.maxHp = 3;
  8259. own1.windfury = true;
  8260. own1.Ready = true;
  8261. this.ownMinions.Add(own1);
  8262. own1 = createNewMinion(cdb.getCardDataFromID("CS2_182"), 2); // jeti
  8263. own1.Hp = 3;
  8264. own1.maxHp = 3;
  8265. own1.windfury = true;
  8266. own1.Ready = true;
  8267. this.ownMinions.Add(own1);
  8268. own1 = createNewMinion(cdb.getCardDataFromID("CS2_182"), 3); // jeti
  8269. own1.Hp = 3;
  8270. own1.maxHp = 3;
  8271. own1.windfury = true;
  8272. own1.Ready = true;
  8273. this.ownMinions.Add(own1);
  8274. own1 = createNewMinion(cdb.getCardDataFromID("CS2_182"), 4); // jeti
  8275. own1.Hp = 3;
  8276. own1.maxHp = 3;
  8277. own1.windfury = true;
  8278. own1.Ready = true;
  8279. this.ownMinions.Add(own1);
  8280. own1 = createNewMinion(cdb.getCardDataFromID("CS2_182"), 5); // jeti
  8281. own1.Hp = 3;
  8282. own1.maxHp = 3;
  8283. own1.windfury = true;
  8284. own1.Ready = true;
  8285. this.ownMinions.Add(own1);
  8286. own1 = createNewMinion(cdb.getCardDataFromID("CS2_182"), 6); // jeti
  8287. own1.Hp = 3;
  8288. own1.maxHp = 3;
  8289. own1.windfury = true;
  8290. own1.Ready = true;
  8291. this.ownMinions.Add(own1);
  8292. // enemys
  8293. own1 = createNewMinion(cdb.getCardDataFromID("CS2_182"), 0); // jeti
  8294. this.enemyMinions.Add(own1);
  8295. own1 = createNewMinion(cdb.getCardDataFromID("CS2_182"), 1); // jeti
  8296. this.enemyMinions.Add(own1);
  8297. own1 = createNewMinion(cdb.getCardDataFromID("CS2_182"), 2); // jeti
  8298. this.enemyMinions.Add(own1);
  8299. own1 = createNewMinion(cdb.getCardDataFromID("CS2_182"), 3); // jeti
  8300. this.enemyMinions.Add(own1);
  8301. own1 = createNewMinion(cdb.getCardDataFromID("CS2_182"), 4); // jeti
  8302. this.enemyMinions.Add(own1);
  8303. own1 = createNewMinion(cdb.getCardDataFromID("CS2_182"), 5); // jeti
  8304. this.enemyMinions.Add(own1);
  8305. own1 = createNewMinion(cdb.getCardDataFromID("CS2_182"), 6); // jeti
  8306. this.enemyMinions.Add(own1);
  8307. }
  8308. updatePositions();
  8309. }
  8310. }
  8311. public class Helpfunctions
  8312. {
  8313. public static List<T> TakeList<T>(IEnumerable<T> source, int limit)
  8314. {
  8315. List<T> retlist = new List<T>();
  8316. int i = 0;
  8317. foreach (T item in source)
  8318. {
  8319. retlist.Add(item);
  8320. i++;
  8321. if (i >= limit) break;
  8322. }
  8323. return retlist;
  8324. }
  8325. public bool runningbot = false;
  8326. private static Helpfunctions instance;
  8327. public static Helpfunctions Instance
  8328. {
  8329. get
  8330. {
  8331. if (instance == null)
  8332. {
  8333. instance = new Helpfunctions();
  8334. }
  8335. return instance;
  8336. }
  8337. }
  8338. string path = Settings.Instance.logpath;
  8339. private Helpfunctions()
  8340. {
  8341. System.IO.File.WriteAllText(path + Settings.Instance.logfile, "");
  8342. }
  8343. private bool writelogg = true;
  8344. public void loggonoff(bool onoff)
  8345. {
  8346. //writelogg = onoff;
  8347. }
  8348. public void createNewLoggfile()
  8349. {
  8350. System.IO.File.WriteAllText(path + Settings.Instance.logfile, "");
  8351. }
  8352. public void logg(string s)
  8353. {
  8354. if (!writelogg) return;
  8355. try
  8356. {
  8357. using (StreamWriter sw = File.AppendText(path + Settings.Instance.logfile))
  8358. {
  8359. sw.WriteLine(s);
  8360. }
  8361. }
  8362. catch { }
  8363. }
  8364. public DateTime UnixTimeStampToDateTime(int unixTimeStamp)
  8365. {
  8366. // Unix timestamp is seconds past epoch
  8367. System.DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
  8368. dtDateTime = dtDateTime.AddSeconds(unixTimeStamp).ToLocalTime();
  8369. return dtDateTime;
  8370. }
  8371. }
  8372. public class PenalityManager
  8373. {
  8374. //todo acolyteofpain
  8375. //todo better aoe-penality
  8376. public Dictionary<string, int> priorityDatabase = new Dictionary<string, int>();
  8377. Dictionary<string, int> HealTargetDatabase = new Dictionary<string, int>();
  8378. Dictionary<string, int> HealHeroDatabase = new Dictionary<string, int>();
  8379. Dictionary<string, int> HealAllDatabase = new Dictionary<string, int>();
  8380. public Dictionary<string, int> DamageTargetDatabase = new Dictionary<string, int>();
  8381. public Dictionary<string, int> DamageTargetSpecialDatabase = new Dictionary<string, int>();
  8382. Dictionary<string, int> DamageAllDatabase = new Dictionary<string, int>();
  8383. Dictionary<string, int> DamageHeroDatabase = new Dictionary<string, int>();
  8384. Dictionary<string, int> DamageRandomDatabase = new Dictionary<string, int>();
  8385. Dictionary<string, int> DamageAllEnemysDatabase = new Dictionary<string, int>();
  8386. Dictionary<string, int> enrageDatabase = new Dictionary<string, int>();
  8387. Dictionary<string, int> silenceDatabase = new Dictionary<string, int>();
  8388. Dictionary<string, int> heroAttackBuffDatabase = new Dictionary<string, int>();
  8389. Dictionary<string, int> attackBuffDatabase = new Dictionary<string, int>();
  8390. Dictionary<string, int> healthBuffDatabase = new Dictionary<string, int>();
  8391. Dictionary<string, int> tauntBuffDatabase = new Dictionary<string, int>();
  8392. Dictionary<string, int> cardDrawBattleCryDatabase = new Dictionary<string, int>();
  8393. Dictionary<string, int> cardDiscardDatabase = new Dictionary<string, int>();
  8394. Dictionary<string, int> destroyOwnDatabase = new Dictionary<string, int>();
  8395. Dictionary<string, int> destroyDatabase = new Dictionary<string, int>();
  8396. Dictionary<string, int> heroDamagingAoeDatabase = new Dictionary<string, int>();
  8397. Dictionary<string, int> returnHandDatabase = new Dictionary<string, int>();
  8398. public Dictionary<string, int> priorityTargets = new Dictionary<string, int>();
  8399. public Dictionary<string, int> specialMinions = new Dictionary<string, int>(); //minions with cardtext, but no battlecry
  8400. private static PenalityManager instance;
  8401. public static PenalityManager Instance
  8402. {
  8403. get
  8404. {
  8405. if (instance == null)
  8406. {
  8407. instance = new PenalityManager();
  8408. }
  8409. return instance;
  8410. }
  8411. }
  8412. private PenalityManager()
  8413. {
  8414. setupHealDatabase();
  8415. setupEnrageDatabase();
  8416. setupDamageDatabase();
  8417. setupPriorityList();
  8418. setupsilenceDatabase();
  8419. setupAttackBuff();
  8420. setupHealthBuff();
  8421. setupCardDrawBattlecry();
  8422. setupDiscardCards();
  8423. setupDestroyOwnCards();
  8424. setupSpecialMins();
  8425. setupEnemyTargetPriority();
  8426. setupHeroDamagingAOE();
  8427. }
  8428. public int getAttackWithMininonPenality(Minion m, Playfield p, int target)
  8429. {
  8430. int pen = 0;
  8431. pen = getAttackSecretPenality(m, p, target);
  8432. return pen;
  8433. }
  8434. public int getAttackWithHeroPenality(int target, Playfield p)
  8435. {
  8436. int retval = 0;
  8437. //no penality, but a bonus, if he has weapon on hand!
  8438. if (p.ownWeaponDurability == 1)
  8439. {
  8440. bool hasweapon = false;
  8441. foreach (Handmanager.Handcard c in p.owncards)
  8442. {
  8443. if (c.card.type == CardDB.cardtype.WEAPON) hasweapon = true;
  8444. }
  8445. if (hasweapon) retval = -p.ownWeaponAttack - 1; // so he doesnt "lose" the weapon in evaluation :D
  8446. }
  8447. return retval;
  8448. }
  8449. public int getPlayCardPenality(CardDB.Card card, int target, Playfield p, int choice)
  8450. {
  8451. int retval = 0;
  8452. string name = card.name;
  8453. //there is no reason to buff HP of minon (because it is not healed)
  8454. int abuff = getAttackBuffPenality(card, target, p, choice);
  8455. int tbuff = getTauntBuffPenality(name, target, p, choice);
  8456. if (name == "markofthewild" && ((abuff == 500 || tbuff == 0) || (abuff == 0 || tbuff == 500)))
  8457. {
  8458. retval = 0;
  8459. }
  8460. else
  8461. {
  8462. retval += abuff + tbuff;
  8463. }
  8464. retval += getHPBuffPenality(card, target, p, choice);
  8465. retval += getSilencePenality(name, target, p, choice);
  8466. retval += getDamagePenality(name, target, p, choice);
  8467. retval += getHealPenality(name, target, p, choice);
  8468. retval += getCardDrawPenality(name, target, p, choice);
  8469. retval += getCardDrawofEffectMinions(card, p);
  8470. retval += getCardDiscardPenality(name, p);
  8471. retval += getDestroyOwnPenality(name, target, p);
  8472. retval += getDestroyPenality(name, target, p);
  8473. retval += getSpecialCardComboPenalitys(card, target, p);
  8474. retval += playSecretPenality(card, p);
  8475. retval += getPlayCardSecretPenality(card, p);
  8476. return retval;
  8477. }
  8478. private int getAttackBuffPenality(CardDB.Card card, int target, Playfield p, int choice)
  8479. {
  8480. string name = card.name;
  8481. int pen = 0;
  8482. //buff enemy?
  8483. if (!this.attackBuffDatabase.ContainsKey(name)) return 0;
  8484. if (target >= 10 && target <= 19)
  8485. {
  8486. if (card.type == CardDB.cardtype.MOB && p.ownMinions.Count == 0) return 0;
  8487. //allow it if you have biggamehunter
  8488. foreach (Handmanager.Handcard hc in p.owncards)
  8489. {
  8490. if (hc.card.name == "biggamehunter") return pen;
  8491. if (hc.card.name == "shadowworddeath") return pen;
  8492. }
  8493. pen = 500;
  8494. }
  8495. return pen;
  8496. }
  8497. private int getHPBuffPenality(CardDB.Card card, int target, Playfield p, int choice)
  8498. {
  8499. string name = card.name;
  8500. int pen = 0;
  8501. //buff enemy?
  8502. if (!this.healthBuffDatabase.ContainsKey(name)) return 0;
  8503. if (target >= 10 && target <= 19 && !this.tauntBuffDatabase.ContainsKey(name))
  8504. {
  8505. pen = 500;
  8506. }
  8507. return pen;
  8508. }
  8509. private int getTauntBuffPenality(string name, int target, Playfield p, int choice)
  8510. {
  8511. int pen = 0;
  8512. //buff enemy?
  8513. if (!this.tauntBuffDatabase.ContainsKey(name)) return 0;
  8514. if (name == "markofnature" && choice != 2) return 0;
  8515. if (target >= 10 && target <= 19)
  8516. {
  8517. //allow it if you have black knight
  8518. foreach (Handmanager.Handcard hc in p.owncards)
  8519. {
  8520. if (hc.card.name == "theblackknight") return 0;
  8521. }
  8522. // allow taunting if target is priority and others have taunt
  8523. bool enemyhasTaunts = false;
  8524. foreach (Minion mnn in p.enemyMinions)
  8525. {
  8526. if (mnn.taunt)
  8527. {
  8528. enemyhasTaunts = true;
  8529. break;
  8530. }
  8531. }
  8532. Minion m = p.enemyMinions[target - 10];
  8533. if (enemyhasTaunts && this.priorityDatabase.ContainsKey(m.name))
  8534. {
  8535. return 0;
  8536. }
  8537. pen = 500;
  8538. }
  8539. return pen;
  8540. }
  8541. private int getSilencePenality(string name, int target, Playfield p, int choice)
  8542. {
  8543. int pen = 0;
  8544. if (name == "earthshock") return 0;//earthshock is handled in damage stuff
  8545. if (name == "keeperofthegrove" && choice != 2) return 0; // look at damage penality in this case
  8546. if (target >= 0 && target <= 9)
  8547. {
  8548. if (this.silenceDatabase.ContainsKey(name))
  8549. {
  8550. // no pen if own is enrage
  8551. Minion m = p.ownMinions[target];
  8552. if ((!m.silenced && (m.name == "ancientwatcher" || m.name == "ragnarosthefirelord")) || m.Angr < m.card.Attack || m.maxHp < m.card.Health || (m.frozen && !m.playedThisTurn && m.numAttacksThisTurn == 0))
  8553. {
  8554. return 0;
  8555. }
  8556. pen += 500;
  8557. }
  8558. }
  8559. if (target >= 10 && target <= 19)
  8560. {
  8561. if (this.silenceDatabase.ContainsKey(name))
  8562. {
  8563. // no pen if own is enrage
  8564. Minion m = p.enemyMinions[target - 10];//
  8565. if (!m.silenced && (m.name == "ancientwatcher" || m.name == "ragnarosthefirelord"))
  8566. {
  8567. return 500;
  8568. }
  8569. //silence nothing
  8570. if ((m.Angr < m.card.Attack || m.maxHp < m.card.Health) || !(m.taunt || m.windfury || m.divineshild || m.enchantments.Count >= 1))
  8571. {
  8572. return 30;
  8573. }
  8574. if (priorityDatabase.ContainsKey(m.name) && !m.silenced)
  8575. {
  8576. return -10;
  8577. }
  8578. pen = 0;
  8579. }
  8580. }
  8581. return pen;
  8582. }
  8583. private int getDamagePenality(string name, int target, Playfield p, int choice)
  8584. {
  8585. int pen = 0;
  8586. if (name == "shieldslam" && p.ownHeroDefence == 0) return 500;
  8587. if (name == "savagery" && p.ownheroAngr == 0) return 500;
  8588. if (name == "keeperofthegrove" && choice != 1) return 0; // look at silence penality
  8589. if (this.DamageAllDatabase.ContainsKey(name)) // aoe penality
  8590. {
  8591. foreach (Handmanager.Handcard hc in p.owncards)
  8592. {
  8593. if (hc.card.name == "execute") return 0;
  8594. }
  8595. if (p.enemyMinions.Count <= 1 || p.enemyMinions.Count + 1 <= p.ownMinions.Count || p.ownMinions.Count >= 3)
  8596. {
  8597. return 20;
  8598. }
  8599. }
  8600. if (this.DamageAllEnemysDatabase.ContainsKey(name)) // aoe penality
  8601. {
  8602. foreach (Handmanager.Handcard hc in p.owncards)
  8603. {
  8604. if (hc.card.name == "execute") return 0;
  8605. }
  8606. if (p.enemyMinions.Count <= 2)
  8607. {
  8608. return 20;
  8609. }
  8610. }
  8611. if (target == 100)
  8612. {
  8613. if (DamageTargetDatabase.ContainsKey(name) || DamageTargetSpecialDatabase.ContainsKey(name))
  8614. {
  8615. pen = 500;
  8616. }
  8617. }
  8618. if (target >= 0 && target <= 9)
  8619. {
  8620. if (DamageTargetDatabase.ContainsKey(name))
  8621. {
  8622. // no pen if own is enrage
  8623. Minion m = p.ownMinions[target];
  8624. //standard ones :D (mostly carddraw
  8625. if (enrageDatabase.ContainsKey(m.name) && !m.wounded)
  8626. {
  8627. return pen;
  8628. }
  8629. // no pen if we have battlerage for example
  8630. int dmg = DamageTargetDatabase[name];
  8631. if (m.card.deathrattle) return 10;
  8632. if (m.Hp > dmg)
  8633. {
  8634. if (m.name == "acolyteofpain" && p.owncards.Count <= 3) return 0;
  8635. foreach (Handmanager.Handcard hc in p.owncards)
  8636. {
  8637. if (hc.card.name == "battlerage") return pen;
  8638. if (hc.card.name == "rampage") return pen;
  8639. }
  8640. }
  8641. pen = 500;
  8642. }
  8643. //special cards
  8644. if (DamageTargetSpecialDatabase.ContainsKey(name))
  8645. {
  8646. int dmg = DamageTargetSpecialDatabase[name];
  8647. Minion m = p.ownMinions[target];
  8648. if (name == "demonfire" && (TAG_RACE)m.card.race == TAG_RACE.DEMON) return 0;
  8649. if (name == "earthshock" && m.Hp >= 2)
  8650. {
  8651. if (priorityDatabase.ContainsKey(m.name) && !m.silenced)
  8652. {
  8653. return 500;
  8654. }
  8655. if ((!m.silenced && (m.name == "ancientwatcher" || m.name == "ragnarosthefirelord")) || m.Angr < m.card.Attack || m.maxHp < m.card.Health || (m.frozen && !m.playedThisTurn && m.numAttacksThisTurn == 0))
  8656. return 0;
  8657. }
  8658. if (name == "earthshock")//dont silence other own minions
  8659. {
  8660. return 500;
  8661. }
  8662. // no pen if own is enrage
  8663. if (enrageDatabase.ContainsKey(m.name) && !m.wounded)
  8664. {
  8665. return pen;
  8666. }
  8667. // no pen if we have battlerage for example
  8668. if (m.Hp > dmg)
  8669. {
  8670. foreach (Handmanager.Handcard hc in p.owncards)
  8671. {
  8672. if (hc.card.name == "battlerage") return pen;
  8673. if (hc.card.name == "rampage") return pen;
  8674. }
  8675. }
  8676. pen = 500;
  8677. }
  8678. }
  8679. return pen;
  8680. }
  8681. private int getHealPenality(string name, int target, Playfield p, int choice)
  8682. {
  8683. ///Todo healpenality for aoe heal
  8684. ///todo auchenai soulpriest
  8685. if (name == "ancientoflore" && choice != 2) return 0;
  8686. int pen = 0;
  8687. int heal = 0;
  8688. if (HealHeroDatabase.ContainsKey(name))
  8689. {
  8690. heal = HealHeroDatabase[name];
  8691. if (target == 200) pen = 500; // dont heal enemy
  8692. if ((target == 100 || target == -1) && p.ownHeroHp + heal > 30) pen = p.ownHeroHp + heal - 30;
  8693. }
  8694. if (HealTargetDatabase.ContainsKey(name))
  8695. {
  8696. heal = HealTargetDatabase[name];
  8697. if (target == 200) pen = 500; // dont heal enemy
  8698. if ((target == 100) && p.ownHeroHp + heal > 30) pen = p.ownHeroHp + heal - 30;
  8699. Minion m = new Minion();
  8700. if (target >= 0 && target < 10)
  8701. {
  8702. m = p.ownMinions[target];
  8703. int wasted = 0;
  8704. if (m.Hp + heal > m.maxHp) wasted = m.Hp + heal - m.maxHp;
  8705. pen = wasted;
  8706. if (m.taunt && wasted <= 2 && m.Hp < m.maxHp) pen -= 5; // if we heal a taunt, its good :D
  8707. }
  8708. if (target >= 10 && target < 20)
  8709. {
  8710. m = p.enemyMinions[target - 10];
  8711. // no penality if we heal enrage enemy
  8712. if (enrageDatabase.ContainsKey(m.name))
  8713. {
  8714. return pen;
  8715. }
  8716. // no penality if we have heal-trigger :D
  8717. int i = 0;
  8718. foreach (Minion mnn in p.ownMinions)
  8719. {
  8720. if (mnn.name == "northshirecleric") i++;
  8721. if (mnn.name == "lightwarden") i++;
  8722. }
  8723. foreach (Minion mnn in p.enemyMinions)
  8724. {
  8725. if (mnn.name == "northshirecleric") i--;
  8726. if (mnn.name == "lightwarden") i--;
  8727. }
  8728. if (i >= 1) return pen;
  8729. // no pen if we have slam
  8730. foreach (Handmanager.Handcard hc in p.owncards)
  8731. {
  8732. if (hc.card.name == "slam") return pen;
  8733. if (hc.card.name == "backstab") return pen;
  8734. }
  8735. pen = 500;
  8736. }
  8737. if ((target == 100) && p.ownHeroHp + heal > 30) pen = p.ownHeroHp + heal - 30;
  8738. }
  8739. return pen;
  8740. }
  8741. private int getCardDrawPenality(string name, int target, Playfield p, int choice)
  8742. {
  8743. // penality if carddraw is late or you have enough cards
  8744. int pen = 0;
  8745. if (!cardDrawBattleCryDatabase.ContainsKey(name)) return 0;
  8746. if (name == "ancientoflore" && choice != 1) return 0;
  8747. if (name == "wrath" && choice != 2) return 0;
  8748. if (name == "nourish" && choice != 2) return 0;
  8749. int carddraw = cardDrawBattleCryDatabase[name];
  8750. if (name == "harrisonjones") carddraw = p.enemyWeaponDurability;
  8751. if (name == "divinefavor") carddraw = p.enemyAnzCards + p.enemycarddraw - (p.owncards.Count);
  8752. if (name == "battlerage")
  8753. {
  8754. carddraw = 0;
  8755. foreach (Minion mnn in p.ownMinions)
  8756. {
  8757. if (mnn.wounded) carddraw++;
  8758. }
  8759. }
  8760. if (name == "slam")
  8761. {
  8762. Minion m = new Minion();
  8763. if (target >= 0 && target <= 9)
  8764. {
  8765. m = p.ownMinions[target];
  8766. }
  8767. if (target >= 10 && target <= 19)
  8768. {
  8769. m = p.enemyMinions[target - 10];
  8770. }
  8771. carddraw = 0;
  8772. if (m.Hp >= 3) carddraw = 1;
  8773. if (carddraw == 0) return 2;
  8774. }
  8775. if (name == "mortalcoil")
  8776. {
  8777. Minion m = new Minion();
  8778. if (target >= 0 && target <= 9)
  8779. {
  8780. m = p.ownMinions[target];
  8781. }
  8782. if (target >= 10 && target <= 19)
  8783. {
  8784. m = p.enemyMinions[target - 10];
  8785. }
  8786. carddraw = 0;
  8787. if (m.Hp == 1) carddraw = 1;
  8788. if (carddraw == 0) return 2;
  8789. }
  8790. if (p.owncards.Count >= 5) return 0;
  8791. pen = -carddraw + p.ownMaxMana - p.mana;
  8792. return pen;
  8793. }
  8794. private int getCardDrawofEffectMinions(CardDB.Card card, Playfield p)
  8795. {
  8796. int pen = 0;
  8797. int carddraw = 0;
  8798. if (card.type == CardDB.cardtype.SPELL)
  8799. {
  8800. foreach (Minion mnn in p.ownMinions)
  8801. {
  8802. if (mnn.name == "gadgetzanauctioneer") carddraw++;
  8803. }
  8804. }
  8805. if (card.type == CardDB.cardtype.MOB && (TAG_RACE)card.race == TAG_RACE.PET)
  8806. {
  8807. foreach (Minion mnn in p.ownMinions)
  8808. {
  8809. if (mnn.name == "starvingbuzzard") carddraw++;
  8810. }
  8811. }
  8812. if (carddraw == 0) return 0;
  8813. if (p.owncards.Count >= 5) return 0;
  8814. pen = -carddraw + p.ownMaxMana - p.mana;
  8815. return pen;
  8816. }
  8817. private int getCardDiscardPenality(string name, Playfield p)
  8818. {
  8819. if (p.owncards.Count == 0) return 0;
  8820. int pen = 0;
  8821. if (this.cardDiscardDatabase.ContainsKey(name))
  8822. {
  8823. int newmana = p.mana - cardDiscardDatabase[name];
  8824. bool canplayanothercard = false;
  8825. foreach (Handmanager.Handcard hc in p.owncards)
  8826. {
  8827. if (hc.card.cost <= newmana)
  8828. {
  8829. canplayanothercard = true;
  8830. }
  8831. }
  8832. if (canplayanothercard) pen += 10;
  8833. }
  8834. return pen;
  8835. }
  8836. private int getDestroyOwnPenality(string name, int target, Playfield p)
  8837. {
  8838. if (!this.destroyOwnDatabase.ContainsKey(name)) return 0;
  8839. int pen = 0;
  8840. if ((name == "brawl" || name == "deathwing" || name == "twistingnether") && p.mobsplayedThisTurn >= 1) return 500;
  8841. if (target >= 0 && target <= 9)
  8842. {
  8843. // dont destroy owns ;_; (except mins with deathrattle effects)
  8844. Minion m = p.ownMinions[target];
  8845. if (m.card.deathrattle) return 10;
  8846. return 500;
  8847. }
  8848. return pen;
  8849. }
  8850. private int getDestroyPenality(string name, int target, Playfield p)
  8851. {
  8852. if (!this.destroyDatabase.ContainsKey(name)) return 0;
  8853. int pen = 0;
  8854. if (target >= 10 && target <= 19)
  8855. {
  8856. // dont destroy owns ;_; (except mins with deathrattle effects)
  8857. Minion m = p.enemyMinions[target - 10];
  8858. if (m.Angr <= 4)
  8859. {
  8860. pen += 25; // so we dont destroy cheap ones :D
  8861. }
  8862. }
  8863. return pen;
  8864. }
  8865. private int getSpecialCardComboPenalitys(CardDB.Card card, int target, Playfield p)
  8866. {
  8867. string name = card.name;
  8868. //some effects, which are bad :D
  8869. int pen = 0;
  8870. Minion m = new Minion();
  8871. if (target >= 0 && target <= 9)
  8872. {
  8873. m = p.ownMinions[target];
  8874. }
  8875. if (target >= 10 && target <= 19)
  8876. {
  8877. m = p.enemyMinions[target - 10];
  8878. }
  8879. if (name == "facelessmanipulator")
  8880. {
  8881. if (target == -1)
  8882. {
  8883. return 21;
  8884. }
  8885. if (this.priorityTargets.ContainsKey(m.name) || m.Angr >= 5)
  8886. {
  8887. return 0;
  8888. }
  8889. return 10;
  8890. }
  8891. if ((name == "polymorph" || name == "hex"))
  8892. {
  8893. if (target >= 0 && target <= 9)
  8894. {
  8895. return 500;
  8896. }
  8897. if (target >= 10 && target <= 19)
  8898. {
  8899. Minion frog = p.enemyMinions[target - 10];
  8900. if (this.priorityTargets.ContainsKey(frog.name)) return 0;
  8901. if (frog.Angr >= 4 && frog.Hp >= 4) return 0;
  8902. return 30;
  8903. }
  8904. }
  8905. if ((name == "biggamehunter") && target == -1)
  8906. {
  8907. return 19;
  8908. }
  8909. if ((name == "defenderofargus" || name == "sunfuryprotector") && p.ownMinions.Count == 0)
  8910. {
  8911. return 10;
  8912. }
  8913. if (name == "unleashthehounds")
  8914. {
  8915. if (p.enemyMinions.Count <= 1)
  8916. {
  8917. return 20;
  8918. }
  8919. }
  8920. if (name == "equality") // aoe penality
  8921. {
  8922. if (p.enemyMinions.Count <= 2 || (p.ownMinions.Count - p.enemyMinions.Count >= 1))
  8923. {
  8924. return 20;
  8925. }
  8926. }
  8927. if (name == "bloodsailraider" && p.ownWeaponDurability == 0)
  8928. {
  8929. //if you have bloodsailraider and no weapon equiped, but own a weapon:
  8930. foreach (Handmanager.Handcard hc in p.owncards)
  8931. {
  8932. if (hc.card.type == CardDB.cardtype.WEAPON) return 10;
  8933. }
  8934. }
  8935. if (name == "theblackknight")
  8936. {
  8937. foreach (Minion mnn in p.enemyMinions)
  8938. {
  8939. if (mnn.taunt && (m.Angr >= 3 || m.Hp >= 3)) return 0;
  8940. }
  8941. return 10;
  8942. }
  8943. if (name == "innerfire")
  8944. {
  8945. if (m.name == "lightspawn") pen = 500;
  8946. }
  8947. if (name == "huntersmark")
  8948. {
  8949. if (target >= 0 && target <= 9) pen = 500; // dont use on own minions
  8950. if (target >= 10 && target <= 19 && (p.enemyMinions[target - 10].Hp <= 4) && p.enemyMinions[target - 10].Angr <= 4) // only use on strong minions
  8951. {
  8952. pen = 20;
  8953. }
  8954. }
  8955. if (name == "aldorpeacekeeper" && target == -1)
  8956. {
  8957. pen = 30;
  8958. }
  8959. if ((name == "aldorpeacekeeper" || name == "humility") && target >= 0 && target <= 19)
  8960. {
  8961. if (target >= 0 && target <= 9) pen = 500; // dont use on own minions
  8962. if (target >= 10 && target <= 19 && p.enemyMinions[target - 10].Angr <= 3) // only use on strong minions
  8963. {
  8964. pen = 30;
  8965. }
  8966. if (m.name == "lightspawn") pen = 500;
  8967. }
  8968. if (returnHandDatabase.ContainsKey(name))
  8969. {
  8970. if (name == "vanish")
  8971. {
  8972. //dont vanish if we have minons on board wich are ready
  8973. bool haveready = false;
  8974. foreach (Minion mins in p.ownMinions)
  8975. {
  8976. if (mins.Ready) haveready = true;
  8977. }
  8978. if (haveready) pen += 10;
  8979. }
  8980. if (target >= 0 && target <= 9)
  8981. {
  8982. Minion mnn = p.ownMinions[target];
  8983. if (mnn.Ready) pen += 10;
  8984. }
  8985. }
  8986. return pen;
  8987. }
  8988. private int playSecretPenality(CardDB.Card card, Playfield p)
  8989. {
  8990. //penality if we play secret and have playable kirintormage
  8991. int pen = 0;
  8992. if (card.Secret)
  8993. {
  8994. foreach (Handmanager.Handcard hc in p.owncards)
  8995. {
  8996. if (hc.card.name == "kirintormage" && p.mana >= hc.card.cost)
  8997. {
  8998. pen = 500;
  8999. }
  9000. }
  9001. }
  9002. return pen;
  9003. }
  9004. ///secret strategys pala
  9005. /// -Attack lowest enemy. If you can’t, use noncombat means to kill it.
  9006. /// -attack with something able to withstand 2 damage.
  9007. /// -Then play something that had low health to begin with to dodge Repentance.
  9008. ///
  9009. ///secret strategys hunter
  9010. /// - kill enemys with your minions with 2 or less heal.
  9011. /// - Use the smallest minion available for the first attack
  9012. /// - Then smack them in the face with whatever’s left.
  9013. /// - If nothing triggered until then, it’s a Snipe, so throw something in front of it that won’t die or is expendable.
  9014. ///
  9015. ///secret strategys mage
  9016. /// - Play a small minion to trigger Mirror Entity.
  9017. /// Then attack the mage directly with the smallest minion on your side.
  9018. /// If nothing triggered by that point, it’s either Spellbender or Counterspell, so hold your spells until you can (and have to!) deal with either.
  9019. private int getPlayCardSecretPenality(CardDB.Card c, Playfield p)
  9020. {
  9021. int pen = 0;
  9022. if (p.enemySecretCount == 0)
  9023. {
  9024. return 0;
  9025. }
  9026. int attackedbefore = 0;
  9027. foreach (Minion mnn in p.ownMinions)
  9028. {
  9029. if (mnn.numAttacksThisTurn >= 1) attackedbefore++;
  9030. }
  9031. if (c.name == "acidicswampooze" && (p.enemyHeroName == "warrior" || p.enemyHeroName == "thief" || p.enemyHeroName == "pala"))
  9032. {
  9033. if (p.enemyHeroName == "thief" && p.enemyWeaponAttack <= 2)
  9034. {
  9035. pen += 100;
  9036. }
  9037. else
  9038. {
  9039. if (p.enemyWeaponAttack <= 1)
  9040. {
  9041. pen += 100;
  9042. }
  9043. }
  9044. }
  9045. if (p.enemyHeroName == "hunter")
  9046. {
  9047. if (c.type == CardDB.cardtype.MOB && (attackedbefore == 0 || c.Health <= 4 || (p.enemyHeroHp >= p.enemyHeroHpStarted && attackedbefore >= 1)))
  9048. {
  9049. pen += 10;
  9050. }
  9051. }
  9052. if (p.enemyHeroName == "mage")
  9053. {
  9054. if (c.type == CardDB.cardtype.MOB)
  9055. {
  9056. Minion m = new Minion();
  9057. m.Hp = c.Health;
  9058. m.maxHp = c.Health;
  9059. m.Angr = c.Attack;
  9060. m.taunt = c.tank;
  9061. m.name = c.name;
  9062. //play first the small minion:
  9063. if ((!isOwnLowestInHand(m, p) && p.mobsplayedThisTurn == 0) || (p.mobsplayedThisTurn == 0 && attackedbefore >= 1)) pen += 10;
  9064. }
  9065. if (c.type == CardDB.cardtype.SPELL && p.cardsPlayedThisTurn == p.mobsplayedThisTurn)
  9066. {
  9067. pen += 10;
  9068. }
  9069. }
  9070. if (p.enemyHeroName == "pala")
  9071. {
  9072. if (c.type == CardDB.cardtype.MOB)
  9073. {
  9074. Minion m = new Minion();
  9075. m.Hp = c.Health;
  9076. m.maxHp = c.Health;
  9077. m.Angr = c.Attack;
  9078. m.taunt = c.tank;
  9079. m.name = c.name;
  9080. if ((!isOwnLowestInHand(m, p) && p.mobsplayedThisTurn == 0) || attackedbefore == 0) pen += 10;
  9081. }
  9082. }
  9083. return pen;
  9084. }
  9085. private int getAttackSecretPenality(Minion m, Playfield p, int target)
  9086. {
  9087. if (p.enemySecretCount == 0)
  9088. {
  9089. return 0;
  9090. }
  9091. int pen = 0;
  9092. int attackedbefore = 0;
  9093. foreach (Minion mnn in p.ownMinions)
  9094. {
  9095. if (mnn.numAttacksThisTurn >= 1) attackedbefore++;
  9096. }
  9097. if (p.enemyHeroName == "hunter")
  9098. {
  9099. bool islow = isOwnLowest(m, p);
  9100. if (attackedbefore == 0 && islow) pen -= 20;
  9101. if (attackedbefore == 0 && !islow) pen += 10;
  9102. if (target == 200 && p.enemyMinions.Count >= 1)
  9103. {
  9104. //penality if we doestn attacked before
  9105. if (hasMinionsWithLowHeal(p)) pen += 10; //penality if we doestn attacked minions before
  9106. }
  9107. }
  9108. if (p.enemyHeroName == "mage")
  9109. {
  9110. if (p.mobsplayedThisTurn == 0) pen += 10;
  9111. bool islow = isOwnLowest(m, p);
  9112. if (target == 200 && !islow)
  9113. {
  9114. pen += 10;
  9115. }
  9116. if (target == 200 && islow && p.mobsplayedThisTurn >= 1)
  9117. {
  9118. pen -= 20;
  9119. }
  9120. }
  9121. if (p.enemyHeroName == "pala")
  9122. {
  9123. bool islow = isOwnLowest(m, p);
  9124. if (target >= 10 && target <= 20 && attackedbefore == 0)
  9125. {
  9126. Minion enem = p.enemyMinions[target - 10];
  9127. if (!isEnemyLowest(enem, p) || m.Hp <= 2) pen += 5;
  9128. }
  9129. if (target == 200 && !islow)
  9130. {
  9131. pen += 5;
  9132. }
  9133. if (target == 200 && p.enemyMinions.Count >= 1 && attackedbefore == 0)
  9134. {
  9135. pen += 5;
  9136. }
  9137. }
  9138. return pen;
  9139. }
  9140. private int getValueOfMinion(Minion m)
  9141. {
  9142. int ret = 0;
  9143. ret += 2 * m.Angr + m.Hp;
  9144. if (m.taunt) ret += 2;
  9145. if (this.priorityDatabase.ContainsKey(m.name)) ret += 20 + priorityDatabase[m.name];
  9146. return ret;
  9147. }
  9148. private bool isOwnLowest(Minion mnn, Playfield p)
  9149. {
  9150. bool ret = true;
  9151. int val = getValueOfMinion(mnn);
  9152. foreach (Minion m in p.ownMinions)
  9153. {
  9154. if (!m.Ready) continue;
  9155. if (getValueOfMinion(m) < val) ret = false;
  9156. }
  9157. return ret;
  9158. }
  9159. private bool isOwnLowestInHand(Minion mnn, Playfield p)
  9160. {
  9161. bool ret = true;
  9162. Minion m = new Minion();
  9163. int val = getValueOfMinion(mnn);
  9164. foreach (Handmanager.Handcard card in p.owncards)
  9165. {
  9166. if (card.card.type != CardDB.cardtype.MOB) continue;
  9167. CardDB.Card c = card.card;
  9168. m.Hp = c.Health;
  9169. m.maxHp = c.Health;
  9170. m.Angr = c.Attack;
  9171. m.taunt = c.tank;
  9172. m.name = c.name;
  9173. if (getValueOfMinion(m) < val) ret = false;
  9174. }
  9175. return ret;
  9176. }
  9177. private int getValueOfEnemyMinion(Minion m)
  9178. {
  9179. int ret = 0;
  9180. ret += m.Hp;
  9181. if (m.taunt) ret -= 2;
  9182. return ret;
  9183. }
  9184. private bool isEnemyLowest(Minion mnn, Playfield p)
  9185. {
  9186. bool ret = true;
  9187. List<targett> litt = p.getAttackTargets();
  9188. int val = getValueOfEnemyMinion(mnn);
  9189. foreach (Minion m in p.enemyMinions)
  9190. {
  9191. if (litt.Find(x => x.target == m.id) == null) continue;
  9192. if (getValueOfEnemyMinion(m) < val) ret = false;
  9193. }
  9194. return ret;
  9195. }
  9196. private bool hasMinionsWithLowHeal(Playfield p)
  9197. {
  9198. bool ret = false;
  9199. foreach (Minion m in p.ownMinions)
  9200. {
  9201. if (m.Hp <= 2 && (m.Ready || this.priorityDatabase.ContainsKey(m.name))) ret = true;
  9202. }
  9203. return ret;
  9204. }
  9205. private void setupEnrageDatabase()
  9206. {
  9207. enrageDatabase.Add("amaniberserker", 0);
  9208. enrageDatabase.Add("angrychicken", 0);
  9209. enrageDatabase.Add("grommashhellscream", 0);
  9210. enrageDatabase.Add("ragingworgen", 0);
  9211. enrageDatabase.Add("spitefulsmith", 0);
  9212. enrageDatabase.Add("taurenwarrior", 0);
  9213. }
  9214. private void setupHealDatabase()
  9215. {
  9216. HealAllDatabase.Add("holynova", 2);//to all own minions
  9217. HealAllDatabase.Add("circleofhealing", 4);//allminions
  9218. HealAllDatabase.Add("darkscalehealer", 2);//all friends
  9219. HealHeroDatabase.Add("drainlife", 2);//tohero
  9220. HealHeroDatabase.Add("guardianofkings", 6);//tohero
  9221. HealHeroDatabase.Add("holyfire", 5);//tohero
  9222. HealHeroDatabase.Add("priestessofelune", 4);//tohero
  9223. HealHeroDatabase.Add("sacrificialpact", 5);//tohero
  9224. HealHeroDatabase.Add("siphonsoul", 3); //tohero
  9225. HealTargetDatabase.Add("ancestralhealing", 1000);
  9226. HealTargetDatabase.Add("ancientsecrets", 5);
  9227. HealTargetDatabase.Add("holylight", 6);
  9228. HealTargetDatabase.Add("earthenringfarseer", 3);
  9229. HealTargetDatabase.Add("healingtouch", 8);
  9230. HealTargetDatabase.Add("layonhands", 8);
  9231. HealTargetDatabase.Add("lesserheal", 2);
  9232. HealTargetDatabase.Add("voodoodoctor", 2);
  9233. HealTargetDatabase.Add("willofmukla", 8);
  9234. }
  9235. private void setupDamageDatabase()
  9236. {
  9237. DamageHeroDatabase.Add("headcrack", 2);
  9238. DamageAllDatabase.Add("abomination", 2);
  9239. DamageAllDatabase.Add("dreadinfernal", 1);
  9240. DamageAllDatabase.Add("hellfire", 3);
  9241. DamageAllDatabase.Add("whirlwind", 1);
  9242. DamageAllDatabase.Add("yseraawakens", 5);
  9243. DamageAllEnemysDatabase.Add("arcaneexplosion", 1);
  9244. DamageAllEnemysDatabase.Add("consecration", 1);
  9245. DamageAllEnemysDatabase.Add("fanofknives", 1);
  9246. DamageAllEnemysDatabase.Add("flamestrike", 4);
  9247. DamageAllEnemysDatabase.Add("holynova", 2);
  9248. DamageAllEnemysDatabase.Add("lightningstorm", 2);
  9249. DamageAllEnemysDatabase.Add("stomp", 1);
  9250. DamageAllEnemysDatabase.Add("madbomber", 1);
  9251. DamageAllEnemysDatabase.Add("swipe", 4);//1 to others
  9252. DamageRandomDatabase.Add("arcanemissiles", 1);
  9253. DamageRandomDatabase.Add("avengingwrath", 1);
  9254. DamageRandomDatabase.Add("cleave", 2);
  9255. DamageRandomDatabase.Add("forkedlightning", 2);
  9256. DamageRandomDatabase.Add("multi-shot", 3);
  9257. DamageTargetSpecialDatabase.Add("crueltaskmaster", 1); // gives 2 attack
  9258. DamageTargetSpecialDatabase.Add("innerrage", 1); // gives 2 attack
  9259. DamageTargetSpecialDatabase.Add("demonfire", 2); // friendly demon get +2/+2
  9260. DamageTargetSpecialDatabase.Add("earthshock", 1); //SILENCE /good for raggy etc or iced
  9261. DamageTargetSpecialDatabase.Add("hammerofwrath", 3); //draw a card
  9262. DamageTargetSpecialDatabase.Add("holywrath", 2);//draw a card
  9263. DamageTargetSpecialDatabase.Add("roguesdoit...", 4);//draw a card
  9264. DamageTargetSpecialDatabase.Add("shiv", 1);//draw a card
  9265. DamageTargetSpecialDatabase.Add("savagery", 1);//dmg=herodamage
  9266. DamageTargetSpecialDatabase.Add("shieldslam", 1);//dmg=armor
  9267. DamageTargetSpecialDatabase.Add("slam", 2);//draw card if it survives
  9268. DamageTargetSpecialDatabase.Add("soulfire", 4);//delete a card
  9269. DamageTargetDatabase.Add("keeperofthegrove", 2); // or silence
  9270. DamageTargetDatabase.Add("wrath", 3);//or 1 + card
  9271. DamageTargetDatabase.Add("coneofcold", 1);
  9272. DamageTargetDatabase.Add("arcaneshot", 2);
  9273. DamageTargetDatabase.Add("backstab", 2);
  9274. DamageTargetDatabase.Add("baneofdoom", 2);
  9275. DamageTargetDatabase.Add("barreltoss", 2);
  9276. DamageTargetDatabase.Add("blizzard", 2);
  9277. DamageTargetDatabase.Add("drainlife", 2);
  9278. DamageTargetDatabase.Add("elvenarcher", 1);
  9279. DamageTargetDatabase.Add("eviscerate", 3);
  9280. DamageTargetDatabase.Add("explosiveshot", 5);
  9281. DamageTargetDatabase.Add("fireelemental", 3);
  9282. DamageTargetDatabase.Add("fireball", 6);
  9283. DamageTargetDatabase.Add("fireblast", 1);
  9284. DamageTargetDatabase.Add("frostshock", 1);
  9285. DamageTargetDatabase.Add("frostbolt", 1);
  9286. DamageTargetDatabase.Add("hoggersmash", 4);
  9287. DamageTargetDatabase.Add("holyfire", 5);
  9288. DamageTargetDatabase.Add("holysmite", 2);
  9289. DamageTargetDatabase.Add("icelance", 4);//only if iced
  9290. DamageTargetDatabase.Add("ironforgerifleman", 1);
  9291. DamageTargetDatabase.Add("killcommand", 3);//or 5
  9292. DamageTargetDatabase.Add("lavaburst", 5);
  9293. DamageTargetDatabase.Add("lightningbolt", 2);
  9294. DamageTargetDatabase.Add("mindshatter", 3);
  9295. DamageTargetDatabase.Add("mindspike", 2);
  9296. DamageTargetDatabase.Add("moonfire", 1);
  9297. DamageTargetDatabase.Add("mortalcoil", 1);
  9298. DamageTargetDatabase.Add("mortalstrike", 4);
  9299. DamageTargetDatabase.Add("perditionsblade", 1);
  9300. DamageTargetDatabase.Add("pyroblast", 10);
  9301. DamageTargetDatabase.Add("shadowbolt", 4);
  9302. DamageTargetDatabase.Add("shotgunblast", 1);
  9303. DamageTargetDatabase.Add("si7agent", 2);
  9304. DamageTargetDatabase.Add("starfall", 5);
  9305. DamageTargetDatabase.Add("starfire", 5);//draw a card, but its to strong
  9306. DamageTargetDatabase.Add("stormpikecommando", 5);
  9307. }
  9308. private void setupsilenceDatabase()
  9309. {
  9310. this.silenceDatabase.Add("dispel", 1);
  9311. this.silenceDatabase.Add("earthshock", 1);
  9312. this.silenceDatabase.Add("massdispel", 1);
  9313. this.silenceDatabase.Add("silence", 1);
  9314. this.silenceDatabase.Add("keeperofthegrove", 1);
  9315. this.silenceDatabase.Add("ironbeakowl", 1);
  9316. this.silenceDatabase.Add("spellbreaker", 1);
  9317. }
  9318. private void setupPriorityList()
  9319. {
  9320. this.priorityDatabase.Add("prophetvelen", 5);
  9321. this.priorityDatabase.Add("archmageantonidas", 5);
  9322. this.priorityDatabase.Add("flametonguetotem", 6);
  9323. this.priorityDatabase.Add("raidleader", 5);
  9324. this.priorityDatabase.Add("grimscaleoracle", 5);
  9325. this.priorityDatabase.Add("direwolfalpha", 6);
  9326. this.priorityDatabase.Add("murlocwarleader", 5);
  9327. this.priorityDatabase.Add("southseacaptain", 5);
  9328. this.priorityDatabase.Add("stormwindchampion", 5);
  9329. this.priorityDatabase.Add("timberwolf", 5);
  9330. this.priorityDatabase.Add("leokk", 5);
  9331. this.priorityDatabase.Add("northshirecleric", 5);
  9332. this.priorityDatabase.Add("sorcerersapprentice", 3);
  9333. this.priorityDatabase.Add("summoningportal", 5);
  9334. this.priorityDatabase.Add("pint-sizedsummoner", 3);
  9335. this.priorityDatabase.Add("scavenginghyena", 5);
  9336. this.priorityDatabase.Add("manatidetotem ", 5);
  9337. }
  9338. private void setupAttackBuff()
  9339. {
  9340. heroAttackBuffDatabase.Add("bite", 4);
  9341. heroAttackBuffDatabase.Add("claw", 2);
  9342. heroAttackBuffDatabase.Add("heroicstrike", 2);
  9343. this.attackBuffDatabase.Add("abusivesergeant", 2);
  9344. this.attackBuffDatabase.Add("ancientofwar", 5); //choice1
  9345. this.attackBuffDatabase.Add("bananas", 1);
  9346. this.attackBuffDatabase.Add("bestialwrath", 2); // NEVER ON enemy MINION
  9347. this.attackBuffDatabase.Add("blessingofkings", 4);
  9348. this.attackBuffDatabase.Add("blessingofmight", 3);
  9349. this.attackBuffDatabase.Add("coldblood", 2);
  9350. this.attackBuffDatabase.Add("crueltaskmaster", 2);
  9351. this.attackBuffDatabase.Add("darkirondwarf", 2);
  9352. this.attackBuffDatabase.Add("innerrage", 2);
  9353. this.attackBuffDatabase.Add("markofnature", 4);//choice1
  9354. this.attackBuffDatabase.Add("markofthewild", 2);
  9355. this.attackBuffDatabase.Add("nightmare", 5); //destroy minion on next turn
  9356. this.attackBuffDatabase.Add("rampage", 3);//only damaged minion
  9357. this.attackBuffDatabase.Add("uproot", 5);
  9358. }
  9359. private void setupHealthBuff()
  9360. {
  9361. this.healthBuffDatabase.Add("ancientofwar", 5);//choice2
  9362. this.healthBuffDatabase.Add("bananas", 1);
  9363. this.healthBuffDatabase.Add("blessingofkings", 4);
  9364. this.healthBuffDatabase.Add("markofnature", 4);//choice2
  9365. this.healthBuffDatabase.Add("markofthewild", 2);
  9366. this.healthBuffDatabase.Add("nightmare", 5);
  9367. this.healthBuffDatabase.Add("powerwordshield", 2);
  9368. this.healthBuffDatabase.Add("rampage", 3);
  9369. this.healthBuffDatabase.Add("rooted", 5);
  9370. this.tauntBuffDatabase.Add("markofnature", 1);
  9371. this.tauntBuffDatabase.Add("markofthewild", 1);
  9372. this.tauntBuffDatabase.Add("rooted", 1);
  9373. }
  9374. private void setupCardDrawBattlecry()
  9375. {
  9376. cardDrawBattleCryDatabase.Add("wrath", 1); //choice=2
  9377. cardDrawBattleCryDatabase.Add("ancientoflore", 2);// choice =1
  9378. cardDrawBattleCryDatabase.Add("nourish", 3); //choice = 2
  9379. cardDrawBattleCryDatabase.Add("ancientteachings", 2);
  9380. cardDrawBattleCryDatabase.Add("excessmana", 1);
  9381. cardDrawBattleCryDatabase.Add("starfire", 1);
  9382. cardDrawBattleCryDatabase.Add("azuredrake", 1);
  9383. cardDrawBattleCryDatabase.Add("coldlightoracle", 2);
  9384. cardDrawBattleCryDatabase.Add("gnomishinventor", 1);
  9385. cardDrawBattleCryDatabase.Add("harrisonjones", 0);
  9386. cardDrawBattleCryDatabase.Add("noviceengineer", 1);
  9387. cardDrawBattleCryDatabase.Add("roguesdoit...", 1);
  9388. cardDrawBattleCryDatabase.Add("arcaneintellect", 1);
  9389. cardDrawBattleCryDatabase.Add("hammerofwrath", 1);
  9390. cardDrawBattleCryDatabase.Add("holywrath", 1);
  9391. cardDrawBattleCryDatabase.Add("layonhands", 3);
  9392. cardDrawBattleCryDatabase.Add("massdispel", 1);
  9393. cardDrawBattleCryDatabase.Add("powerwordshield", 1);
  9394. cardDrawBattleCryDatabase.Add("fanofknives", 1);
  9395. cardDrawBattleCryDatabase.Add("shiv", 1);
  9396. cardDrawBattleCryDatabase.Add("sprint", 4);
  9397. cardDrawBattleCryDatabase.Add("farsight", 1);
  9398. cardDrawBattleCryDatabase.Add("lifetap", 1);
  9399. cardDrawBattleCryDatabase.Add("commandingshout", 1);
  9400. cardDrawBattleCryDatabase.Add("shieldblock", 1);
  9401. cardDrawBattleCryDatabase.Add("slam", 1); //if survives
  9402. cardDrawBattleCryDatabase.Add("mortalcoil", 1);//only if kills
  9403. cardDrawBattleCryDatabase.Add("battlerage", 1);//only if wounded own minions
  9404. cardDrawBattleCryDatabase.Add("divinefavor", 1);//only if enemy has more cards than you
  9405. }
  9406. private void setupDiscardCards()
  9407. {
  9408. cardDiscardDatabase.Add("doomguard", 5);
  9409. cardDiscardDatabase.Add("soulfire", 0);
  9410. cardDiscardDatabase.Add("succubus", 2);
  9411. }
  9412. private void setupDestroyOwnCards()
  9413. {
  9414. this.destroyOwnDatabase.Add("brawl", 0);
  9415. this.destroyOwnDatabase.Add("deathwing", 0);
  9416. this.destroyOwnDatabase.Add("twistingnether", 0);
  9417. this.destroyOwnDatabase.Add("naturalize", 0);//not own mins
  9418. this.destroyOwnDatabase.Add("shadowworddeath", 0);//not own mins
  9419. this.destroyOwnDatabase.Add("shadowwordpain", 0);//not own mins
  9420. this.destroyOwnDatabase.Add("siphonsoul", 0);//not own mins
  9421. this.destroyOwnDatabase.Add("biggamehunter", 0);//not own mins
  9422. this.destroyOwnDatabase.Add("hungrycrab", 0);//not own mins
  9423. this.destroyOwnDatabase.Add("sacrificialpact", 0);//not own mins
  9424. this.destroyDatabase.Add("assassinate", 0);//not own mins
  9425. this.destroyDatabase.Add("corruption", 0);//not own mins
  9426. this.destroyDatabase.Add("execute", 0);//not own mins
  9427. this.destroyDatabase.Add("naturalize", 0);//not own mins
  9428. this.destroyDatabase.Add("siphonsoul", 0);//not own mins
  9429. this.destroyDatabase.Add("mindcontrol", 0);//not own mins
  9430. }
  9431. private void setupReturnBackToHandCards()
  9432. {
  9433. returnHandDatabase.Add("ancientbrewmaster", 0);
  9434. returnHandDatabase.Add("dream", 0);
  9435. returnHandDatabase.Add("kidnapper", 0);//if combo
  9436. returnHandDatabase.Add("shadowstep", 0);
  9437. returnHandDatabase.Add("vanish", 0);
  9438. returnHandDatabase.Add("youthfulbrewmaster", 0);
  9439. }
  9440. private void setupHeroDamagingAOE()
  9441. {
  9442. this.heroDamagingAoeDatabase.Add("", 0);
  9443. }
  9444. private void setupSpecialMins()
  9445. {
  9446. this.specialMinions.Add("amaniberserker", 0);
  9447. this.specialMinions.Add("angrychicken", 0);
  9448. this.specialMinions.Add("abomination", 0);
  9449. this.specialMinions.Add("acolyteofpain", 0);
  9450. this.specialMinions.Add("alarm-o-bot", 0);
  9451. this.specialMinions.Add("archmage", 0);
  9452. this.specialMinions.Add("archmageantonidas", 0);
  9453. this.specialMinions.Add("armorsmith", 0);
  9454. this.specialMinions.Add("auchenaisoulpriest", 0);
  9455. this.specialMinions.Add("azuredrake", 0);
  9456. this.specialMinions.Add("barongeddon", 0);
  9457. this.specialMinions.Add("bloodimp", 0);
  9458. this.specialMinions.Add("bloodmagethalnos", 0);
  9459. this.specialMinions.Add("cairnebloodhoof", 0);
  9460. this.specialMinions.Add("cultmaster", 0);
  9461. this.specialMinions.Add("dalaranmage", 0);
  9462. this.specialMinions.Add("demolisher", 0);
  9463. this.specialMinions.Add("direwolfalpha", 0);
  9464. this.specialMinions.Add("doomsayer", 0);
  9465. this.specialMinions.Add("emperorcobra", 0);
  9466. this.specialMinions.Add("etherealarcanist", 0);
  9467. this.specialMinions.Add("flametonguetotem", 0);
  9468. this.specialMinions.Add("flesheatingghoul", 0);
  9469. this.specialMinions.Add("gadgetzanauctioneer", 0);
  9470. this.specialMinions.Add("grimscaleoracle", 0);
  9471. this.specialMinions.Add("grommashhellscream", 0);
  9472. this.specialMinions.Add("gruul", 0);
  9473. this.specialMinions.Add("gurubashiberserker", 0);
  9474. this.specialMinions.Add("harvestgolem", 0);
  9475. this.specialMinions.Add("hogger", 0);
  9476. this.specialMinions.Add("illidanstormrage", 0);
  9477. this.specialMinions.Add("impmaster", 0);
  9478. this.specialMinions.Add("knifejuggler", 0);
  9479. this.specialMinions.Add("koboldgeomancer", 0);
  9480. this.specialMinions.Add("lepergnome", 0);
  9481. this.specialMinions.Add("lightspawn", 0);
  9482. this.specialMinions.Add("lighwarden", 0);
  9483. this.specialMinions.Add("lightwell", 0);
  9484. this.specialMinions.Add("loothoader", 0);
  9485. this.specialMinions.Add("lorewalkercho", 0);
  9486. this.specialMinions.Add("malygos", 0);
  9487. this.specialMinions.Add("manaaddict", 0);
  9488. this.specialMinions.Add("manatidetotem", 0);
  9489. this.specialMinions.Add("manawraith", 0);
  9490. this.specialMinions.Add("manawyrm", 0);
  9491. this.specialMinions.Add("masterswordsmith", 0);
  9492. this.specialMinions.Add("murloctidecaller", 0);
  9493. this.specialMinions.Add("murlocwarleader", 0);
  9494. this.specialMinions.Add("natpagle", 0);
  9495. this.specialMinions.Add("northshirecleric", 0);
  9496. this.specialMinions.Add("ogremagi", 0);
  9497. this.specialMinions.Add("oldmurk-eye", 0);
  9498. this.specialMinions.Add("patientassasin", 0);
  9499. this.specialMinions.Add("pint-sizedsummoner", 0);
  9500. this.specialMinions.Add("prophetvelen", 0);
  9501. this.specialMinions.Add("questingadventurer", 0);
  9502. this.specialMinions.Add("ragingworgen", 0);
  9503. this.specialMinions.Add("raidleader", 0);
  9504. this.specialMinions.Add("savannahhighmane", 0);
  9505. this.specialMinions.Add("scavenginghyena", 0);
  9506. this.specialMinions.Add("secretkeeper", 0);
  9507. this.specialMinions.Add("sorcerersapprentice", 0);
  9508. this.specialMinions.Add("southseacaptain", 0);
  9509. this.specialMinions.Add("spitefulsmith", 0);
  9510. this.specialMinions.Add("starvingbuzzard", 0);
  9511. this.specialMinions.Add("stormwindchampion", 0);
  9512. this.specialMinions.Add("summoningportal", 0);
  9513. this.specialMinions.Add("sylvanaswindrunner", 0);
  9514. this.specialMinions.Add("taurenwarrior", 0);
  9515. this.specialMinions.Add("thebeast", 0);
  9516. this.specialMinions.Add("timberwolf", 0);
  9517. this.specialMinions.Add("tirionfordring", 0);
  9518. this.specialMinions.Add("tundrarhino", 0);
  9519. this.specialMinions.Add("unboundelemental", 0);
  9520. this.specialMinions.Add("venturecomercenary", 0);
  9521. this.specialMinions.Add("violentteacher", 0);
  9522. this.specialMinions.Add("warsongcommander", 0);
  9523. this.specialMinions.Add("waterelemental", 0);
  9524. }
  9525. private void setupEnemyTargetPriority()
  9526. {
  9527. priorityTargets.Add("angrychicken", 10);
  9528. priorityTargets.Add("lightwarden", 10);
  9529. priorityTargets.Add("secretkeeper", 10);
  9530. priorityTargets.Add("youngdragonhawk", 10);
  9531. priorityTargets.Add("bloodmagethalnos", 10);
  9532. priorityTargets.Add("direwolfalpha", 10);
  9533. priorityTargets.Add("doomsayer", 10);
  9534. priorityTargets.Add("knifejuggler", 10);
  9535. priorityTargets.Add("koboldgeomancer", 10);
  9536. priorityTargets.Add("manaaddict", 10);
  9537. priorityTargets.Add("masterswordsmith", 10);
  9538. priorityTargets.Add("natpagle", 10);
  9539. priorityTargets.Add("murloctidehunter", 10);
  9540. priorityTargets.Add("pint-sizedsummoner", 10);
  9541. priorityTargets.Add("wildpyromancer", 10);
  9542. priorityTargets.Add("alarm-o-bot", 10);
  9543. priorityTargets.Add("acolyteofpain", 10);
  9544. priorityTargets.Add("demolisher", 10);
  9545. priorityTargets.Add("flesheatingghoul", 10);
  9546. priorityTargets.Add("impmaster", 10);
  9547. priorityTargets.Add("questingadventurer", 10);
  9548. priorityTargets.Add("raidleader", 10);
  9549. priorityTargets.Add("thrallmarfarseer", 10);
  9550. priorityTargets.Add("cultmaster", 10);
  9551. priorityTargets.Add("leeroyjenkins", 10);
  9552. priorityTargets.Add("violetteacher", 10);
  9553. priorityTargets.Add("gadgetzanauctioneer", 10);
  9554. priorityTargets.Add("hogger", 10);
  9555. priorityTargets.Add("illidanstormrage", 10);
  9556. priorityTargets.Add("barongeddon", 10);
  9557. priorityTargets.Add("stormwindchampion", 10);
  9558. //warrior cards
  9559. priorityTargets.Add("frothingberserker", 10);
  9560. priorityTargets.Add("warsongcommander", 10);
  9561. //warlock cards
  9562. priorityTargets.Add("summoningportal", 10);
  9563. //shaman cards
  9564. priorityTargets.Add("dustdevil", 10);
  9565. priorityTargets.Add("wrathofairtotem", 10);
  9566. priorityTargets.Add("flametonguetotem", 10);
  9567. priorityTargets.Add("manatidetotem", 10);
  9568. priorityTargets.Add("unboundelemental", 10);
  9569. //rogue cards
  9570. //priest cards
  9571. priorityTargets.Add("northshirecleric", 10);
  9572. priorityTargets.Add("lightwell", 10);
  9573. priorityTargets.Add("auchenaisoulpriest", 10);
  9574. priorityTargets.Add("prophetvelen", 10);
  9575. //paladin cards
  9576. //mage cards
  9577. priorityTargets.Add("manawyrm", 10);
  9578. priorityTargets.Add("sorcererapprentice", 10);
  9579. priorityTargets.Add("etherealarcanist", 10);
  9580. priorityTargets.Add("archmageantonidas", 10);
  9581. //hunter cards
  9582. priorityTargets.Add("timberwolf", 10);
  9583. priorityTargets.Add("scavenginghyena", 10);
  9584. priorityTargets.Add("starvingbuzzard", 10);
  9585. priorityTargets.Add("leokk", 10);
  9586. priorityTargets.Add("tundrarhino", 10);
  9587. }
  9588. }
  9589. public class CardDB
  9590. {
  9591. // Data is stored in hearthstone-folder -> data->win cardxml0
  9592. //(data-> cardxml0 seems outdated (blutelfkleriker has 3hp there >_>)
  9593. public enum cardtype
  9594. {
  9595. NONE,
  9596. MOB,
  9597. SPELL,
  9598. WEAPON,
  9599. HEROPWR,
  9600. ENCHANTMENT,
  9601. }
  9602. public enum ErrorType2
  9603. {
  9604. NONE,//=0
  9605. REQ_MINION_TARGET,//=1
  9606. REQ_FRIENDLY_TARGET,//=2
  9607. REQ_ENEMY_TARGET,//=3
  9608. REQ_DAMAGED_TARGET,//=4
  9609. REQ_ENCHANTED_TARGET,
  9610. REQ_FROZEN_TARGET,
  9611. REQ_CHARGE_TARGET,
  9612. REQ_TARGET_MAX_ATTACK,//=8
  9613. REQ_NONSELF_TARGET,//=9
  9614. REQ_TARGET_WITH_RACE,//=10
  9615. REQ_TARGET_TO_PLAY,//=11
  9616. REQ_NUM_MINION_SLOTS,//=12
  9617. REQ_WEAPON_EQUIPPED,//=13
  9618. REQ_ENOUGH_MANA,//=14
  9619. REQ_YOUR_TURN,
  9620. REQ_NONSTEALTH_ENEMY_TARGET,
  9621. REQ_HERO_TARGET,//17
  9622. REQ_SECRET_CAP,
  9623. REQ_MINION_CAP_IF_TARGET_AVAILABLE,//19
  9624. REQ_MINION_CAP,
  9625. REQ_TARGET_ATTACKED_THIS_TURN,
  9626. REQ_TARGET_IF_AVAILABLE,//=22
  9627. REQ_MINIMUM_ENEMY_MINIONS,//=23 /like spalen :D
  9628. REQ_TARGET_FOR_COMBO,//=24
  9629. REQ_NOT_EXHAUSTED_ACTIVATE,
  9630. REQ_UNIQUE_SECRET,
  9631. REQ_TARGET_TAUNTER,
  9632. REQ_CAN_BE_ATTACKED,
  9633. REQ_ACTION_PWR_IS_MASTER_PWR,
  9634. REQ_TARGET_MAGNET,
  9635. REQ_ATTACK_GREATER_THAN_0,
  9636. REQ_ATTACKER_NOT_FROZEN,
  9637. REQ_HERO_OR_MINION_TARGET,
  9638. REQ_CAN_BE_TARGETED_BY_SPELLS,
  9639. REQ_SUBCARD_IS_PLAYABLE,
  9640. REQ_TARGET_FOR_NO_COMBO,
  9641. REQ_NOT_MINION_JUST_PLAYED,
  9642. REQ_NOT_EXHAUSTED_HERO_POWER,
  9643. REQ_CAN_BE_TARGETED_BY_OPPONENTS,
  9644. REQ_ATTACKER_CAN_ATTACK,
  9645. REQ_TARGET_MIN_ATTACK,//=41
  9646. REQ_CAN_BE_TARGETED_BY_HERO_POWERS,
  9647. REQ_ENEMY_TARGET_NOT_IMMUNE,
  9648. REQ_ENTIRE_ENTOURAGE_NOT_IN_PLAY,//44 (totemic call)
  9649. REQ_MINIMUM_TOTAL_MINIONS,//45 (scharmuetzel)
  9650. REQ_MUST_TARGET_TAUNTER,//=46
  9651. REQ_UNDAMAGED_TARGET//=47
  9652. }
  9653. public class Card
  9654. {
  9655. public string CardID = "";
  9656. public int entityID = 0;
  9657. public string name = "";
  9658. public int race = 0;
  9659. public int rarity = 0;
  9660. public int cost = 0;
  9661. public int crdtype = 0;
  9662. public cardtype type = CardDB.cardtype.NONE;
  9663. public string description = "";
  9664. public int carddraw = 0;
  9665. public int Attack = 0;
  9666. public int Health = 0;
  9667. public int Durability = 0;//for weapons
  9668. public bool target = false;
  9669. public string targettext = "";
  9670. public bool tank = false;
  9671. public bool Silence = false;
  9672. public bool choice = false;
  9673. public bool windfury = false;
  9674. public bool poisionous = false;
  9675. public bool deathrattle = false;
  9676. public bool battlecry = false;
  9677. public bool oneTurnEffect = false;
  9678. public bool Enrage = false;
  9679. public bool Aura = false;
  9680. public bool Elite = false;
  9681. public bool Combo = false;
  9682. public bool Recall = false;
  9683. public int recallValue = 0;
  9684. public bool immuneWhileAttacking = false;
  9685. public bool immuneToSpellpowerg = false;
  9686. public bool Stealth = false;
  9687. public bool Freeze = false;
  9688. public bool AdjacentBuff = false;
  9689. public bool Shield = false;
  9690. public bool Charge = false;
  9691. public bool Secret = false;
  9692. public bool Morph = false;
  9693. public bool Spellpower = false;
  9694. public bool GrantCharge = false;
  9695. public bool HealTarget = false;
  9696. //playRequirements, reqID= siehe PlayErrors->ErrorType
  9697. public int needEmptyPlacesForPlaying = 0;
  9698. public int needWithMinAttackValueOf = 0;
  9699. public int needWithMaxAttackValueOf = 0;
  9700. public int needRaceForPlaying = 0;
  9701. public int needMinNumberOfEnemy = 0;
  9702. public int needMinTotalMinions = 0;
  9703. public int needMinionsCapIfAvailable = 0;
  9704. public List<ErrorType2> playrequires = new List<ErrorType2>();
  9705. public int spellpowervalue = 0;
  9706. public Card()
  9707. { }
  9708. public Card(Card c)
  9709. {
  9710. this.entityID = c.entityID;
  9711. this.rarity = c.rarity;
  9712. this.AdjacentBuff = c.AdjacentBuff;
  9713. this.Attack = c.Attack;
  9714. this.Aura = c.Aura;
  9715. this.battlecry = c.battlecry;
  9716. this.carddraw = c.carddraw;
  9717. this.CardID = c.CardID;
  9718. this.Charge = c.Charge;
  9719. this.choice = c.choice;
  9720. this.Combo = c.Combo;
  9721. this.cost = c.cost;
  9722. this.crdtype = c.crdtype;
  9723. this.deathrattle = c.deathrattle;
  9724. this.description = c.description;
  9725. this.Durability = c.Durability;
  9726. this.Elite = c.Elite;
  9727. this.Enrage = c.Enrage;
  9728. this.Freeze = c.Freeze;
  9729. this.GrantCharge = c.GrantCharge;
  9730. this.HealTarget = c.HealTarget;
  9731. this.Health = c.Health;
  9732. this.immuneToSpellpowerg = c.immuneToSpellpowerg;
  9733. this.immuneWhileAttacking = c.immuneWhileAttacking;
  9734. this.Morph = c.Morph;
  9735. this.name = c.name;
  9736. this.needEmptyPlacesForPlaying = c.needEmptyPlacesForPlaying;
  9737. this.needMinionsCapIfAvailable = c.needMinionsCapIfAvailable;
  9738. this.needMinNumberOfEnemy = c.needMinNumberOfEnemy;
  9739. this.needMinTotalMinions = c.needMinTotalMinions;
  9740. this.needRaceForPlaying = c.needRaceForPlaying;
  9741. this.needWithMaxAttackValueOf = c.needWithMaxAttackValueOf;
  9742. this.needWithMinAttackValueOf = c.needWithMinAttackValueOf;
  9743. this.oneTurnEffect = c.oneTurnEffect;
  9744. this.playrequires.AddRange(c.playrequires);
  9745. this.poisionous = c.poisionous;
  9746. this.race = c.race;
  9747. this.Recall = c.Recall;
  9748. this.recallValue = c.recallValue;
  9749. this.Secret = c.Secret;
  9750. this.Shield = c.Shield;
  9751. this.Silence = c.Silence;
  9752. this.Spellpower = c.Spellpower;
  9753. this.spellpowervalue = c.spellpowervalue;
  9754. this.Stealth = c.Stealth;
  9755. this.tank = c.tank;
  9756. this.target = c.target;
  9757. this.targettext = c.targettext;
  9758. this.type = c.type;
  9759. this.windfury = c.windfury;
  9760. this.playrequires.AddRange(c.playrequires);
  9761. }
  9762. public bool isRequirementInList(CardDB.ErrorType2 et)
  9763. {
  9764. foreach (CardDB.ErrorType2 et2 in this.playrequires)
  9765. {
  9766. if (et == et2)
  9767. {
  9768. return true;
  9769. }
  9770. }
  9771. return false;
  9772. }
  9773. public List<targett> getTargetsForCard(Playfield p)
  9774. {
  9775. List<targett> retval = new List<targett>();
  9776. if (isRequirementInList(CardDB.ErrorType2.REQ_TARGET_FOR_COMBO) && p.cardsPlayedThisTurn == 0) return retval;
  9777. if (isRequirementInList(CardDB.ErrorType2.REQ_TARGET_TO_PLAY) || isRequirementInList(CardDB.ErrorType2.REQ_NONSELF_TARGET) || isRequirementInList(CardDB.ErrorType2.REQ_TARGET_IF_AVAILABLE) || isRequirementInList(CardDB.ErrorType2.REQ_TARGET_FOR_COMBO))
  9778. {
  9779. retval.Add(new targett(100, p.ownHeroEntity));//ownhero
  9780. retval.Add(new targett(200, p.enemyHeroEntity));//enemyhero
  9781. foreach (Minion m in p.ownMinions)
  9782. {
  9783. if ((this.type == cardtype.SPELL || this.type == cardtype.HEROPWR) && (m.name == "faeriedragon" || m.name == "laughingsister")) continue;
  9784. retval.Add(new targett(m.id, m.entitiyID));
  9785. }
  9786. foreach (Minion m in p.enemyMinions)
  9787. {
  9788. if (((this.type == cardtype.SPELL || this.type == cardtype.HEROPWR) && (m.name == "faeriedragon" || m.name == "laughingsister")) || m.stealth) continue;
  9789. retval.Add(new targett(m.id + 10, m.entitiyID));
  9790. }
  9791. }
  9792. if (isRequirementInList(CardDB.ErrorType2.REQ_HERO_TARGET))
  9793. {
  9794. retval.RemoveAll(x => (x.target <= 30));
  9795. }
  9796. if (isRequirementInList(CardDB.ErrorType2.REQ_MINION_TARGET))
  9797. {
  9798. retval.RemoveAll(x => (x.target == 100) || (x.target == 200));
  9799. }
  9800. if (isRequirementInList(CardDB.ErrorType2.REQ_FRIENDLY_TARGET))
  9801. {
  9802. retval.RemoveAll(x => (x.target >= 10 && x.target <= 20) || (x.target == 200));
  9803. }
  9804. if (isRequirementInList(CardDB.ErrorType2.REQ_ENEMY_TARGET))
  9805. {
  9806. retval.RemoveAll(x => (x.target <= 9 || (x.target == 100)));
  9807. }
  9808. if (isRequirementInList(CardDB.ErrorType2.REQ_DAMAGED_TARGET))
  9809. {
  9810. foreach (Minion m in p.ownMinions)
  9811. {
  9812. if (!m.wounded)
  9813. {
  9814. retval.RemoveAll(x => x.targetEntity == m.entitiyID);
  9815. }
  9816. }
  9817. foreach (Minion m in p.enemyMinions)
  9818. {
  9819. if (!m.wounded)
  9820. {
  9821. retval.RemoveAll(x => x.targetEntity == m.entitiyID);
  9822. }
  9823. }
  9824. }
  9825. if (isRequirementInList(CardDB.ErrorType2.REQ_UNDAMAGED_TARGET))
  9826. {
  9827. foreach (Minion m in p.ownMinions)
  9828. {
  9829. if (m.wounded)
  9830. {
  9831. retval.RemoveAll(x => x.targetEntity == m.entitiyID);
  9832. }
  9833. }
  9834. foreach (Minion m in p.enemyMinions)
  9835. {
  9836. if (m.wounded)
  9837. {
  9838. retval.RemoveAll(x => x.targetEntity == m.entitiyID);
  9839. }
  9840. }
  9841. }
  9842. if (isRequirementInList(CardDB.ErrorType2.REQ_TARGET_MAX_ATTACK))
  9843. {
  9844. foreach (Minion m in p.ownMinions)
  9845. {
  9846. if (m.Angr > this.needWithMaxAttackValueOf)
  9847. {
  9848. retval.RemoveAll(x => x.targetEntity == m.entitiyID);
  9849. }
  9850. }
  9851. foreach (Minion m in p.enemyMinions)
  9852. {
  9853. if (m.Angr > this.needWithMaxAttackValueOf)
  9854. {
  9855. retval.RemoveAll(x => x.targetEntity == m.entitiyID);
  9856. }
  9857. }
  9858. }
  9859. if (isRequirementInList(CardDB.ErrorType2.REQ_TARGET_MIN_ATTACK))
  9860. {
  9861. foreach (Minion m in p.ownMinions)
  9862. {
  9863. if (m.Angr < this.needWithMinAttackValueOf)
  9864. {
  9865. retval.RemoveAll(x => x.targetEntity == m.entitiyID);
  9866. }
  9867. }
  9868. foreach (Minion m in p.enemyMinions)
  9869. {
  9870. if (m.Angr < this.needWithMinAttackValueOf)
  9871. {
  9872. retval.RemoveAll(x => x.targetEntity == m.entitiyID);
  9873. }
  9874. }
  9875. }
  9876. if (isRequirementInList(CardDB.ErrorType2.REQ_TARGET_WITH_RACE))
  9877. {
  9878. foreach (Minion m in p.ownMinions)
  9879. {
  9880. if (!(m.card.race == this.needRaceForPlaying))
  9881. {
  9882. retval.RemoveAll(x => x.targetEntity == m.entitiyID);
  9883. }
  9884. }
  9885. foreach (Minion m in p.enemyMinions)
  9886. {
  9887. if (!(m.card.race == this.needRaceForPlaying))
  9888. {
  9889. retval.RemoveAll(x => x.targetEntity == m.entitiyID);
  9890. }
  9891. }
  9892. }
  9893. if (isRequirementInList(CardDB.ErrorType2.REQ_MUST_TARGET_TAUNTER))
  9894. {
  9895. foreach (Minion m in p.ownMinions)
  9896. {
  9897. if (!m.taunt)
  9898. {
  9899. retval.RemoveAll(x => x.targetEntity == m.entitiyID);
  9900. }
  9901. }
  9902. foreach (Minion m in p.enemyMinions)
  9903. {
  9904. if (!m.taunt)
  9905. {
  9906. retval.RemoveAll(x => x.targetEntity == m.entitiyID);
  9907. }
  9908. }
  9909. }
  9910. return retval;
  9911. }
  9912. public int getManaCost(Playfield p)
  9913. {
  9914. int retval = this.cost;
  9915. int offset = 0; // if offset < 0 costs become lower, if >0 costs are higher at the end
  9916. // CARDS that increase the manacosts of others ##############################
  9917. //Manacosts changes with soeldner der venture co.
  9918. if (p.soeldnerDerVenture != p.startedWithsoeldnerDerVenture && this.type == cardtype.MOB)
  9919. {
  9920. offset += (p.soeldnerDerVenture - p.startedWithsoeldnerDerVenture) * 3;
  9921. }
  9922. //Manacosts changes with mana-ghost
  9923. if (p.managespenst != p.startedWithManagespenst && this.type == cardtype.MOB)
  9924. {
  9925. offset += (p.managespenst - p.startedWithManagespenst);
  9926. }
  9927. // CARDS that decrease the manacosts of others ##############################
  9928. //Manacosts changes with the summoning-portal >_>
  9929. if (p.startedWithbeschwoerungsportal != p.beschwoerungsportal && this.type == cardtype.MOB)
  9930. { //cant lower the mana to 0
  9931. int temp = (p.startedWithbeschwoerungsportal - p.beschwoerungsportal) * 2;
  9932. if (retval + temp <= 0) temp = -retval + 1;
  9933. offset = offset + temp;
  9934. }
  9935. //Manacosts changes with the pint-sized summoner
  9936. if (p.winzigebeschwoererin >= 1 && p.mobsplayedThisTurn >= 1 && p.startedWithMobsPlayedThisTurn == 0 && this.type == cardtype.MOB)
  9937. { // if we start oure calculations with 0 mobs played, then the cardcost are 1 mana to low in the further calculations (with the little summoner on field)
  9938. offset += p.winzigebeschwoererin;
  9939. }
  9940. if (p.mobsplayedThisTurn == 0 && p.winzigebeschwoererin <= p.startedWithWinzigebeschwoererin && this.type == cardtype.MOB)
  9941. { // one pint-sized summoner got killed, before we played the first mob -> the manacost are higher of all mobs
  9942. offset += (p.startedWithWinzigebeschwoererin - p.winzigebeschwoererin);
  9943. }
  9944. //Manacosts changes with the zauberlehrling summoner
  9945. if (p.zauberlehrling != p.startedWithZauberlehrling && this.type == cardtype.SPELL)
  9946. { //if the number of zauberlehrlings change
  9947. offset += (p.startedWithZauberlehrling - p.zauberlehrling);
  9948. }
  9949. //manacosts are lowered, after we played preparation
  9950. if (p.playedPreparation && this.type == cardtype.SPELL)
  9951. { //if the number of zauberlehrlings change
  9952. offset -= 3;
  9953. }
  9954. switch (this.name)
  9955. {
  9956. case "dreadcorsair":
  9957. retval = retval + offset - p.ownWeaponAttack + p.ownWeaponAttackStarted; // if weapon attack change we change manacost
  9958. break;
  9959. case "seagiant":
  9960. retval = retval + offset - p.ownMinions.Count + p.ownMobsCountStarted;
  9961. break;
  9962. case "mountaingiant":
  9963. retval = retval + offset - p.owncards.Count + p.ownCardsCountStarted;
  9964. break;
  9965. case "moltengiant":
  9966. retval = retval + offset - p.ownHeroHp + p.ownHeroHpStarted;
  9967. break;
  9968. default:
  9969. retval = retval + offset;
  9970. break;
  9971. }
  9972. if (this.Secret && p.playedmagierinderkirintor)
  9973. {
  9974. retval = 0;
  9975. }
  9976. retval = Math.Max(0, retval);
  9977. return retval;
  9978. }
  9979. public bool canplayCard(Playfield p)
  9980. {
  9981. //is playrequirement?
  9982. bool haveToDoRequires = isRequirementInList(CardDB.ErrorType2.REQ_TARGET_TO_PLAY);
  9983. bool retval = true;
  9984. // cant play if i have to few mana
  9985. if (p.mana < this.getManaCost(p)) return false;
  9986. // cant play mob, if i have allready 7 mininos
  9987. if (this.type == CardDB.cardtype.MOB && p.ownMinions.Count >= 7) return false;
  9988. if (isRequirementInList(CardDB.ErrorType2.REQ_MINIMUM_ENEMY_MINIONS))
  9989. {
  9990. if (p.enemyMinions.Count < this.needMinNumberOfEnemy) return false;
  9991. }
  9992. if (isRequirementInList(CardDB.ErrorType2.REQ_NUM_MINION_SLOTS))
  9993. {
  9994. if (p.ownMinions.Count > 7 - this.needEmptyPlacesForPlaying) return false;
  9995. }
  9996. if (isRequirementInList(CardDB.ErrorType2.REQ_WEAPON_EQUIPPED))
  9997. {
  9998. if (p.ownWeaponName == "") return false;
  9999. }
  10000. if (isRequirementInList(CardDB.ErrorType2.REQ_MINIMUM_TOTAL_MINIONS))
  10001. {
  10002. if (this.needMinTotalMinions > p.ownMinions.Count + p.enemyMinions.Count) return false;
  10003. }
  10004. if (haveToDoRequires)
  10005. {
  10006. if (this.getTargetsForCard(p).Count == 0) return false;
  10007. //it requires a target-> return false if
  10008. }
  10009. if (isRequirementInList(CardDB.ErrorType2.REQ_TARGET_IF_AVAILABLE) && isRequirementInList(CardDB.ErrorType2.REQ_MINION_CAP_IF_TARGET_AVAILABLE))
  10010. {
  10011. if (this.getTargetsForCard(p).Count >= 1 && p.ownMinions.Count > 7 - this.needMinionsCapIfAvailable) return false;
  10012. }
  10013. if (isRequirementInList(CardDB.ErrorType2.REQ_ENTIRE_ENTOURAGE_NOT_IN_PLAY))
  10014. {
  10015. int difftotem = 0;
  10016. foreach (Minion m in p.ownMinions)
  10017. {
  10018. if (m.name == "healingtotem" || m.name == "wrathofairtotem" || m.name == "searingtotem" || m.name == "stoneclawtotem") difftotem++;
  10019. }
  10020. if (difftotem == 4) return false;
  10021. }
  10022. if (this.Secret)
  10023. {
  10024. if (p.ownSecretsIDList.Contains(this.CardID)) return false;
  10025. if (p.ownSecretsIDList.Count >= 5) return false;
  10026. }
  10027. return true;
  10028. }
  10029. }
  10030. List<Card> cardlist = new List<Card>();
  10031. private static CardDB instance;
  10032. public static CardDB Instance
  10033. {
  10034. get
  10035. {
  10036. if (instance == null)
  10037. {
  10038. instance = new CardDB();
  10039. }
  10040. return instance;
  10041. }
  10042. }
  10043. private CardDB()
  10044. {
  10045. string[] lines = new string[0] { };
  10046. try
  10047. {
  10048. string path = Settings.Instance.path;
  10049. lines = System.IO.File.ReadAllLines(path + "_carddb.txt");
  10050. }
  10051. catch
  10052. {
  10053. Helpfunctions.Instance.logg("cant find carddb.txt");
  10054. }
  10055. cardlist.Clear();
  10056. Card c = new Card();
  10057. int de = 0;
  10058. bool targettext = false;
  10059. //placeholdercard
  10060. Card plchldr = new Card();
  10061. plchldr.name = "unknown";
  10062. plchldr.cost = 1000;
  10063. this.cardlist.Add(plchldr);
  10064. foreach (string s in lines)
  10065. {
  10066. if (s.Contains("/Entity"))
  10067. {
  10068. if (c.type == cardtype.ENCHANTMENT)
  10069. {
  10070. //Helpfunctions.Instance.logg(c.CardID);
  10071. //Helpfunctions.Instance.logg(c.name);
  10072. //Helpfunctions.Instance.logg(c.description);
  10073. continue;
  10074. }
  10075. if (c.name != "")
  10076. {
  10077. //Helpfunctions.Instance.logg(c.name);
  10078. this.cardlist.Add(c);
  10079. }
  10080. }
  10081. if (s.Contains("<Entity version=\"2\" CardID=\""))
  10082. {
  10083. c = new Card();
  10084. de = 0;
  10085. targettext = false;
  10086. string temp = s.Replace("<Entity version=\"2\" CardID=\"", "");
  10087. temp = temp.Replace("\">", "");
  10088. c.CardID = temp;
  10089. continue;
  10090. }
  10091. if (s.Contains("<Entity version=\"1\" CardID=\""))
  10092. {
  10093. c = new Card();
  10094. de = 0;
  10095. targettext = false;
  10096. string temp = s.Replace("<Entity version=\"1\" CardID=\"", "");
  10097. temp = temp.Replace("\">", "");
  10098. c.CardID = temp;
  10099. continue;
  10100. }
  10101. if (s.Contains("<Tag name=\"Health\""))
  10102. {
  10103. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10104. temp = temp.Split('\"')[0];
  10105. c.Health = Convert.ToInt32(temp);
  10106. continue;
  10107. }
  10108. if (s.Contains("<Tag name=\"Atk\""))
  10109. {
  10110. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10111. temp = temp.Split('\"')[0];
  10112. c.Attack = Convert.ToInt32(temp);
  10113. continue;
  10114. }
  10115. if (s.Contains("<Tag name=\"Race\""))
  10116. {
  10117. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10118. temp = temp.Split('\"')[0];
  10119. c.race = Convert.ToInt32(temp);
  10120. continue;
  10121. }
  10122. if (s.Contains("<Tag name=\"Rarity\""))
  10123. {
  10124. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10125. temp = temp.Split('\"')[0];
  10126. c.rarity = Convert.ToInt32(temp);
  10127. continue;
  10128. }
  10129. if (s.Contains("<Tag name=\"Cost\""))
  10130. {
  10131. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10132. temp = temp.Split('\"')[0];
  10133. c.cost = Convert.ToInt32(temp);
  10134. continue;
  10135. }
  10136. if (s.Contains("<Tag name=\"CardType\""))
  10137. {
  10138. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10139. temp = temp.Split('\"')[0];
  10140. if (c.name != "")
  10141. {
  10142. //Helpfunctions.Instance.logg(temp);
  10143. }
  10144. c.crdtype = Convert.ToInt32(temp);
  10145. if (c.crdtype == 10)
  10146. {
  10147. c.type = CardDB.cardtype.HEROPWR;
  10148. }
  10149. if (c.crdtype == 4)
  10150. {
  10151. c.type = CardDB.cardtype.MOB;
  10152. }
  10153. if (c.crdtype == 5)
  10154. {
  10155. c.type = CardDB.cardtype.SPELL;
  10156. }
  10157. if (c.crdtype == 6)
  10158. {
  10159. c.type = CardDB.cardtype.ENCHANTMENT;
  10160. }
  10161. if (c.crdtype == 7)
  10162. {
  10163. c.type = CardDB.cardtype.WEAPON;
  10164. }
  10165. continue;
  10166. }
  10167. if (s.Contains("<enUS>"))
  10168. {
  10169. string temp = s.Replace("<enUS>", "");
  10170. temp = temp.Replace("</enUS>", "");
  10171. temp = temp.Replace("&lt;", "");
  10172. temp = temp.Replace("b&gt;", "");
  10173. temp = temp.Replace("/b&gt;", "");
  10174. temp = temp.ToLower();
  10175. if (de == 0)
  10176. {
  10177. temp = temp.Replace("'", "");
  10178. temp = temp.Replace(" ", "");
  10179. temp = temp.Replace(":", "");
  10180. temp = temp.Replace(".", "");
  10181. temp = temp.Replace("!", "");
  10182. //temp = temp.Replace("ß", "ss");
  10183. //temp = temp.Replace("ü", "ue");
  10184. //temp = temp.Replace("ä", "ae");
  10185. //temp = temp.Replace("ö", "oe");
  10186. //Helpfunctions.Instance.logg(temp);
  10187. c.name = temp;
  10188. }
  10189. if (de == 1)
  10190. {
  10191. c.description = temp;
  10192. if (c.description.Contains("choose one"))
  10193. {
  10194. c.choice = true;
  10195. //Helpfunctions.Instance.logg(c.name + " is choice");
  10196. }
  10197. }
  10198. if (targettext)
  10199. {
  10200. c.targettext = temp;
  10201. targettext = false;
  10202. }
  10203. de++;
  10204. continue;
  10205. }
  10206. if (s.Contains("<Tag name=\"Poisonous\""))
  10207. {
  10208. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10209. temp = temp.Split('\"')[0];
  10210. int ti = Convert.ToInt32(temp);
  10211. if (ti == 1) c.poisionous = true;
  10212. continue;
  10213. }
  10214. if (s.Contains("<Tag name=\"Enrage\""))
  10215. {
  10216. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10217. temp = temp.Split('\"')[0];
  10218. int ti = Convert.ToInt32(temp);
  10219. if (ti == 1) c.Enrage = true;
  10220. continue;
  10221. }
  10222. if (s.Contains("<Tag name=\"OneTurnEffect\""))
  10223. {
  10224. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10225. temp = temp.Split('\"')[0];
  10226. int ti = Convert.ToInt32(temp);
  10227. if (ti == 1) c.oneTurnEffect = true;
  10228. continue;
  10229. }
  10230. if (s.Contains("<Tag name=\"Aura\""))
  10231. {
  10232. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10233. temp = temp.Split('\"')[0];
  10234. int ti = Convert.ToInt32(temp);
  10235. if (ti == 1) c.Aura = true;
  10236. continue;
  10237. }
  10238. if (s.Contains("<Tag name=\"Taunt\""))
  10239. {
  10240. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10241. temp = temp.Split('\"')[0];
  10242. int ti = Convert.ToInt32(temp);
  10243. if (ti == 1) c.tank = true;
  10244. continue;
  10245. }
  10246. if (s.Contains("<Tag name=\"Battlecry\""))
  10247. {
  10248. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10249. temp = temp.Split('\"')[0];
  10250. int ti = Convert.ToInt32(temp);
  10251. if (ti == 1) c.battlecry = true;
  10252. continue;
  10253. }
  10254. if (s.Contains("<Tag name=\"Windfury\""))
  10255. {
  10256. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10257. temp = temp.Split('\"')[0];
  10258. int ti = Convert.ToInt32(temp);
  10259. if (ti == 1) c.windfury = true;
  10260. continue;
  10261. }
  10262. if (s.Contains("<Tag name=\"Deathrattle\""))
  10263. {
  10264. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10265. temp = temp.Split('\"')[0];
  10266. int ti = Convert.ToInt32(temp);
  10267. if (ti == 1) c.deathrattle = true;
  10268. continue;
  10269. }
  10270. if (s.Contains("<Tag name=\"Durability\""))
  10271. {
  10272. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10273. temp = temp.Split('\"')[0];
  10274. c.Durability = Convert.ToInt32(temp);
  10275. continue;
  10276. }
  10277. if (s.Contains("<Tag name=\"Elite\""))
  10278. {
  10279. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10280. temp = temp.Split('\"')[0];
  10281. int ti = Convert.ToInt32(temp);
  10282. if (ti == 1) c.Elite = true;
  10283. continue;
  10284. }
  10285. if (s.Contains("<Tag name=\"Combo\""))
  10286. {
  10287. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10288. temp = temp.Split('\"')[0];
  10289. int ti = Convert.ToInt32(temp);
  10290. if (ti == 1) c.Combo = true;
  10291. continue;
  10292. }
  10293. if (s.Contains("<Tag name=\"Recall\""))
  10294. {
  10295. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10296. temp = temp.Split('\"')[0];
  10297. int ti = Convert.ToInt32(temp);
  10298. if (ti == 1) c.Recall = true;
  10299. c.recallValue = 1;
  10300. if (c.name == "forkedlightning") c.recallValue = 2;
  10301. if (c.name == "dustdevil") c.recallValue = 2;
  10302. if (c.name == "lightningstorm") c.recallValue = 2;
  10303. if (c.name == "lavaburst") c.recallValue = 2;
  10304. if (c.name == "feralspirit") c.recallValue = 2;
  10305. if (c.name == "doomhammer") c.recallValue = 2;
  10306. if (c.name == "earthelemental") c.recallValue = 3;
  10307. continue;
  10308. }
  10309. if (s.Contains("<Tag name=\"ImmuneToSpellpower\""))
  10310. {
  10311. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10312. temp = temp.Split('\"')[0];
  10313. int ti = Convert.ToInt32(temp);
  10314. if (ti == 1) c.immuneToSpellpowerg = true;
  10315. continue;
  10316. }
  10317. if (s.Contains("<Tag name=\"Stealth\""))
  10318. {
  10319. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10320. temp = temp.Split('\"')[0];
  10321. int ti = Convert.ToInt32(temp);
  10322. if (ti == 1) c.Stealth = true;
  10323. continue;
  10324. }
  10325. if (s.Contains("<Tag name=\"Secret\""))
  10326. {
  10327. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10328. temp = temp.Split('\"')[0];
  10329. int ti = Convert.ToInt32(temp);
  10330. if (ti == 1) c.Secret = true;
  10331. continue;
  10332. }
  10333. if (s.Contains("<Tag name=\"Freeze\""))
  10334. {
  10335. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10336. temp = temp.Split('\"')[0];
  10337. int ti = Convert.ToInt32(temp);
  10338. if (ti == 1) c.Freeze = true;
  10339. continue;
  10340. }
  10341. if (s.Contains("<Tag name=\"AdjacentBuff\""))
  10342. {
  10343. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10344. temp = temp.Split('\"')[0];
  10345. int ti = Convert.ToInt32(temp);
  10346. if (ti == 1) c.AdjacentBuff = true;
  10347. continue;
  10348. }
  10349. if (s.Contains("<Tag name=\"Divine Shield\""))
  10350. {
  10351. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10352. temp = temp.Split('\"')[0];
  10353. int ti = Convert.ToInt32(temp);
  10354. if (ti == 1) c.Shield = true;
  10355. continue;
  10356. }
  10357. if (s.Contains("<Tag name=\"Charge\""))
  10358. {
  10359. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10360. temp = temp.Split('\"')[0];
  10361. int ti = Convert.ToInt32(temp);
  10362. if (ti == 1) c.Charge = true;
  10363. continue;
  10364. }
  10365. if (s.Contains("<Tag name=\"Silence\""))
  10366. {
  10367. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10368. temp = temp.Split('\"')[0];
  10369. int ti = Convert.ToInt32(temp);
  10370. if (ti == 1) c.Silence = true;
  10371. continue;
  10372. }
  10373. if (s.Contains("<Tag name=\"Morph\""))
  10374. {
  10375. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10376. temp = temp.Split('\"')[0];
  10377. int ti = Convert.ToInt32(temp);
  10378. if (ti == 1) c.Morph = true;
  10379. continue;
  10380. }
  10381. if (s.Contains("<Tag name=\"Spellpower\""))
  10382. {
  10383. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10384. temp = temp.Split('\"')[0];
  10385. int ti = Convert.ToInt32(temp);
  10386. if (ti == 1) c.Spellpower = true;
  10387. c.spellpowervalue = 1;
  10388. if (c.name == "ancientmage") c.spellpowervalue = 0;
  10389. if (c.name == "malygos") c.spellpowervalue = 5;
  10390. continue;
  10391. }
  10392. if (s.Contains("<Tag name=\"GrantCharge\""))
  10393. {
  10394. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10395. temp = temp.Split('\"')[0];
  10396. int ti = Convert.ToInt32(temp);
  10397. if (ti == 1) c.GrantCharge = true;
  10398. continue;
  10399. }
  10400. if (s.Contains("<Tag name=\"HealTarget\""))
  10401. {
  10402. string temp = s.Split(new string[] { "value=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10403. temp = temp.Split('\"')[0];
  10404. int ti = Convert.ToInt32(temp);
  10405. if (ti == 1) c.HealTarget = true;
  10406. continue;
  10407. }
  10408. if (s.Contains("TargetingArrowText"))
  10409. {
  10410. c.target = true;
  10411. targettext = true;
  10412. continue;
  10413. }
  10414. if (s.Contains("<PlayRequirement"))
  10415. {
  10416. string temp = s.Split(new string[] { "reqID=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10417. temp = temp.Split('\"')[0];
  10418. ErrorType2 et2 = (ErrorType2)Convert.ToInt32(temp);
  10419. c.playrequires.Add(et2);
  10420. }
  10421. if (s.Contains("<PlayRequirement reqID=\"12\" param=\""))
  10422. {
  10423. string temp = s.Split(new string[] { "param=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10424. temp = temp.Split('\"')[0];
  10425. c.needEmptyPlacesForPlaying = Convert.ToInt32(temp);
  10426. continue;
  10427. }
  10428. if (s.Contains("PlayRequirement reqID=\"41\" param=\""))
  10429. {
  10430. string temp = s.Split(new string[] { "param=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10431. temp = temp.Split('\"')[0];
  10432. c.needWithMinAttackValueOf = Convert.ToInt32(temp);
  10433. continue;
  10434. }
  10435. if (s.Contains("PlayRequirement reqID=\"8\" param=\""))
  10436. {
  10437. string temp = s.Split(new string[] { "param=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10438. temp = temp.Split('\"')[0];
  10439. c.needWithMaxAttackValueOf = Convert.ToInt32(temp);
  10440. continue;
  10441. }
  10442. if (s.Contains("PlayRequirement reqID=\"10\" param=\""))
  10443. {
  10444. string temp = s.Split(new string[] { "param=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10445. temp = temp.Split('\"')[0];
  10446. c.needRaceForPlaying = Convert.ToInt32(temp);
  10447. continue;
  10448. }
  10449. if (s.Contains("PlayRequirement reqID=\"23\" param=\""))
  10450. {
  10451. string temp = s.Split(new string[] { "param=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10452. temp = temp.Split('\"')[0];
  10453. c.needMinNumberOfEnemy = Convert.ToInt32(temp);
  10454. continue;
  10455. }
  10456. if (s.Contains("PlayRequirement reqID=\"45\" param=\""))
  10457. {
  10458. string temp = s.Split(new string[] { "param=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10459. temp = temp.Split('\"')[0];
  10460. c.needMinTotalMinions = Convert.ToInt32(temp);
  10461. continue;
  10462. }
  10463. if (s.Contains("PlayRequirement reqID=\"19\" param=\""))
  10464. {
  10465. string temp = s.Split(new string[] { "param=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10466. temp = temp.Split('\"')[0];
  10467. c.needMinionsCapIfAvailable = Convert.ToInt32(temp);
  10468. continue;
  10469. }
  10470. if (s.Contains("<Tag name="))
  10471. {
  10472. string temp = s.Split(new string[] { "<Tag name=\"" }, StringSplitOptions.RemoveEmptyEntries)[1];
  10473. temp = temp.Split('\"')[0];
  10474. /*
  10475. if (temp != "DevState" && temp != "FlavorText" && temp != "ArtistName" && temp != "Cost" && temp != "EnchantmentIdleVisual" && temp != "EnchantmentBirthVisual" && temp != "Collectible" && temp != "CardSet" && temp != "AttackVisualType" && temp != "CardName" && temp != "Class" && temp != "CardTextInHand" && temp != "Rarity" && temp != "TriggerVisual" && temp != "Faction" && temp != "HowToGetThisGoldCard" && temp != "HowToGetThisCard" && temp != "CardTextInPlay")
  10476. Helpfunctions.Instance.logg(s);*/
  10477. }
  10478. }
  10479. }
  10480. public Card getCardData(string cardname)
  10481. {
  10482. string target = cardname.ToLower();
  10483. Card c = new Card();
  10484. foreach (Card ca in this.cardlist)
  10485. {
  10486. if (ca.name == target)
  10487. {
  10488. return ca;
  10489. }
  10490. }
  10491. return new Card(c);
  10492. }
  10493. public Card getCardDataFromID(string id)
  10494. {
  10495. string target = id;
  10496. Card c = new Card();
  10497. foreach (Card ca in this.cardlist)
  10498. {
  10499. if (ca.CardID == target)
  10500. {
  10501. return ca;
  10502. }
  10503. }
  10504. return new Card(c);
  10505. }
  10506. private void rdtxt()
  10507. {
  10508. foreach (Card c in this.cardlist)
  10509. {
  10510. if (c.description.Contains("karte") && c.description.Contains("zieht"))
  10511. {
  10512. c.carddraw = 1;
  10513. }
  10514. if (c.description.Contains("waehlt aus") && c.description.Contains("oder"))
  10515. {
  10516. c.choice = true;
  10517. }
  10518. }
  10519. }
  10520. public static Enchantment getEnchantmentFromCardID(string cardID)
  10521. {
  10522. Enchantment retval = new Enchantment();
  10523. retval.CARDID = cardID;
  10524. if (cardID == "CS2_188o")//insiriert dieser diener hat +2 angriff in diesem zug. (ruchloser unteroffizier)
  10525. {
  10526. retval.angrbuff = 2;
  10527. }
  10528. if (cardID == "CS2_059o")//blutpakt (blutwichtel)
  10529. {
  10530. retval.hpbuff = 1;
  10531. }
  10532. if (cardID == "EX1_019e")//Segen der Klerikerin (blutelfenklerikerin)
  10533. {
  10534. retval.angrbuff = 1;
  10535. retval.hpbuff = 1;
  10536. }
  10537. if (cardID == "CS2_045e")//waffedesfelsbeissers
  10538. {
  10539. retval.angrbuff = 3;
  10540. }
  10541. if (cardID == "EX1_587e")//windfury
  10542. {
  10543. retval.windfury = true;
  10544. }
  10545. if (cardID == "EX1_355e")//urteildestemplers granted by blessed champion
  10546. {
  10547. retval.angrfaktor = 2;
  10548. }
  10549. if (cardID == "NEW1_036e")//befehlsruf
  10550. {
  10551. retval.cantLowerHPbelowONE = true;
  10552. }
  10553. if (cardID == "CS2_046e")// kampfrausch
  10554. {
  10555. retval.angrbuff = 3;
  10556. }
  10557. if (cardID == "CS2_104e")// toben
  10558. {
  10559. retval.angrbuff = 3;
  10560. retval.hpbuff = 3;
  10561. }
  10562. if (cardID == "DREAM_05e")// alptraum
  10563. {
  10564. retval.angrbuff = 5;
  10565. retval.hpbuff = 5;
  10566. }
  10567. if (cardID == "CS2_022e")// verwandlung
  10568. {
  10569. retval.angrbuff = 3;
  10570. }
  10571. if (cardID == "EX1_611e")// gefangen
  10572. {
  10573. //icetrap?
  10574. }
  10575. if (cardID == "EX1_014te")// banane
  10576. {
  10577. retval.angrbuff = 1;
  10578. retval.hpbuff = 1;
  10579. }
  10580. if (cardID == "EX1_178ae")// festgewurzelt
  10581. {
  10582. retval.hpbuff = 5;
  10583. retval.taunt = true;
  10584. }
  10585. if (cardID == "CS2_011o")// wildesbruellen
  10586. {
  10587. retval.angrbuff = 2;
  10588. }
  10589. if (cardID == "EX1_366e")// rechtschaffen
  10590. {
  10591. retval.angrbuff = 1;
  10592. retval.hpbuff = 1;
  10593. }
  10594. if (cardID == "CS2_017o")// klauen (ownhero +1angr)
  10595. {
  10596. }
  10597. if (cardID == "EX1_604o")// rasend
  10598. {
  10599. retval.angrbuff = 1;
  10600. }
  10601. if (cardID == "EX1_084e")// sturmangriff
  10602. {
  10603. retval.charge = true;
  10604. }
  10605. if (cardID == "CS1_129e")// inneresfeuer // angr = live
  10606. {
  10607. retval.angrEqualLife = true;
  10608. }
  10609. if (cardID == "EX1_603e")// aufzackgebracht (fieser zuchtmeister)
  10610. {
  10611. retval.angrbuff = 2;
  10612. }
  10613. if (cardID == "EX1_507e")// mrgglaargl! der murlocanführer verleiht +2/+1.
  10614. {
  10615. retval.angrbuff = 2;
  10616. retval.hpbuff = 1;
  10617. }
  10618. if (cardID == "CS2_038e")// geistderahnen : todesröcheln: dieser diener kehrt aufs schlachtfeld zurück.
  10619. {
  10620. }
  10621. if (cardID == "NEW1_024o")// gruenhauts befehl +1/+1.
  10622. {
  10623. retval.angrbuff = 1;
  10624. retval.hpbuff = 1;
  10625. }
  10626. if (cardID == "EX1_590e")// schattenvonmuru : angriff und leben durch aufgezehrte gottesschilde erhöht. (blutritter)
  10627. {
  10628. retval.angrbuff = 3;
  10629. retval.hpbuff = 3;
  10630. }
  10631. if (cardID == "CS2_074e")// toedlichesgift
  10632. {
  10633. }
  10634. if (cardID == "EX1_258e")// ueberladen von entfesselnder elementar
  10635. {
  10636. retval.angrbuff = 1;
  10637. retval.hpbuff = 1;
  10638. }
  10639. if (cardID == "TU4f_004o")// vermaechtnisdeskaisers von cho
  10640. {
  10641. retval.angrbuff = 2;
  10642. retval.hpbuff = 2;
  10643. }
  10644. if (cardID == "NEW1_017e")// gefuellterbauch randvoll mit murloc. (hungrigekrabbe)
  10645. {
  10646. retval.angrbuff = 2;
  10647. retval.hpbuff = 2;
  10648. }
  10649. if (cardID == "EX1_334e")// dunklerbefehl von dunkler Wahnsin
  10650. {
  10651. }
  10652. if (cardID == "CS2_087e")// segendermacht von segendermacht
  10653. {
  10654. retval.angrbuff = 3;
  10655. }
  10656. if (cardID == "EX1_613e")// vancleefsrache dieser diener hat erhöhten angriff und erhöhtes leben.
  10657. {
  10658. retval.angrbuff = 2;
  10659. retval.hpbuff = 2;
  10660. }
  10661. if (cardID == "EX1_623e")// infusion
  10662. {
  10663. retval.hpbuff = 3;
  10664. }
  10665. if (cardID == "CS2_073e2")// kaltbluetigkeit +4
  10666. {
  10667. retval.angrbuff = 4;
  10668. }
  10669. if (cardID == "EX1_162o")// staerkedesrudels der terrorwolfalpha verleiht diesem diener +1 angriff.
  10670. {
  10671. retval.angrbuff = 1;
  10672. }
  10673. if (cardID == "EX1_549o")// zorndeswildtiers +2 angriff und immun/ in diesem zug.
  10674. {
  10675. retval.angrbuff = 2;
  10676. retval.imune = true;
  10677. }
  10678. if (cardID == "EX1_091o")// kontrollederkabale dieser diener wurde von einer kabaleschattenpriesterin gestohlen.
  10679. {
  10680. }
  10681. if (cardID == "CS2_084e")// maldesjaegers
  10682. {
  10683. retval.setHPtoOne = true;
  10684. }
  10685. if (cardID == "NEW1_036e2")// befehlsruf2 ? das leben eurer diener kann in diesem zug nicht unter 1 fallen.
  10686. {
  10687. retval.cantLowerHPbelowONE = true;
  10688. }
  10689. if (cardID == "CS2_122e")// angespornt der schlachtzugsleiter verleiht diesem diener +1 angriff. (schlachtzugsleiter)
  10690. {
  10691. retval.angrbuff = 1;
  10692. }
  10693. if (cardID == "CS2_103e")// charge
  10694. {
  10695. retval.charge = true;
  10696. }
  10697. if (cardID == "EX1_080o")// geheimnissebewahren erhöhte werte.
  10698. {
  10699. retval.angrbuff = 1;
  10700. retval.hpbuff = 1;
  10701. }
  10702. if (cardID == "CS2_005o")// klaue +2 angriff in diesem zug.
  10703. {
  10704. retval.angrbuff = 2;
  10705. }
  10706. if (cardID == "EX1_363e2")// segenderweisheit
  10707. {
  10708. retval.cardDrawOnAngr = true;
  10709. }
  10710. if (cardID == "EX1_178be")// entwurzelt +5 angr
  10711. {
  10712. retval.angrbuff = 5;
  10713. }
  10714. if (cardID == "CS2_222o")// diemachtsturmwinds +1+1 (von champ of sturmwind)
  10715. {
  10716. retval.angrbuff = 1;
  10717. retval.hpbuff = 1;
  10718. }
  10719. if (cardID == "EX1_399e")// amoklauf von gurubashi berserker
  10720. {
  10721. retval.angrbuff = 3;
  10722. }
  10723. if (cardID == "CS2_041e")// machtderahnen
  10724. {
  10725. retval.taunt = true;
  10726. }
  10727. if (cardID == "EX1_612o")// machtderkirintor
  10728. {
  10729. }
  10730. if (cardID == "EX1_004e")// elunesanmut erhöhtes leben. von junger priesterin
  10731. {
  10732. retval.hpbuff = 1;
  10733. }
  10734. if (cardID == "EX1_246e")// verhext dieser diener wurde verwandelt.
  10735. {
  10736. }
  10737. if (cardID == "EX1_244e")// machtdertotems (card that buffs hp of totems)
  10738. {
  10739. retval.hpbuff = 2;
  10740. }
  10741. if (cardID == "EX1_607e")// innerewut (innere wut)
  10742. {
  10743. retval.angrbuff = 2;
  10744. }
  10745. if (cardID == "EX1_573ae")// gunstdeshalbgotts (cenarius?)
  10746. {
  10747. retval.angrbuff = 2;
  10748. retval.hpbuff = 2;
  10749. }
  10750. if (cardID == "EX1_411e2")// schliffbenoetigt angriff verringert. von waffe blutschrei
  10751. {
  10752. retval.angrbuff = -1;
  10753. }
  10754. if (cardID == "CS2_063e")// verderbnis wird zu beginn des zuges des verderbenden spielers vernichtet.
  10755. {
  10756. }
  10757. if (cardID == "CS2_181e")// vollekraft +2 angr ka von wem
  10758. {
  10759. retval.angrbuff = 2;
  10760. }
  10761. if (cardID == "EX1_508o")// mlarggragllabl! dieser murloc hat +1 angriff. (grimmschuppenorakel)
  10762. {
  10763. retval.angrbuff = 1;
  10764. }
  10765. if (cardID == "CS2_073e")// kaltbluetigkeit +2 angriff.
  10766. {
  10767. retval.angrbuff = 2;
  10768. }
  10769. if (cardID == "NEW1_018e")// goldrausch von blutsegelraeuberin
  10770. {
  10771. }
  10772. if (cardID == "EX1_059e2")// experimente! der verrückte alchemist hat angriff und leben vertauscht.
  10773. {
  10774. }
  10775. if (cardID == "EX1_570e")// biss (only hero)
  10776. {
  10777. retval.angrbuff = 4;
  10778. }
  10779. if (cardID == "EX1_360e")// demut angriff wurde auf 1 gesetzt.
  10780. {
  10781. retval.setANGRtoOne = true;
  10782. }
  10783. if (cardID == "DS1_175o")// wutgeheul durch waldwolf
  10784. {
  10785. retval.angrbuff = 1;
  10786. }
  10787. if (cardID == "EX1_596e")// daemonenfeuer
  10788. {
  10789. retval.angrbuff = 2;
  10790. retval.hpbuff = 2;
  10791. }
  10792. if (cardID == "EX1_158e")// seeledeswaldes todesröcheln: ruft einen treant (2/2) herbei.
  10793. {
  10794. }
  10795. if (cardID == "EX1_316e")// ueberwaeltigendemacht
  10796. {
  10797. retval.angrbuff = 4;
  10798. retval.hpbuff = 4;
  10799. }
  10800. if (cardID == "EX1_044e")// stufenaufstieg erhöhter angriff und erhöhtes leben. (rastloser abenteuer)
  10801. {
  10802. }
  10803. if (cardID == "EX1_304e")// verzehren erhöhte werte. (hexer)
  10804. {
  10805. }
  10806. if (cardID == "EX1_363e")// segenderweisheit der segnende spieler zieht eine karte, wenn dieser diener angreift.
  10807. {
  10808. }
  10809. if (cardID == "CS2_105e")// heldenhafterstoss
  10810. {
  10811. }
  10812. if (cardID == "EX1_128e")// verhuellt bleibt bis zu eurem nächsten zug verstohlen.
  10813. {
  10814. }
  10815. if (cardID == "NEW1_033o")// himmelsauge leokk verleiht diesem diener +1 angriff.
  10816. {
  10817. retval.angrbuff = 1;
  10818. }
  10819. if (cardID == "CS2_004e")// machtwortschild
  10820. {
  10821. retval.hpbuff = 2;
  10822. }
  10823. if (cardID == "EX1_382e")// waffenniederlegen! angriff auf 1 gesetzt.
  10824. {
  10825. retval.setANGRtoOne = true;
  10826. }
  10827. if (cardID == "CS2_092e")// segenderkoenige
  10828. {
  10829. retval.angrbuff = 4;
  10830. retval.hpbuff = 4;
  10831. }
  10832. if (cardID == "NEW1_012o")// manasaettigung erhöhter angriff.
  10833. {
  10834. }
  10835. if (cardID == "EX1_619e")// gleichheit leben auf 1 gesetzt.
  10836. {
  10837. retval.setHPtoOne = true;
  10838. }
  10839. if (cardID == "EX1_509e")// blarghghl erhöhter angriff.
  10840. {
  10841. retval.angrbuff = 1;
  10842. }
  10843. if (cardID == "CS2_009e")// malderwildnis
  10844. {
  10845. retval.angrbuff = 2;
  10846. retval.hpbuff = 2;
  10847. retval.taunt = true;
  10848. }
  10849. if (cardID == "EX1_103e")// mrghlglhal +2 leben.
  10850. {
  10851. retval.hpbuff = 2;
  10852. }
  10853. if (cardID == "NEW1_038o")// wachstum gruul wächst ...
  10854. {
  10855. }
  10856. if (cardID == "CS1_113e")// gedankenkontrolle
  10857. {
  10858. }
  10859. if (cardID == "CS2_236e")// goettlicherwille dieser diener hat doppeltes leben.
  10860. {
  10861. }
  10862. if (cardID == "CS2_083e")// geschaerft +1 angriff in diesem zug.
  10863. {
  10864. retval.angrbuff = 1;
  10865. }
  10866. if (cardID == "TU4c_008e")// diemachtmuklas
  10867. {
  10868. retval.angrbuff = 8;
  10869. }
  10870. if (cardID == "EX1_379e")// busse
  10871. {
  10872. retval.setHPtoOne = true;
  10873. }
  10874. if (cardID == "EX1_274e")// puremacht! (astraler arkanist)
  10875. {
  10876. retval.angrbuff = 2;
  10877. retval.hpbuff = 2;
  10878. }
  10879. if (cardID == "CS2_221e")// vorsicht!scharf! +2 angriff von hasserfüllte schmiedin.
  10880. {
  10881. retval.weaponAttack = 2;
  10882. }
  10883. if (cardID == "EX1_409e")// aufgewertet +1 angriff und +1 haltbarkeit.
  10884. {
  10885. retval.weaponAttack = 1;
  10886. retval.weapondurability = 1;
  10887. }
  10888. if (cardID == "tt_004o")//kannibalismus (fleischfressender ghul)
  10889. {
  10890. retval.angrbuff = 1;
  10891. }
  10892. if (cardID == "EX1_155ae")// maldernatur
  10893. {
  10894. retval.angrbuff = 4;
  10895. }
  10896. if (cardID == "NEW1_025e")// verstaerkt (by emboldener 3000)
  10897. {
  10898. retval.angrbuff = 1;
  10899. retval.hpbuff = 1;
  10900. }
  10901. if (cardID == "EX1_584e")// lehrenderkirintor zauberschaden+1 (by uralter magier)
  10902. {
  10903. retval.zauberschaden = 1;
  10904. }
  10905. if (cardID == "EX1_160be")// rudelfuehrer +1/+1. (macht der wildnis)
  10906. {
  10907. retval.angrbuff = 1;
  10908. retval.hpbuff = 1;
  10909. }
  10910. if (cardID == "TU4c_006e")// banane
  10911. {
  10912. retval.angrbuff = 1;
  10913. retval.hpbuff = 1;
  10914. }
  10915. if (cardID == "NEW1_027e")// yarrr! der südmeerkapitän verleiht +1/+1.
  10916. {
  10917. retval.angrbuff = 1;
  10918. retval.hpbuff = 1;
  10919. }
  10920. if (cardID == "DS1_070o")// praesenzdesmeisters +2/+2 und spott/. (hundemeister)
  10921. {
  10922. retval.angrbuff = 2;
  10923. retval.hpbuff = 2;
  10924. retval.taunt = true;
  10925. }
  10926. if (cardID == "EX1_046e")// gehaertet +2 angriff in diesem zug. (dunkeleisenzwerg)
  10927. {
  10928. retval.angrbuff = 2;
  10929. }
  10930. if (cardID == "EX1_531e")// satt erhöhter angriff und erhöhtes leben. (aasfressende Hyaene)
  10931. {
  10932. retval.angrbuff = 2;
  10933. retval.hpbuff = 1;
  10934. }
  10935. if (cardID == "CS2_226e")// bannerderfrostwoelfe erhöhte werte. (frostwolfkriegsfuerst)
  10936. {
  10937. retval.angrbuff = 1;
  10938. retval.hpbuff = 1;
  10939. }
  10940. if (cardID == "DS1_178e")// sturmangriff tundranashorn verleiht ansturm.
  10941. {
  10942. retval.charge = true;
  10943. }
  10944. if (cardID == "CS2_226o")//befehlsgewalt der kriegsfürst der frostwölfe hat erhöhten angriff und erhöhtes leben.
  10945. {
  10946. retval.angrbuff = 1;
  10947. retval.hpbuff = 1;
  10948. }
  10949. if (cardID == "Mekka4e")// verwandelt wurde in ein huhn verwandelt!
  10950. {
  10951. }
  10952. if (cardID == "EX1_411e")// blutrausch kein haltbarkeitsverlust. (blutschrei)
  10953. {
  10954. }
  10955. if (cardID == "EX1_145o")// vorbereitung der nächste zauber, den ihr in diesem zug wirkt, kostet (3) weniger.
  10956. {
  10957. }
  10958. if (cardID == "EX1_055o")// gestaerkt die manasüchtige hat erhöhten angriff.
  10959. {
  10960. retval.angrbuff = 2;
  10961. }
  10962. if (cardID == "CS2_053e")// fernsicht eine eurer karten kostet (3) weniger.
  10963. {
  10964. }
  10965. if (cardID == "CS2_146o")// geschaerft +1 haltbarkeit.
  10966. {
  10967. retval.weapondurability = 1;
  10968. }
  10969. if (cardID == "EX1_059e")// experimente! der verrückte alchemist hat angriff und leben vertauscht.
  10970. {
  10971. }
  10972. if (cardID == "EX1_565o")// flammenzunge +2 angriff von totem der flammenzunge.
  10973. {
  10974. retval.angrbuff = 2;
  10975. }
  10976. if (cardID == "EX1_001e")// wachsam erhöhter angriff. (lichtwaechterin)
  10977. {
  10978. retval.angrbuff = 2;
  10979. }
  10980. if (cardID == "EX1_536e")// aufgewertet erhöhte haltbarkeit.
  10981. {
  10982. retval.weaponAttack = 1;
  10983. retval.weapondurability = 1;
  10984. }
  10985. if (cardID == "EX1_155be")// maldernatur dieser diener hat +4 leben und spott/.
  10986. {
  10987. retval.hpbuff = 4;
  10988. retval.taunt = true;
  10989. }
  10990. if (cardID == "CS2_103e2")// sturmangriff +2 angriff und ansturm/.
  10991. {
  10992. retval.angrbuff = 2;
  10993. retval.charge = true;
  10994. }
  10995. if (cardID == "TU4f_006o")// transzendenz cho kann nicht angegriffen werden, bevor ihr seine diener erledigt habt.
  10996. {
  10997. }
  10998. if (cardID == "EX1_043e")// stundedeszwielichts erhöhtes leben. (zwielichtdrache)
  10999. {
  11000. retval.hpbuff = 1;
  11001. }
  11002. if (cardID == "NEW1_037e")// bewaffnet erhöhter angriff. meisterschwertschmied
  11003. {
  11004. retval.angrbuff = 1;
  11005. }
  11006. if (cardID == "EX1_161o")// demoralisierendesgebruell dieser diener hat -3 angriff in diesem zug.
  11007. {
  11008. }
  11009. if (cardID == "EX1_093e")// handvonargus
  11010. {
  11011. retval.angrbuff = 1;
  11012. retval.hpbuff = 1;
  11013. retval.taunt = true;
  11014. }
  11015. return retval;
  11016. }
  11017. }
  11018. public class BoardTester
  11019. {
  11020. int ownPlayer = 1;
  11021. int mana = 0;
  11022. int maxmana = 0;
  11023. string ownheroname = "";
  11024. int ownherohp = 0;
  11025. int ownherodefence = 0;
  11026. bool ownheroready = false;
  11027. bool ownHeroimmunewhileattacking = false;
  11028. int ownheroattacksThisRound = 0;
  11029. int ownHeroAttack = 0;
  11030. string ownHeroWeapon = "";
  11031. int ownHeroWeaponAttack = 0;
  11032. int ownHeroWeaponDurability = 0;
  11033. int numMinionsPlayedThisTurn = 0;
  11034. int cardsPlayedThisTurn = 0;
  11035. int overdrive = 0;
  11036. int enemySecrets = 0;
  11037. bool ownHeroFrozen = false;
  11038. List<string> ownsecretlist = new List<string>();
  11039. string enemyheroname = "";
  11040. int enemyherohp = 0;
  11041. int enemyherodefence = 0;
  11042. bool enemyFrozen = false;
  11043. int enemyWeaponAttack = 0;
  11044. int enemyWeaponDur = 0;
  11045. string enemyWeapon = "";
  11046. List<Minion> ownminions = new List<Minion>();
  11047. List<Minion> enemyminions = new List<Minion>();
  11048. List<Handmanager.Handcard> handcards = new List<Handmanager.Handcard>();
  11049. public BoardTester()
  11050. {
  11051. string[] lines = new string[0] { };
  11052. try
  11053. {
  11054. string path = Settings.Instance.path;
  11055. lines = System.IO.File.ReadAllLines(path + "test.txt");
  11056. }
  11057. catch
  11058. {
  11059. Helpfunctions.Instance.logg("cant find test.txt");
  11060. return;
  11061. }
  11062. CardDB.Card heroability = CardDB.Instance.getCardDataFromID("CS2_034");
  11063. bool abilityReady = false;
  11064. int readstate = 0;
  11065. int counter = 0;
  11066. Minion tempminion = new Minion();
  11067. int j = 0;
  11068. foreach (string sss in lines)
  11069. {
  11070. string s = sss + " ";
  11071. Helpfunctions.Instance.logg(s);
  11072. if (s.StartsWith("ailoop"))
  11073. {
  11074. break;
  11075. }
  11076. if (s.StartsWith("####"))
  11077. {
  11078. continue;
  11079. }
  11080. if (s.StartsWith("start calculations"))
  11081. {
  11082. continue;
  11083. }
  11084. if (s.StartsWith("enemy secretsCount:"))
  11085. {
  11086. this.enemySecrets = Convert.ToInt32(s.Split(' ')[2]);
  11087. continue;
  11088. }
  11089. if (s.StartsWith("mana "))
  11090. {
  11091. string ss = s.Replace("mana ", "");
  11092. mana = Convert.ToInt32(ss.Split('/')[0]);
  11093. maxmana = Convert.ToInt32(ss.Split('/')[1]);
  11094. }
  11095. if (readstate == 42 && counter == 1) // player
  11096. {
  11097. this.overdrive = Convert.ToInt32(s.Split(' ')[4]);
  11098. this.numMinionsPlayedThisTurn = Convert.ToInt32(s.Split(' ')[2]);
  11099. this.cardsPlayedThisTurn = Convert.ToInt32(s.Split(' ')[3]);
  11100. this.ownPlayer = Convert.ToInt32(s.Split(' ')[5]);
  11101. }
  11102. if (readstate == 1 && counter == 1) // class + hp + defence + immune
  11103. {
  11104. ownheroname = s.Split(' ')[0];
  11105. ownherohp = Convert.ToInt32(s.Split(' ')[1]);
  11106. ownherodefence = Convert.ToInt32(s.Split(' ')[2]);
  11107. string boolim = s.Split(' ')[4];
  11108. this.ownHeroimmunewhileattacking = (boolim == "True") ? true : false;
  11109. }
  11110. if (readstate == 1 && counter == 2) // ready, num attacks this turn, frozen
  11111. {
  11112. string readystate = s.Split(' ')[1];
  11113. this.ownheroready = (readystate == "True") ? true : false;
  11114. this.ownheroattacksThisRound = Convert.ToInt32(s.Split(' ')[3]);
  11115. this.ownHeroFrozen = (s.Split(' ')[5] == "True") ? true : false;
  11116. ownHeroAttack = Convert.ToInt32(s.Split(' ')[7]);
  11117. ownHeroWeaponAttack = Convert.ToInt32(s.Split(' ')[8]);
  11118. this.ownHeroWeaponDurability = Convert.ToInt32(s.Split(' ')[9]);
  11119. if (ownHeroWeaponAttack == 0)
  11120. {
  11121. ownHeroWeapon = ""; //:D
  11122. }
  11123. else
  11124. {
  11125. ownHeroWeapon = s.Split(' ')[10];
  11126. }
  11127. }
  11128. if (readstate == 1 && counter == 3) // ability + abilityready
  11129. {
  11130. abilityReady = (s.Split(' ')[1] == "True") ? true : false;
  11131. heroability = CardDB.Instance.getCardDataFromID(s.Split(' ')[2]);
  11132. }
  11133. if (readstate == 1 && counter >= 5) // secrets
  11134. {
  11135. if (!s.StartsWith("enemyhero:"))
  11136. {
  11137. ownsecretlist.Add(s.Replace(" ", ""));
  11138. }
  11139. }
  11140. if (readstate == 2 && counter == 1) // class + hp + defence + frozen
  11141. {
  11142. enemyheroname = s.Split(' ')[0];
  11143. enemyherohp = Convert.ToInt32(s.Split(' ')[1]);
  11144. enemyherodefence = Convert.ToInt32(s.Split(' ')[2]);
  11145. enemyFrozen = (s.Split(' ')[3] == "True") ? true : false;
  11146. }
  11147. if (readstate == 2 && counter == 2) // wepon + stuff
  11148. {
  11149. this.enemyWeaponAttack = Convert.ToInt32(s.Split(' ')[0]);
  11150. this.enemyWeaponDur = Convert.ToInt32(s.Split(' ')[1]);
  11151. if (enemyWeaponDur == 0)
  11152. {
  11153. this.enemyWeapon = "";
  11154. }
  11155. else
  11156. {
  11157. this.enemyWeapon = s.Split(' ')[2];
  11158. }
  11159. }
  11160. if (readstate == 3) // minion or enchantment
  11161. {
  11162. if (s.Contains(" id "))
  11163. {
  11164. if (counter >= 2) this.ownminions.Add(tempminion);
  11165. string minionname = s.Split(' ')[0];
  11166. int attack = Convert.ToInt32(s.Split(new string[] { " A:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
  11167. int hp = Convert.ToInt32(s.Split(new string[] { " H:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
  11168. int maxhp = Convert.ToInt32(s.Split(new string[] { " mH:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
  11169. bool ready = s.Split(new string[] { " rdy:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
  11170. bool taunt = s.Split(new string[] { " tnt:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
  11171. bool silenced = false;
  11172. if (s.Contains(" silenced:")) silenced = s.Split(new string[] { " silenced:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
  11173. bool divshield = false;
  11174. if (s.Contains(" divshield:")) divshield = s.Split(new string[] { " divshield:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
  11175. bool ptt = false;//played this turn
  11176. if (s.Contains(" ptt:")) ptt = s.Split(new string[] { " ptt:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
  11177. bool wndfry = false;//windfurry
  11178. if (s.Contains(" wndfr:")) wndfry = s.Split(new string[] { " wndfr:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
  11179. int natt = 0;
  11180. if (s.Contains(" natt:")) natt = Convert.ToInt32(s.Split(new string[] { " natt:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
  11181. int ent = 1000 + j;
  11182. if (s.Contains(" e:")) ent = Convert.ToInt32(s.Split(new string[] { " e:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
  11183. int id = Convert.ToInt32(s.Split(new string[] { " id " }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
  11184. tempminion = createNewMinion(CardDB.Instance.getCardData(minionname), id);
  11185. tempminion.Angr = attack;
  11186. tempminion.Hp = hp;
  11187. tempminion.maxHp = maxhp;
  11188. tempminion.Ready = ready;
  11189. tempminion.taunt = taunt;
  11190. tempminion.divineshild = divshield;
  11191. tempminion.playedThisTurn = ptt;
  11192. tempminion.windfury = wndfry;
  11193. tempminion.numAttacksThisTurn = natt;
  11194. tempminion.entitiyID = ent;
  11195. tempminion.silenced = silenced;
  11196. if (maxhp > hp) tempminion.wounded = true;
  11197. }
  11198. else
  11199. {
  11200. try
  11201. {
  11202. Enchantment e = CardDB.getEnchantmentFromCardID(s.Split(' ')[0]);
  11203. e.controllerOfCreator = Convert.ToInt32(s.Split(' ')[2]);
  11204. e.creator = Convert.ToInt32(s.Split(' ')[1]);
  11205. tempminion.enchantments.Add(e);
  11206. }
  11207. catch
  11208. {
  11209. }
  11210. }
  11211. }
  11212. if (readstate == 4) // minion or enchantment
  11213. {
  11214. if (s.Contains(" id "))
  11215. {
  11216. if (counter >= 2) this.enemyminions.Add(tempminion);
  11217. string minionname = s.Split(' ')[0];
  11218. int attack = Convert.ToInt32(s.Split(new string[] { " A:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
  11219. int hp = Convert.ToInt32(s.Split(new string[] { " H:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
  11220. int maxhp = Convert.ToInt32(s.Split(new string[] { " mH:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
  11221. bool ready = s.Split(new string[] { " rdy:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
  11222. bool taunt = s.Split(new string[] { " tnt:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
  11223. bool silenced = false;
  11224. if (s.Contains(" silenced:")) silenced = s.Split(new string[] { " silenced:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
  11225. bool divshield = false;
  11226. if (s.Contains(" divshield:")) divshield = s.Split(new string[] { " divshield:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
  11227. bool ptt = false;//played this turn
  11228. if (s.Contains(" ptt:")) ptt = s.Split(new string[] { " ptt:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
  11229. bool wndfry = false;//windfurry
  11230. if (s.Contains(" wndfr:")) wndfry = s.Split(new string[] { " wndfr:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0] == "True" ? true : false;
  11231. int natt = 0;
  11232. if (s.Contains(" natt:")) natt = Convert.ToInt32(s.Split(new string[] { " natt:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
  11233. int ent = 1000 + j;
  11234. if (s.Contains(" e:")) ent = Convert.ToInt32(s.Split(new string[] { " e:" }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
  11235. int id = Convert.ToInt32(s.Split(new string[] { " id " }, StringSplitOptions.RemoveEmptyEntries)[1].Split(' ')[0]);
  11236. tempminion = createNewMinion(CardDB.Instance.getCardData(minionname), id);
  11237. tempminion.Angr = attack;
  11238. tempminion.Hp = hp;
  11239. tempminion.maxHp = maxhp;
  11240. tempminion.Ready = ready;
  11241. tempminion.taunt = taunt;
  11242. tempminion.divineshild = divshield;
  11243. tempminion.playedThisTurn = ptt;
  11244. tempminion.windfury = wndfry;
  11245. tempminion.numAttacksThisTurn = natt;
  11246. tempminion.entitiyID = ent;
  11247. tempminion.silenced = silenced;
  11248. if (maxhp > hp) tempminion.wounded = true;
  11249. }
  11250. else
  11251. {
  11252. try
  11253. {
  11254. Enchantment e = CardDB.getEnchantmentFromCardID(s.Split(' ')[0]);
  11255. e.controllerOfCreator = Convert.ToInt32(s.Split(' ')[2]);
  11256. e.creator = Convert.ToInt32(s.Split(' ')[1]);
  11257. tempminion.enchantments.Add(e);
  11258. }
  11259. catch
  11260. {
  11261. }
  11262. }
  11263. }
  11264. if (readstate == 5) // minion or enchantment
  11265. {
  11266. Handmanager.Handcard card = new Handmanager.Handcard();
  11267. string minionname = s.Split(' ')[2];
  11268. int pos = Convert.ToInt32(s.Split(' ')[1]);
  11269. int mana = Convert.ToInt32(s.Split(' ')[3]);
  11270. card.card = CardDB.Instance.getCardData(minionname);
  11271. card.entity = Convert.ToInt32(s.Split(' ')[5]);
  11272. card.card.cost = mana;
  11273. card.position = pos;
  11274. handcards.Add(card);
  11275. }
  11276. if (s.StartsWith("ownhero:"))
  11277. {
  11278. readstate = 1;
  11279. counter = 0;
  11280. }
  11281. if (s.StartsWith("enemyhero:"))
  11282. {
  11283. readstate = 2;
  11284. counter = 0;
  11285. }
  11286. if (s.StartsWith("OwnMinions:"))
  11287. {
  11288. readstate = 3;
  11289. counter = 0;
  11290. }
  11291. if (s.StartsWith("EnemyMinions:"))
  11292. {
  11293. if (counter >= 2) this.ownminions.Add(tempminion);
  11294. readstate = 4;
  11295. counter = 0;
  11296. }
  11297. if (s.StartsWith("Own Handcards:"))
  11298. {
  11299. if (counter >= 2) this.enemyminions.Add(tempminion);
  11300. readstate = 5;
  11301. counter = 0;
  11302. }
  11303. if (s.StartsWith("player:"))
  11304. {
  11305. readstate = 42;
  11306. counter = 0;
  11307. }
  11308. counter++;
  11309. j++;
  11310. }
  11311. Helpfunctions.Instance.logg("rdy");
  11312. Hrtprozis.Instance.setOwnPlayer(ownPlayer);
  11313. Handmanager.Instance.setOwnPlayer(ownPlayer);
  11314. Hrtprozis.Instance.updatePlayer(this.maxmana, this.mana, this.cardsPlayedThisTurn, this.numMinionsPlayedThisTurn, this.overdrive, 100, 200);
  11315. Hrtprozis.Instance.updateSecretStuff(this.ownsecretlist, enemySecrets);
  11316. int numattttHero = 0;
  11317. bool herowindfury = false;
  11318. Hrtprozis.Instance.updateOwnHero(this.ownHeroWeapon, this.ownHeroWeaponAttack, this.ownHeroWeaponDurability, ownHeroimmunewhileattacking, this.ownHeroAttack, this.ownherohp, this.ownherodefence, this.ownheroname, this.ownheroready, this.ownHeroFrozen, heroability, abilityReady, numattttHero, herowindfury);
  11319. Hrtprozis.Instance.updateEnemyHero(this.enemyWeapon, this.enemyWeaponAttack, this.enemyWeaponDur, this.enemyWeaponAttack, this.enemyherohp, this.enemyherodefence, this.enemyheroname, this.enemyFrozen);
  11320. Hrtprozis.Instance.updateMinions(this.ownminions, this.enemyminions);
  11321. Handmanager.Instance.setHandcards(this.handcards, this.handcards.Count, 5);
  11322. }
  11323. private Minion createNewMinion(CardDB.Card c, int id)
  11324. {
  11325. Minion m = new Minion();
  11326. m.card = c;
  11327. m.id = id;
  11328. m.zonepos = id + 1;
  11329. m.entitiyID = c.entityID;
  11330. m.Posix = 0;
  11331. m.Posiy = 0;
  11332. m.Angr = c.Attack;
  11333. m.Hp = c.Health;
  11334. m.maxHp = c.Health;
  11335. m.name = c.name;
  11336. m.playedThisTurn = true;
  11337. m.numAttacksThisTurn = 0;
  11338. if (c.windfury) m.windfury = true;
  11339. if (c.tank) m.taunt = true;
  11340. if (c.Charge)
  11341. {
  11342. m.Ready = true;
  11343. m.charge = true;
  11344. }
  11345. if (c.poisionous) m.poisonous = true;
  11346. if (c.Stealth) m.stealth = true;
  11347. if (m.name == "lightspawn" && !m.silenced)
  11348. {
  11349. m.Angr = m.Hp;
  11350. }
  11351. return m;
  11352. }
  11353. }
  11354. public class Enchantment
  11355. {
  11356. public bool cantBeDispelled = false;
  11357. public string CARDID = "";
  11358. public int creator = 0;
  11359. public int angrbuff = 0;
  11360. public int hpbuff = 0;
  11361. public int weaponAttack = 0;
  11362. public int weapondurability = 0;
  11363. public int angrfaktor = 1;
  11364. public int hpfaktor = 1;
  11365. public bool charge = false;
  11366. public bool divineshild = false;
  11367. public bool taunt = false;
  11368. public bool cantLowerHPbelowONE = false;
  11369. public bool angrEqualLife = false;
  11370. public bool imune = false;
  11371. public bool setHPtoOne = false;
  11372. public bool setANGRtoOne = false;
  11373. public bool cardDrawOnAngr = false;
  11374. public bool windfury = false;
  11375. public int zauberschaden = 0;
  11376. public int controllerOfCreator = 0;
  11377. }
  11378. public class Minion
  11379. {
  11380. public int id = -1;
  11381. public int Posix = 0;
  11382. public int Posiy = 0;
  11383. public int Hp = 0;
  11384. public int maxHp = 0;
  11385. public int Angr = 0;
  11386. public bool Ready = false;
  11387. public bool taunt = false;
  11388. public bool wounded = false;//hp red?
  11389. public string name = "";
  11390. public CardDB.Card card;
  11391. public bool divineshild = false;
  11392. public bool windfury = false;
  11393. public bool frozen = false;
  11394. public int zonepos = 0;
  11395. public bool stealth = false;
  11396. public bool immune = false;
  11397. public bool exhausted = false;
  11398. public int numAttacksThisTurn = 0;
  11399. public bool playedThisTurn = false;
  11400. public bool charge = false;
  11401. public bool poisonous = false;
  11402. public bool silenced = false;
  11403. public int entitiyID = -1;
  11404. public bool cantLowerHPbelowONE = false;
  11405. public List<Enchantment> enchantments = new List<Enchantment>();
  11406. public Minion()
  11407. {
  11408. }
  11409. public Minion(Minion m)
  11410. {
  11411. this.id = m.id;
  11412. this.Posix = m.Posix;
  11413. this.Posiy = m.Posiy;
  11414. this.Hp = m.Hp;
  11415. this.maxHp = m.maxHp;
  11416. this.Angr = m.Angr;
  11417. this.Ready = m.Ready;
  11418. this.taunt = m.taunt;
  11419. this.wounded = m.wounded;
  11420. this.name = m.name;
  11421. this.card = m.card;
  11422. this.divineshild = m.divineshild;
  11423. this.windfury = m.windfury;
  11424. this.frozen = m.frozen;
  11425. this.zonepos = m.zonepos;
  11426. this.stealth = m.stealth;
  11427. this.immune = m.immune;
  11428. this.exhausted = m.exhausted;
  11429. this.numAttacksThisTurn = m.numAttacksThisTurn;
  11430. this.playedThisTurn = m.playedThisTurn;
  11431. this.charge = m.charge;
  11432. this.poisonous = m.poisonous;
  11433. this.silenced = m.silenced;
  11434. this.entitiyID = m.entitiyID;
  11435. this.enchantments.AddRange(m.enchantments);
  11436. this.cantLowerHPbelowONE = m.cantLowerHPbelowONE;
  11437. }
  11438. public void setMinionTominion(Minion m)
  11439. {
  11440. this.id = m.id;
  11441. this.Posix = m.Posix;
  11442. this.Posiy = m.Posiy;
  11443. this.Hp = m.Hp;
  11444. this.maxHp = m.maxHp;
  11445. this.Angr = m.Angr;
  11446. this.Ready = m.Ready;
  11447. this.taunt = m.taunt;
  11448. this.wounded = m.wounded;
  11449. this.name = m.name;
  11450. this.card = m.card;
  11451. this.divineshild = m.divineshild;
  11452. this.windfury = m.windfury;
  11453. this.frozen = m.frozen;
  11454. this.zonepos = m.zonepos;
  11455. this.stealth = m.stealth;
  11456. this.immune = m.immune;
  11457. this.exhausted = m.exhausted;
  11458. this.numAttacksThisTurn = m.numAttacksThisTurn;
  11459. this.playedThisTurn = m.playedThisTurn;
  11460. this.charge = m.charge;
  11461. this.poisonous = m.poisonous;
  11462. this.silenced = m.silenced;
  11463. this.entitiyID = m.entitiyID;
  11464. this.enchantments.AddRange(m.enchantments);
  11465. }
  11466. }
  11467. public class BattleField
  11468. {
  11469. public class tagpair
  11470. {
  11471. public int Name = 0;
  11472. public int Value = 0;
  11473. }
  11474. public class HrtUnit
  11475. {
  11476. public string CardID = "";
  11477. public int entitiyID = 0;
  11478. public List<tagpair> tags = new List<tagpair>();
  11479. public int getTag(GAME_TAG gt)
  11480. {
  11481. foreach (tagpair t in tags)
  11482. {
  11483. if ((GAME_TAG)t.Name == gt)
  11484. {
  11485. return t.Value;
  11486. }
  11487. }
  11488. return 0;
  11489. }
  11490. }
  11491. private static BattleField instance;
  11492. public static BattleField Instance
  11493. {
  11494. get
  11495. {
  11496. if (instance == null)
  11497. {
  11498. instance = new BattleField();
  11499. }
  11500. return instance;
  11501. }
  11502. }
  11503. private BattleField()
  11504. {
  11505. }
  11506. }
  11507. public enum Side
  11508. {
  11509. NEUTRAL,
  11510. FRIENDLY,
  11511. OPPOSING
  11512. }
  11513. public enum GAME_TAG
  11514. {
  11515. STATE = 204,
  11516. TURN = 20,
  11517. STEP = 19,
  11518. NEXT_STEP = 198,
  11519. TEAM_ID = 31,
  11520. PLAYER_ID = 30,
  11521. STARTHANDSIZE = 29,
  11522. MAXHANDSIZE = 28,
  11523. MAXRESOURCES = 176,
  11524. TIMEOUT = 7,
  11525. TURN_START,
  11526. TURN_TIMER_SLUSH,
  11527. GOLD_REWARD_STATE = 13,
  11528. FIRST_PLAYER = 24,
  11529. CURRENT_PLAYER = 23,
  11530. HERO_ENTITY = 27,
  11531. RESOURCES = 26,
  11532. RESOURCES_USED = 25,
  11533. FATIGUE = 22,
  11534. PLAYSTATE = 17,
  11535. CURRENT_SPELLPOWER = 291,
  11536. MULLIGAN_STATE = 305,
  11537. HAND_REVEALED = 348,
  11538. CARDNAME = 185,
  11539. CARDTEXT_INHAND = 184,
  11540. CARDRACE = 200,
  11541. CARDTYPE = 202,
  11542. COST = 48,
  11543. HEALTH = 45,
  11544. ATK = 47,
  11545. DURABILITY = 187,
  11546. ARMOR = 292,
  11547. PREDAMAGE = 318,
  11548. TARGETING_ARROW_TEXT = 325,
  11549. LAST_AFFECTED_BY = 18,
  11550. ENCHANTMENT_BIRTH_VISUAL = 330,
  11551. ENCHANTMENT_IDLE_VISUAL,
  11552. PREMIUM = 12,
  11553. IGNORE_DAMAGE = 1,
  11554. IGNORE_DAMAGE_OFF = 354,
  11555. ENTITY_ID = 53,
  11556. DEFINITION = 52,
  11557. OWNER = 51,
  11558. CONTROLLER = 50,
  11559. ZONE = 49,
  11560. EXHAUSTED = 43,
  11561. ATTACHED = 40,
  11562. PROPOSED_ATTACKER = 39,
  11563. ATTACKING = 38,
  11564. PROPOSED_DEFENDER = 37,
  11565. DEFENDING = 36,
  11566. PROTECTED = 35,
  11567. PROTECTING = 34,
  11568. RECENTLY_ARRIVED = 33,
  11569. DAMAGE = 44,
  11570. TRIGGER_VISUAL = 32,
  11571. TAUNT = 190,
  11572. SPELLPOWER = 192,
  11573. DIVINE_SHIELD = 194,
  11574. CHARGE = 197,
  11575. SECRET = 219,
  11576. MORPH = 293,
  11577. DIVINE_SHIELD_READY = 314,
  11578. TAUNT_READY = 306,
  11579. STEALTH_READY,
  11580. CHARGE_READY,
  11581. CREATOR = 313,
  11582. CANT_DRAW = 232,
  11583. CANT_PLAY = 231,
  11584. CANT_DISCARD = 230,
  11585. CANT_DESTROY = 229,
  11586. CANT_TARGET = 228,
  11587. CANT_ATTACK = 227,
  11588. CANT_EXHAUST = 226,
  11589. CANT_READY = 225,
  11590. CANT_REMOVE_FROM_GAME = 224,
  11591. CANT_SET_ASIDE = 223,
  11592. CANT_DAMAGE = 222,
  11593. CANT_HEAL = 221,
  11594. CANT_BE_DESTROYED = 247,
  11595. CANT_BE_TARGETED = 246,
  11596. CANT_BE_ATTACKED = 245,
  11597. CANT_BE_EXHAUSTED = 244,
  11598. CANT_BE_READIED = 243,
  11599. CANT_BE_REMOVED_FROM_GAME = 242,
  11600. CANT_BE_SET_ASIDE = 241,
  11601. CANT_BE_DAMAGED = 240,
  11602. CANT_BE_HEALED = 239,
  11603. CANT_BE_SUMMONING_SICK = 253,
  11604. CANT_BE_DISPELLED = 314,
  11605. INCOMING_DAMAGE_CAP = 238,
  11606. INCOMING_DAMAGE_ADJUSTMENT = 237,
  11607. INCOMING_DAMAGE_MULTIPLIER = 236,
  11608. INCOMING_HEALING_CAP = 235,
  11609. INCOMING_HEALING_ADJUSTMENT = 234,
  11610. INCOMING_HEALING_MULTIPLIER = 233,
  11611. FROZEN = 260,
  11612. JUST_PLAYED,
  11613. LINKEDCARD,
  11614. ZONE_POSITION,
  11615. CANT_BE_FROZEN,
  11616. COMBO_ACTIVE = 266,
  11617. CARD_TARGET,
  11618. NUM_CARDS_PLAYED_THIS_TURN = 269,
  11619. CANT_BE_TARGETED_BY_OPPONENTS,
  11620. NUM_TURNS_IN_PLAY,
  11621. SUMMONED = 205,
  11622. ENRAGED = 212,
  11623. SILENCED = 188,
  11624. WINDFURY,
  11625. LOYALTY = 216,
  11626. DEATHRATTLE,
  11627. ADJACENT_BUFF = 350,
  11628. STEALTH = 191,
  11629. BATTLECRY = 218,
  11630. NUM_TURNS_LEFT = 272,
  11631. OUTGOING_DAMAGE_CAP,
  11632. OUTGOING_DAMAGE_ADJUSTMENT,
  11633. OUTGOING_DAMAGE_MULTIPLIER,
  11634. OUTGOING_HEALING_CAP,
  11635. OUTGOING_HEALING_ADJUSTMENT,
  11636. OUTGOING_HEALING_MULTIPLIER,
  11637. INCOMING_ABILITY_DAMAGE_ADJUSTMENT,
  11638. INCOMING_COMBAT_DAMAGE_ADJUSTMENT,
  11639. OUTGOING_ABILITY_DAMAGE_ADJUSTMENT,
  11640. OUTGOING_COMBAT_DAMAGE_ADJUSTMENT,
  11641. OUTGOING_ABILITY_DAMAGE_MULTIPLIER,
  11642. OUTGOING_ABILITY_DAMAGE_CAP,
  11643. INCOMING_ABILITY_DAMAGE_MULTIPLIER,
  11644. INCOMING_ABILITY_DAMAGE_CAP,
  11645. OUTGOING_COMBAT_DAMAGE_MULTIPLIER,
  11646. OUTGOING_COMBAT_DAMAGE_CAP,
  11647. INCOMING_COMBAT_DAMAGE_MULTIPLIER,
  11648. INCOMING_COMBAT_DAMAGE_CAP,
  11649. IS_MORPHED = 294,
  11650. TEMP_RESOURCES,
  11651. RECALL_OWED,
  11652. NUM_ATTACKS_THIS_TURN,
  11653. NEXT_ALLY_BUFF = 302,
  11654. MAGNET,
  11655. FIRST_CARD_PLAYED_THIS_TURN,
  11656. CARD_ID = 186,
  11657. CANT_BE_TARGETED_BY_ABILITIES = 311,
  11658. SHOULDEXITCOMBAT,
  11659. PARENT_CARD = 316,
  11660. NUM_MINIONS_PLAYED_THIS_TURN,
  11661. CANT_BE_TARGETED_BY_HERO_POWERS = 332,
  11662. COMBO = 220,
  11663. ELITE = 114,
  11664. CARD_SET = 183,
  11665. FACTION = 201,
  11666. RARITY = 203,
  11667. CLASS = 199,
  11668. MISSION_EVENT = 6,
  11669. FREEZE = 208,
  11670. RECALL = 215,
  11671. SILENCE = 339,
  11672. COUNTER,
  11673. ARTISTNAME = 342,
  11674. FLAVORTEXT = 351,
  11675. FORCED_PLAY,
  11676. LOW_HEALTH_THRESHOLD,
  11677. SPELLPOWER_DOUBLE = 356,
  11678. HEALING_DOUBLE,
  11679. NUM_OPTIONS_PLAYED_THIS_TURN,
  11680. NUM_OPTIONS,
  11681. TO_BE_DESTROYED,
  11682. HEALTH_MINIMUM = 337,
  11683. AURA = 362,
  11684. POISONOUS,
  11685. HOW_TO_EARN,
  11686. HOW_TO_EARN_GOLDEN,
  11687. AFFECTED_BY_SPELL_POWER = 370,
  11688. IMMUNE_WHILE_ATTACKING = 373
  11689. }
  11690. public enum TAG_ZONE
  11691. {
  11692. INVALID,
  11693. PLAY,
  11694. DECK,
  11695. HAND,
  11696. GRAVEYARD,
  11697. REMOVEDFROMGAME,
  11698. SETASIDE,
  11699. SECRET
  11700. }
  11701. public enum TAG_MULLIGAN
  11702. {
  11703. INVALID,
  11704. INPUT,
  11705. DEALING,
  11706. WAITING,
  11707. DONE
  11708. }
  11709. public enum TAG_CLASS
  11710. {
  11711. INVALID,
  11712. DEATHKNIGHT,
  11713. DRUID,
  11714. HUNTER,
  11715. MAGE,
  11716. PALADIN,
  11717. PRIEST,
  11718. ROGUE,
  11719. SHAMAN,
  11720. WARLOCK,
  11721. WARRIOR,
  11722. DREAM
  11723. }
  11724. public enum TAG_CARDTYPE
  11725. {
  11726. INVALID,
  11727. GAME,
  11728. PLAYER,
  11729. HERO,
  11730. MINION,
  11731. ABILITY,
  11732. ENCHANTMENT,
  11733. WEAPON,
  11734. ITEM,
  11735. TOKEN,
  11736. HERO_POWER
  11737. }
  11738. public enum AttackType
  11739. {
  11740. INVALID,
  11741. REGULAR,
  11742. PROPOSED,
  11743. CANCELED,
  11744. ONLY_ATTACKER,
  11745. ONLY_DEFENDER,
  11746. ONLY_PROPOSED_ATTACKER,
  11747. ONLY_PROPOSED_DEFENDER,
  11748. WAITING_ON_PROPOSED_ATTACKER,
  11749. WAITING_ON_PROPOSED_DEFENDER,
  11750. WAITING_ON_ATTACKER,
  11751. WAITING_ON_DEFENDER
  11752. }
  11753. public enum TAG_PLAYSTATE
  11754. {
  11755. INVALID,
  11756. PLAYING,
  11757. WINNING,
  11758. LOSING,
  11759. WON,
  11760. LOST,
  11761. TIED,
  11762. DISCONNECTED,
  11763. QUIT
  11764. }
  11765. public enum TAG_RACE
  11766. {
  11767. INVALID,
  11768. BLOODELF,
  11769. DRAENEI,
  11770. DWARF,
  11771. GNOME,
  11772. GOBLIN,
  11773. HUMAN,
  11774. NIGHTELF,
  11775. ORC,
  11776. TAUREN,
  11777. TROLL,
  11778. UNDEAD,
  11779. WORGEN,
  11780. GOBLIN2,
  11781. MURLOC,
  11782. DEMON,
  11783. SCOURGE,
  11784. MECHANICAL,
  11785. ELEMENTAL,
  11786. OGRE,
  11787. PET,
  11788. TOTEM,
  11789. NERUBIAN,
  11790. PIRATE,
  11791. DRAGON
  11792. }
  11793. public enum TAG_STATE
  11794. {
  11795. INVALID,
  11796. LOADING,
  11797. RUNNING,
  11798. COMPLETE
  11799. }
  11800. public enum TAG_STEP
  11801. {
  11802. INVALID,
  11803. BEGIN_FIRST,
  11804. BEGIN_SHUFFLE,
  11805. BEGIN_DRAW,
  11806. BEGIN_MULLIGAN,
  11807. MAIN_BEGIN,
  11808. MAIN_READY,
  11809. MAIN_RESOURCE,
  11810. MAIN_DRAW,
  11811. MAIN_START,
  11812. MAIN_ACTION,
  11813. MAIN_COMBAT,
  11814. MAIN_END,
  11815. MAIN_NEXT,
  11816. FINAL_WRAPUP,
  11817. FINAL_GAMEOVER,
  11818. MAIN_CLEANUP,
  11819. MAIN_START_TRIGGERS
  11820. }
  11821. public enum CHOICE_TYPE
  11822. {
  11823. INVALID,
  11824. MULLIGAN,
  11825. GENERAL
  11826. }
  11827. class Settings
  11828. {
  11829. public string path = "";
  11830. public string logpath = "";
  11831. public string logfile = "Logg.txt";
  11832. private static Settings instance;
  11833. public static Settings Instance
  11834. {
  11835. get
  11836. {
  11837. if (instance == null)
  11838. {
  11839. instance = new Settings();
  11840. }
  11841. return instance;
  11842. }
  11843. }
  11844. private Settings()
  11845. {
  11846. }
  11847. public void setFilePath(string path)
  11848. {
  11849. this.path = path;
  11850. }
  11851. public void setLoggPath(string path)
  11852. {
  11853. this.logpath = path;
  11854. }
  11855. public void setLoggFile(string path)
  11856. {
  11857. this.logfile = path;
  11858. }
  11859. }
  11860. public class targett
  11861. {
  11862. public int target = -1;
  11863. public int targetEntity = -1;
  11864. public targett(int targ, int ent)
  11865. {
  11866. this.target = targ;
  11867. this.targetEntity = ent;
  11868. }
  11869. }
  11870. }