What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal
RebornBuddy Forums

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

API starting guide - Custom Mulligan

Status
Not open for further replies.

hankerspace

New Member
Joined
Apr 4, 2014
Messages
164
API released

Here is a little guide to explain how to make your custom mulligan.

Errors

Script compilation is done during Bot startup. Compilation errors are displayed in log window. If your custom mulligan is avaible, it will be avaible in 'custom mulligan" list. Else you deck contains errors. Check log window.

Documentation

Your custom mulligan MUST inheritate ICustomMulligan

The entrypoint of a custom mulligan is
Code:
IEnumerator DoMulligan()
. In this function, you must end mulligan on your own with TritonHS.EndMulligan();.

Your custom mulligan must be placed in CustomMulligan folder.

Only 3 functions are needed to create a custom mulligan :

Code:
TritonHS.EndMulligan(); // To end the mulligan and draw new cards
TritonHS.GetMulliganCards(); // Which returns a List of HSCard. This list contains the 3 (or 4) cards available for the mulligan.
TritonHS.ToggleMulliganCard(HSCard); // This function toggle the state of a mulligan card (replace it or not)

Samples

Here is the default Custom mulligan sourcecode :

Code:
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Triton.Common;
using Triton.Game;

namespace Triton.Bot
{
    class DefaultMulligan : ICustomMulligan
    {
        private const int MaximumCost = 3;
        public IEnumerator DoMulligan()
        {
            List<HSCard> cards = TritonHS.GetMulliganCards();

            // Find mulligans cards where cost > MaxCost
            foreach (HSCard c in cards.Where(c => c.Card.GetCost() > MaximumCost))
            {
                // Toggle this card
                TritonHS.ToggleMulliganCard(c);

                // Make sure we give the game time to actually click stuff.
                yield return Coroutine.Sleep(1000);
            }


            yield return Coroutine.Sleep(2000);
            TritonHS.EndMulligan();
        }
    }
}

Good luck everyone ;)
 
Last edited:
Hanker Every time. You say "Good Luck Everyone" it always makes me laugh and think of this
[video=youtube;LLuaPZWkvZ0]http://www.youtube.com/watch?v=LLuaPZWkvZ0[/video]
 
can we change only maximum cost? (sorry im retarded when it comes to coding)
 
can we change only maximum cost? (sorry im retarded when it comes to coding)

I'm the same but looking over what hanker wrote I don't think so but we wait for him or other to let us know. Because to me it's gibberish

Even tho mana cost is a good start. And deff helps

Mulligan should be done with card I'd. And with options to keep one or 2 of the same card if you get that. Like silverfish mulligan.
 
Sounds great!
But how can we use this ?

Create a .cs file in CustomMulligans/MyMulligans/MyFirstMulligan.cs

Insert this sourcecode inside the file :

Code:
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Triton.Common;
using Triton.Game;
using Triton.Bot;

namespace MyMulligans
{
    class MyFirstMulligan: ICustomMulligan
    {
        private const int MaximumCost = 3;
        public IEnumerator DoMulligan()
        {
            List<HSCard> cards = TritonHS.GetMulliganCards();

            // Find mulligans cards where cost > MaxCost
            foreach (HSCard c in cards.Where(c => c.Card.GetCost() > MaximumCost))
            {
                // Toggle this card
                TritonHS.ToggleMulliganCard(c);

                // Make sure we give the game time to actually click stuff.
                yield return Coroutine.Sleep(1000);
            }


            yield return Coroutine.Sleep(2000);
            TritonHS.EndMulligan();
        }
    }
}

Change this value : private const int MaximumCost = 3; to replace cards with cost > MaximumCost.

Thats a simple way to change Maximum cost.
 
Last edited:
[Compiler Error] \CustomMulligans\MyMulligans\MyFirstMulligan.cs(9,29) : error CS0246: The type or namespace name 'ICustomMulligan' could not be found (are you missing a using directive or an assembly reference?)

i get this error when i try your code in the post over me, and this when i try the one on the first post

[Compiler Error] \CustomMulligans\MyMulligans\MyFirstMulligan.cs(17,53) : error CS1061: 'Triton.Game.HSCard' does not contain a definition for 'Card' and no extension method 'Card' accepting a first argument of type 'Triton.Game.HSCard' could be found (are you missing a using directive or an assembly reference?)
 
[Compiler Error] \CustomMulligans\MyMulligans\MyFirstMulligan.cs(9,29) : error CS0246: The type or namespace name 'ICustomMulligan' could not be found (are you missing a using directive or an assembly reference?)

i get this error when i try your code in the post over me, and this when i try the one on the first post

[Compiler Error] \CustomMulligans\MyMulligans\MyFirstMulligan.cs(17,53) : error CS1061: 'Triton.Game.HSCard' does not contain a definition for 'Card' and no extension method 'Card' accepting a first argument of type 'Triton.Game.HSCard' could be found (are you missing a using directive or an assembly reference?)

Try again code in last post, ive updated it.
 
[Compiler Error] \CustomMulligans\MyMulligans\second.cs(18,53) : error CS1061: 'Triton.Game.HSCard' does not contain a definition for 'Card' and no extension method 'Card' accepting a first argument of type 'Triton.Game.HSCard' could be found (are you missing a using directive or an assembly reference?)

now i get this with that code
 
[Compiler Error] \CustomMulligans\MyMulligans\second.cs(18,53) : error CS1061: 'Triton.Game.HSCard' does not contain a definition for 'Card' and no extension method 'Card' accepting a first argument of type 'Triton.Game.HSCard' could be found (are you missing a using directive or an assembly reference?)

now i get this with that code

Oh my bad, remove this line : Logging.Write("Replacing {0} in starting hand.", c.Card.GetName());
 
[Compiler Error] c:\Users\Smypm\Desktop\buddy\CustomMulligans\MyMulligans\second.cs(18,53) : error CS1955: Non-invocable member 'Triton.Game.HSCard.Cost' cannot be used like a method.

well xD
 
i'm a new guy,what‘s the meaning of custom mulligan?What effect does it have?What is the difference between custom deck and custom mulligan?
 
Adding any folder to CustomMulligans makes HearthBuddy stop responding. Taking it out makes it function normally. Including just the .cs file leads to HearthBuddy not recognizing it. What can I do?
 
Adding any folder to CustomMulligans makes HearthBuddy stop responding. Taking it out makes it function normally. Including just the .cs file leads to HearthBuddy not recognizing it. What can I do?

Yeah, the .cs file need to be in a subfolder (CustomMulligans/MyMulligans/mulligan1.cs)

Do you have this error with CustomDecks too ?

Try to run as admin.
 
Edited. Previously it was a question here, but i figured it out by myself.

So, here, mb it might help to some one.

Idea of mulligan logic: replace any card, if it's not Undertaker (FP1_028), Leper Gnome (EX1_029), Webspinner (FP1_011), Spectral Spider (FP1_002), Mad Scientist (FP1_004).

Code:
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Triton.Common;
using Triton.Game;

namespace Triton.Bot
{
    class HunterMulligan : ICustomMulligan
    {
        public IEnumerator DoMulligan()
        {
            List<HSCard> cards = TritonHS.GetMulliganCards();

            foreach (HSCard c in cards)
            {
                if(c.Id != "FP1_028" && c.Id != "EX1_029" && c.Id != "FP1_011" && c.Id != "FP1_002" && c.Id != "FP1_004" && c.Id != "GAME_005")
                {

                   TritonHS.ToggleMulliganCard(c);
                   //Logging.Write("Replacing {0} in starting hand.", c.Id); 

                   // Make sure we give the game time to actually click stuff.
                   yield return Coroutine.Sleep(1000);
                }
            }


            yield return Coroutine.Sleep(2000);
            TritonHS.EndMulligan();
        }
    }

}

Also, this line:
Code:
    class HunterMulligan : ICustomMulligan
HunterMulligan - name of mulligan rule, you are free to change it, to distinguish them if there is many of rules.

P.S. Can some one explain to me: is it normal, that bot trying to replace Coin (GAME_005)? Or it's some kind of game code, that gives you a coin, but hides it from visible mulligan, but bot still can see it?

P.P.S. Is there any way to determine class of the opponent? I want to create few exception rules, based on a opponent class, but not sure how to determine it.
 
Last edited:
Made one more script. I like it better, because here i'm choosing cards what i want to keep in my hand, and not the ones that i should replace (no need to create rules for high cost cards, or cards like shadowflame, shadow word: death).
Also i found how determine what class is my hero, and what class is opponent, it helped to create few rules for specific classes.

Here is example, with few rules of keeping cards, and hero checking. I hope somebody can find it useful.

Code:
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Triton.Common;
using Triton.Game;

namespace Triton.Bot
{
    class HunterAggro : ICustomMulligan
    {
        public IEnumerator DoMulligan()
        {
            List<HSCard> cards = TritonHS.GetMulliganCards(); //list of cards on mulligan

            HSCard eP = TritonHS.EnemyHero; //enemy hero info
            HSCard oP = TritonHS.OurHero;   //our hero info
            //Possible hero id's:
            //HERO_01 - Warrior
            //HERO_02 - Shaman
            //HERO_03 - Rogue
            //HERO_04 - Paladin
            //HERO_05 - Hunter
            //HERO_06 - Druid
            //HERO_07 - Warlock
            //HERO_08 - Mage
            //HERO_09 - Priest

            foreach (HSCard c in cards)
            {
                //Coin (id: GAME_005). Deal with it.
                if(c.Id == "GAME_005") { continue; }

                //Keepeing in hand cards: Undertaker (FP1_028), Leper Gnome (EX1_029), Webspinner (FP1_011), Spectral Spider (FP1_002), Mad Scientist (FP1_004)
                if(c.Id == "FP1_028" || c.Id == "EX1_029" || c.Id == "FP1_011" || c.Id == "FP1_002" || c.Id == "FP1_004")
                {
                   continue;
                }

                //Special rules if our hero is Hunter
                if(oP.Id == "HERO_05")
                {
                  //If opponent is Priest, keep Eaglehorn Bow (EX1_536)
                  if(eP.Id == "HERO_09" && c.Id == "EX1_536")
                  {
                     continue;
                  }
                }

                TritonHS.ToggleMulliganCard(c);

                // Make sure we give the game time to actually click stuff.
                yield return Coroutine.Sleep(1);

            }


            yield return Coroutine.Sleep(2);
            TritonHS.EndMulligan();
        }
    }

}
 
Last edited:
Status
Not open for further replies.
Back
Top