private bool HasWorthyAbility(Card.Cards id) { switch (Load(id).Cost) { case 1: return(Load(id).Stealth || Load(id).HasBattlecry || Load(id).HasDeathrattle || Load(id).Divineshield || Load(id).Poison); case 2: return((Load(id).Stealth || Load(id).HasBattlecry || Load(id).HasDeathrattle || Load(id).Divineshield || Load(id).Poison || Load(id).Windfury || Load(id).Charge) && Load(id).Atk > 1 && Load(id).Health > 1); case 3: return((Load(id).Stealth || Load(id).HasBattlecry || Load(id).HasDeathrattle || Load(id).Divineshield || Load(id).Poison || Load(id).Windfury || Load(id).IsAdapt || Load(id).IsDiscover) && Load(id).Atk > 1 && Load(id).Health > 1); ; default: return(false); } }
public Card.Cards HandlePickDecision(Card.Cards originCard, List <Card.Cards> choices, Board board) { try { Parser HsReplayParser = new Parser(); Log(string.Format("Trying to parse HSReplay for {0} in {1} mode ...", CardTemplate.LoadFromId(originCard).Name, Bot.CurrentMode())); var parsedResults = HsReplayParser.GetHSReplayResults(Database.Get.GetDbfIdFromCardId(originCard.ToString()), ConvertMode(Bot.CurrentMode())); Log("Datas parsed successfully !"); /*foreach (var res in parsedResults) * { * Log(res.CardId + " - Popularity : " + res.Popularity + " - Winrate :" + res.Winrate); * }*/ return(FindBestPick(parsedResults, choices)); } catch (Exception e) { Log(e.ToString()); return(Card.Cards.CRED_01); } }
public BoardCard(string MulliganCard_STR) { Card.Cards _mulliganCard = CardTemplate.StringToCard(MulliganCard_STR); ResultingBoardCard = ConvertToBoardCard(_mulliganCard); IsMaxManaCard = ResultingBoardCard.Cost == MainLists.MaxManaCost; }
public Card.Cards HandlePickDecision(Card.Cards originCard, List <Card.Cards> choices, Board board) { //Logic for special discovers if (originCard == Cards.ArchThiefRafaam) { Card.Cards mirrorOfDoom = Card.Cards.LOEA16_5; Card.Cards timepieceOfHorror = Card.Cards.LOEA16_4; Card.Cards lanternOfPower = Card.Cards.LOEA16_3; //Insert Rafaam logic AddLog("ArchThiefRafamm special case"); PrintLog(); return(mirrorOfDoom); } try { choices = choices.OrderByDescending(x => GetValue(x, board)).ToList(); var choice = choices.First(); PrintLog(); return(choice); } catch (InvalidOperationException) { AddLog("Card not found in Tierlist. Falling back to Smartbot default Discover."); PrintLog(); return(Card.Cards.CRED_01); } }
private int GetValue(Card.Cards card, Board board) { //if (Lethal(card, board)) return 1000; Not implemented int value; //Values saved in this var for debug printouts AddLog(" -- Name: " + CardTemplate.LoadFromId(card).Name); //Use custom eval method if there is one if (CardValues.ContainsKey(card)) { value = CardValues[card](board); AddLog("Eval Value: " + value); } else { //Ask for value of card in our class for neutral cards and class cards of your class. Ask for value of the cards class if it's a class card from another class var cclass = CardTemplate.LoadFromId(card).Class == Card.CClass.NONE ? board.FriendClass : CardTemplate.LoadFromId(card).Class; value = TierList.GetCardValue(card, cclass); AddLog("List Value: " + value); AddLog("List Class: " + cclass); } //if (_playableMinions.Contains(card) && LowOnMinions(board)) return value + 20; Not implemented return(value); }
public CardValue(Card.Cards card, double points, int hero, int friend) { _card = card; _points = points; _hero = hero; _friend = friend; }
public static void ManageNeutralMinion(Card.Cards card) { //<= max mana var boardCard = new BoardCard(card); if (boardCard.ResultingBoardCard.Quality >= ValueReader.MinCardQualityToInstantAddMinion) //epic by default { MainLists.chosenCards.Add(card); } else { //card quality not hight enoughbut <= max mana if (!ValueReader.AttendMinionValue || boardCard.ResultingBoardCard.Cost < ValueReader.MinManaCostToAttendValue) { //mana <= max cost & mana < MinManaCostToAttendValue MainLists.chosenCards.Add(card); } else if (boardCard.ResultingBoardCard.Cost >= ValueReader.MinManaCostToAttendValue) { var minionCard = new NeutralMinion(card); MinionValue.Value requiredMinNeutralMinionValue = minionCard.minionBoardCard.IsMaxManaCard && ValueReader.IncreaseMinMinionValueIfMaxCost ? ValueReader.IncreasedMinNeutralMinionValue : ValueReader.MinNeutralMinionValue; if (minionCard.thisCardValue >= requiredMinNeutralMinionValue) { MainLists.chosenCards.Add(card); } } } }
public static bool HasGoodEffect(Card.Cards _card) { var card = new BoardCard(_card).ResultingBoardCard; return(card.Charge || card.Divineshield || card.Enrage || card.Freeze || card.Stealth || card.Taunt || card.Windfury || card.Spellpower > 0); }
private void Keep(Card.Cards id, string log = "") { CardsToKeep.Add(id); if (log != "") { Log(log); } }
private bool IsWorthyTwoDrop(Card.Cards id) { if (SpellsAndWeaponsToAlwaysKeep.Contains(id)) { return(true); } return(CardTemplate.LoadFromId(id).Cost == 2 && CardTemplate.LoadFromId(id).Atk >= 2 && CardTemplate.LoadFromId(id).Health >= 2 && CardTemplate.LoadFromId(id).Type == Card.CType.MINION); }
public static int CardAvailable(Board board, Card.Cards card) { var numb = board.Deck.Count(x => x == card); numb -= board.FriendGraveyard.Count(x => x == card); numb -= board.MinionFriend.Count(x => x.Template.Id == card); return(numb); }
public static bool WouldTakeMinion(CardTemplate boardCard) { try { if (new NeutralMinion(boardCard).minionBoardCard == null) //not a neutral minion { return(false); } //<= max mana Card.Cards card = CardTemplate.StringToCard(boardCard.Id.ToString()); #region normalChecks if (MainLists.whiteList.Contains(boardCard.Id.ToString())) { return(true); } if (MainLists.blackList.Contains((boardCard.Id.ToString()))) { return(false); } if (boardCard.Quality >= ValueReader.MinCardQualityToInstantAddMinion) //epic by default { return(true); } //card quality not hight enough and mana to high too if ((!ValueReader.AttendMinionValue || boardCard.Cost < ValueReader.MinManaCostToAttendValue) && boardCard.Cost <= MainLists.MaxManaCost) { return(true); } if (boardCard.Cost > MainLists.MaxManaCost) { return(false); } //value has to be attended var minionCard = new NeutralMinion(card); MinionValue.Value requiredMinNeutralMinionValue = minionCard.minionBoardCard.IsMaxManaCard && ValueReader.IncreaseMinMinionValueIfMaxCost ? ValueReader.IncreasedMinNeutralMinionValue : ValueReader.MinNeutralMinionValue; return(minionCard.thisCardValue >= requiredMinNeutralMinionValue); #endregion normalChecks } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } }
private bool IsWorthyThreeDrop(Card.Cards id) { if (Load(id).Cost == 3 && WorthySpells.Contains(id)) { return(true); } return(Load(id).Cost == 3 && ((Load(id).Type == Card.CType.MINION && (HasWorthyAbility(id) || HasWorthyStats(id))) || (Load(id).Type == Card.CType.WEAPON))); }
//================================================// // Function GetTokenCount // // // // return: // // int with card's minion number // // // // Counts card's tokens // //================================================// private int GetTokenCount(Card.Cards card) { CardTemplate cardTmp = CardTemplate.LoadFromId(card); if (_tokens.ContainsKey(card)) { return(_tokens[card]); } return(cardTmp.Type == Card.CType.MINION ? 1 : 0); }
private bool IsWorthyOneDrop(Card.Cards id) { if (id == Card.Cards.CFM_637) { return(false); } if (Load(id).Cost == 1 && WorthySpells.Contains(id)) { return(true); } return(Load(id).Cost == 1 && HasWorthyStats(id)); }
private float FindCardValue(List <HSReplayResultEntry> entries, Card.Cards card) { HSReplayResultEntry entry = entries.FirstOrDefault(x => x.CardId == card.ToString()); if (entry == null) { Log(string.Format("Choice [{0}] doesn't have value in HSReplay datas", CardTemplate.LoadFromId(card).Name)); return(0); } return(ComputeValue(entry.Popularity, entry.Winrate)); }
//Get value of certain card in certain class public int GetCardValue(Card.Cards card, Card.CClass friendlyClass) { //Look for value in our class if the card is neutral or from our class. Otherwise look for value in the class that the card belongs to. var cclass = CardTemplate.LoadFromId(card).Class == Card.CClass.NONE ? friendlyClass : CardTemplate.LoadFromId(card).Class; try { //If there is no specific value for the requested class, use neutral value. return((int)Cards.Find(x => x.Id == card).Scores[cclass] == 0 ? (int)Cards.Find(x => x.Id == card).Scores[Card.CClass.NONE] : (int)Cards.Find(x => x.Id == card).Scores[cclass]); } catch (Exception e) { throw new InvalidOperationException("The card " + card + " could not be found in the Tierlist.", e); } }
private bool HasWorthyStats(Card.Cards id) { switch (Load(id).Cost) { case 1: return(Load(id).Atk >= 1); case 2: return(Load(id).Atk + Load(id).Health >= 4 && Load(id).Health > 1 && Load(id).Atk > 1); case 3: return(Load(id).Atk + Load(id).Health >= 6 && Load(id).Health > 1 && Load(id).Atk > 1); default: return(false); } }
private NeutralMinion(Card.Cards NeutralMinionMulliganCard) { minionBoardCard = new BoardCard(NeutralMinionMulliganCard).IsClassCard() || NeutralMinionMulliganCard.ToString() == "GAME_005" ? null : new BoardCard(NeutralMinionMulliganCard); thisCardValue = minionBoardCard != null ? MinionValue.SetCardValue(minionBoardCard) : MinionValue.Value.NotANeutralMinion; if (minionBoardCard != null && MainLists.whiteList.Contains(minionBoardCard.ResultingBoardCard.Name)) { thisCardValue = MinionValue.Value.InWhiteList; } }
/// <summary> /// load obvious whitelist first to determine if Value.InWhiteList /// </summary> /// <param name="NeutralMinionBoardCard"></param> public NeutralMinion(CardTemplate NeutralMinionBoardCard) { Card.Cards NeutralMinionMulliganCardCard = BoardToMulliganCard(NeutralMinionBoardCard); minionBoardCard = NeutralMinionBoardCard.Class != Card.CClass.NONE || NeutralMinionMulliganCardCard.ToString() == "GAME_005" ? null : new BoardCard(NeutralMinionMulliganCardCard); thisCardValue = minionBoardCard != null?MinionValue.SetCardValue(minionBoardCard) : MinionValue.Value.NotANeutralMinion; if (minionBoardCard != null && MainLists.whiteList.Contains(minionBoardCard.ResultingBoardCard.Name)) { thisCardValue = MinionValue.Value.InWhiteList; } }
public override int Modifiers(Card.Cards card, Board board, int value) { var inHand = board.Hand.Sum(x => x.CurrentCost); inHand = inHand < 1 ? 1 : inHand; double handValue = (double)(board.ManaAvailable + board.MaxMana) / inHand; switch (CardTemplate.LoadFromId(card).Cost) { case 1: return((int)(value - handValue * 35)); case 2: return((int)(value - handValue * 30)); case 3: return((int)(value - handValue * 25)); } return(value); }
private int GetValue(Card.Cards card, Board board) { AddLog("Name: " + CardTemplate.LoadFromId(card).Name); var deck = "Universal"; //Next level deck identification I know. Thank you. AddLog("Deck identified: " + deck); var specificDeckLogic = CardDictionarys.ContainsKey(deck) ? CardDictionarys[deck] : CardDictionarys["Universal"]; DeckLogic deckLogic; if (!specificDeckLogic.CardValues.ContainsKey(card)) { AddLog("Deckspecific logic: " + "No."); deckLogic = CardDictionarys["Universal"]; } else { AddLog("Deckspecific logic: " + "Yes."); deckLogic = specificDeckLogic; } int value; if (deckLogic.CardValues.ContainsKey(card)) { AddLog("Custom logic: " + "Yes."); value = deckLogic.CardValues[card](board); } else { AddLog("Custom logic: " + "No."); value = TierList.GetCardValue(card, board.FriendClass); } value = specificDeckLogic.Modifiers(card, board, value); AddLog("Card value: " + value); AddLog(""); return(value); }
public Card.Cards HandlePickDecision(Card.Cards originCard, List <Card.Cards> choices, Board board) { //Logic for special discovers if (originCard == Cards.ArchThiefRafaam) { Card.Cards mirrorOfDoom = Card.Cards.LOEA16_5; //Card.Cards timepieceOfHorror = Card.Cards.LOEA16_4; //Card.Cards lanternOfPower = Card.Cards.LOEA16_3; //Insert Rafaam logic AddLog("RAAAAAAAFAAAAAAAAAMMMMMMMMMMM THE SUPREMEEE ARCHEOLOGIST"); PrintLog(); return(mirrorOfDoom); } if (originCard == Cards.Kazakus) { //Not sure how this works AddLog("KAZAMMMAAKUSSS CLOWNFIESTA"); PrintLog(); //Always pick middle -> 5 mana return(choices[1]); } //Try discover logic for usual cards, if it fails pick left card and print error to log try { var choice = choices.OrderByDescending(x => GetValue(x, board)).First(); PrintLog(); return(choice); } catch (Exception e) { _log = "\r\n[-MasterwaiDisco-]"; Bot.Log("Error in discover"); Bot.Log(e.ToString()); return(choices[0]); } }
//Get value of certain card in certain class public int GetCardValue(Card.Cards card, Card.CClass cclass) { //If there is no specific value for the requested class, use neutral value. try { if ((int)Cards.Find(x => x.Id == card).Scores[cclass] == 0) { return((int)Cards.Find(x => x.Id == card).Scores[Card.CClass.NONE]); } else { return((int)Cards.Find(x => x.Id == card).Scores[cclass]); } } catch (Exception e) { return(0); } finally { } return(0); }
public Card(Card.Cards card) { aCard = card; }
//private string description; public Card.Cards HandlePickDecision(Card.Cards originCard, List <Card.Cards> choices, Board board) //originCard; ID of card played by SB: choices; names of cards for selection: board; 3 states , Even, Losing, Winning { // Local variables declaration int _discoverIndex = 1; string Version = "V4.9", description; string Divider = new string('=', 47); string Divider2 = new string('=', 50); string Origin_Card = CardTemplate.LoadFromId(originCard).Name; // Get play mode _mode = CurrentMode(Bot.CurrentMode()); //Create card list List <CardValue> choicesCardValue = new List <CardValue>(); // Get custom file if exists try { string currentAchetype = !String.IsNullOrEmpty(GetCurrentHSReplayArchetype()) ? GetCurrentHSReplayArchetype() : GetCurrentLocalArchetype(); // Only get files that contains with the word "Custom" and bot current deck or discover card name. string[] fileNames = Directory.GetFiles(Directory.GetCurrentDirectory() + @"\DiscoverCC\" + _mode + '\\', "Custom*.ini"); foreach (string discoverFile in fileNames) { // Get custom file if origin card name and current archetype matches if (Regex.Replace(discoverFile, @"[\s+_,]", String.Empty).IndexOf(Regex.Replace(Origin_Card, @"[\s+_,]", String.Empty), StringComparison.OrdinalIgnoreCase) >= 0 && Regex.Replace(discoverFile, @"[\s+_,]", String.Empty).IndexOf(Regex.Replace(currentAchetype, @"[\s+_,]", String.Empty), StringComparison.OrdinalIgnoreCase) >= 0) { Bot.Log("Using archetype: " + currentAchetype); _discoverFile = discoverFile; _discoverIndex = 0; break; } else if (String.Equals(discoverFile, "Custom " + Origin_Card + ".ini", StringComparison.OrdinalIgnoreCase)) { _discoverFile = discoverFile; _discoverIndex = 0; break; } } } catch (Exception) { Bot.Log("[Discover] -> File not found"); Bot.Log("More information in SmartBot forums"); Bot.Log("https://smartbot.ws/forums/index.php?/topic/9672-evil_eyes-hsreplay-discover-choices/"); _discoverIndex = 1; } //Main loop starts here double TotalPoints = 0; LogChoice = 4; do { switch (_discoverIndex) { case 0: fileName = Path.GetFileName(_discoverFile); _iniTierList0 = new IniManager(fileName); // load custom file into List break; case 1: fileName = Origin_Card + ".ini"; _iniTierList0 = new IniManager(Directory.GetCurrentDirectory() + @"\DiscoverCC\" + _mode + '\\' + fileName); // load HSReplay file into List break; case 2: _iniTierList0 = new IniManager(Directory.GetCurrentDirectory() + @"\DiscoverCC\" + _mode + '\\' + "discover.ini"); // load "discover.ini" file into List LogChoice = 3; break; } choicesCardValue.Clear(); //Search for best points int heroIndex = 0; int friend; int.TryParse(_iniTierList0.GetString("Hero", "FriendClass", "0"), out friend); foreach (var card in choices) // loops for each card { double points = 0; var cardTemplate = CardTemplate.LoadFromId(card); //cardTemplate = Name of card + [CardId], card = CardId // Check for any special conditions if (originCard == Card.Cards.BAR_079) //Kazakus, Golem Shaper { points = KazakusGolemShaper(CardTemplate.LoadFromId(bestChoice).Name, cardTemplate.Name, board); LogChoice = 1; } else if (originCard == Card.Cards.DMF_075) //Guess the Weight { if (card == Card.Cards.DMF_075a2) //Less! { Guess_The_Weight = GuessTheWeight(board); //Guess the Weight, sub program read once points = Convert.ToDouble(Guess_The_Weight.Split(new char[] { '/' })[0].Trim()); } else if (card == Card.Cards.DMF_075a) //More! { points = Convert.ToDouble(Guess_The_Weight.Split(new char[] { '/' })[1].Trim()); } else { Guess_The_Weight = cardTemplate.Name + ", Cost: " + cardTemplate.Cost.ToString(); //Display name and cost of weight card LogChoice = 2; } } else { string HeroClass = friend == 1 ? board.FriendClass.ToString() : board.EnemyClass.ToString(); // Get friendly/opponent hero class double.TryParse(_iniTierList0.GetString(cardTemplate.Name, HeroClass, "0"), NumberStyles.Any, CultureInfo.InvariantCulture, out points); // search for card from TierList if (points < 0.001) // if points is zero, search for default points { double.TryParse(_iniTierList0.GetString(cardTemplate.Name, "points", "0"), NumberStyles.Any, CultureInfo.InvariantCulture, out points); } else { heroIndex = Array.IndexOf(heroes, HeroClass); } } choicesCardValue.Add(new CardValue(card, points, heroIndex, friend)); //add points, class, hero to each card TotalPoints += points; // Adding points, check if points is not = zero } _discoverIndex++; } while (!(TotalPoints > 0 || _discoverIndex > 2)); // Select best card double bestPoints = 0; for (var i = 0; i < choicesCardValue.Count; i++) //index through each card { var cardValue = choicesCardValue[i]; // index through cardValue double pts = cardValue.GetPoints(); // calls cardValue subroutine, get points int heroIndex = cardValue.GetHeroClass(); // calls cardValue subroutine, get hero class bool friend = Convert.ToBoolean(cardValue.GetFriend()); // calls cardValue subroutine, get friend/opponent hero string hero = heroIndex != 0 ? friend ? ", friend - " + heroes[heroIndex] : ", enemy - " + heroes[heroIndex] : null; //preparation to log Bot.Log(i + 1 + ") " + CardTemplate.LoadFromId(cardValue.GetCard()).Name + ": " + pts + hero); // output cards choices to log if (!(bestPoints < pts)) { continue; // selects highest points } bestChoice = cardValue.GetCard(); // calls cardValue subroutine, get card assign to bestChoice bestPoints = pts; // calls cardValue subroutine, get points assign to bestPoints } //Log description choices switch (LogChoice) { case 1: description = "From: Kazakus, Golem Shaper, minion count: " + board.MinionFriend.Count + " mana available: " + board.ManaAvailable; break; case 2: description = "From: Guess the Weight: " + Guess_The_Weight; break; case 3: description = "No cards found from: " + Origin_Card + ".ini, using: discover.ini, Mode - " + _mode; break; default: description = "From: " + fileName + ", Mode - " + _mode; break; } // Out to Bot log Bot.Log(Version + Divider); Bot.Log("Best: " + CardTemplate.LoadFromId(bestChoice).Name + ": " + bestPoints); Bot.Log(description); Bot.Log(Divider2); return(bestChoice); // returns cardID }
public virtual int Modifiers(Card.Cards card, Board board, int value) { return(value); }
private CardTemplate ConvertToBoardCard(Card.Cards MulliganCard) { return(CardTemplate.LoadFromId(MulliganCard)); }
public BoardCard(Card.Cards MulliganCard) { ResultingBoardCard = ConvertToBoardCard(MulliganCard); IsMaxManaCard = ResultingBoardCard.Cost == MainLists.MaxManaCost; }
private bool IsWorthyFourDrop(Card.Cards id) { return(CardTemplate.LoadFromId(id).Cost == 4 && CardTemplate.LoadFromId(id).Type == Card.CType.MINION); }