Example #1
0
        private async Task AttemptToFailErrand(ICanPerformErrand actor, ErrandType errandType, Errand errand, PerformErrandResult result)
        {
            //higher actorTypes have extra chances to kill an opponent, but have extra 'dice rolls' to fail their task
            foreach (var item in Enumerable.Range(0, ((int)actor.ActorType) + 1))
            {
                _stopwatch.Start();
                Thread.Sleep((int)errandType / ((int)actor.ActorType + 1) + _randomGenerator.Next(1000));
                if (TaskedFailedDiceRoll())
                {
                    //actor destroyed the errand task!!!!
                    errand.Status          = ErrandStatus.Failed;
                    result.TerminatedActor = await _battleService.KillAnotherActor(actor);

                    break;
                }
            }
        }