Skip to content

Commit

Permalink
Fix Augmented Elekk
Browse files Browse the repository at this point in the history
  • Loading branch information
azeier committed Apr 13, 2019
1 parent e539e0e commit 13955ae
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 26 deletions.
47 changes: 27 additions & 20 deletions Hearthstone Deck Tracker/LogReader/Handlers/PowerHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,19 +138,6 @@ public void Handle(string logLine, IHsGameState gameState, IGame game)
Log.Info($"Found known cardId for entity {id}: {cardId}");
gameState.KnownCardIds[blockId.Value].Remove(cardId);
}
if(gameState.CurrentBlock.Parent != null)
gameState.CurrentBlock.Parent.LastAddedCardId = cardId;
}
else if(blockId.HasValue && !gameState.KnownCardIds.ContainsKey(blockId.Value))
{
if(gameState.CurrentBlock.CardId == Collectible.Neutral.AugmentedElekk)
{
if(gameState.CurrentBlock.Parent != null)
cardId = gameState.CurrentBlock.Parent.LastAddedCardId;

if(!string.IsNullOrEmpty(cardId))
Log.Info($"Found known cardId for entity {id}: {cardId}");
}
}
}
game.Entities.Add(id, new Entity(id) {CardId = cardId});
Expand Down Expand Up @@ -233,7 +220,8 @@ public void Handle(string logLine, IHsGameState gameState, IGame game)
var match = BlockStartRegex.Match(logLine);
var blockType = match.Success ? match.Groups["type"].Value : null;
var cardId = match.Success ? match.Groups["Id"].Value : null;
gameState.BlockStart(blockType, cardId);
var target = GetTargetCardId(match);
gameState.BlockStart(blockType, cardId, target);

if(match.Success && (blockType == "TRIGGER" || blockType == "POWER"))
{
Expand All @@ -249,7 +237,7 @@ public void Handle(string logLine, IHsGameState gameState, IGame game)

if(string.IsNullOrEmpty(actionStartingCardId))
{
if(game.Entities.TryGetValue(actionStartingEntityId, out Entity actionEntity))
if(game.Entities.TryGetValue(actionStartingEntityId, out var actionEntity))
actionStartingCardId = actionEntity.CardId;
}
if(string.IsNullOrEmpty(actionStartingCardId))
Expand All @@ -264,6 +252,15 @@ public void Handle(string logLine, IHsGameState gameState, IGame game)
{
actionStartingCardId = cardId;
}
if(blockType == "TRIGGER" && actionStartingCardId == Collectible.Neutral.AugmentedElekk)
{
if(gameState.CurrentBlock.Parent != null)
{
actionStartingCardId = gameState.CurrentBlock.Parent.CardId;
blockType = gameState.CurrentBlock.Parent.Type;
target = gameState.CurrentBlock.Parent.Target;
}
}
if(blockType == "TRIGGER")
{
switch(actionStartingCardId)
Expand All @@ -284,11 +281,11 @@ public void Handle(string logLine, IHsGameState gameState, IGame game)
AddKnownCardId(gameState, NonCollectible.Warrior.DirehornHatchling_DirehornMatriarchToken);
break;
case Collectible.Mage.FrozenClone:
AddKnownCardId(gameState, GetTargetCardId(match), 2);
AddKnownCardId(gameState, target, 2);
break;
case Collectible.Shaman.Moorabi:
case Collectible.Rogue.SonyaShadowdancer:
AddKnownCardId(gameState, GetTargetCardId(match));
AddKnownCardId(gameState, target);
break;
case Collectible.Neutral.HoardingDragon:
AddKnownCardId(gameState, NonCollectible.Neutral.TheCoin, 2);
Expand All @@ -308,14 +305,16 @@ public void Handle(string logLine, IHsGameState gameState, IGame game)
case Collectible.Neutral.SparkDrill:
AddKnownCardId(gameState, NonCollectible.Neutral.SparkDrill_SparkToken, 2);
break;
//TODO: Augmented Elekk
case NonCollectible.Neutral.HakkartheSoulflayer_CorruptedBloodToken:
AddKnownCardId(gameState, NonCollectible.Neutral.HakkartheSoulflayer_CorruptedBloodToken, 2);
break;
//TODO: Gral, the Shark?
case Collectible.Paladin.ImmortalPrelate:
AddKnownCardId(gameState, Collectible.Paladin.ImmortalPrelate);
break;
case Collectible.Warrior.Wrenchcalibur:
AddKnownCardId(gameState, NonCollectible.Neutral.SeaforiumBomber_BombToken);
break;
}
}
else //POWER
Expand All @@ -325,7 +324,7 @@ public void Handle(string logLine, IHsGameState gameState, IGame game)
case Collectible.Rogue.GangUp:
case Collectible.Hunter.DireFrenzy:
case Collectible.Rogue.LabRecruiter:
AddKnownCardId(gameState, GetTargetCardId(match), 3);
AddKnownCardId(gameState, target, 3);
break;
case Collectible.Rogue.BeneathTheGrounds:
AddKnownCardId(gameState, NonCollectible.Rogue.BeneaththeGrounds_NerubianAmbushToken, 3);
Expand All @@ -341,7 +340,7 @@ public void Handle(string logLine, IHsGameState gameState, IGame game)
case Collectible.Neutral.BalefulBanker:
case Collectible.Neutral.DollmasterDorian:
case Collectible.Priest.Seance:
AddKnownCardId(gameState, GetTargetCardId(match));
AddKnownCardId(gameState, target);
break;
case Collectible.Mage.ForgottenTorch:
AddKnownCardId(gameState, NonCollectible.Mage.ForgottenTorch_RoaringTorchToken);
Expand Down Expand Up @@ -422,6 +421,7 @@ public void Handle(string logLine, IHsGameState gameState, IGame game)
AddKnownCardId(gameState, NonCollectible.Priest.ExtraArms_MoreArmsToken);
break;
case Collectible.Neutral.SeaforiumBomber:
case Collectible.Warrior.ClockworkGoblin:
AddKnownCardId(gameState, NonCollectible.Neutral.SeaforiumBomber_BombToken);
break;
//case Collectible.Rogue.Wanted: -- TODO
Expand All @@ -438,6 +438,13 @@ public void Handle(string logLine, IHsGameState gameState, IGame game)
case Collectible.Neutral.BootyBayBookie:
AddKnownCardId(gameState, NonCollectible.Neutral.TheCoin);
break;
case Collectible.Neutral.PortalKeeper:
case Collectible.Neutral.PortalOverfiend:
AddKnownCardId(gameState, NonCollectible.Neutral.PortalKeeper_FelhoundPortalToken);
break;
case Collectible.Rogue.TogwagglesScheme:
AddKnownCardId(gameState, target);
break;
default:
if(playerEntity.Value != null && playerEntity.Value.GetTag(GameTag.CURRENT_PLAYER) == 1
&& !gameState.PlayerUsedHeroPower
Expand Down
11 changes: 6 additions & 5 deletions Hearthstone Deck Tracker/LogReader/HsGameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public void SetCurrentEntity(int id)
private int _maxBlockId;
public Block CurrentBlock { get; private set; }

public void BlockStart(string type, string cardId)
public void BlockStart(string type, string cardId, string target)
{
var blockId = _maxBlockId++;
CurrentBlock = CurrentBlock?.CreateChild(blockId, type, cardId) ?? new Block(null, blockId, type, cardId);
CurrentBlock = CurrentBlock?.CreateChild(blockId, type, cardId, target) ?? new Block(null, blockId, type, cardId, target);
}

public void BlockEnd()
Expand All @@ -89,19 +89,20 @@ public class Block
public int Id { get; }
public string Type { get; }
public string CardId { get; }
public string Target { get; }

public string LastAddedCardId { get; set; }
public Entity EntityDiscardedByArchivist { get; set; }

public Block(Block parent, int blockId, string type, string cardId)
public Block(Block parent, int blockId, string type, string cardId, string target)
{
Parent = parent;
Children = new List<Block>();
Id = blockId;
Type = type;
CardId = cardId;
Target = target;
}

public Block CreateChild(int blockId, string type, string cardId) => new Block(this, blockId, type, cardId);
public Block CreateChild(int blockId, string type, string cardId, string target) => new Block(this, blockId, type, cardId, target);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public interface IHsGameState
void Reset();
void SetCurrentEntity(int id);
void ResetCurrentEntity();
void BlockStart(string type, string cardId);
void BlockStart(string type, string cardId, string target);
void BlockEnd();
Block CurrentBlock { get; }
Tuple<int, string> ChameleosReveal { get; set; }
Expand Down

0 comments on commit 13955ae

Please sign in to comment.