Skip to content

Casting error from Enchantment to ICharacter. #183

@lunjohnzhang

Description

@lunjohnzhang

Hello,

We have implemented a .NETCore Evaluator to iteratively run games. When we try to use the Game.Process(PlayTask gameTask) function to process a game, .NET gives us this error after certain iterations

Unhandled Exception: System.AggregateException: One or more errors occurred. (Unable to cast object of type 'SabberStoneCore.Model.Entities.Enchantment' to type 'SabberStoneCore.Model.Entities.ICharacter'.) ---> System.InvalidCastException: Unable to cast object of type 'SabberStoneCore.Model.Entities.Enchantment' to type 'SabberStoneCore.Model.Entities.ICharacter'.
at SabberStoneCore.Model.Game.Process(PlayerTask gameTask) in /Users/yulunzhang/Desktop/Coding/icaros/hearthstone/SabberStone/SabberStoneCore/src/Model/Game.cs:line 486
at DeckEvaluator.Evaluation.GameEvaluator.PlayGame() in /Users/yulunzhang/Desktop/Coding/icaros/hearthstone/EvoStone/DeckEvaluator/src/Evaluation/GameEvaluator.cs:line 165
at DeckEvaluator.Evaluation.GameDispatcher.runGame(Int32 gameId, GameEvaluator ev) in /Users/yulunzhang/Desktop/Coding/icaros/hearthstone/EvoStone/DeckEvaluator/src/Evaluation/GameDispatcher.cs:line 72
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_01.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion) --- End of stack trace from previous location where exception was thrown --- at System.Threading.Tasks.Parallel.<>c__DisplayClass19_01.b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Replica1.ExecuteAction(Boolean& yieldedBeforeCompletion) at System.Threading.Tasks.TaskReplicator.Replica.Execute() --- End of inner exception stack trace --- at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction1 action, ParallelOptions options, Boolean stopOnFirstFailure)
at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action1 body, Action2 bodyWithState, Func4 bodyWithLocal, Func1 localInit, Action1 localFinally) --- End of stack trace from previous location where exception was thrown --- at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException) at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action1 body, Action2 bodyWithState, Func4 bodyWithLocal, Func1 localInit, Action1 localFinally)
at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body)
at DeckEvaluator.Evaluation.GameDispatcher.Run() in /Users/yulunzhang/Desktop/Coding/icaros/hearthstone/EvoStone/DeckEvaluator/src/Evaluation/GameDispatcher.cs:line 127
at DeckEvaluator.Program.Main(String[] args) in /Users/yulunzhang/Desktop/Coding/icaros/hearthstone/EvoStone/DeckEvaluator/src/Program.cs:line 119
[1] 78423 abort dotnet bin/DeckEvaluator.dll 1

This error exposes a casting error in Game.cs, but when we look through the source code of SabberStone it doesn't seem to have such a casting on the specified place (line 486 of Game.cs). We will appreciate if you can help us with this.

SabberStone version: 2.1.0 (we pull the code from master and compiled it)
.NETCore version: 2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions