/ai/action-copy.cs
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
- // the ai :D
- //please ask/write me if you use this in your project
- using System;
- using System.Collections.Generic;
- using System.Text;
- //TODO:
- //test wichtelmeisterin, befehlsruf
- //tueftlermeisteroberfunks
- //verrückter bomber ( 3 damage to random chars)
- //nozdormu (for computing time :D)
- //faehrtenlesen
- // lehrensucher cho
- //scharmuetzel kills all :D
- namespace HREngine.Bots
- {
- public class Action
- {
- public bool cardplay = false;
- public bool heroattack = false;
- public bool useability = false;
- public bool minionplay = false;
- public CardDB.Card card;
- public int cardEntitiy = -1;
- public int owntarget = -1; //= target where card/minion is placed
- public int ownEntitiy = -1;
- public int enemytarget = -1; // target where red arrow is placed
- public int enemyEntitiy = -1;
- public int druidchoice = 0; // 1 left card, 2 right card
- public int numEnemysBeforePlayed = 0;
- public void print()
- {
- Helpfunctions help = Helpfunctions.Instance;
- help.logg("current Action: ");
- if (this.cardplay)
- {
- help.logg("play " + this.card.name);
- if (this.druidchoice >= 1) help.logg("choose choise " + this.druidchoice);
- help.logg("with position " + this.cardEntitiy);
- if (this.owntarget >= 0)
- {
- help.logg("on position " + this.ownEntitiy);
- }
- if (this.enemytarget >= 0)
- {
- help.logg("and target to " + this.enemytarget + " " + this.enemyEntitiy);
- }
- }
- if (this.minionplay)
- {
- help.logg("attacker: " + this.owntarget + " enemy: " + this.enemytarget);
- help.logg("targetplace " + this.enemyEntitiy);
- }
- if (this.heroattack)
- {
- help.logg("attack with hero, enemy: " + this.enemytarget);
- help.logg("targetplace " + this.enemyEntitiy);
- }
- if (this.useability)
- {
- help.logg("useability ");
- if (this.enemytarget >= 0)
- {
- help.logg("on enemy: " + this.enemytarget + "targetplace " + this.enemyEntitiy);
- }
- }
- help.logg("");
- }
- }
- public class Playfield
- {
- public bool logging = false;
- public int evaluatePenality = 0;
- public int ownController = 0;
- public int ownHeroEntity = -1;
- public int enemyHeroEntity = -1;
- public int value = Int32.MinValue;
- public int guessingHeroDamage = 0;
- public int mana = 0;
- public int enemyHeroHp = 30;
- public string ownHeroName = "";
- public string enemyHeroName = "";
- public bool ownHeroReady = false;
- public int ownHeroNumAttackThisTurn = 0;
- public bool ownHeroWindfury = false;
- public List<string> ownSecretsIDList = new List<string>();
- public int enemySecretCount = 0;
- public int ownHeroHp = 30;
- public int ownheroAngr = 0;
- public bool ownHeroFrozen = false;
- public bool enemyHeroFrozen = false;
- public bool heroImmuneWhileAttacking = false;
- public int ownWeaponDurability = 0;
- public int ownWeaponAttack = 0;
- public string ownWeaponName = "";
-
- public int enemyWeaponAttack = 0;
- public int enemyWeaponDurability = 0;
- public List<Minion> ownMinions = new List<Minion>();
- public List<Minion> enemyMinions = new List<Minion>();
- public List<Handmanager.Handcard> owncards = new List<Handmanager.Handcard>();
- public List<Action> playactions = new List<Action>();
- public bool complete = false;
- public int owncarddraw = 0;
- public int ownHeroDefence = 0;
- public int enemycarddraw = 0;
- public int enemyAnzCards = 0;
- public int enemyHeroDefence = 0;
- public bool ownAbilityReady = false;
- public int doublepriest = 0;
- public int spellpower = 0;
- public bool auchenaiseelenpriesterin = false;
- public bool playedmagierinderkirintor = false;
- public bool playedPreparation = false;
- public int winzigebeschwoererin = 0;
- public int startedWithWinzigebeschwoererin = 0;
- public int zauberlehrling = 0;
- public int startedWithZauberlehrling = 0;
- public int managespenst = 0;
- public int startedWithManagespenst = 0;
- public int soeldnerDerVenture = 0;
- public int startedWithsoeldnerDerVenture = 0;
- public int beschwoerungsportal = 0;
- public int startedWithbeschwoerungsportal = 0;
- public int ownWeaponAttackStarted = 0;
- public int ownMobsCountStarted = 0;
- public int ownCardsCountStarted = 0;
- public int ownHeroHpStarted = 30;
- public int mobsplayedThisTurn = 0;
- public int startedWithMobsPlayedThisTurn = 0;
- public int cardsPlayedThisTurn = 0;
- public int ueberladung = 0; //=recall
- public int ownMaxMana = 0;
- public int enemyMaxMana = 0;
- public int lostDamage = 0;
- public int lostHealth = 0;
- public int lostWeaponDamage = 0;
- public CardDB.Card ownHeroAblility;
- Helpfunctions help = Helpfunctions.Instance;
- private void addMinionsReal(List<Minion> source, List<Minion> trgt)
- {
- foreach (Minion m in source)
- {
- Minion mc = new Minion(m);
- trgt.Add(mc);
- }
- }
- private void addCardsReal(List<Handmanager.Handcard> source)
- {
- foreach (Handmanager.Handcard m in source)
- {
- Handmanager.Handcard mc = new Handmanager.Handcard();
- mc.card = new CardDB.Card(m.card);
- mc.position = m.position;
- mc.entity = m.entity;
- this.owncards.Add(mc);
- }
- }
- public Playfield()
- {
- this.ownController = Hrtprozis.Instance.getOwnController();
- this.ownHeroEntity = Hrtprozis.Instance.ownHeroEntity;
- this.enemyHeroEntity = Hrtprozis.Instance.enemyHeroEntitiy;
- this.mana = Hrtprozis.Instance.currentMana;
- this.ownMaxMana = Hrtprozis.Instance.ownMaxMana;
- this.enemyMaxMana = Hrtprozis.Instance.enemyMaxMana;
- this.evaluatePenality = 0;
- this.ownSecretsIDList = Hrtprozis.Instance.ownSecretList;
- this.enemySecretCount = Hrtprozis.Instance.enemySecretCount;
- addMinionsReal(Hrtprozis.Instance.ownMinions, ownMinions);
- addMinionsReal(Hrtprozis.Instance.enemyMinions, enemyMinions);
- addCardsReal(Handmanager.Instance.handCards);
- this.enemyHeroHp = Hrtprozis.Instance.enemyHp;
- this.ownHeroName = Hrtprozis.Instance.heroname;
- this.enemyHeroName = Hrtprozis.Instance.enemyHeroname;
- this.ownHeroHp = Hrtprozis.Instance.heroHp;
- this.complete = false;
- this.ownHeroReady = Hrtprozis.Instance.ownheroisread;
- this.ownHeroWindfury = Hrtprozis.Instance.ownHeroWindfury;
- this.ownHeroNumAttackThisTurn = Hrtprozis.Instance.ownHeroNumAttacksThisTurn;
- this.ownHeroFrozen = Hrtprozis.Instance.herofrozen;
- this.enemyHeroFrozen = Hrtprozis.Instance.enemyfrozen;
- this.ownheroAngr = Hrtprozis.Instance.heroAtk;
- this.heroImmuneWhileAttacking = Hrtprozis.Instance.heroImmuneToDamageWhileAttacking;
- this.ownWeaponDurability = Hrtprozis.Instance.heroWeaponDurability;
- this.ownWeaponAttack = Hrtprozis.Instance.heroWeaponAttack;
- this.ownWeaponName = Hrtprozis.Instance.ownHeroWeapon;
- this.owncarddraw = 0;
- this.ownHeroDefence = 0;
- this.enemyHeroDefence = 0;
- this.enemyWeaponAttack = 0;//dont know jet
- this.enemyWeaponDurability = Hrtprozis.Instance.enemyWeaponDurability;
- this.enemycarddraw = 0;
- this.enemyAnzCards = Handmanager.Instance.enemyAnzCards;
- this.ownAbilityReady = Hrtprozis.Instance.ownAbilityisReady;
- this.ownHeroAblility = Hrtprozis.Instance.heroAbility;
- this.doublepriest = 0;
- this.spellpower = 0;
- value = -1000000;
- this.mobsplayedThisTurn = Hrtprozis.Instance.numMinionsPlayedThisTurn;
- this.startedWithMobsPlayedThisTurn = Hrtprozis.Instance.numMinionsPlayedThisTurn;// only change mobsplayedthisturm
- this.cardsPlayedThisTurn = Hrtprozis.Instance.cardsPlayedThisTurn;
- this.ueberladung = Hrtprozis.Instance.ueberladung;
- //need the following for manacost-calculation
- this.ownHeroHpStarted = this.ownHeroHp;
- this.ownWeaponAttackStarted = this.ownWeaponAttack;
- this.ownCardsCountStarted = this.owncards.Count;
- this.ownMobsCountStarted = this.ownMinions.Count;
- this.playedmagierinderkirintor = false;
- this.playedPreparation = false;
- this.zauberlehrling = 0;
- this.winzigebeschwoererin = 0;
- this.managespenst = 0;
- this.soeldnerDerVenture = 0;
- this.beschwoerungsportal = 0;
- this.startedWithbeschwoerungsportal = 0;
- this.startedWithManagespenst = 0;
- this.startedWithWinzigebeschwoererin = 0;
- this.startedWithZauberlehrling = 0;
- this.startedWithsoeldnerDerVenture = 0;
- foreach (Minion m in this.ownMinions)
- {
- if (m.silenced) continue;
- if (m.name == "prophetvelen") this.doublepriest++;
- spellpower = spellpower + m.card.spellpowervalue;
- if (m.name == "auchenaiseelenpriesterin") this.auchenaiseelenpriesterin = true;
- if (m.name == "winzigebeschwoererin")
- {
- this.winzigebeschwoererin++;
- this.startedWithWinzigebeschwoererin++;
- }
- if (m.name == "zauberlehrling")
- {
- this.zauberlehrling++;
- this.startedWithZauberlehrling++;
- }
- if (m.name == "managespenst")
- {
- this.managespenst++;
- this.startedWithManagespenst++;
- }
- if (m.name == "soeldnerderventureco")
- {
- this.soeldnerDerVenture++;
- this.startedWithsoeldnerDerVenture++;
- }
- if (m.name == "beschwoerungsportal")
- {
- this.beschwoerungsportal++;
- this.startedWithbeschwoerungsportal++;
- }
- foreach (Enchantment e in m.enchantments)// only at first init needed, after that its copied
- {
- if (e.CARDID == "NEW1_036e" || e.CARDID == "NEW1_036e2") m.cantLowerHPbelowONE = true;
- }
- }
- foreach (Minion m in this.enemyMinions)
- {
- if (m.silenced) continue;
- if (m.name == "managespenst")
- {
- this.managespenst++;
- this.startedWithManagespenst++;
- }
- }
- }
- public Playfield(Playfield p)
- {
- this.ownController = p.ownController;
- this.ownHeroEntity = p.ownHeroEntity;
- this.enemyHeroEntity = p.enemyHeroEntity;
- this.evaluatePenality = p.evaluatePenality;
- foreach(string s in p.ownSecretsIDList)
- { this.ownSecretsIDList.Add(s); }
- this.enemySecretCount = p.enemySecretCount;
- this.mana = p.mana;
- this.ownMaxMana = p.ownMaxMana;
- this.enemyMaxMana = p.enemyMaxMana;
- addMinionsReal(p.ownMinions, ownMinions);
- addMinionsReal(p.enemyMinions, enemyMinions);
- addCardsReal(p.owncards);
- this.enemyHeroHp = p.enemyHeroHp;
- this.ownHeroName = p.ownHeroName;
- this.enemyHeroName = p.enemyHeroName;
- this.ownHeroHp = p.ownHeroHp;
- this.playactions.AddRange(p.playactions);
- this.complete = false;
- this.ownHeroReady = p.ownHeroReady;
- this.ownHeroNumAttackThisTurn = p.ownHeroNumAttackThisTurn;
- this.ownHeroWindfury = p.ownHeroWindfury;
- this.ownheroAngr = p.ownheroAngr;
- this.ownHeroFrozen = p.ownHeroFrozen;
- this.enemyHeroFrozen = p.enemyHeroFrozen;
- this.heroImmuneWhileAttacking = p.heroImmuneWhileAttacking;
- this.owncarddraw = p.owncarddraw;
- this.ownHeroDefence = p.ownHeroDefence;
- this.enemyWeaponAttack = p.enemyWeaponAttack;
- this.enemycarddraw = p.enemycarddraw;
- this.enemyAnzCards = p.enemyAnzCards;
- this.enemyHeroDefence = p.enemyHeroDefence;
- this.ownWeaponDurability = p.ownWeaponDurability;
- this.ownWeaponAttack = p.ownWeaponAttack;
- this.ownWeaponName = p.ownWeaponName;
- this.lostDamage = p.lostDamage;
- this.lostWeaponDamage = p.lostWeaponDamage;
- this.lostHealth = p.lostHealth;
- this.ownAbilityReady = p.ownAbilityReady;
- this.ownHeroAblility = p.ownHeroAblility;
- this.doublepriest = 0;
- this.spellpower = 0;
- value = -1000000;
- this.mobsplayedThisTurn = p.mobsplayedThisTurn;
- this.startedWithMobsPlayedThisTurn = p.startedWithMobsPlayedThisTurn;
- this.cardsPlayedThisTurn = p.cardsPlayedThisTurn;
- this.ueberladung = p.ueberladung;
- //need the following for manacost-calculation
- this.ownHeroHpStarted = p.ownHeroHpStarted;
- this.ownWeaponAttackStarted = p.ownWeaponAttackStarted;
- this.ownCardsCountStarted = p.ownCardsCountStarted;
- this.ownMobsCountStarted = p.ownMobsCountStarted;
- this.startedWithWinzigebeschwoererin = p.startedWithWinzigebeschwoererin;
- this.playedmagierinderkirintor = p.playedmagierinderkirintor;
- this.startedWithZauberlehrling = p.startedWithZauberlehrling;
- this.startedWithWinzigebeschwoererin = p.startedWithWinzigebeschwoererin;
- this.startedWithManagespenst = p.startedWithManagespenst;
- this.startedWithsoeldnerDerVenture = p.startedWithsoeldnerDerVenture;
- this.startedWithbeschwoerungsportal = p.startedWithbeschwoerungsportal;
- this.zauberlehrling = 0;
- this.winzigebeschwoererin = 0;
- this.managespenst = 0;
- this.soeldnerDerVenture = 0;
- foreach (Minion m in this.ownMinions)
- {
- if (m.silenced) continue;
- if (m.name == "prophetvelen") this.doublepriest++;
- spellpower = spellpower + m.card.spellpowervalue;
- if (m.name == "auchenaiseelenpriesterin") this.auchenaiseelenpriesterin = true;
- if (m.name == "winzigebeschwoererin") this.winzigebeschwoererin++;
- if (m.name == "zauberlehrling") this.zauberlehrling++;
- if (m.name == "managespenst") this.managespenst++;
- if (m.name == "soeldnerderventureco") this.soeldnerDerVenture++;
- if (m.name == "beschwoerungsportal") this.beschwoerungsportal++;
- }
- foreach (Minion m in this.enemyMinions)
- {
- if (m.silenced) continue;
- if (m.name == "managespenst") this.managespenst++;
- }
- }
- public int getValuee()
- {
- //if (value >= -200000) return value;
- int retval = 0;
- retval += owncards.Count * 1;
-
- retval += ownMinions.Count * 10;
- retval -= enemyMinions.Count * 10;
- retval += ownHeroHp + ownHeroDefence;
- retval += -enemyHeroHp - enemyHeroDefence;
- retval += ownheroAngr;// +ownWeaponDurability;
- retval -= enemyWeaponDurability;
- retval += owncarddraw * 5;
- retval -= enemycarddraw * 5;
- retval += this.ownMaxMana;
- if (enemyMinions.Count >= 0)
- {
- int anz = enemyMinions.Count;
- int owntaunt = ownMinions.FindAll(x => x.taunt == true).Count;
- int froggs = ownMinions.FindAll(x => x.name == "frosch").Count;
- owntaunt -= froggs;
- if (owntaunt == 0) retval -= 10 * anz;
- retval += owntaunt * 10 - 11 * anz;
- }
- foreach (Minion m in this.ownMinions)
- {
- retval += m.Hp * 1;
- retval += m.Angr * 2;
- if (m.Angr >= m.maxHp + 1)
- {
- //is a tanky minion
- retval += m.Hp;
- }
- if (m.windfury) retval += m.Angr;
- }
- foreach (Minion m in this.enemyMinions)
- {
- retval -= m.Hp;
- retval -= m.Angr*2;
- if (m.Angr >= m.maxHp + 1)
- {
- //is a tanky minion
- retval -= m.Hp;
- }
- if (m.windfury) retval -= m.Angr;
- if (m.taunt) retval -= 5;
- if (m.name == "schlachtzugsleiter") retval -= 5;
- if (m.name == "grimmschuppenorakel") retval -= 5;
- if (m.name == "terrorwolfalpha") retval -= 2;
- if (m.name == "murlocanfuehrer") retval -= 5;
- if (m.name == "suedmeerkapitaen") retval -= 5;
- if (m.name == "championvonsturmwind") retval -= 10;
- if (m.name == "waldwolf") retval -= 5;
- if (m.name == "leokk") retval -= 5;
- if (m.name == "klerikerinvonnordhain") retval -= 5;
- if (m.name == "zauberlehrling") retval -= 3;
- if (m.name == "winzigebeschwoererin") retval -= 3;
- }
- retval -= lostDamage;//damage which was to high (like killing a 2/1 with an 3/3 -> => lostdamage =2
- retval -= lostWeaponDamage;
- if (ownMinions.Count == 0) retval -= 20;
- if (enemyMinions.Count == 0) retval += 20;
- if (enemyHeroHp <= 0) retval = 10000;
- if (ownHeroHp <= 0) retval = -10000;
- this.value = retval;
- return retval;
- }
- public List<targett> getAttackTargets()
- {
- List<targett> trgts = new List<targett>();
- List<targett> trgts2 = new List<targett>();
- trgts2.Add(new targett(200, this.enemyHeroEntity));
- bool hastanks = false;
- foreach (Minion m in this.enemyMinions)
- {
- if (m.stealth) continue; // cant target stealth
- if (m.taunt)
- {
- hastanks = true;
- trgts.Add(new targett(m.id + 10, m.entitiyID));
- }
- else
- {
- trgts2.Add(new targett(m.id + 10, m.entitiyID));
- }
- }
- if (hastanks) return trgts;
- return trgts2;
- }
- public int getBestPlace(CardDB.Card card)
- {
- if (card.type != CardDB.cardtype.MOB) return 0;
- if (this.ownMinions.Count <= 1) return 0;
- int[] places = new int[this.ownMinions.Count];
- int i = 0;
- int tempval = 0;
- 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
- {
- i = 0;
- foreach (Minion m in this.ownMinions)
- {
- places[i] = 0;
- tempval = 0;
- if (!m.taunt)
- {
- tempval -= m.Hp;
- }
- else
- {
- tempval = 30;
- }
- if (m.name == "flammenzungentotem") tempval += 50;
- if (m.name == "schlachtzugsleiter") tempval += 30;
- if (m.name == "grimmschuppenorakel") tempval += 30;
- if (m.name == "terrorwolfalpha") tempval += 50;
- if (m.name == "murlocanfuehrer") tempval += 30;
- if (m.name == "suedmeerkapitaen") tempval += 30;
- if (m.name == "championvonsturmwind") tempval += 30;
- if (m.name == "waldwolf") tempval += 30;
- if (m.name == "leokk") tempval += 30;
- if (m.name == "klerikerinvonnordhain") tempval += 30;
- if (m.name == "zauberlehrling") tempval += 20;
- if (m.name == "winzigebeschwoererin") tempval += 10;
- if (m.name == "beschwoerungsportal") tempval += 20;
- if (m.name == "aasfressendehyaene") tempval += 20;
- places[i] = tempval;
- i++;
- }
- i = 0;
- int bestpl = 7;
- int bestval = 10000;
- foreach (Minion m in this.ownMinions)
- {
- int prev = 0;
- int next = 0;
- if (i >= 1) prev = places[i - 1];
- next = places[i];
- if(bestval > prev + next)
- {
- bestval = prev + next;
- bestpl = i;
- }
- i++;
- }
- return bestpl;
- }
- // normal placement
- int cardvalue = card.Attack * 2 + card.Health;
- if (card.tank)
- {
- cardvalue += 5;
- cardvalue += card.Health;
- }
- if (card.name == "flammenzungentotem") cardvalue += 50;
- if (card.name == "schlachtzugsleiter") cardvalue += 10;
- if (card.name == "grimmschuppenorakel") cardvalue += 10;
- if (card.name == "terrorwolfalpha") cardvalue += 50;
- if (card.name == "murlocanfuehrer") cardvalue += 10;
- if (card.name == "suedmeerkapitaen") cardvalue += 10;
- if (card.name == "championvonsturmwind") cardvalue += 10;
- if (card.name == "waldwolf") cardvalue += 10;
- if (card.name == "leokk") cardvalue += 10;
- if (card.name == "cardvalue") cardvalue += 10;
- if (card.name == "zauberlehrling") cardvalue += 10;
- if (card.name == "winzigebeschwoererin") cardvalue += 10;
- if (card.name == "beschwoerungsportal") cardvalue += 10;
- if (card.name == "aasfressendehyaene") cardvalue += 10;
- i = 0;
- foreach(Minion m in this.ownMinions)
- {
- places[i] = 0;
- tempval = m.Angr * 2 + m.maxHp;
- if (m.taunt)
- {
- tempval += 6;
- tempval += m.maxHp;
- }
- if (m.name == "flammenzungentotem") tempval += 50;
- if (m.name == "schlachtzugsleiter") tempval += 10;
- if (m.name == "grimmschuppenorakel") tempval += 10;
- if (m.name == "terrorwolfalpha") tempval += 50;
- if (m.name == "murlocanfuehrer") tempval += 10;
- if (m.name == "suedmeerkapitaen") tempval += 10;
- if (m.name == "championvonsturmwind") tempval += 10;
- if (m.name == "waldwolf") tempval += 10;
- if (m.name == "leokk") tempval += 10;
- if (m.name == "klerikerinvonnordhain") tempval += 10;
- if (m.name == "zauberlehrling") tempval += 10;
- if (m.name == "winzigebeschwoererin") tempval += 10;
- if (m.name == "beschwoerungsportal") tempval += 10;
- if (m.name == "aasfressendehyaene") tempval += 10;
- places[i] = tempval;
- i++;
- }
- //bigminion if >=10
- int bestplace = 0;
- int bestvale = 0;
- tempval=0;
- i=0;
- for (int j = 0; j <= this.ownMinions.Count; j++ )
- {
- int prev = cardvalue;
- int next = cardvalue;
- if (i >= 1) prev = places[i - 1];
- if (i < this.ownMinions.Count) next = places[i];
- if (cardvalue >= prev && cardvalue >= next)
- {
- tempval = 2 * cardvalue - prev - next;
- if (tempval > bestvale)
- {
- bestplace = i;
- bestvale = tempval;
- }
- }
- if (cardvalue <= prev && cardvalue <= next)
- {
- tempval = -2 * cardvalue + prev + next;
- if (tempval > bestvale)
- {
- bestplace = i ;
- bestvale = tempval;
- }
- }
- i++;
- }
- return bestplace;
- }
- public int getBestPlacePrint(CardDB.Card card)
- {
- if (card.type != CardDB.cardtype.MOB) return 0;
- if (this.ownMinions.Count <= 1) return 0;
- int[] places = new int[this.ownMinions.Count];
- int i = 0;
- int tempval = 0;
- 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
- {
- i = 0;
- foreach (Minion m in this.ownMinions)
- {
- places[i] = 0;
- tempval = 0;
- if (!m.taunt)
- {
- tempval -= m.Hp;
- }
- else
- {
- tempval = 30;
- }
- if (m.name == "flammenzungentotem") tempval += 50;
- if (m.name == "schlachtzugsleiter") tempval += 30;
- if (m.name == "grimmschuppenorakel") tempval += 30;
- if (m.name == "terrorwolfalpha") tempval += 50;
- if (m.name == "murlocanfuehrer") tempval += 30;
- if (m.name == "suedmeerkapitaen") tempval += 30;
- if (m.name == "championvonsturmwind") tempval += 30;
- if (m.name == "waldwolf") tempval += 30;
- if (m.name == "leokk") tempval += 30;
- if (m.name == "klerikerinvonnordhain") tempval += 30;
- if (m.name == "zauberlehrling") tempval += 20;
- if (m.name == "winzigebeschwoererin") tempval += 10;
- if (m.name == "beschwoerungsportal") tempval += 20;
- if (m.name == "aasfressendehyaene") tempval += 20;
- places[i] = tempval;
- i++;
- }
- i = 0;
- int bestpl = 7;
- int bestval = 10000;
- foreach (Minion m in this.ownMinions)
- {
- help.logg(places[i]+"");
- int prev = 0;
- int next = 0;
- if (i >= 1) prev = places[i - 1];
- next = places[i];
- if (bestval > prev + next)
- {
- bestval = prev + next;
- bestpl = i ;
- }
- i++;
- }
- return bestpl;
- }
- // normal placement
- int cardvalue = card.Attack * 2 + card.Health;
- if (card.tank)
- {
- cardvalue += 5;
- cardvalue += card.Health;
- }
- if (card.name == "flammenzungentotem") tempval += 50;
- if (card.name == "schlachtzugsleiter") cardvalue += 10;
- if (card.name == "grimmschuppenorakel") cardvalue += 10;
- if (card.name == "terrorwolfalpha") cardvalue += 50;
- if (card.name == "murlocanfuehrer") cardvalue += 10;
- if (card.name == "suedmeerkapitaen") cardvalue += 10;
- if (card.name == "championvonsturmwind") cardvalue += 10;
- if (card.name == "waldwolf") cardvalue += 10;
- if (card.name == "leokk") cardvalue += 10;
- if (card.name == "cardvalue") cardvalue += 10;
- if (card.name == "zauberlehrling") cardvalue += 10;
- if (card.name == "winzigebeschwoererin") cardvalue += 10;
- if (card.name == "beschwoerungsportal") cardvalue += 10;
- if (card.name == "aasfressendehyaene") cardvalue += 10;
- i = 0;
- foreach (Minion m in this.ownMinions)
- {
- places[i] = 0;
- tempval = m.Angr * 2 + m.maxHp;
- if (m.taunt)
- {
- tempval += 6;
- tempval += m.maxHp;
- }
- if (m.name == "flammenzungentotem") tempval += 50;
- if (m.name == "schlachtzugsleiter") tempval += 10;
- if (m.name == "grimmschuppenorakel") tempval += 10;
- if (m.name == "terrorwolfalpha") tempval += 50;
- if (m.name == "murlocanfuehrer") tempval += 10;
- if (m.name == "suedmeerkapitaen") tempval += 10;
- if (m.name == "championvonsturmwind") tempval += 10;
- if (m.name == "waldwolf") tempval += 10;
- if (m.name == "leokk") tempval += 10;
- if (m.name == "klerikerinvonnordhain") tempval += 10;
- if (m.name == "zauberlehrling") tempval += 10;
- if (m.name == "winzigebeschwoererin") tempval += 10;
- if (m.name == "beschwoerungsportal") tempval += 10;
- if (m.name == "aasfressendehyaene") tempval += 10;
- places[i] = tempval;
- help.logg(places[i] + "");
- i++;
- }
- //bigminion if >=10
- int bestplace = 0;
- int bestvale = 0;
- tempval = 0;
- i = 0;
- help.logg(cardvalue + " (own)");
- i = 0;
- for (int j = 0; j <= this.ownMinions.Count; j++)
- {
- int prev = cardvalue;
- int next = cardvalue;
- if (i >= 1) prev = places[i - 1];
- if (i < this.ownMinions.Count)
- {
- next = places[i];
- }
- if (cardvalue >= prev && cardvalue >= next)
- {
- tempval = 2 * cardvalue - prev - next;
- if (tempval > bestvale)
- {
- bestplace = i ;
- bestvale = tempval;
- }
- }
- if (cardvalue <= prev && cardvalue <= next)
- {
- tempval = -2 * cardvalue + prev + next;
- if (tempval > bestvale)
- {
- bestplace = i;
- bestvale = tempval;
- }
- }
- i++;
- }
- help.logg(bestplace + " (best)");
- return bestplace;
- }
- public void endTurn()
- {
- this.complete = true;
- endTurnBuffs(true);//end own buffs
- endTurnEffect(true);//own turn ends
- startTurnEffect(false);//enemy turn begins
- guessHeroDamage();
- simulateTraps();
-
- }
- private void guessHeroDamage()
- {
- int ghd = 0;
- foreach (Minion m in this.enemyMinions)
- {
- if (m.frozen) continue;
- ghd += m.Angr;
- if (m.windfury) ghd += m.Angr;
- }
- if (this.enemyHeroName == "druid") ghd++;
- if (this.enemyHeroName == "mage") ghd++;
- if (this.enemyHeroName == "thief") ghd++;
- if (this.enemyHeroName == "hunter") ghd += 2;
- ghd += enemyWeaponAttack;
- foreach (Minion m in this.ownMinions)
- {
- if (m.frozen) continue;
- if (m.taunt) ghd -= m.Hp;
- if (m.taunt && m.divineshild) ghd -= 1;
- }
- this.guessingHeroDamage = Math.Max(0, ghd);
- }
- private void simulateTraps()
- {
- // DONT KILL ENEMY HERO (cause its only guessing)
- foreach (string secretID in this.ownSecretsIDList)
- {
- //hunter secrets############
- if (secretID == "EX1_554") //snaketrap
- {
- //call 3 snakes (if possible)
- int posi = this.ownMinions.Count - 1;
- CardDB.Card kid = CardDB.Instance.getCardData("schlange");
- callKid(kid, posi, true);
- callKid(kid, posi, true);
- callKid(kid, posi, true);
- }
- if (secretID == "EX1_609") //snipe
- {
- //kill weakest minion of enemy
- List<Minion> temp = new List<Minion>(this.enemyMinions);
- temp.Sort((a, b) => a.Angr.CompareTo(b.Angr));//take the weakest
- if (temp.Count == 0) continue;
- Minion m = temp[0];
- minionGetDamagedOrHealed(m, 4, 0, false);
- }
- if (secretID == "EX1_610") //explosive trap
- {
- //take 2 damage to each enemy
- List<Minion> temp = new List<Minion>(this.enemyMinions);
- foreach (Minion m in temp)
- {
- minionGetDamagedOrHealed(m, 2, 0, false);
- }
- attackEnemyHeroWithoutKill(2);
- }
- if (secretID == "EX1_611") //freezing trap
- {
- //return weakest enemy minion to hand
- List<Minion> temp = new List<Minion>(this.enemyMinions);
- temp.Sort((a, b) => a.Angr.CompareTo(b.Angr));//take the weakest
- if (temp.Count == 0) continue;
- Minion m = temp[0];
- minionReturnToHand(m, false);
- }
- if (secretID == "EX1_533") // missdirection
- {
- // first damage to your hero is nulled -> lower guessingHeroDamage
- List<Minion> temp = new List<Minion>(this.enemyMinions);
- temp.Sort((a, b) => a.Angr.CompareTo(b.Angr));//take the weakest
- if (temp.Count == 0) continue;
- Minion m = temp[0];
- this.guessingHeroDamage = Math.Max(0, this.guessingHeroDamage -= Math.Max(m.Angr,1));
- this.ownHeroDefence += this.enemyMinions.Count;// the more the enemy minions has on board, the more the posibility to destroy something other :D
- }
- //mage secrets############
- if (secretID == "EX1_287") //counterspell
- {
- // what should we do?
- this.ownHeroDefence += 5;
- }
- if (secretID == "EX1_289") //ice barrier
- {
- this.ownHeroDefence += 8;
- }
- if (secretID == "EX1_295") //ice barrier
- {
- //set the guessed Damage to zero
- this.guessingHeroDamage = 0;
- }
- if (secretID == "EX1_294") //mirror entity
- {
- //summon snake ( a weak minion)
- int posi = this.ownMinions.Count - 1;
- CardDB.Card kid = CardDB.Instance.getCardData("schlange");
- callKid(kid, posi, true);
- }
- if (secretID == "tt_010") //spellbender
- {
- //whut???
- // add 2 to your defence (most attack-buffs give +2, lots of damage spells too)
- this.ownHeroDefence += 2;
- }
- if (secretID == "EX1_594") // vaporize
- {
- // first damage to your hero is nulled -> lower guessingHeroDamage and destroy weakest minion
- List<Minion> temp = new List<Minion>(this.enemyMinions);
- temp.Sort((a, b) => a.Angr.CompareTo(b.Angr));//take the weakest
- if (temp.Count == 0) continue;
- Minion m = temp[0];
- this.guessingHeroDamage = Math.Max(0, this.guessingHeroDamage -= Math.Max(m.Angr, 1));
- minionGetDestroyed(m, false);
- }
- //pala secrets############
- if (secretID == "EX1_132") // eye for an eye
- {
- // enemy takes one damage
- attackEnemyHeroWithoutKill(1);
- }
- if (secretID == "EX1_130") // noble sacrifice
- {
- //lower guessed hero damage
- List<Minion> temp = new List<Minion>(this.enemyMinions);
- temp.Sort((a, b) => a.Angr.CompareTo(b.Angr));//take the weakest
- if (temp.Count == 0) continue;
- Minion m = temp[0];
- this.guessingHeroDamage = Math.Max(0, this.guessingHeroDamage -= Math.Max(m.Angr, 1));
- }
- if (secretID == "EX1_136") // redemption
- {
- // we give our weakest minion a divine shield :D
- List<Minion> temp = new List<Minion>(this.ownMinions);
- temp.Sort((a, b) => a.Hp.CompareTo(b.Hp));//take the weakest
- if (temp.Count == 0) continue;
- foreach (Minion m in temp)
- {
- if (m.divineshild) continue;
- m.divineshild = true;
- break;
- }
- }
- if (secretID == "EX1_379") // repentance
- {
- // set his current lowest hp minion to x/1
- List<Minion> temp = new List<Minion>(this.enemyMinions);
- temp.Sort((a, b) => a.Hp.CompareTo(b.Hp));//take the weakest
- if (temp.Count == 0) continue;
- Minion m = temp[0];
- m.Hp = 1;
- m.maxHp = 1;
- }
- }
-
- }
- private void endTurnBuffs(bool own)
- {
- List<Minion> temp = new List<Minion>();
- if (own)
- {
- temp.AddRange(this.ownMinions);
- }
- else
- {
- temp.AddRange(this.enemyMinions);
- }
- // end buffs
- foreach (Minion m in temp)
- {
- m.cantLowerHPbelowONE = false;
- m.immune = false;
- List<Enchantment> tempench = new List<Enchantment>(m.enchantments);
- foreach (Enchantment e in tempench)
- {
- if (e.CARDID == "EX1_316e")//ueberwaeltigende macht
- {
- minionGetDestroyed(m, own);
- }
- if (e.CARDID == "CS2_046e")//kampfrausch
- {
- debuff(m, e);
- }
- if (e.CARDID == "CS2_045e")// waffe felsbeiser
- {
- debuff(m, e);
- }
- if (e.CARDID == "EX1_046e")// dunkeleisenzwerg
- {
- debuff(m, e);
- }
- if (e.CARDID == "CS2_188o")// ruchloserunteroffizier
- {
- debuff(m, e);
- }
- if (e.CARDID == "EX1_055o")// manasuechtige
- {
- debuff(m, e);
- }
- if (e.CARDID == "EX1_549o")//zorn des wildtiers
- {
- debuff(m, e);
- }
- if (e.CARDID == "EX1_334e")// dunkler wahnsin (control minion till end of turn)
- {
- //"uncontrol minion"
- minionGetControlled(m, false, true);
- }
- }
- }
- }
- private void endTurnEffect(bool own)
- {
- List<Minion> temp = new List<Minion>();
- List<Minion> ownmins = new List<Minion>();
- List<Minion> enemymins = new List<Minion>();
- if (own)
- {
- temp.AddRange(this.ownMinions);
- ownmins.AddRange(this.ownMinions);
- enemymins.AddRange(this.enemyMinions);
- }
- else
- {
- temp.AddRange(this.enemyMinions);
- ownmins.AddRange(this.enemyMinions);
- enemymins.AddRange(this.ownMinions);
- }
-
- foreach (Minion m in temp)
- {
- if (m.silenced) continue;
- if (m.name == "barongeddon") // all other chards get dmg get 2 dmg
- {
- List<Minion> temp2 = new List<Minion>(this.ownMinions);
- foreach (Minion mm in temp2)
- {
- if (mm.entitiyID != m.entitiyID)
- {
- minionGetDamagedOrHealed(mm, 2, 0, true);
- }
- }
- temp2.Clear();
- temp2.AddRange(this.enemyMinions);
- foreach (Minion mm in temp2)
- {
- if (mm.entitiyID != m.entitiyID)
- {
- minionGetDamagedOrHealed(mm, 2, 0, false);
- }
- }
- attackOrHealHero(2, true);
- attackOrHealHero(2, false);
- }
- if (m.name == "blutwichtel" || m.name == "jungepriesterin") // buff a minion
- {
- List<Minion> temp2 = new List<Minion>(ownmins);
- temp2.Sort((a, b) => a.Hp.CompareTo(b.Hp));//buff the weakest
- foreach (Minion mins in Helpfunctions.TakeList(temp2, 1))
- {
- minionGetBuffed(mins, 0, 1, own);
- }
- }
- if (m.name == "meisterschwertschmied") // buff a minion
- {
- List<Minion> temp2 = new List<Minion>(ownmins);
- temp2.Sort((a, b) => a.Angr.CompareTo(b.Angr));//buff the weakest
- foreach (Minion mins in Helpfunctions.TakeList(temp2, 1))
- {
- minionGetBuffed(mins, 1, 0, own);
- }
- }
- if (m.name == "kraftverstaerker3000") // buff a minion
- {
- List<Minion> temp2 = new List<Minion>(this.enemyMinions);
- temp2.Sort((a, b) => -a.Angr.CompareTo(b.Angr));//buff the strongest enemy
- foreach (Minion mins in Helpfunctions.TakeList(temp2, 1))
- {
- minionGetBuffed(mins, 1, 0, false);//buff alyways enemy :D
- }
- }
- if (m.name == "gruul") // gain +1/+1
- {
- minionGetBuffed(m, 1, 1, own);
- }
- if (m.name == "astralerarkanist") // gain +2/+2
- {
- if (own && this.ownSecretsIDList.Count>=1)
- {
- minionGetBuffed(m, 2, 2, own);
- }
- if (!own && this.enemySecretCount >= 1)
- {
- minionGetBuffed(m, 2, 2, own);
- }
- }
-
- if (m.name == "manafluttotem") // draw card
- {
- if (own)
- {
- this.owncarddraw++;
- this.drawACard("");
- }
- else
- {
- this.enemycarddraw++;
- }
- }
- if (m.name == "heiltotem") // heal
- {
- List<Minion> temp2 = new List<Minion>(ownmins);
- foreach (Minion mins in temp2)
- {
- minionGetDamagedOrHealed(mins, 0, 1, own);
- }
- }
- if (m.name == "hogger") // summon
- {
- int posi = m.id;
- CardDB.Card kid = CardDB.Instance.getCardData("gnoll");
- callKid(kid, posi, own);
- }
- if (m.name == "wichtelmeisterin") // damage itself and summon
- {
- int posi = m.id;
- if (m.Hp == 1) posi--;
- minionGetDamagedOrHealed(m, 1, 0, own);
- CardDB.Card kid = CardDB.Instance.getCardData("wichtel");
- callKid(kid, posi, own);
- }
- if (m.name == "natpagle") // draw card
- {
- if (own)
- {
- this.owncarddraw++;
- this.drawACard("");
- }
- else
- {
- this.enemycarddraw++;
- }
- }
- if (m.name == "ragnarosderfeuerfuerst") // summon
- {
- if (this.enemyMinions.Count >= 1)
- {
- List<Minion> temp2 = new List<Minion>(enemymins);
- temp2.Sort((a, b) => -a.Hp.CompareTo(b.Hp));//damage the stronges
- foreach (Minion mins in Helpfunctions.TakeList(temp2, 1))
- {
- minionGetDamagedOrHealed(mins, 8, 0, !own);
- }
- }
- else
- {
- attackOrHealHero(8, !own);
- }
- }
- if (m.name == "reparaturbot") // heal damaged char
- {
- attackOrHealHero(-6, false);
- }
- if (m.card.CardID == "EX1_tk9") //treant which is destroyed
- {
- minionGetDestroyed(m, own);
- }
- if (m.name == "ysera") // draw card
- {
- if (own)
- {
- this.owncarddraw++;
- this.drawACard("yseraerwacht");
- }
- else
- {
- this.enemycarddraw++;
- }
- }
- }
- }
- private void startTurnEffect(bool own)
- {
- List<Minion> temp = new List<Minion>();
- List<Minion> ownmins = new List<Minion>();
- List<Minion> enemymins = new List<Minion>();
- if (own)
- {
- temp.AddRange(this.ownMinions);
- ownmins.AddRange(this.ownMinions);
- enemymins.AddRange(this.enemyMinions);
- }
- else
- {
- temp.AddRange(this.enemyMinions);
- ownmins.AddRange(this.enemyMinions);
- enemymins.AddRange(this.ownMinions);
- }
- bool untergang=false;
- foreach (Minion m in temp)
- {
- if (m.silenced) continue;
- if (m.name == "verwuester") // deal 2 dmg
- {
- List<Minion> temp2 = new List<Minion>(enemymins);
- foreach (Minion mins in temp2)
- {
- minionGetDamagedOrHealed(mins, 2, 0, !own);
- }
- }
- if (m.name == "untergangsverkuender") // destroy
- {
- untergang = true;
- }
- if (m.name == "zielsuchendeshuhn") // ok
- {
- minionGetDestroyed(m, own);
- if (own)
- {
- this.owncarddraw += 3;
- this.drawACard("");
- this.drawACard("");
- this.drawACard("");
- …
Large files files are truncated, but you can click here to view the full file