PageRenderTime 71ms CodeModel.GetById 32ms RepoModel.GetById 1ms app.codeStats 1ms

/ai/action-copy.cs

https://github.com/revolutioncom/HRCustomClasses
C# | 5956 lines | 4973 code | 779 blank | 204 comment | 1813 complexity | b6f681dcd5a41ac720cb2689f495f489 MD5 | raw file

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

  1. // the ai :D
  2. //please ask/write me if you use this in your project
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. //TODO:
  7. //test wichtelmeisterin, befehlsruf
  8. //tueftlermeisteroberfunks
  9. //verrückter bomber ( 3 damage to random chars)
  10. //nozdormu (for computing time :D)
  11. //faehrtenlesen
  12. // lehrensucher cho
  13. //scharmuetzel kills all :D
  14. namespace HREngine.Bots
  15. {
  16. public class Action
  17. {
  18. public bool cardplay = false;
  19. public bool heroattack = false;
  20. public bool useability = false;
  21. public bool minionplay = false;
  22. public CardDB.Card card;
  23. public int cardEntitiy = -1;
  24. public int owntarget = -1; //= target where card/minion is placed
  25. public int ownEntitiy = -1;
  26. public int enemytarget = -1; // target where red arrow is placed
  27. public int enemyEntitiy = -1;
  28. public int druidchoice = 0; // 1 left card, 2 right card
  29. public int numEnemysBeforePlayed = 0;
  30. public void print()
  31. {
  32. Helpfunctions help = Helpfunctions.Instance;
  33. help.logg("current Action: ");
  34. if (this.cardplay)
  35. {
  36. help.logg("play " + this.card.name);
  37. if (this.druidchoice >= 1) help.logg("choose choise " + this.druidchoice);
  38. help.logg("with position " + this.cardEntitiy);
  39. if (this.owntarget >= 0)
  40. {
  41. help.logg("on position " + this.ownEntitiy);
  42. }
  43. if (this.enemytarget >= 0)
  44. {
  45. help.logg("and target to " + this.enemytarget + " " + this.enemyEntitiy);
  46. }
  47. }
  48. if (this.minionplay)
  49. {
  50. help.logg("attacker: " + this.owntarget + " enemy: " + this.enemytarget);
  51. help.logg("targetplace " + this.enemyEntitiy);
  52. }
  53. if (this.heroattack)
  54. {
  55. help.logg("attack with hero, enemy: " + this.enemytarget);
  56. help.logg("targetplace " + this.enemyEntitiy);
  57. }
  58. if (this.useability)
  59. {
  60. help.logg("useability ");
  61. if (this.enemytarget >= 0)
  62. {
  63. help.logg("on enemy: " + this.enemytarget + "targetplace " + this.enemyEntitiy);
  64. }
  65. }
  66. help.logg("");
  67. }
  68. }
  69. public class Playfield
  70. {
  71. public bool logging = false;
  72. public int evaluatePenality = 0;
  73. public int ownController = 0;
  74. public int ownHeroEntity = -1;
  75. public int enemyHeroEntity = -1;
  76. public int value = Int32.MinValue;
  77. public int guessingHeroDamage = 0;
  78. public int mana = 0;
  79. public int enemyHeroHp = 30;
  80. public string ownHeroName = "";
  81. public string enemyHeroName = "";
  82. public bool ownHeroReady = false;
  83. public int ownHeroNumAttackThisTurn = 0;
  84. public bool ownHeroWindfury = false;
  85. public List<string> ownSecretsIDList = new List<string>();
  86. public int enemySecretCount = 0;
  87. public int ownHeroHp = 30;
  88. public int ownheroAngr = 0;
  89. public bool ownHeroFrozen = false;
  90. public bool enemyHeroFrozen = false;
  91. public bool heroImmuneWhileAttacking = false;
  92. public int ownWeaponDurability = 0;
  93. public int ownWeaponAttack = 0;
  94. public string ownWeaponName = "";
  95. public int enemyWeaponAttack = 0;
  96. public int enemyWeaponDurability = 0;
  97. public List<Minion> ownMinions = new List<Minion>();
  98. public List<Minion> enemyMinions = new List<Minion>();
  99. public List<Handmanager.Handcard> owncards = new List<Handmanager.Handcard>();
  100. public List<Action> playactions = new List<Action>();
  101. public bool complete = false;
  102. public int owncarddraw = 0;
  103. public int ownHeroDefence = 0;
  104. public int enemycarddraw = 0;
  105. public int enemyAnzCards = 0;
  106. public int enemyHeroDefence = 0;
  107. public bool ownAbilityReady = false;
  108. public int doublepriest = 0;
  109. public int spellpower = 0;
  110. public bool auchenaiseelenpriesterin = false;
  111. public bool playedmagierinderkirintor = false;
  112. public bool playedPreparation = false;
  113. public int winzigebeschwoererin = 0;
  114. public int startedWithWinzigebeschwoererin = 0;
  115. public int zauberlehrling = 0;
  116. public int startedWithZauberlehrling = 0;
  117. public int managespenst = 0;
  118. public int startedWithManagespenst = 0;
  119. public int soeldnerDerVenture = 0;
  120. public int startedWithsoeldnerDerVenture = 0;
  121. public int beschwoerungsportal = 0;
  122. public int startedWithbeschwoerungsportal = 0;
  123. public int ownWeaponAttackStarted = 0;
  124. public int ownMobsCountStarted = 0;
  125. public int ownCardsCountStarted = 0;
  126. public int ownHeroHpStarted = 30;
  127. public int mobsplayedThisTurn = 0;
  128. public int startedWithMobsPlayedThisTurn = 0;
  129. public int cardsPlayedThisTurn = 0;
  130. public int ueberladung = 0; //=recall
  131. public int ownMaxMana = 0;
  132. public int enemyMaxMana = 0;
  133. public int lostDamage = 0;
  134. public int lostHealth = 0;
  135. public int lostWeaponDamage = 0;
  136. public CardDB.Card ownHeroAblility;
  137. Helpfunctions help = Helpfunctions.Instance;
  138. private void addMinionsReal(List<Minion> source, List<Minion> trgt)
  139. {
  140. foreach (Minion m in source)
  141. {
  142. Minion mc = new Minion(m);
  143. trgt.Add(mc);
  144. }
  145. }
  146. private void addCardsReal(List<Handmanager.Handcard> source)
  147. {
  148. foreach (Handmanager.Handcard m in source)
  149. {
  150. Handmanager.Handcard mc = new Handmanager.Handcard();
  151. mc.card = new CardDB.Card(m.card);
  152. mc.position = m.position;
  153. mc.entity = m.entity;
  154. this.owncards.Add(mc);
  155. }
  156. }
  157. public Playfield()
  158. {
  159. this.ownController = Hrtprozis.Instance.getOwnController();
  160. this.ownHeroEntity = Hrtprozis.Instance.ownHeroEntity;
  161. this.enemyHeroEntity = Hrtprozis.Instance.enemyHeroEntitiy;
  162. this.mana = Hrtprozis.Instance.currentMana;
  163. this.ownMaxMana = Hrtprozis.Instance.ownMaxMana;
  164. this.enemyMaxMana = Hrtprozis.Instance.enemyMaxMana;
  165. this.evaluatePenality = 0;
  166. this.ownSecretsIDList = Hrtprozis.Instance.ownSecretList;
  167. this.enemySecretCount = Hrtprozis.Instance.enemySecretCount;
  168. addMinionsReal(Hrtprozis.Instance.ownMinions, ownMinions);
  169. addMinionsReal(Hrtprozis.Instance.enemyMinions, enemyMinions);
  170. addCardsReal(Handmanager.Instance.handCards);
  171. this.enemyHeroHp = Hrtprozis.Instance.enemyHp;
  172. this.ownHeroName = Hrtprozis.Instance.heroname;
  173. this.enemyHeroName = Hrtprozis.Instance.enemyHeroname;
  174. this.ownHeroHp = Hrtprozis.Instance.heroHp;
  175. this.complete = false;
  176. this.ownHeroReady = Hrtprozis.Instance.ownheroisread;
  177. this.ownHeroWindfury = Hrtprozis.Instance.ownHeroWindfury;
  178. this.ownHeroNumAttackThisTurn = Hrtprozis.Instance.ownHeroNumAttacksThisTurn;
  179. this.ownHeroFrozen = Hrtprozis.Instance.herofrozen;
  180. this.enemyHeroFrozen = Hrtprozis.Instance.enemyfrozen;
  181. this.ownheroAngr = Hrtprozis.Instance.heroAtk;
  182. this.heroImmuneWhileAttacking = Hrtprozis.Instance.heroImmuneToDamageWhileAttacking;
  183. this.ownWeaponDurability = Hrtprozis.Instance.heroWeaponDurability;
  184. this.ownWeaponAttack = Hrtprozis.Instance.heroWeaponAttack;
  185. this.ownWeaponName = Hrtprozis.Instance.ownHeroWeapon;
  186. this.owncarddraw = 0;
  187. this.ownHeroDefence = 0;
  188. this.enemyHeroDefence = 0;
  189. this.enemyWeaponAttack = 0;//dont know jet
  190. this.enemyWeaponDurability = Hrtprozis.Instance.enemyWeaponDurability;
  191. this.enemycarddraw = 0;
  192. this.enemyAnzCards = Handmanager.Instance.enemyAnzCards;
  193. this.ownAbilityReady = Hrtprozis.Instance.ownAbilityisReady;
  194. this.ownHeroAblility = Hrtprozis.Instance.heroAbility;
  195. this.doublepriest = 0;
  196. this.spellpower = 0;
  197. value = -1000000;
  198. this.mobsplayedThisTurn = Hrtprozis.Instance.numMinionsPlayedThisTurn;
  199. this.startedWithMobsPlayedThisTurn = Hrtprozis.Instance.numMinionsPlayedThisTurn;// only change mobsplayedthisturm
  200. this.cardsPlayedThisTurn = Hrtprozis.Instance.cardsPlayedThisTurn;
  201. this.ueberladung = Hrtprozis.Instance.ueberladung;
  202. //need the following for manacost-calculation
  203. this.ownHeroHpStarted = this.ownHeroHp;
  204. this.ownWeaponAttackStarted = this.ownWeaponAttack;
  205. this.ownCardsCountStarted = this.owncards.Count;
  206. this.ownMobsCountStarted = this.ownMinions.Count;
  207. this.playedmagierinderkirintor = false;
  208. this.playedPreparation = false;
  209. this.zauberlehrling = 0;
  210. this.winzigebeschwoererin = 0;
  211. this.managespenst = 0;
  212. this.soeldnerDerVenture = 0;
  213. this.beschwoerungsportal = 0;
  214. this.startedWithbeschwoerungsportal = 0;
  215. this.startedWithManagespenst = 0;
  216. this.startedWithWinzigebeschwoererin = 0;
  217. this.startedWithZauberlehrling = 0;
  218. this.startedWithsoeldnerDerVenture = 0;
  219. foreach (Minion m in this.ownMinions)
  220. {
  221. if (m.silenced) continue;
  222. if (m.name == "prophetvelen") this.doublepriest++;
  223. spellpower = spellpower + m.card.spellpowervalue;
  224. if (m.name == "auchenaiseelenpriesterin") this.auchenaiseelenpriesterin = true;
  225. if (m.name == "winzigebeschwoererin")
  226. {
  227. this.winzigebeschwoererin++;
  228. this.startedWithWinzigebeschwoererin++;
  229. }
  230. if (m.name == "zauberlehrling")
  231. {
  232. this.zauberlehrling++;
  233. this.startedWithZauberlehrling++;
  234. }
  235. if (m.name == "managespenst")
  236. {
  237. this.managespenst++;
  238. this.startedWithManagespenst++;
  239. }
  240. if (m.name == "soeldnerderventureco")
  241. {
  242. this.soeldnerDerVenture++;
  243. this.startedWithsoeldnerDerVenture++;
  244. }
  245. if (m.name == "beschwoerungsportal")
  246. {
  247. this.beschwoerungsportal++;
  248. this.startedWithbeschwoerungsportal++;
  249. }
  250. foreach (Enchantment e in m.enchantments)// only at first init needed, after that its copied
  251. {
  252. if (e.CARDID == "NEW1_036e" || e.CARDID == "NEW1_036e2") m.cantLowerHPbelowONE = true;
  253. }
  254. }
  255. foreach (Minion m in this.enemyMinions)
  256. {
  257. if (m.silenced) continue;
  258. if (m.name == "managespenst")
  259. {
  260. this.managespenst++;
  261. this.startedWithManagespenst++;
  262. }
  263. }
  264. }
  265. public Playfield(Playfield p)
  266. {
  267. this.ownController = p.ownController;
  268. this.ownHeroEntity = p.ownHeroEntity;
  269. this.enemyHeroEntity = p.enemyHeroEntity;
  270. this.evaluatePenality = p.evaluatePenality;
  271. foreach(string s in p.ownSecretsIDList)
  272. { this.ownSecretsIDList.Add(s); }
  273. this.enemySecretCount = p.enemySecretCount;
  274. this.mana = p.mana;
  275. this.ownMaxMana = p.ownMaxMana;
  276. this.enemyMaxMana = p.enemyMaxMana;
  277. addMinionsReal(p.ownMinions, ownMinions);
  278. addMinionsReal(p.enemyMinions, enemyMinions);
  279. addCardsReal(p.owncards);
  280. this.enemyHeroHp = p.enemyHeroHp;
  281. this.ownHeroName = p.ownHeroName;
  282. this.enemyHeroName = p.enemyHeroName;
  283. this.ownHeroHp = p.ownHeroHp;
  284. this.playactions.AddRange(p.playactions);
  285. this.complete = false;
  286. this.ownHeroReady = p.ownHeroReady;
  287. this.ownHeroNumAttackThisTurn = p.ownHeroNumAttackThisTurn;
  288. this.ownHeroWindfury = p.ownHeroWindfury;
  289. this.ownheroAngr = p.ownheroAngr;
  290. this.ownHeroFrozen = p.ownHeroFrozen;
  291. this.enemyHeroFrozen = p.enemyHeroFrozen;
  292. this.heroImmuneWhileAttacking = p.heroImmuneWhileAttacking;
  293. this.owncarddraw = p.owncarddraw;
  294. this.ownHeroDefence = p.ownHeroDefence;
  295. this.enemyWeaponAttack = p.enemyWeaponAttack;
  296. this.enemycarddraw = p.enemycarddraw;
  297. this.enemyAnzCards = p.enemyAnzCards;
  298. this.enemyHeroDefence = p.enemyHeroDefence;
  299. this.ownWeaponDurability = p.ownWeaponDurability;
  300. this.ownWeaponAttack = p.ownWeaponAttack;
  301. this.ownWeaponName = p.ownWeaponName;
  302. this.lostDamage = p.lostDamage;
  303. this.lostWeaponDamage = p.lostWeaponDamage;
  304. this.lostHealth = p.lostHealth;
  305. this.ownAbilityReady = p.ownAbilityReady;
  306. this.ownHeroAblility = p.ownHeroAblility;
  307. this.doublepriest = 0;
  308. this.spellpower = 0;
  309. value = -1000000;
  310. this.mobsplayedThisTurn = p.mobsplayedThisTurn;
  311. this.startedWithMobsPlayedThisTurn = p.startedWithMobsPlayedThisTurn;
  312. this.cardsPlayedThisTurn = p.cardsPlayedThisTurn;
  313. this.ueberladung = p.ueberladung;
  314. //need the following for manacost-calculation
  315. this.ownHeroHpStarted = p.ownHeroHpStarted;
  316. this.ownWeaponAttackStarted = p.ownWeaponAttackStarted;
  317. this.ownCardsCountStarted = p.ownCardsCountStarted;
  318. this.ownMobsCountStarted = p.ownMobsCountStarted;
  319. this.startedWithWinzigebeschwoererin = p.startedWithWinzigebeschwoererin;
  320. this.playedmagierinderkirintor = p.playedmagierinderkirintor;
  321. this.startedWithZauberlehrling = p.startedWithZauberlehrling;
  322. this.startedWithWinzigebeschwoererin = p.startedWithWinzigebeschwoererin;
  323. this.startedWithManagespenst = p.startedWithManagespenst;
  324. this.startedWithsoeldnerDerVenture = p.startedWithsoeldnerDerVenture;
  325. this.startedWithbeschwoerungsportal = p.startedWithbeschwoerungsportal;
  326. this.zauberlehrling = 0;
  327. this.winzigebeschwoererin = 0;
  328. this.managespenst = 0;
  329. this.soeldnerDerVenture = 0;
  330. foreach (Minion m in this.ownMinions)
  331. {
  332. if (m.silenced) continue;
  333. if (m.name == "prophetvelen") this.doublepriest++;
  334. spellpower = spellpower + m.card.spellpowervalue;
  335. if (m.name == "auchenaiseelenpriesterin") this.auchenaiseelenpriesterin = true;
  336. if (m.name == "winzigebeschwoererin") this.winzigebeschwoererin++;
  337. if (m.name == "zauberlehrling") this.zauberlehrling++;
  338. if (m.name == "managespenst") this.managespenst++;
  339. if (m.name == "soeldnerderventureco") this.soeldnerDerVenture++;
  340. if (m.name == "beschwoerungsportal") this.beschwoerungsportal++;
  341. }
  342. foreach (Minion m in this.enemyMinions)
  343. {
  344. if (m.silenced) continue;
  345. if (m.name == "managespenst") this.managespenst++;
  346. }
  347. }
  348. public int getValuee()
  349. {
  350. //if (value >= -200000) return value;
  351. int retval = 0;
  352. retval += owncards.Count * 1;
  353. retval += ownMinions.Count * 10;
  354. retval -= enemyMinions.Count * 10;
  355. retval += ownHeroHp + ownHeroDefence;
  356. retval += -enemyHeroHp - enemyHeroDefence;
  357. retval += ownheroAngr;// +ownWeaponDurability;
  358. retval -= enemyWeaponDurability;
  359. retval += owncarddraw * 5;
  360. retval -= enemycarddraw * 5;
  361. retval += this.ownMaxMana;
  362. if (enemyMinions.Count >= 0)
  363. {
  364. int anz = enemyMinions.Count;
  365. int owntaunt = ownMinions.FindAll(x => x.taunt == true).Count;
  366. int froggs = ownMinions.FindAll(x => x.name == "frosch").Count;
  367. owntaunt -= froggs;
  368. if (owntaunt == 0) retval -= 10 * anz;
  369. retval += owntaunt * 10 - 11 * anz;
  370. }
  371. foreach (Minion m in this.ownMinions)
  372. {
  373. retval += m.Hp * 1;
  374. retval += m.Angr * 2;
  375. if (m.Angr >= m.maxHp + 1)
  376. {
  377. //is a tanky minion
  378. retval += m.Hp;
  379. }
  380. if (m.windfury) retval += m.Angr;
  381. }
  382. foreach (Minion m in this.enemyMinions)
  383. {
  384. retval -= m.Hp;
  385. retval -= m.Angr*2;
  386. if (m.Angr >= m.maxHp + 1)
  387. {
  388. //is a tanky minion
  389. retval -= m.Hp;
  390. }
  391. if (m.windfury) retval -= m.Angr;
  392. if (m.taunt) retval -= 5;
  393. if (m.name == "schlachtzugsleiter") retval -= 5;
  394. if (m.name == "grimmschuppenorakel") retval -= 5;
  395. if (m.name == "terrorwolfalpha") retval -= 2;
  396. if (m.name == "murlocanfuehrer") retval -= 5;
  397. if (m.name == "suedmeerkapitaen") retval -= 5;
  398. if (m.name == "championvonsturmwind") retval -= 10;
  399. if (m.name == "waldwolf") retval -= 5;
  400. if (m.name == "leokk") retval -= 5;
  401. if (m.name == "klerikerinvonnordhain") retval -= 5;
  402. if (m.name == "zauberlehrling") retval -= 3;
  403. if (m.name == "winzigebeschwoererin") retval -= 3;
  404. }
  405. retval -= lostDamage;//damage which was to high (like killing a 2/1 with an 3/3 -> => lostdamage =2
  406. retval -= lostWeaponDamage;
  407. if (ownMinions.Count == 0) retval -= 20;
  408. if (enemyMinions.Count == 0) retval += 20;
  409. if (enemyHeroHp <= 0) retval = 10000;
  410. if (ownHeroHp <= 0) retval = -10000;
  411. this.value = retval;
  412. return retval;
  413. }
  414. public List<targett> getAttackTargets()
  415. {
  416. List<targett> trgts = new List<targett>();
  417. List<targett> trgts2 = new List<targett>();
  418. trgts2.Add(new targett(200, this.enemyHeroEntity));
  419. bool hastanks = false;
  420. foreach (Minion m in this.enemyMinions)
  421. {
  422. if (m.stealth) continue; // cant target stealth
  423. if (m.taunt)
  424. {
  425. hastanks = true;
  426. trgts.Add(new targett(m.id + 10, m.entitiyID));
  427. }
  428. else
  429. {
  430. trgts2.Add(new targett(m.id + 10, m.entitiyID));
  431. }
  432. }
  433. if (hastanks) return trgts;
  434. return trgts2;
  435. }
  436. public int getBestPlace(CardDB.Card card)
  437. {
  438. if (card.type != CardDB.cardtype.MOB) return 0;
  439. if (this.ownMinions.Count <= 1) return 0;
  440. int[] places = new int[this.ownMinions.Count];
  441. int i = 0;
  442. int tempval = 0;
  443. if (card.name == "sonnenzornbeschuetzerin" || card.name == "verteidigervonargus") // bestplace, if right and left minions have no taunt + lots of hp, dont make priority-minions to taunt
  444. {
  445. i = 0;
  446. foreach (Minion m in this.ownMinions)
  447. {
  448. places[i] = 0;
  449. tempval = 0;
  450. if (!m.taunt)
  451. {
  452. tempval -= m.Hp;
  453. }
  454. else
  455. {
  456. tempval = 30;
  457. }
  458. if (m.name == "flammenzungentotem") tempval += 50;
  459. if (m.name == "schlachtzugsleiter") tempval += 30;
  460. if (m.name == "grimmschuppenorakel") tempval += 30;
  461. if (m.name == "terrorwolfalpha") tempval += 50;
  462. if (m.name == "murlocanfuehrer") tempval += 30;
  463. if (m.name == "suedmeerkapitaen") tempval += 30;
  464. if (m.name == "championvonsturmwind") tempval += 30;
  465. if (m.name == "waldwolf") tempval += 30;
  466. if (m.name == "leokk") tempval += 30;
  467. if (m.name == "klerikerinvonnordhain") tempval += 30;
  468. if (m.name == "zauberlehrling") tempval += 20;
  469. if (m.name == "winzigebeschwoererin") tempval += 10;
  470. if (m.name == "beschwoerungsportal") tempval += 20;
  471. if (m.name == "aasfressendehyaene") tempval += 20;
  472. places[i] = tempval;
  473. i++;
  474. }
  475. i = 0;
  476. int bestpl = 7;
  477. int bestval = 10000;
  478. foreach (Minion m in this.ownMinions)
  479. {
  480. int prev = 0;
  481. int next = 0;
  482. if (i >= 1) prev = places[i - 1];
  483. next = places[i];
  484. if(bestval > prev + next)
  485. {
  486. bestval = prev + next;
  487. bestpl = i;
  488. }
  489. i++;
  490. }
  491. return bestpl;
  492. }
  493. // normal placement
  494. int cardvalue = card.Attack * 2 + card.Health;
  495. if (card.tank)
  496. {
  497. cardvalue += 5;
  498. cardvalue += card.Health;
  499. }
  500. if (card.name == "flammenzungentotem") cardvalue += 50;
  501. if (card.name == "schlachtzugsleiter") cardvalue += 10;
  502. if (card.name == "grimmschuppenorakel") cardvalue += 10;
  503. if (card.name == "terrorwolfalpha") cardvalue += 50;
  504. if (card.name == "murlocanfuehrer") cardvalue += 10;
  505. if (card.name == "suedmeerkapitaen") cardvalue += 10;
  506. if (card.name == "championvonsturmwind") cardvalue += 10;
  507. if (card.name == "waldwolf") cardvalue += 10;
  508. if (card.name == "leokk") cardvalue += 10;
  509. if (card.name == "cardvalue") cardvalue += 10;
  510. if (card.name == "zauberlehrling") cardvalue += 10;
  511. if (card.name == "winzigebeschwoererin") cardvalue += 10;
  512. if (card.name == "beschwoerungsportal") cardvalue += 10;
  513. if (card.name == "aasfressendehyaene") cardvalue += 10;
  514. i = 0;
  515. foreach(Minion m in this.ownMinions)
  516. {
  517. places[i] = 0;
  518. tempval = m.Angr * 2 + m.maxHp;
  519. if (m.taunt)
  520. {
  521. tempval += 6;
  522. tempval += m.maxHp;
  523. }
  524. if (m.name == "flammenzungentotem") tempval += 50;
  525. if (m.name == "schlachtzugsleiter") tempval += 10;
  526. if (m.name == "grimmschuppenorakel") tempval += 10;
  527. if (m.name == "terrorwolfalpha") tempval += 50;
  528. if (m.name == "murlocanfuehrer") tempval += 10;
  529. if (m.name == "suedmeerkapitaen") tempval += 10;
  530. if (m.name == "championvonsturmwind") tempval += 10;
  531. if (m.name == "waldwolf") tempval += 10;
  532. if (m.name == "leokk") tempval += 10;
  533. if (m.name == "klerikerinvonnordhain") tempval += 10;
  534. if (m.name == "zauberlehrling") tempval += 10;
  535. if (m.name == "winzigebeschwoererin") tempval += 10;
  536. if (m.name == "beschwoerungsportal") tempval += 10;
  537. if (m.name == "aasfressendehyaene") tempval += 10;
  538. places[i] = tempval;
  539. i++;
  540. }
  541. //bigminion if >=10
  542. int bestplace = 0;
  543. int bestvale = 0;
  544. tempval=0;
  545. i=0;
  546. for (int j = 0; j <= this.ownMinions.Count; j++ )
  547. {
  548. int prev = cardvalue;
  549. int next = cardvalue;
  550. if (i >= 1) prev = places[i - 1];
  551. if (i < this.ownMinions.Count) next = places[i];
  552. if (cardvalue >= prev && cardvalue >= next)
  553. {
  554. tempval = 2 * cardvalue - prev - next;
  555. if (tempval > bestvale)
  556. {
  557. bestplace = i;
  558. bestvale = tempval;
  559. }
  560. }
  561. if (cardvalue <= prev && cardvalue <= next)
  562. {
  563. tempval = -2 * cardvalue + prev + next;
  564. if (tempval > bestvale)
  565. {
  566. bestplace = i ;
  567. bestvale = tempval;
  568. }
  569. }
  570. i++;
  571. }
  572. return bestplace;
  573. }
  574. public int getBestPlacePrint(CardDB.Card card)
  575. {
  576. if (card.type != CardDB.cardtype.MOB) return 0;
  577. if (this.ownMinions.Count <= 1) return 0;
  578. int[] places = new int[this.ownMinions.Count];
  579. int i = 0;
  580. int tempval = 0;
  581. if (card.name == "sonnenzornbeschuetzerin" || card.name == "verteidigervonargus") // bestplace, if right and left minions have no taunt + lots of hp, dont make priority-minions to taunt
  582. {
  583. i = 0;
  584. foreach (Minion m in this.ownMinions)
  585. {
  586. places[i] = 0;
  587. tempval = 0;
  588. if (!m.taunt)
  589. {
  590. tempval -= m.Hp;
  591. }
  592. else
  593. {
  594. tempval = 30;
  595. }
  596. if (m.name == "flammenzungentotem") tempval += 50;
  597. if (m.name == "schlachtzugsleiter") tempval += 30;
  598. if (m.name == "grimmschuppenorakel") tempval += 30;
  599. if (m.name == "terrorwolfalpha") tempval += 50;
  600. if (m.name == "murlocanfuehrer") tempval += 30;
  601. if (m.name == "suedmeerkapitaen") tempval += 30;
  602. if (m.name == "championvonsturmwind") tempval += 30;
  603. if (m.name == "waldwolf") tempval += 30;
  604. if (m.name == "leokk") tempval += 30;
  605. if (m.name == "klerikerinvonnordhain") tempval += 30;
  606. if (m.name == "zauberlehrling") tempval += 20;
  607. if (m.name == "winzigebeschwoererin") tempval += 10;
  608. if (m.name == "beschwoerungsportal") tempval += 20;
  609. if (m.name == "aasfressendehyaene") tempval += 20;
  610. places[i] = tempval;
  611. i++;
  612. }
  613. i = 0;
  614. int bestpl = 7;
  615. int bestval = 10000;
  616. foreach (Minion m in this.ownMinions)
  617. {
  618. help.logg(places[i]+"");
  619. int prev = 0;
  620. int next = 0;
  621. if (i >= 1) prev = places[i - 1];
  622. next = places[i];
  623. if (bestval > prev + next)
  624. {
  625. bestval = prev + next;
  626. bestpl = i ;
  627. }
  628. i++;
  629. }
  630. return bestpl;
  631. }
  632. // normal placement
  633. int cardvalue = card.Attack * 2 + card.Health;
  634. if (card.tank)
  635. {
  636. cardvalue += 5;
  637. cardvalue += card.Health;
  638. }
  639. if (card.name == "flammenzungentotem") tempval += 50;
  640. if (card.name == "schlachtzugsleiter") cardvalue += 10;
  641. if (card.name == "grimmschuppenorakel") cardvalue += 10;
  642. if (card.name == "terrorwolfalpha") cardvalue += 50;
  643. if (card.name == "murlocanfuehrer") cardvalue += 10;
  644. if (card.name == "suedmeerkapitaen") cardvalue += 10;
  645. if (card.name == "championvonsturmwind") cardvalue += 10;
  646. if (card.name == "waldwolf") cardvalue += 10;
  647. if (card.name == "leokk") cardvalue += 10;
  648. if (card.name == "cardvalue") cardvalue += 10;
  649. if (card.name == "zauberlehrling") cardvalue += 10;
  650. if (card.name == "winzigebeschwoererin") cardvalue += 10;
  651. if (card.name == "beschwoerungsportal") cardvalue += 10;
  652. if (card.name == "aasfressendehyaene") cardvalue += 10;
  653. i = 0;
  654. foreach (Minion m in this.ownMinions)
  655. {
  656. places[i] = 0;
  657. tempval = m.Angr * 2 + m.maxHp;
  658. if (m.taunt)
  659. {
  660. tempval += 6;
  661. tempval += m.maxHp;
  662. }
  663. if (m.name == "flammenzungentotem") tempval += 50;
  664. if (m.name == "schlachtzugsleiter") tempval += 10;
  665. if (m.name == "grimmschuppenorakel") tempval += 10;
  666. if (m.name == "terrorwolfalpha") tempval += 50;
  667. if (m.name == "murlocanfuehrer") tempval += 10;
  668. if (m.name == "suedmeerkapitaen") tempval += 10;
  669. if (m.name == "championvonsturmwind") tempval += 10;
  670. if (m.name == "waldwolf") tempval += 10;
  671. if (m.name == "leokk") tempval += 10;
  672. if (m.name == "klerikerinvonnordhain") tempval += 10;
  673. if (m.name == "zauberlehrling") tempval += 10;
  674. if (m.name == "winzigebeschwoererin") tempval += 10;
  675. if (m.name == "beschwoerungsportal") tempval += 10;
  676. if (m.name == "aasfressendehyaene") tempval += 10;
  677. places[i] = tempval;
  678. help.logg(places[i] + "");
  679. i++;
  680. }
  681. //bigminion if >=10
  682. int bestplace = 0;
  683. int bestvale = 0;
  684. tempval = 0;
  685. i = 0;
  686. help.logg(cardvalue + " (own)");
  687. i = 0;
  688. for (int j = 0; j <= this.ownMinions.Count; j++)
  689. {
  690. int prev = cardvalue;
  691. int next = cardvalue;
  692. if (i >= 1) prev = places[i - 1];
  693. if (i < this.ownMinions.Count)
  694. {
  695. next = places[i];
  696. }
  697. if (cardvalue >= prev && cardvalue >= next)
  698. {
  699. tempval = 2 * cardvalue - prev - next;
  700. if (tempval > bestvale)
  701. {
  702. bestplace = i ;
  703. bestvale = tempval;
  704. }
  705. }
  706. if (cardvalue <= prev && cardvalue <= next)
  707. {
  708. tempval = -2 * cardvalue + prev + next;
  709. if (tempval > bestvale)
  710. {
  711. bestplace = i;
  712. bestvale = tempval;
  713. }
  714. }
  715. i++;
  716. }
  717. help.logg(bestplace + " (best)");
  718. return bestplace;
  719. }
  720. public void endTurn()
  721. {
  722. this.complete = true;
  723. endTurnBuffs(true);//end own buffs
  724. endTurnEffect(true);//own turn ends
  725. startTurnEffect(false);//enemy turn begins
  726. guessHeroDamage();
  727. simulateTraps();
  728. }
  729. private void guessHeroDamage()
  730. {
  731. int ghd = 0;
  732. foreach (Minion m in this.enemyMinions)
  733. {
  734. if (m.frozen) continue;
  735. ghd += m.Angr;
  736. if (m.windfury) ghd += m.Angr;
  737. }
  738. if (this.enemyHeroName == "druid") ghd++;
  739. if (this.enemyHeroName == "mage") ghd++;
  740. if (this.enemyHeroName == "thief") ghd++;
  741. if (this.enemyHeroName == "hunter") ghd += 2;
  742. ghd += enemyWeaponAttack;
  743. foreach (Minion m in this.ownMinions)
  744. {
  745. if (m.frozen) continue;
  746. if (m.taunt) ghd -= m.Hp;
  747. if (m.taunt && m.divineshild) ghd -= 1;
  748. }
  749. this.guessingHeroDamage = Math.Max(0, ghd);
  750. }
  751. private void simulateTraps()
  752. {
  753. // DONT KILL ENEMY HERO (cause its only guessing)
  754. foreach (string secretID in this.ownSecretsIDList)
  755. {
  756. //hunter secrets############
  757. if (secretID == "EX1_554") //snaketrap
  758. {
  759. //call 3 snakes (if possible)
  760. int posi = this.ownMinions.Count - 1;
  761. CardDB.Card kid = CardDB.Instance.getCardData("schlange");
  762. callKid(kid, posi, true);
  763. callKid(kid, posi, true);
  764. callKid(kid, posi, true);
  765. }
  766. if (secretID == "EX1_609") //snipe
  767. {
  768. //kill weakest minion of enemy
  769. List<Minion> temp = new List<Minion>(this.enemyMinions);
  770. temp.Sort((a, b) => a.Angr.CompareTo(b.Angr));//take the weakest
  771. if (temp.Count == 0) continue;
  772. Minion m = temp[0];
  773. minionGetDamagedOrHealed(m, 4, 0, false);
  774. }
  775. if (secretID == "EX1_610") //explosive trap
  776. {
  777. //take 2 damage to each enemy
  778. List<Minion> temp = new List<Minion>(this.enemyMinions);
  779. foreach (Minion m in temp)
  780. {
  781. minionGetDamagedOrHealed(m, 2, 0, false);
  782. }
  783. attackEnemyHeroWithoutKill(2);
  784. }
  785. if (secretID == "EX1_611") //freezing trap
  786. {
  787. //return weakest enemy minion to hand
  788. List<Minion> temp = new List<Minion>(this.enemyMinions);
  789. temp.Sort((a, b) => a.Angr.CompareTo(b.Angr));//take the weakest
  790. if (temp.Count == 0) continue;
  791. Minion m = temp[0];
  792. minionReturnToHand(m, false);
  793. }
  794. if (secretID == "EX1_533") // missdirection
  795. {
  796. // first damage to your hero is nulled -> lower guessingHeroDamage
  797. List<Minion> temp = new List<Minion>(this.enemyMinions);
  798. temp.Sort((a, b) => a.Angr.CompareTo(b.Angr));//take the weakest
  799. if (temp.Count == 0) continue;
  800. Minion m = temp[0];
  801. this.guessingHeroDamage = Math.Max(0, this.guessingHeroDamage -= Math.Max(m.Angr,1));
  802. this.ownHeroDefence += this.enemyMinions.Count;// the more the enemy minions has on board, the more the posibility to destroy something other :D
  803. }
  804. //mage secrets############
  805. if (secretID == "EX1_287") //counterspell
  806. {
  807. // what should we do?
  808. this.ownHeroDefence += 5;
  809. }
  810. if (secretID == "EX1_289") //ice barrier
  811. {
  812. this.ownHeroDefence += 8;
  813. }
  814. if (secretID == "EX1_295") //ice barrier
  815. {
  816. //set the guessed Damage to zero
  817. this.guessingHeroDamage = 0;
  818. }
  819. if (secretID == "EX1_294") //mirror entity
  820. {
  821. //summon snake ( a weak minion)
  822. int posi = this.ownMinions.Count - 1;
  823. CardDB.Card kid = CardDB.Instance.getCardData("schlange");
  824. callKid(kid, posi, true);
  825. }
  826. if (secretID == "tt_010") //spellbender
  827. {
  828. //whut???
  829. // add 2 to your defence (most attack-buffs give +2, lots of damage spells too)
  830. this.ownHeroDefence += 2;
  831. }
  832. if (secretID == "EX1_594") // vaporize
  833. {
  834. // first damage to your hero is nulled -> lower guessingHeroDamage and destroy weakest minion
  835. List<Minion> temp = new List<Minion>(this.enemyMinions);
  836. temp.Sort((a, b) => a.Angr.CompareTo(b.Angr));//take the weakest
  837. if (temp.Count == 0) continue;
  838. Minion m = temp[0];
  839. this.guessingHeroDamage = Math.Max(0, this.guessingHeroDamage -= Math.Max(m.Angr, 1));
  840. minionGetDestroyed(m, false);
  841. }
  842. //pala secrets############
  843. if (secretID == "EX1_132") // eye for an eye
  844. {
  845. // enemy takes one damage
  846. attackEnemyHeroWithoutKill(1);
  847. }
  848. if (secretID == "EX1_130") // noble sacrifice
  849. {
  850. //lower guessed hero damage
  851. List<Minion> temp = new List<Minion>(this.enemyMinions);
  852. temp.Sort((a, b) => a.Angr.CompareTo(b.Angr));//take the weakest
  853. if (temp.Count == 0) continue;
  854. Minion m = temp[0];
  855. this.guessingHeroDamage = Math.Max(0, this.guessingHeroDamage -= Math.Max(m.Angr, 1));
  856. }
  857. if (secretID == "EX1_136") // redemption
  858. {
  859. // we give our weakest minion a divine shield :D
  860. List<Minion> temp = new List<Minion>(this.ownMinions);
  861. temp.Sort((a, b) => a.Hp.CompareTo(b.Hp));//take the weakest
  862. if (temp.Count == 0) continue;
  863. foreach (Minion m in temp)
  864. {
  865. if (m.divineshild) continue;
  866. m.divineshild = true;
  867. break;
  868. }
  869. }
  870. if (secretID == "EX1_379") // repentance
  871. {
  872. // set his current lowest hp minion to x/1
  873. List<Minion> temp = new List<Minion>(this.enemyMinions);
  874. temp.Sort((a, b) => a.Hp.CompareTo(b.Hp));//take the weakest
  875. if (temp.Count == 0) continue;
  876. Minion m = temp[0];
  877. m.Hp = 1;
  878. m.maxHp = 1;
  879. }
  880. }
  881. }
  882. private void endTurnBuffs(bool own)
  883. {
  884. List<Minion> temp = new List<Minion>();
  885. if (own)
  886. {
  887. temp.AddRange(this.ownMinions);
  888. }
  889. else
  890. {
  891. temp.AddRange(this.enemyMinions);
  892. }
  893. // end buffs
  894. foreach (Minion m in temp)
  895. {
  896. m.cantLowerHPbelowONE = false;
  897. m.immune = false;
  898. List<Enchantment> tempench = new List<Enchantment>(m.enchantments);
  899. foreach (Enchantment e in tempench)
  900. {
  901. if (e.CARDID == "EX1_316e")//ueberwaeltigende macht
  902. {
  903. minionGetDestroyed(m, own);
  904. }
  905. if (e.CARDID == "CS2_046e")//kampfrausch
  906. {
  907. debuff(m, e);
  908. }
  909. if (e.CARDID == "CS2_045e")// waffe felsbeiser
  910. {
  911. debuff(m, e);
  912. }
  913. if (e.CARDID == "EX1_046e")// dunkeleisenzwerg
  914. {
  915. debuff(m, e);
  916. }
  917. if (e.CARDID == "CS2_188o")// ruchloserunteroffizier
  918. {
  919. debuff(m, e);
  920. }
  921. if (e.CARDID == "EX1_055o")// manasuechtige
  922. {
  923. debuff(m, e);
  924. }
  925. if (e.CARDID == "EX1_549o")//zorn des wildtiers
  926. {
  927. debuff(m, e);
  928. }
  929. if (e.CARDID == "EX1_334e")// dunkler wahnsin (control minion till end of turn)
  930. {
  931. //"uncontrol minion"
  932. minionGetControlled(m, false, true);
  933. }
  934. }
  935. }
  936. }
  937. private void endTurnEffect(bool own)
  938. {
  939. List<Minion> temp = new List<Minion>();
  940. List<Minion> ownmins = new List<Minion>();
  941. List<Minion> enemymins = new List<Minion>();
  942. if (own)
  943. {
  944. temp.AddRange(this.ownMinions);
  945. ownmins.AddRange(this.ownMinions);
  946. enemymins.AddRange(this.enemyMinions);
  947. }
  948. else
  949. {
  950. temp.AddRange(this.enemyMinions);
  951. ownmins.AddRange(this.enemyMinions);
  952. enemymins.AddRange(this.ownMinions);
  953. }
  954. foreach (Minion m in temp)
  955. {
  956. if (m.silenced) continue;
  957. if (m.name == "barongeddon") // all other chards get dmg get 2 dmg
  958. {
  959. List<Minion> temp2 = new List<Minion>(this.ownMinions);
  960. foreach (Minion mm in temp2)
  961. {
  962. if (mm.entitiyID != m.entitiyID)
  963. {
  964. minionGetDamagedOrHealed(mm, 2, 0, true);
  965. }
  966. }
  967. temp2.Clear();
  968. temp2.AddRange(this.enemyMinions);
  969. foreach (Minion mm in temp2)
  970. {
  971. if (mm.entitiyID != m.entitiyID)
  972. {
  973. minionGetDamagedOrHealed(mm, 2, 0, false);
  974. }
  975. }
  976. attackOrHealHero(2, true);
  977. attackOrHealHero(2, false);
  978. }
  979. if (m.name == "blutwichtel" || m.name == "jungepriesterin") // buff a minion
  980. {
  981. List<Minion> temp2 = new List<Minion>(ownmins);
  982. temp2.Sort((a, b) => a.Hp.CompareTo(b.Hp));//buff the weakest
  983. foreach (Minion mins in Helpfunctions.TakeList(temp2, 1))
  984. {
  985. minionGetBuffed(mins, 0, 1, own);
  986. }
  987. }
  988. if (m.name == "meisterschwertschmied") // buff a minion
  989. {
  990. List<Minion> temp2 = new List<Minion>(ownmins);
  991. temp2.Sort((a, b) => a.Angr.CompareTo(b.Angr));//buff the weakest
  992. foreach (Minion mins in Helpfunctions.TakeList(temp2, 1))
  993. {
  994. minionGetBuffed(mins, 1, 0, own);
  995. }
  996. }
  997. if (m.name == "kraftverstaerker3000") // buff a minion
  998. {
  999. List<Minion> temp2 = new List<Minion>(this.enemyMinions);
  1000. temp2.Sort((a, b) => -a.Angr.CompareTo(b.Angr));//buff the strongest enemy
  1001. foreach (Minion mins in Helpfunctions.TakeList(temp2, 1))
  1002. {
  1003. minionGetBuffed(mins, 1, 0, false);//buff alyways enemy :D
  1004. }
  1005. }
  1006. if (m.name == "gruul") // gain +1/+1
  1007. {
  1008. minionGetBuffed(m, 1, 1, own);
  1009. }
  1010. if (m.name == "astralerarkanist") // gain +2/+2
  1011. {
  1012. if (own && this.ownSecretsIDList.Count>=1)
  1013. {
  1014. minionGetBuffed(m, 2, 2, own);
  1015. }
  1016. if (!own && this.enemySecretCount >= 1)
  1017. {
  1018. minionGetBuffed(m, 2, 2, own);
  1019. }
  1020. }
  1021. if (m.name == "manafluttotem") // draw card
  1022. {
  1023. if (own)
  1024. {
  1025. this.owncarddraw++;
  1026. this.drawACard("");
  1027. }
  1028. else
  1029. {
  1030. this.enemycarddraw++;
  1031. }
  1032. }
  1033. if (m.name == "heiltotem") // heal
  1034. {
  1035. List<Minion> temp2 = new List<Minion>(ownmins);
  1036. foreach (Minion mins in temp2)
  1037. {
  1038. minionGetDamagedOrHealed(mins, 0, 1, own);
  1039. }
  1040. }
  1041. if (m.name == "hogger") // summon
  1042. {
  1043. int posi = m.id;
  1044. CardDB.Card kid = CardDB.Instance.getCardData("gnoll");
  1045. callKid(kid, posi, own);
  1046. }
  1047. if (m.name == "wichtelmeisterin") // damage itself and summon
  1048. {
  1049. int posi = m.id;
  1050. if (m.Hp == 1) posi--;
  1051. minionGetDamagedOrHealed(m, 1, 0, own);
  1052. CardDB.Card kid = CardDB.Instance.getCardData("wichtel");
  1053. callKid(kid, posi, own);
  1054. }
  1055. if (m.name == "natpagle") // draw card
  1056. {
  1057. if (own)
  1058. {
  1059. this.owncarddraw++;
  1060. this.drawACard("");
  1061. }
  1062. else
  1063. {
  1064. this.enemycarddraw++;
  1065. }
  1066. }
  1067. if (m.name == "ragnarosderfeuerfuerst") // summon
  1068. {
  1069. if (this.enemyMinions.Count >= 1)
  1070. {
  1071. List<Minion> temp2 = new List<Minion>(enemymins);
  1072. temp2.Sort((a, b) => -a.Hp.CompareTo(b.Hp));//damage the stronges
  1073. foreach (Minion mins in Helpfunctions.TakeList(temp2, 1))
  1074. {
  1075. minionGetDamagedOrHealed(mins, 8, 0, !own);
  1076. }
  1077. }
  1078. else
  1079. {
  1080. attackOrHealHero(8, !own);
  1081. }
  1082. }
  1083. if (m.name == "reparaturbot") // heal damaged char
  1084. {
  1085. attackOrHealHero(-6, false);
  1086. }
  1087. if (m.card.CardID == "EX1_tk9") //treant which is destroyed
  1088. {
  1089. minionGetDestroyed(m, own);
  1090. }
  1091. if (m.name == "ysera") // draw card
  1092. {
  1093. if (own)
  1094. {
  1095. this.owncarddraw++;
  1096. this.drawACard("yseraerwacht");
  1097. }
  1098. else
  1099. {
  1100. this.enemycarddraw++;
  1101. }
  1102. }
  1103. }
  1104. }
  1105. private void startTurnEffect(bool own)
  1106. {
  1107. List<Minion> temp = new List<Minion>();
  1108. List<Minion> ownmins = new List<Minion>();
  1109. List<Minion> enemymins = new List<Minion>();
  1110. if (own)
  1111. {
  1112. temp.AddRange(this.ownMinions);
  1113. ownmins.AddRange(this.ownMinions);
  1114. enemymins.AddRange(this.enemyMinions);
  1115. }
  1116. else
  1117. {
  1118. temp.AddRange(this.enemyMinions);
  1119. ownmins.AddRange(this.enemyMinions);
  1120. enemymins.AddRange(this.ownMinions);
  1121. }
  1122. bool untergang=false;
  1123. foreach (Minion m in temp)
  1124. {
  1125. if (m.silenced) continue;
  1126. if (m.name == "verwuester") // deal 2 dmg
  1127. {
  1128. List<Minion> temp2 = new List<Minion>(enemymins);
  1129. foreach (Minion mins in temp2)
  1130. {
  1131. minionGetDamagedOrHealed(mins, 2, 0, !own);
  1132. }
  1133. }
  1134. if (m.name == "untergangsverkuender") // destroy
  1135. {
  1136. untergang = true;
  1137. }
  1138. if (m.name == "zielsuchendeshuhn") // ok
  1139. {
  1140. minionGetDestroyed(m, own);
  1141. if (own)
  1142. {
  1143. this.owncarddraw += 3;
  1144. this.drawACard("");
  1145. this.drawACard("");
  1146. this.drawACard("");

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