private void getHandcards() { handCards.Clear(); this.anzcards = 0; this.enemyAnzCards = 0; List <HRCard> list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND); list.AddRange(HRCard.GetCards(HRPlayer.GetEnemyPlayer(), HRCardZone.HAND)); foreach (HRCard item in list) { HREntity entitiy = item.GetEntity(); if (entitiy.GetControllerId() == this.ownPlayerController && entitiy.GetZonePosition() >= 1) // own handcard { CardDB.Card c = CardDB.Instance.getCardDataFromID(entitiy.GetCardId()); //c.cost = entitiy.GetCost(); //c.entityID = entitiy.GetEntityId(); Handmanager.Handcard hc = new Handmanager.Handcard(); hc.card = c; hc.position = entitiy.GetZonePosition(); hc.entity = entitiy.GetEntityId(); hc.manacost = entitiy.GetCost(); handCards.Add(hc); this.anzcards++; } if (entitiy.GetControllerId() != this.ownPlayerController && entitiy.GetZonePosition() >= 1) // enemy handcard { this.enemyAnzCards++; } } }
public void updateEverything(BotBase botbase) { HRPlayer ownPlayer = HRPlayer.GetLocalPlayer(); HRPlayer enemyPlayer = HRPlayer.GetEnemyPlayer(); ownPlayerController = ownPlayer.GetHero().GetControllerId(); //ownPlayer.GetHero().GetControllerId() // create hero + minion data getHerostuff(); getMinions(); getHandcards(); // send ai the data: Hrtprozis.Instance.setOwnPlayer(ownPlayerController); Handmanager.Instance.setOwnPlayer(ownPlayerController); Hrtprozis.Instance.updatePlayer(this.ownMaxMana, this.currentMana, this.cardsPlayedThisTurn, this.numMinionsPlayedThisTurn, this.ueberladung, ownPlayer.GetHero().GetEntityId(), enemyPlayer.GetHero().GetEntityId()); Hrtprozis.Instance.updateOwnHero(this.ownHeroWeapon, this.heroWeaponAttack, this.heroWeaponDurability, this.heroImmuneToDamageWhileAttacking, this.heroAtk, this.heroHp, this.heroDefence, this.heroname, this.ownheroisread, this.ownheroAlreadyAttacked, this.herofrozen, this.heroAbility, this.ownAbilityisReady); Hrtprozis.Instance.updateEnemyHero(this.enemyHeroWeapon, this.enemyWeaponAttack, this.enemyWeaponDurability, this.enemyAtk, this.enemyHp, this.enemyDefence, this.enemyHeroname, this.enemyfrozen); Hrtprozis.Instance.updateMinions(this.ownMinions, this.enemyMinions); Handmanager.Instance.setHandcards(this.handCards, this.anzcards, this.enemyAnzCards); // print data Hrtprozis.Instance.printHero(); Hrtprozis.Instance.printOwnMinions(); Hrtprozis.Instance.printEnemyMinions(); Handmanager.Instance.printcards(); // calculate stuff HRLog.Write("calculating stuff..."); Ai.Instance.dosomethingclever(botbase); }
private List <HREntity> getallEntitys() { List <HREntity> result = new List <HREntity>(); HREntity ownhero = HRPlayer.GetLocalPlayer().GetHero(); HREntity enemyhero = HRPlayer.GetEnemyPlayer().GetHero(); HREntity ownHeroAbility = HRPlayer.GetLocalPlayer().GetHeroPower(); List <HRCard> list2 = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.PLAY); List <HRCard> list3 = HRCard.GetCards(HRPlayer.GetEnemyPlayer(), HRCardZone.PLAY); result.Add(ownhero); result.Add(enemyhero); result.Add(ownHeroAbility); foreach (HRCard item in list2) { result.Add(item.GetEntity()); } foreach (HRCard item in list3) { result.Add(item.GetEntity()); } return(result); }
private bool autoconcede() { if (HREngine.API.Utilities.HRSettings.Get.SelectedGameMode == HRGameMode.ARENA) { return(false); } if (HREngine.API.Utilities.HRSettings.Get.SelectedGameMode != HRGameMode.RANKED_PLAY) { return(false); } int totalwin = this.wins; int totallose = this.loses; /*if ((totalwin + totallose - KeepConcede) != 0) * { * Helpfunctions.Instance.ErrorLog("#info: win:" + totalwin + " concede:" + KeepConcede + " lose:" + (totallose - KeepConcede) + " real winrate:" + (totalwin * 100 / (totalwin + totallose - KeepConcede))); * }*/ int curlvl = HRPlayer.GetLocalPlayer().GetRank(); if (curlvl > this.concedeLvl) { this.lossedtodo = 0; return(false); } if (this.oldwin != totalwin) { this.oldwin = totalwin; if (this.lossedtodo > 0) { this.lossedtodo--; } Helpfunctions.Instance.ErrorLog("not today!! (you won a game)"); this.isgoingtoconcede = true; return(true); } if (this.lossedtodo > 0) { this.lossedtodo--; Helpfunctions.Instance.ErrorLog("not today!"); this.isgoingtoconcede = true; return(true); } if (curlvl < this.concedeLvl) { this.lossedtodo = 3; Helpfunctions.Instance.ErrorLog("your rank is " + curlvl + " targeted rank is " + this.concedeLvl + " -> concede!"); Helpfunctions.Instance.ErrorLog("not today!!!"); this.isgoingtoconcede = true; return(true); } return(false); }
protected virtual ActionBase PlayCardsToField() { // Get all available cards... List <HRCard> availableCards = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND); if (availableCards.Count > 0) { HRCard coin = null; foreach (var item in availableCards) { #region Skip The Coin string cardID = item.GetEntity().GetCardId(); if (cardID == "GAME_005" || cardID == "GAME_005e") { coin = item; continue; } #endregion if (item.GetEntity().GetCost() <= HRPlayer.GetLocalPlayer().GetNumAvailableResources()) { if (HRBattle.CanUseCard(item.GetEntity()) && HRCardManager.IsCardAllowedByRule(item)) { return(new PlayCardAction(item)); } } } #region The Coin Feature // Feature: The Coin // https://github.com/juce-mmocrawlerbots/HREngine/issues/13 if (coin != null) { foreach (var card in availableCards) { if (card.GetEntity().GetCardId() != coin.GetEntity().GetCardId()) { if (card.GetEntity().IsMinion() || card.GetEntity().IsSpell() || (!HRPlayer.GetLocalPlayer().HasWeapon() && card.GetEntity().IsWeapon())) { if (card.GetEntity().GetCost() <= (HRPlayer.GetLocalPlayer().GetNumAvailableResources() + 1)) { HRLog.Write( String.Format("Spawn [{0}] and then [{1}]", coin.GetEntity().GetName(), card.GetEntity().GetName())); NextFixedAction = new PlayCardAction(card); return(new PlayCardAction(coin)); } } } } } #endregion } return(null); }
private List <HREntity> GetFriendEntitiesOnBoard() { List <HREntity> ret = new List <HREntity>(); foreach (HRCard c in HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.PLAY)) { ret.Add(c.GetEntity()); } return(ret); }
private void printstuff() { HRPlayer ownPlayer = HRPlayer.GetLocalPlayer(); Helpfunctions.Instance.logg("#######################################################################"); Helpfunctions.Instance.logg("#######################################################################"); Helpfunctions.Instance.logg("start calculations, current time: " + DateTime.Now.ToString("HH:mm:ss") + " V" + this.versionnumber + " " + this.botbehave); Helpfunctions.Instance.logg("#######################################################################"); Helpfunctions.Instance.logg("mana " + currentMana + "/" + ownMaxMana); Helpfunctions.Instance.logg("emana " + enemyMaxMana); Helpfunctions.Instance.logg("own secretsCount: " + ownPlayer.GetSecretDefinitions().Count); Helpfunctions.Instance.logg("enemy secretsCount: " + enemySecretCount); }
private List <HRCard> GetPlayableCards(List <HRCard> list) { int manaLeft = HRPlayer.GetLocalPlayer().GetNumAvailableResources(); List <HRCard> result = new List <HRCard>(); foreach (var item in list) { if (item.GetEntity().GetCost() <= manaLeft && HRBattle.CanUseCard(item.GetEntity())) { result.Add(item); } } return(result); }
protected HREngine.API.Actions.ActionBase UpdateMulliganState() { if (HRMulligan.IsMulliganActive()) { var list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND); foreach (var item in list) { if (!RejectedCardList.ContainsKey(item.GetEntity().GetEntityId()) && item.GetEntity().GetCost() >= 4) { RejectedCardList.Add(item.GetEntity().GetEntityId(), item); return(new RejectCardsAction(item)); } } } return(null); }
private void printstuff(bool runEx) { HRPlayer ownPlayer = HRPlayer.GetLocalPlayer(); int ownsecretcount = ownPlayer.GetSecretDefinitions().Count; string dtimes = DateTime.Now.ToString("HH:mm:ss:ffff"); string enemysecretIds = ""; enemysecretIds = Probabilitymaker.Instance.getEnemySecretData(); Helpfunctions.Instance.logg("#######################################################################"); Helpfunctions.Instance.logg("#######################################################################"); Helpfunctions.Instance.logg("start calculations, current time: " + DateTime.Now.ToString("HH:mm:ss") + " V" + this.versionnumber + " " + this.botbehave); Helpfunctions.Instance.logg("#######################################################################"); Helpfunctions.Instance.logg("mana " + currentMana + "/" + ownMaxMana); Helpfunctions.Instance.logg("emana " + enemyMaxMana); Helpfunctions.Instance.logg("own secretsCount: " + ownsecretcount); Helpfunctions.Instance.logg("enemy secretsCount: " + enemySecretCount + " ;" + enemysecretIds); Ai.Instance.currentCalculatedBoard = dtimes; if (runEx) { Helpfunctions.Instance.resetBuffer(); Helpfunctions.Instance.writeBufferToActionFile(); Helpfunctions.Instance.resetBuffer(); Helpfunctions.Instance.writeToBuffer("#######################################################################"); Helpfunctions.Instance.writeToBuffer("#######################################################################"); Helpfunctions.Instance.writeToBuffer("start calculations, current time: " + dtimes + " V" + this.versionnumber + " " + this.botbehave); Helpfunctions.Instance.writeToBuffer("#######################################################################"); Helpfunctions.Instance.writeToBuffer("mana " + currentMana + "/" + ownMaxMana); Helpfunctions.Instance.writeToBuffer("emana " + enemyMaxMana); Helpfunctions.Instance.writeToBuffer("own secretsCount: " + ownsecretcount); Helpfunctions.Instance.writeToBuffer("enemy secretsCount: " + enemySecretCount + " ;" + enemysecretIds); } Hrtprozis.Instance.printHero(runEx); Hrtprozis.Instance.printOwnMinions(runEx); Hrtprozis.Instance.printEnemyMinions(runEx); Handmanager.Instance.printcards(runEx); Probabilitymaker.Instance.printTurnGraveYard(runEx); Probabilitymaker.Instance.printGraveyards(runEx); if (runEx) { Helpfunctions.Instance.writeBufferToFile(); } }
protected virtual ActionBase Attack() { HREntity target = GetNextAttackToAttack(); if (target != null) { var current = PlayerState.GetPossibleAttack( HRPlayer.GetLocalPlayer(), target.GetRemainingHP() + target.GetArmor()); if (current.Cards.Count > 0) { return(new AttackAction(current.Cards[0], target)); } } return(null); }
private void getHandcards() { handCards.Clear(); this.anzcards = 0; this.enemyAnzCards = 0; List <HRCard> list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND); foreach (HRCard item in list) { HREntity entitiy = item.GetEntity(); if (entitiy.GetControllerId() == this.ownPlayerController && entitiy.GetZonePosition() >= 1) // own handcard { CardDB.Card c = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(entitiy.GetCardId())); //c.cost = entitiy.GetCost(); //c.entityID = entitiy.GetEntityId(); Handmanager.Handcard hc = new Handmanager.Handcard(); hc.card = c; hc.position = entitiy.GetZonePosition(); hc.entity = entitiy.GetEntityId(); hc.manacost = entitiy.GetCost(); hc.addattack = 0; if (c.name == CardDB.cardName.bolvarfordragon) { hc.addattack = entitiy.GetATK() - 1; // -1 because it starts with 1, we count only the additional attackvalue } handCards.Add(hc); this.anzcards++; } //maybe check if it has BRM_028e on it? } Dictionary <int, HREntity> allEntitys = HRGame.GetEntityMap(); foreach (HREntity ent in allEntitys.Values) { if (ent.GetControllerId() != this.ownPlayerController && ent.GetZonePosition() >= 1 && ent.GetZone() == HRCardZone.HAND) // enemy handcard { this.enemyAnzCards++; } } }
private HREngine.API.Actions.ActionBase HandleBattleMulliganPhase() { SmartCc = new Simulation(); SmartCc.CreateLogFolder(); SmartCc.TurnCount = 0; if (HRMulligan.IsMulliganActive()) { List <HRCard> Choices = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND); List <Card> ParsedChoices = new List <Card>(); foreach (HRCard card in Choices) { HREntity entity = card.GetEntity(); Card c = Card.Create(entity.GetCardId(), true, entity.GetEntityId()); c.CurrentCost = entity.GetCost(); ParsedChoices.Add(c); } List <HRCard> CardsToKeep = new List <HRCard>(); foreach (Card c in ProfileInterface.Behavior.HandleMulligan(ParsedChoices)) { foreach (HRCard card in Choices) { if (c.Id == card.GetEntity().GetEntityId()) { CardsToKeep.Add(card); } } } foreach (HRCard card in Choices) { if (!CardsToKeep.Contains(card)) { HRMulligan.ToggleCard(card); } } return(null); } return(null); }
protected virtual ActionBase AttackTauntMinions(PlayerState EnemyState) { // TODO: Sort list by ATK, descending. if (EnemyState.TauntMinions.Count == 0) { return(null); } foreach (var item in EnemyState.TauntMinions) { if (!item.IsStealthed()) { var power = PlayerState.GetPossibleAttack( HRPlayer.GetLocalPlayer(), item.GetRemainingHP()); if (power.Attack >= item.GetRemainingHP()) { if (power.Cards.Count > 0) { return(new AttackAction(power.Cards[0], item)); } } } } // There are enemy Taunts but we cannot kill at least one // of them. :/ // // Just attack it... var nextTaunt = EnemyState.TauntMinions[0]; // No taunts found that can be killed, attack first one. var current = PlayerState.GetPossibleAttack( HRPlayer.GetLocalPlayer(), nextTaunt.GetRemainingHP()); if (current.Cards.Count > 0) { return(new AttackAction(current.Cards[0], nextTaunt)); } return(null); }
private HREngine.API.Actions.ActionBase HandleBattleMulliganPhase() { HRLog.Write("handle mulligan"); if (HRMulligan.IsMulliganActive()) { var list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND); foreach (var item in list) { if (item.GetEntity().GetCost() >= 4) { HRLog.Write("Rejecting Mulligan Card " + item.GetEntity().GetName() + " because it cost is >= 4."); HRMulligan.ToggleCard(item); } } return(null); //HRMulligan.EndMulligan(); } return(null); }
private void getDecks() { Dictionary <int, HREntity> allEntitys = HRGame.GetEntityMap(); int owncontroler = HRPlayer.GetLocalPlayer().GetControllerId(); int enemycontroler = HRPlayer.GetEnemyPlayer().GetControllerId(); List <CardDB.cardIDEnum> ownCards = new List <CardDB.cardIDEnum>(); List <CardDB.cardIDEnum> enemyCards = new List <CardDB.cardIDEnum>(); foreach (HREntity ent in allEntitys.Values) { if (ent.GetZone() == HRCardZone.SECRET && ent.GetControllerId() == enemycontroler) { continue; // cant know enemy secrets :D } if (ent.GetCardType() == HRCardType.MINION || ent.GetCardType() == HRCardType.WEAPON || ent.GetCardType() == HRCardType.ABILITY) { CardDB.cardIDEnum cardid = CardDB.Instance.cardIdstringToEnum(ent.GetCardId()); //string owner = "own"; //if (ent.GetControllerId() == enemycontroler) owner = "enemy"; //if (ent.GetControllerId() == enemycontroler && ent.GetZone() == HRCardZone.HAND) Helpfunctions.Instance.logg("enemy card in hand: " + "cardindeck: " + cardid + " " + ent.GetName()); //if (cardid != CardDB.cardIDEnum.None) Helpfunctions.Instance.logg("cardindeck: " + cardid + " " + ent.GetName() + " " + ent.GetZone() + " " + owner + " " + ent.GetCardType()); if (cardid != CardDB.cardIDEnum.None) { if (ent.GetControllerId() == owncontroler) { ownCards.Add(cardid); } else { enemyCards.Add(cardid); } } } } Probabilitymaker.Instance.setOwnCards(ownCards); Probabilitymaker.Instance.setEnemyCards(enemyCards); }
protected override HRCard GetMinionByPriority(HRCard lastMinion) { HREntity result = null; if (HRPlayer.GetLocalPlayer().GetNumEnemyMinionsInPlay() < HRPlayer.GetLocalPlayer().GetNumFriendlyMinionsInPlay() || HRPlayer.GetLocalPlayer().GetNumEnemyMinionsInPlay() < 4) { result = HRBattle.GetNextMinionByPriority(MinionPriority.Hero); } else { result = HRBattle.GetNextMinionByPriority(MinionPriority.LowestHealth); } if (result != null && (lastMinion == null || lastMinion != null && lastMinion.GetEntity().GetCardId() != result.GetCardId())) { return(result.GetCard()); } return(null); }
protected virtual HREntity GetNextAttackToAttack() { HREntity result = null; if (HRPlayer.GetLocalPlayer().GetNumEnemyMinionsInPlay() < HRPlayer.GetLocalPlayer().GetNumFriendlyMinionsInPlay() || HRPlayer.GetLocalPlayer().GetNumEnemyMinionsInPlay() < 4) { result = HRBattle.GetNextMinionByPriority(MinionPriority.Hero); } else { result = HRBattle.GetNextMinionByPriority(MinionPriority.LowestHealth); } if (result == null) { return(HRPlayer.GetEnemyPlayer().GetHero()); } return(result); }
private HREngine.API.Actions.ActionBase UpdateBattleState() { HREngine.API.Actions.ActionBase result = NextFixedAction; if (result != null) { NextFixedAction = null; return(result); } HRPlayer ownPlayer = HRPlayer.GetLocalPlayer(); HRPlayer enemyPlayer = HRPlayer.GetEnemyPlayer(); ownPlayerController = ownPlayer.GetControllerId();//ownPlayer.GetHero().GetControllerId() // create hero + minion data getHerostuff(); getMinions(); getHandcards(); // send ai the data: Hrtprozis.Instance.setOwnPlayer(ownPlayerController); Handmanager.Instance.setOwnPlayer(ownPlayerController); Hrtprozis.Instance.updateOwnHero(this.ownHeroWeapon, this.heroWeaponAttack, this.heroWeaponDurability, this.heroImmuneToDamageWhileAttacking, this.heroAtk, this.heroHp, this.heroDefence, this.heroname, this.ownheroisread, this.ownheroAlreadyAttacked, this.herofrozen, this.heroAbility, this.ownAbilityisReady); Hrtprozis.Instance.updateEnemyHero(this.enemyHeroWeapon, this.enemyWeaponAttack, this.enemyWeaponDurability, this.enemyAtk, this.enemyHp, this.enemyDefence, this.enemyHeroname, this.enemyfrozen); Hrtprozis.Instance.updateMinions(this.ownMinions, this.enemyMinions); Handmanager.Instance.setHandcards(this.handCards, this.anzcards, this.enemyAnzCards); // print data Hrtprozis.Instance.printHero(); Hrtprozis.Instance.printOwnMinions(); Hrtprozis.Instance.printEnemyMinions(); Handmanager.Instance.printcards(); // Next cards to push... //result = PlayCardsToField(); return(null); }
private void getHandcards() { handCards.Clear(); this.anzcards = 0; this.enemyAnzCards = 0; List <HRCard> list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND); foreach (HRCard item in list) { HREntity entitiy = item.GetEntity(); if (entitiy.GetControllerId() == this.ownPlayerController && entitiy.GetZonePosition() >= 1) // own handcard { CardDB.Card c = CardDB.Instance.getCardDataFromID(CardDB.Instance.cardIdstringToEnum(entitiy.GetCardId())); //c.cost = entitiy.GetCost(); //c.entityID = entitiy.GetEntityId(); Handmanager.Handcard hc = new Handmanager.Handcard(); hc.card = c; hc.position = entitiy.GetZonePosition(); hc.entity = entitiy.GetEntityId(); hc.manacost = entitiy.GetCost(); handCards.Add(hc); this.anzcards++; } } Dictionary <int, HREntity> allEntitys = HRGame.GetEntityMap(); foreach (HREntity ent in allEntitys.Values) { if (ent.GetControllerId() != this.ownPlayerController && ent.GetZonePosition() >= 1 && ent.GetZone() == HRCardZone.HAND) // enemy handcard { this.enemyAnzCards++; } } }
private void getHerostuff() { HRPlayer ownPlayer = HRPlayer.GetLocalPlayer(); HRPlayer enemyPlayer = HRPlayer.GetEnemyPlayer(); HREntity ownhero = ownPlayer.GetHero(); HREntity enemyhero = enemyPlayer.GetHero(); HREntity ownHeroAbility = ownPlayer.GetHeroPower(); //player stuff######################### //this.currentMana =ownPlayer.GetTag(HRGameTag.RESOURCES) - ownPlayer.GetTag(HRGameTag.RESOURCES_USED) + ownPlayer.GetTag(HRGameTag.TEMP_RESOURCES); this.currentMana = ownPlayer.GetNumAvailableResources(); this.ownMaxMana = ownPlayer.GetTag(HRGameTag.RESOURCES);//ownPlayer.GetRealTimeTempMana(); Helpfunctions.Instance.logg("#######################################################################"); Helpfunctions.Instance.logg("#######################################################################"); Helpfunctions.Instance.logg("start calculations, current time: " + DateTime.Now.ToString("HH:mm:ss")); Helpfunctions.Instance.logg("#######################################################################"); Helpfunctions.Instance.logg("mana " + currentMana + "/" + ownMaxMana); Helpfunctions.Instance.logg("own secretsCount: " + ownPlayer.GetSecretDefinitions().Count); enemySecretCount = HRCard.GetCards(enemyPlayer, HRCardZone.SECRET).Count; enemySecretCount = 0; Helpfunctions.Instance.logg("enemy secretsCount: " + enemySecretCount); this.ownSecretList = ownPlayer.GetSecretDefinitions(); this.numMinionsPlayedThisTurn = ownPlayer.GetTag(HRGameTag.NUM_MINIONS_PLAYED_THIS_TURN); this.cardsPlayedThisTurn = ownPlayer.GetTag(HRGameTag.NUM_CARDS_PLAYED_THIS_TURN); //if (ownPlayer.HasCombo()) this.cardsPlayedThisTurn = 1; this.ueberladung = ownPlayer.GetTag(HRGameTag.RECALL_OWED); //get weapon stuff this.ownHeroWeapon = ""; this.heroWeaponAttack = 0; this.heroWeaponDurability = 0; this.ownHeroFatigue = ownhero.GetFatigue(); this.enemyHeroFatigue = enemyhero.GetFatigue(); //this.ownDecksize = HRCard.GetCards(ownPlayer, HRCardZone.DECK).Count; //this.enemyDecksize = HRCard.GetCards(enemyPlayer, HRCardZone.DECK).Count; this.enemyHeroWeapon = ""; this.enemyWeaponAttack = 0; this.enemyWeaponDurability = 0; if (enemyPlayer.HasWeapon()) { HREntity weapon = enemyPlayer.GetWeaponCard().GetEntity(); this.enemyHeroWeapon = CardDB.Instance.getCardDataFromID(weapon.GetCardId()).name; this.enemyWeaponAttack = weapon.GetATK(); this.enemyWeaponDurability = weapon.GetDurability(); } //own hero stuff########################### this.heroAtk = ownhero.GetATK(); this.heroHp = ownhero.GetHealth() - ownhero.GetDamage(); this.heroDefence = ownhero.GetArmor(); this.heroname = Hrtprozis.Instance.heroIDtoName(ownhero.GetCardId()); bool exausted = false; exausted = ownhero.IsExhausted(); this.ownheroisread = true; this.heroImmuneToDamageWhileAttacking = (ownhero.IsImmune()) ? true : false; this.herofrozen = ownhero.IsFrozen(); this.heroNumAttacksThisTurn = ownhero.GetNumAttacksThisTurn(); this.heroHasWindfury = ownhero.HasWindfury(); //int numberofattacks = ownhero.GetNumAttacksThisTurn(); //HRLog.Write(ownhero.GetName() + " ready params ex: " + exausted + " " + heroAtk + " " + numberofattacks + " " + herofrozen); if (exausted == true) { this.ownheroisread = false; } if (exausted == false && this.heroAtk == 0) { this.ownheroisread = false; } if (herofrozen) { ownheroisread = false; } if (ownPlayer.HasWeapon()) { HREntity weapon = ownPlayer.GetWeaponCard().GetEntity(); this.ownHeroWeapon = CardDB.Instance.getCardDataFromID(weapon.GetCardId()).name; this.heroWeaponAttack = weapon.GetATK(); this.heroWeaponDurability = weapon.GetTag(HRGameTag.DURABILITY) - weapon.GetTag(HRGameTag.DAMAGE);//weapon.GetDurability(); this.heroImmuneToDamageWhileAttacking = false; if (this.ownHeroWeapon == "gladiatorslongbow") { this.heroImmuneToDamageWhileAttacking = true; } //HRLog.Write("weapon: " + ownHeroWeapon + " " + heroWeaponAttack + " " + heroWeaponDurability); } //enemy hero stuff############################################################### this.enemyAtk = enemyhero.GetATK(); this.enemyHp = enemyhero.GetHealth() - enemyhero.GetDamage(); this.enemyHeroname = Hrtprozis.Instance.heroIDtoName(enemyhero.GetCardId()); this.enemyDefence = enemyhero.GetArmor(); this.enemyfrozen = enemyhero.IsFrozen(); //own hero ablity stuff########################################################### this.heroAbility = CardDB.Instance.getCardDataFromID(ownHeroAbility.GetCardId()); this.ownAbilityisReady = (ownHeroAbility.IsExhausted()) ? false : true; // if exhausted, ability is NOT ready }
private HREngine.API.Actions.ActionBase HandleBattleMulliganPhase() { if (Settings.Instance.learnmode) { return(new HREngine.API.Actions.MakeNothingAction()); } //Helpfunctions.Instance.ErrorLog("handle mulligan"); if (HRMulligan.IsMulliganActive()) { var list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND); HRPlayer enemyPlayer = HRPlayer.GetEnemyPlayer(); HRPlayer ownPlayer = HRPlayer.GetLocalPlayer(); string enemName = Hrtprozis.Instance.heroIDtoName(enemyPlayer.GetHeroCard().GetEntity().GetCardId()); string ownName = Hrtprozis.Instance.heroIDtoName(ownPlayer.GetHeroCard().GetEntity().GetCardId()); if (Mulligan.Instance.hasmulliganrules(ownName, enemName)) { List <Mulligan.CardIDEntity> celist = new List <Mulligan.CardIDEntity>(); foreach (var item in list) { if (item.GetEntity().GetCardId() != "GAME_005")// dont mulligan coin { celist.Add(new Mulligan.CardIDEntity(item.GetEntity().GetCardId(), item.GetEntity().GetEntityId())); } } List <int> mullientitys = Mulligan.Instance.whatShouldIMulligan(celist, ownName, enemName); foreach (var item in list) { if (mullientitys.Contains(item.GetEntity().GetEntityId())) { Helpfunctions.Instance.ErrorLog("Rejecting Mulligan Card " + item.GetEntity().GetName() + " because of your rules"); HRMulligan.ToggleCard(item); } } } else { foreach (var item in list) { if (item.GetEntity().GetCost() >= 4) { Helpfunctions.Instance.ErrorLog("Rejecting Mulligan Card " + item.GetEntity().GetName() + " because it cost is >= 4."); HRMulligan.ToggleCard(item); } if (item.GetEntity().GetCardId() == "EX1_308" || item.GetEntity().GetCardId() == "EX1_622" || item.GetEntity().GetCardId() == "EX1_005") { Helpfunctions.Instance.ErrorLog("Rejecting Mulligan Card " + item.GetEntity().GetName() + " because it is soulfire or shadow word: death"); HRMulligan.ToggleCard(item); } } } sf.setnewLoggFile(); //writeSettings(); if (Mulligan.Instance.loserLoserLoser) { if (!autoconcede()) { concedeVSenemy(ownName, enemName); } } return(null); //HRMulligan.EndMulligan(); } return(null); }
/// <summary> /// [EN] /// This handler is executed when the local player turn is active. /// /// [DE] /// Dieses Event wird ausgelöst wenn der Spieler am Zug ist. /// </summary> private HREngine.API.Actions.ActionBase HandleOnBattleStateUpdate() { try { if (this.isgoingtoconcede) { if (HREngine.API.Utilities.HRSettings.Get.SelectedGameMode == HRGameMode.ARENA) { this.isgoingtoconcede = false; } else { return(new HREngine.API.Actions.ConcedeAction()); } } if (Settings.Instance.passiveWaiting && sf.waitingForSilver) { if (!this.sf.readActionFile(true)) { return(new HREngine.API.Actions.MakeNothingAction()); } } if (Settings.Instance.learnmode && (HRBattle.IsInTargetMode() || HRChoice.IsChoiceActive())) { return(new HREngine.API.Actions.MakeNothingAction()); } if (HRBattle.IsInTargetMode() && dirtytarget >= 0) { Helpfunctions.Instance.ErrorLog("dirty targeting..."); HREntity target = getEntityWithNumber(dirtytarget); dirtytarget = -1; return(new HREngine.API.Actions.TargetAction(target)); } if (HRChoice.IsChoiceActive()) { if (this.dirtychoice >= 1) { List <HREntity> choices = HRChoice.GetChoiceCards(); int choice = this.dirtychoice; this.dirtychoice = -1; string ccId = this.choiceCardId; this.choiceCardId = ""; HREntity target = choices[choice - 1]; if (ccId == "EX1_160") { foreach (HREntity hre in choices) { if (choice == 1 && hre.GetCardId() == "EX1_160b") { target = hre; } if (choice == 2 && hre.GetCardId() == "EX1_160a") { target = hre; } } } if (ccId == "NEW1_008") { foreach (HREntity hre in choices) { if (choice == 1 && hre.GetCardId() == "NEW1_008a") { target = hre; } if (choice == 2 && hre.GetCardId() == "NEW1_008b") { target = hre; } } } if (ccId == "EX1_178") { foreach (HREntity hre in choices) { if (choice == 1 && hre.GetCardId() == "EX1_178a") { target = hre; } if (choice == 2 && hre.GetCardId() == "EX1_178b") { target = hre; } } } if (ccId == "EX1_573") { foreach (HREntity hre in choices) { if (choice == 1 && hre.GetCardId() == "EX1_573a") { target = hre; } if (choice == 2 && hre.GetCardId() == "EX1_573b") { target = hre; } } } if (ccId == "EX1_165")//druid of the claw { foreach (HREntity hre in choices) { if (choice == 1 && hre.GetCardId() == "EX1_165t1") { target = hre; } if (choice == 2 && hre.GetCardId() == "EX1_165t2") { target = hre; } } } if (ccId == "EX1_166")//keeper of the grove { foreach (HREntity hre in choices) { if (choice == 1 && hre.GetCardId() == "EX1_166a") { target = hre; } if (choice == 2 && hre.GetCardId() == "EX1_166b") { target = hre; } } } if (ccId == "EX1_155") { foreach (HREntity hre in choices) { if (choice == 1 && hre.GetCardId() == "EX1_155a") { target = hre; } if (choice == 2 && hre.GetCardId() == "EX1_155b") { target = hre; } } } if (ccId == "EX1_164") { foreach (HREntity hre in choices) { if (choice == 1 && hre.GetCardId() == "EX1_164a") { target = hre; } if (choice == 2 && hre.GetCardId() == "EX1_164b") { target = hre; } } } if (ccId == "New1_007")//starfall { foreach (HREntity hre in choices) { if (choice == 1 && hre.GetCardId() == "New1_007b") { target = hre; } if (choice == 2 && hre.GetCardId() == "New1_007a") { target = hre; } } } if (ccId == "EX1_154")//warth { foreach (HREntity hre in choices) { if (choice == 1 && hre.GetCardId() == "EX1_154a") { target = hre; } if (choice == 2 && hre.GetCardId() == "EX1_154b") { target = hre; } } } Helpfunctions.Instance.logg("chooses the card: " + target.GetCardId()); return(new HREngine.API.Actions.ChoiceAction(target)); } else { //Todo: ultimate tracking-simulation! List <HREntity> choices = HRChoice.GetChoiceCards(); Random r = new Random(); int choice = r.Next(0, choices.Count); Helpfunctions.Instance.logg("chooses a random card"); return(new HREngine.API.Actions.ChoiceAction(choices[choice])); } } bool templearn = sf.updateEverything(behave, Settings.Instance.useExternalProcess, Settings.Instance.passiveWaiting); if (templearn == true) { Settings.Instance.printlearnmode = true; } if (Settings.Instance.passiveWaiting && sf.waitingForSilver) { return(new HREngine.API.Actions.MakeNothingAction()); } if (Settings.Instance.learnmode) { if (Settings.Instance.printlearnmode) { Ai.Instance.simmulateWholeTurnandPrint(); } Settings.Instance.printlearnmode = false; return(new HREngine.API.Actions.MakeNothingAction()); } if (Ai.Instance.bestmoveValue <= -900 && Settings.Instance.enemyConcede) { return(new HREngine.API.Actions.ConcedeAction()); } Action moveTodo = Ai.Instance.bestmove; if (moveTodo == null || moveTodo.actionType == actionEnum.endturn) { Helpfunctions.Instance.ErrorLog("end turn"); return(null); } Helpfunctions.Instance.ErrorLog("play action"); moveTodo.print(); if (moveTodo.actionType == actionEnum.playcard) { HRCard cardtoplay = getCardWithNumber(moveTodo.card.entity); if (moveTodo.target != null) { HREntity target = getEntityWithNumber(moveTodo.target.entitiyID); Helpfunctions.Instance.ErrorLog("play: " + cardtoplay.GetEntity().GetName() + " target: " + target.GetName()); Helpfunctions.Instance.logg("play: " + cardtoplay.GetEntity().GetName() + " target: " + target.GetName() + " choice: " + moveTodo.druidchoice); if (moveTodo.druidchoice >= 1) { this.dirtytarget = moveTodo.target.entitiyID; this.dirtychoice = moveTodo.druidchoice; //1=leftcard, 2= rightcard this.choiceCardId = moveTodo.card.card.cardIDenum.ToString(); } if (moveTodo.card.card.type == CardDB.cardtype.MOB) { return(new HREngine.API.Actions.PlayCardAction(cardtoplay, target, moveTodo.place)); } return(new HREngine.API.Actions.PlayCardAction(cardtoplay, target)); } else { Helpfunctions.Instance.ErrorLog("play: " + cardtoplay.GetEntity().GetName() + " target nothing"); Helpfunctions.Instance.logg("play: " + cardtoplay.GetEntity().GetName() + " choice: " + moveTodo.druidchoice); if (moveTodo.druidchoice >= 1) { this.dirtychoice = moveTodo.druidchoice; //1=leftcard, 2= rightcard this.choiceCardId = moveTodo.card.card.cardIDenum.ToString(); } if (moveTodo.card.card.type == CardDB.cardtype.MOB) { return(new HREngine.API.Actions.PlayCardAction(cardtoplay, null, moveTodo.place)); } return(new HREngine.API.Actions.PlayCardAction(cardtoplay)); } } if (moveTodo.actionType == actionEnum.attackWithMinion) { HREntity attacker = getEntityWithNumber(moveTodo.own.entitiyID); HREntity target = getEntityWithNumber(moveTodo.target.entitiyID); Helpfunctions.Instance.ErrorLog("minion attack: " + attacker.GetName() + " target: " + target.GetName()); Helpfunctions.Instance.logg("minion attack: " + attacker.GetName() + " target: " + target.GetName()); return(new HREngine.API.Actions.AttackAction(attacker, target)); } if (moveTodo.actionType == actionEnum.attackWithHero) { HREntity attacker = getEntityWithNumber(moveTodo.own.entitiyID); HREntity target = getEntityWithNumber(moveTodo.target.entitiyID); this.dirtytarget = moveTodo.target.entitiyID; Helpfunctions.Instance.ErrorLog("heroattack: " + attacker.GetName() + " target: " + target.GetName()); Helpfunctions.Instance.logg("heroattack: " + attacker.GetName() + " target: " + target.GetName()); if (HRPlayer.GetLocalPlayer().HasWeapon()) { Helpfunctions.Instance.ErrorLog("hero attack with weapon"); return(new HREngine.API.Actions.AttackAction(HRPlayer.GetLocalPlayer().GetWeaponCard().GetEntity(), target)); } Helpfunctions.Instance.ErrorLog("hero attack without weapon"); //Helpfunctions.Instance.ErrorLog("attacker entity: " + HRPlayer.GetLocalPlayer().GetHero().GetEntityId()); //return new HREngine.API.Actions.AttackAction(HRPlayer.GetLocalPlayer().GetHero(), target); return(new HREngine.API.Actions.PlayCardAction(HRPlayer.GetLocalPlayer().GetHeroCard(), target)); } if (moveTodo.actionType == actionEnum.useHeroPower) { HRCard cardtoplay = HRPlayer.GetLocalPlayer().GetHeroPower().GetCard(); if (moveTodo.target != null) { HREntity target = getEntityWithNumber(moveTodo.target.entitiyID); Helpfunctions.Instance.ErrorLog("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target " + target.GetName()); Helpfunctions.Instance.logg("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target " + target.GetName()); return(new HREngine.API.Actions.PlayCardAction(cardtoplay, target)); } else { Helpfunctions.Instance.ErrorLog("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target nothing"); Helpfunctions.Instance.logg("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target nothing"); return(new HREngine.API.Actions.PlayCardAction(cardtoplay)); } } } catch (Exception Exception) { Helpfunctions.Instance.ErrorLog(Exception.Message); Helpfunctions.Instance.ErrorLog(Environment.StackTrace); if (Settings.Instance.learnmode) { return(new HREngine.API.Actions.MakeNothingAction()); } } return(null); //HRBattle.FinishRound(); }
protected override ActionBase PlayCardsToField() { var EnemyState = new PlayerState(HRPlayer.GetEnemyPlayer()); var LocalState = new PlayerState(HRPlayer.GetLocalPlayer()); var Sorting = new Sorting(); // Retreive cards that can be played. List <HRCard> playableList = GetPlayableCards(HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND)); // Update list with conditions matching this custom class. GetConditionalCards(playableList, EnemyState, LocalState); // Sort by cost (ascending) Sorting.SortByCost(ref playableList); // Finally sort by custom priority playableList = SortByPriority(playableList); // Taunts if (LocalState.TauntMinions.Count == 0) { foreach (var minion in playableList) { HREntity Target = null; if (minion.GetEntity().HasTaunt() && CanHandleCard(minion, EnemyState, LocalState, ref Target)) { return(new PlayCardAction(minion, Target)); } } } // Charges foreach (var minion in playableList) { HREntity Target = null; if (minion.GetEntity().HasCharge() && CanHandleCard(minion, EnemyState, LocalState, ref Target)) { return(new PlayCardAction(minion, Target)); } } // All other available foreach (var minion in playableList) { HREntity Target = null; if (CanHandleCard(minion, EnemyState, LocalState, ref Target)) { return(new PlayCardAction(minion, Target)); } } // Use Hero Power that make sense at last... if (LocalState.Player.GetHeroPower().GetCost() <= LocalState.Mana) { if (LocalState.Player.GetHero().GetClass() == HRClass.HUNTER) { if (HRBattle.CanUseCard(LocalState.Player.GetHeroPower())) { return(new PlayCardAction(LocalState.Player.GetHeroPower().GetCard())); } } } if (LocalState.Player.HasWeapon()) { if (HRBattle.CanUseCard(LocalState.Player.GetHeroCard().GetEntity())) { return(new AttackAction(LocalState.Player.GetWeaponCard().GetEntity(), GetNextAttackToAttack())); } } return(null); }
private List <HRCard> getallHandCards() { List <HRCard> list = HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND); return(list); }
private void SeedSmartCc() { SmartCc.SimuCount++; Board root = new Board(); HREntity HeroEnemy = HRPlayer.GetEnemyPlayer().GetHero(); Card ce = Card.Create(HeroEnemy.GetCardId(), false, HeroEnemy.GetEntityId()); root.HeroEnemy = ce; HREntity HeroFriend = HRPlayer.GetLocalPlayer().GetHero(); root.HeroFriend = Card.Create(HeroFriend.GetCardId(), true, HeroFriend.GetEntityId()); root.HeroEnemy.CurrentHealth = HeroEnemy.GetHealth() - HeroEnemy.GetDamage(); root.HeroEnemy.MaxHealth = 30; root.HeroEnemy.CurrentArmor = HeroEnemy.GetArmor(); root.HeroFriend.CurrentHealth = HeroFriend.GetHealth() - HeroFriend.GetDamage(); root.HeroFriend.MaxHealth = 30; root.HeroFriend.IsFrozen = HeroFriend.IsFrozen(); root.HeroFriend.CurrentArmor = HeroFriend.GetArmor(); root.HeroFriend.CurrentAtk = HeroFriend.GetATK(); if (HRCard.GetCards(HRPlayer.GetEnemyPlayer(), HRCardZone.SECRET).Count > 0) { root.SecretEnemy = true; } if (HRPlayer.GetEnemyPlayer().HasWeapon()) { HRCard weaponEnemyCard = HRPlayer.GetEnemyPlayer().GetWeaponCard(); if (weaponEnemyCard != null) { root.WeaponEnemy = Card.Create(weaponEnemyCard.GetEntity().GetCardId(), false, weaponEnemyCard.GetEntity().GetEntityId()); } } if (HRPlayer.GetLocalPlayer().HasWeapon()) { HRCard weaponFriendCard = HRPlayer.GetLocalPlayer().GetWeaponCard(); if (weaponFriendCard != null) { root.WeaponFriend = Card.Create(weaponFriendCard.GetEntity().GetCardId(), true, weaponFriendCard.GetEntity().GetEntityId()); root.WeaponFriend.IsTired = (weaponFriendCard.GetEntity().GetNumAttacksThisTurn() > 0 || HeroFriend.GetNumAttacksThisTurn() > 0); } } root.ManaAvailable = HRPlayer.GetLocalPlayer().GetNumAvailableResources(); foreach (HREntity e in GetEnemyEntitiesOnBoard()) { Card newc = Card.Create(e.GetCardId(), false, e.GetEntityId()); newc.CurrentAtk = e.GetATK(); newc.CurrentHealth = e.GetHealth() - e.GetDamage(); newc.MaxHealth = e.GetHealth(); foreach (HREntity az in e.GetEnchantments()) { Buff b = Buff.GetBuffById(az.GetCardId()); if (b != null) { b.OwnerId = az.GetCreatorId(); newc.AddBuff(b); newc.currentAtk -= b.Atk; newc.CurrentHealth -= b.Hp; newc.maxHealth -= b.Hp; } } newc.CurrentCost = e.GetCost(); newc.IsCharge = e.HasCharge(); newc.IsDivineShield = e.HasDivineShield(); newc.IsEnraged = e.IsEnraged(); newc.IsFrozen = e.IsFrozen(); newc.HasFreeze = e.IsFreeze(); newc.IsStealth = e.IsStealthed(); newc.IsSilenced = e.IsSilenced(); newc.HasPoison = e.IsPoisonous(); newc.IsWindfury = e.HasWindfury(); newc.IsTaunt = e.HasTaunt(); newc.Index = e.GetTag(HRGameTag.ZONE_POSITION) - 1; // HRLog.Write(e.GetName() + " at " + newc.Index.ToString()); root.MinionEnemy.Add(newc); } foreach (HREntity e in GetFriendEntitiesOnBoard()) { Card newc = Card.Create(e.GetCardId(), true, e.GetEntityId()); newc.CurrentAtk = e.GetATK(); newc.CurrentHealth = e.GetHealth() - e.GetDamage(); newc.MaxHealth = e.GetHealth(); foreach (HREntity az in e.GetEnchantments()) { Buff b = Buff.GetBuffById(az.GetCardId()); if (b != null) { b.OwnerId = az.GetCreatorId(); newc.AddBuff(b); newc.currentAtk -= b.Atk; newc.CurrentHealth -= b.Hp; newc.MaxHealth -= b.Hp; } } newc.CurrentCost = e.GetCost(); newc.IsCharge = e.HasCharge(); newc.IsDivineShield = e.HasDivineShield(); newc.IsEnraged = e.IsEnraged(); newc.IsFrozen = e.IsFrozen(); newc.HasFreeze = e.IsFreeze(); newc.IsStealth = e.IsStealthed(); newc.IsSilenced = e.IsSilenced(); newc.HasPoison = e.IsPoisonous(); newc.IsWindfury = e.HasWindfury(); newc.IsTaunt = e.HasTaunt(); newc.IsTired = e.IsExhausted(); newc.IsImmune = e.IsImmune(); newc.Index = e.GetTag(HRGameTag.ZONE_POSITION) - 1; newc.CountAttack = e.GetTag(HRGameTag.NUM_ATTACKS_THIS_TURN); root.MinionFriend.Add(newc); } foreach (HRCard c in HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.SECRET)) { Card newc = Card.Create(c.GetEntity().GetCardId(), true, c.GetEntity().GetEntityId()); root.Secret.Add(newc); } foreach (HRCard c in GetAllCardsInHand()) { Card newc = Card.Create(c.GetEntity().GetCardId(), true, c.GetEntity().GetEntityId()); root.Hand.Add(newc); } if (!HRPlayer.GetLocalPlayer().GetHeroPower().IsExhausted()) { root.Ability = Card.Create(HRPlayer.GetLocalPlayer().GetHeroPower().GetCardId(), true, HRPlayer.GetLocalPlayer().GetHeroPower().GetEntityId()); } if (!HRPlayer.GetEnemyPlayer().GetHeroPower().IsExhausted()) { root.EnemyAbility = Card.Create(HRPlayer.GetEnemyPlayer().GetHeroPower().GetCardId(), false, HRPlayer.GetEnemyPlayer().GetHeroPower().GetEntityId()); } root.TurnCount = SmartCc.TurnCount + 1; SmartCc.root = root; }
private HREngine.API.Actions.ActionBase HandleOnBattleStateUpdate() { if (SmartCc == null) { SmartCc = new Simulation(); SmartCc.CreateLogFolder(); SmartCc.TurnCount = 0; } while (true) { if (SmartCc.NeedCalculation) { HRLog.Write("Seed"); SeedSmartCc(); HRLog.Write("Simulation"); StreamReader str = new StreamReader(CardTemplate.DatabasePath + "Bots/SmartCC/Config/useThreading"); string use = str.ReadLine(); str.Close(); if (use == "true") { SmartCc.Simulate(true); } else { SmartCc.Simulate(false); } HRLog.Write("Simulation Done"); } if (SmartCc.ActionStack.Count <= 0) { HRLog.Write("Simulation didnt found any action"); } else { HRLog.Write("Actions :"); foreach (Action a in SmartCc.ActionStack) { HRLog.Write(a.ToString()); } } ActionToDo = SmartCc.GetNextAction(); try { switch (ActionToDo.Type) { case Action.ActionType.TARGET: HREntity targett = GetEntityById(ActionToDo.Target.Id); return(new HREngine.API.Actions.TargetAction(targett)); case Action.ActionType.CHOICE: if (HREngine.API.HRChoice.IsChoiceActive()) { List <HREntity> choices = HRChoice.GetChoiceCards(); if (SmartCc.ChoiceTarget != null) { SmartCc.InsertTargetAction(SmartCc.ChoiceTarget); SmartCc.ChoiceTarget = null; } return(new HREngine.API.Actions.ChoiceAction(choices[ActionToDo.Choice - 1])); } else { return(null); } case Action.ActionType.CAST_ABILITY: HRCard cardAbility = HRPlayer.GetLocalPlayer().GetHeroPower().GetCard(); if (ActionToDo.Target != null) { HREntity target = GetEntityById(ActionToDo.Target.Id); return(new HREngine.API.Actions.PlayCardAction(cardAbility, target, ActionToDo.Index + 1)); } else { return(new HREngine.API.Actions.PlayCardAction(cardAbility, null, ActionToDo.Index + 1)); } case Action.ActionType.CAST_WEAPON: case Action.ActionType.CAST_MINION: case Action.ActionType.CAST_SPELL: HRCard card = GetCardById(ActionToDo.Actor.Id); if (ActionToDo.Actor.HasChoices) { HRLog.Write("CARD HAS CHOICES"); if (ActionToDo.Target != null) { SmartCc.ChoiceTarget = ActionToDo.Target; } SmartCc.InsertChoiceAction(ActionToDo.Choice); } if (ActionToDo.Target != null) { HREntity target = GetEntityById(ActionToDo.Target.Id); return(new HREngine.API.Actions.PlayCardAction(card, target, ActionToDo.Index + 1)); } else { return(new HREngine.API.Actions.PlayCardAction(card, null, ActionToDo.Index + 1)); } case Action.ActionType.HERO_ATTACK: HREntity attackerAttack = GetEntityById(ActionToDo.Actor.Id); HREntity targetAttack = GetEntityById(ActionToDo.Target.Id); if (HRPlayer.GetLocalPlayer().HasWeapon()) { return(new HREngine.API.Actions.AttackAction(HRPlayer.GetLocalPlayer().GetWeaponCard().GetEntity(), targetAttack)); } return(new HREngine.API.Actions.AttackAction(HRPlayer.GetLocalPlayer().GetHero(), targetAttack)); case Action.ActionType.MINION_ATTACK: HREntity attackerAttackM = GetEntityById(ActionToDo.Actor.Id); HREntity targetAttackM = GetEntityById(ActionToDo.Target.Id); return(new HREngine.API.Actions.AttackAction(attackerAttackM, targetAttackM)); case Action.ActionType.END_TURN: HRLog.Write("EndTurn"); SmartCc.TurnCount++; SmartCc.SimuCount = 0; //HRBattle.FinishRound(); return(null); case Action.ActionType.RESIMULATE: HRLog.Write("Resimulate"); SmartCc.NeedCalculation = true; continue; } } catch (Exception Exception) { HRLog.Write(Exception.Message); HRLog.Write(Environment.StackTrace); return(null); } HRLog.Write("Action not handled"); return(null); } SmartCc.NeedCalculation = true; return(null); }
private List <HRCard> GetAllCardsInHand() { return(HRCard.GetCards(HRPlayer.GetLocalPlayer(), HRCardZone.HAND)); }
/// <summary> /// [EN] /// This handler is executed when the local player turn is active. /// /// [DE] /// Dieses Event wird ausgelöst wenn der Spieler am Zug ist. /// </summary> private HREngine.API.Actions.ActionBase HandleOnBattleStateUpdate() { try { if (HRBattle.IsInTargetMode() && dirtytarget >= 0) { HRLog.Write("dirty targeting..."); HREntity target = getEntityWithNumber(dirtytarget); dirtytarget = -1; return(new HREngine.API.Actions.TargetAction(target)); } //SafeHandleBattleLocalPlayerTurnHandler(); sf.updateEverything(this); Action moveTodo = Ai.Instance.bestmove; if (moveTodo == null) { HRLog.Write("end turn"); return(null); } HRLog.Write("play action"); moveTodo.print(); if (moveTodo.cardplay) { HRCard cardtoplay = getCardWithNumber(moveTodo.cardEntitiy); if (moveTodo.enemytarget >= 0) { HREntity target = getEntityWithNumber(moveTodo.enemyEntitiy); HRLog.Write("play: " + cardtoplay.GetEntity().GetName() + " target: " + target.GetName()); Helpfunctions.Instance.logg("play: " + cardtoplay.GetEntity().GetName() + " target: " + target.GetName()); if (moveTodo.handcard.card.type == CardDB.cardtype.MOB) { return(new HREngine.API.Actions.PlayCardAction(cardtoplay, target, moveTodo.owntarget + 1)); } return(new HREngine.API.Actions.PlayCardAction(cardtoplay, target)); } else { HRLog.Write("play: " + cardtoplay.GetEntity().GetName() + " target nothing"); if (moveTodo.handcard.card.type == CardDB.cardtype.MOB) { return(new HREngine.API.Actions.PlayCardAction(cardtoplay, null, moveTodo.owntarget + 1)); } return(new HREngine.API.Actions.PlayCardAction(cardtoplay)); } } if (moveTodo.minionplay) { HREntity attacker = getEntityWithNumber(moveTodo.ownEntitiy); HREntity target = getEntityWithNumber(moveTodo.enemyEntitiy); HRLog.Write("minion attack: " + attacker.GetName() + " target: " + target.GetName()); Helpfunctions.Instance.logg("minion attack: " + attacker.GetName() + " target: " + target.GetName()); return(new HREngine.API.Actions.AttackAction(attacker, target)); } if (moveTodo.heroattack) { HREntity attacker = getEntityWithNumber(moveTodo.ownEntitiy); HREntity target = getEntityWithNumber(moveTodo.enemyEntitiy); this.dirtytarget = moveTodo.enemyEntitiy; //HRLog.Write("heroattack: attkr:" + moveTodo.ownEntitiy + " defender: " + moveTodo.enemyEntitiy); HRLog.Write("heroattack: " + attacker.GetName() + " target: " + target.GetName()); Helpfunctions.Instance.logg("heroattack: " + attacker.GetName() + " target: " + target.GetName()); if (HRPlayer.GetLocalPlayer().HasWeapon()) { HRLog.Write("hero attack with weapon"); return(new HREngine.API.Actions.AttackAction(HRPlayer.GetLocalPlayer().GetWeaponCard().GetEntity(), target)); } HRLog.Write("hero attack without weapon"); //HRLog.Write("attacker entity: " + HRPlayer.GetLocalPlayer().GetHero().GetEntityId()); return(new HREngine.API.Actions.AttackAction(HRPlayer.GetLocalPlayer().GetHero(), target)); } if (moveTodo.useability) { HRCard cardtoplay = HRPlayer.GetLocalPlayer().GetHeroPower().GetCard(); if (moveTodo.enemytarget >= 0) { HREntity target = getEntityWithNumber(moveTodo.enemyEntitiy); HRLog.Write("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target " + target.GetName()); Helpfunctions.Instance.logg("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target " + target.GetName()); return(new HREngine.API.Actions.PlayCardAction(cardtoplay, target)); } else { HRLog.Write("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target nothing"); Helpfunctions.Instance.logg("use ablitiy: " + cardtoplay.GetEntity().GetName() + " target nothing"); return(new HREngine.API.Actions.PlayCardAction(cardtoplay)); } } } catch (Exception Exception) { HRLog.Write(Exception.Message); HRLog.Write(Environment.StackTrace); } return(null); //HRBattle.FinishRound(); }
private void getMinions() { ownMinions.Clear(); enemyMinions.Clear(); HRPlayer ownPlayer = HRPlayer.GetLocalPlayer(); HRPlayer enemyPlayer = HRPlayer.GetEnemyPlayer(); // ALL minions on Playfield: List <HRCard> list = HRCard.GetCards(ownPlayer, HRCardZone.PLAY); list.AddRange(HRCard.GetCards(enemyPlayer, HRCardZone.PLAY)); List <HREntity> enchantments = new List <HREntity>(); foreach (HRCard item in list) { HREntity entitiy = item.GetEntity(); int zp = entitiy.GetZonePosition(); if (entitiy.GetCardType() == HRCardType.MINION && zp >= 1) { //HRLog.Write("zonepos " + zp); CardDB.Card c = CardDB.Instance.getCardDataFromID(entitiy.GetCardId()); Minion m = new Minion(); m.name = c.name; m.handcard.card = c; m.Angr = entitiy.GetATK(); m.maxHp = entitiy.GetHealth(); m.Hp = m.maxHp - entitiy.GetDamage(); m.wounded = false; if (m.maxHp > m.Hp) { m.wounded = true; } m.exhausted = entitiy.IsExhausted(); m.taunt = (entitiy.HasTaunt()) ? true : false; m.charge = (entitiy.HasCharge()) ? true : false; m.numAttacksThisTurn = entitiy.GetNumAttacksThisTurn(); int temp = entitiy.GetNumTurnsInPlay(); m.playedThisTurn = (temp == 0) ? true : false; m.windfury = (entitiy.HasWindfury()) ? true : false; m.frozen = (entitiy.IsFrozen()) ? true : false; m.divineshild = (entitiy.HasDivineShield()) ? true : false; m.stealth = (entitiy.IsStealthed()) ? true : false; m.poisonous = (entitiy.IsPoisonous()) ? true : false; m.immune = (entitiy.IsImmune()) ? true : false; m.silenced = (entitiy.GetTag(HRGameTag.SILENCED) >= 1) ? true:false; m.zonepos = zp; m.id = m.zonepos - 1; m.entitiyID = entitiy.GetEntityId(); m.enchantments.Clear(); //HRLog.Write( m.name + " ready params ex: " + m.exhausted + " charge: " +m.charge + " attcksthisturn: " + m.numAttacksThisTurn + " playedthisturn " + m.playedThisTurn ); m.Ready = false; // if exhausted, he is NOT ready if (!m.playedThisTurn && !m.exhausted && !m.frozen && (m.numAttacksThisTurn == 0 || (m.numAttacksThisTurn == 1 && m.windfury))) { m.Ready = true; } if (m.playedThisTurn && m.charge && (m.numAttacksThisTurn == 0 || (m.numAttacksThisTurn == 1 && m.windfury))) { //m.exhausted = false; m.Ready = true; } if (!m.silenced && (m.name == "ancientwatcher" || m.name == "ragnarosthefirelord")) { m.Ready = false; } if (entitiy.GetControllerId() == this.ownPlayerController) // OWN minion { this.ownMinions.Add(m); } else { this.enemyMinions.Add(m); } } // minions added if (entitiy.GetCardType() == HRCardType.WEAPON) { //HRLog.Write("found weapon!"); if (entitiy.GetControllerId() == this.ownPlayerController) // OWN weapon { this.ownHeroWeapon = CardDB.Instance.getCardDataFromID(entitiy.GetCardId()).name; this.heroWeaponAttack = entitiy.GetATK(); this.heroWeaponDurability = entitiy.GetDurability(); //this.heroImmuneToDamageWhileAttacking = false; } else { this.enemyHeroWeapon = CardDB.Instance.getCardDataFromID(entitiy.GetCardId()).name; this.enemyWeaponAttack = entitiy.GetATK(); this.enemyWeaponDurability = entitiy.GetDurability(); } } if (entitiy.GetCardType() == HRCardType.ENCHANTMENT) { enchantments.Add(entitiy); } } foreach (HRCard item in list) { foreach (HREntity e in item.GetEntity().GetEnchantments()) { enchantments.Add(e); } } // add enchantments to minions setEnchantments(enchantments); }