예제 #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;
                }
            }
        }
예제 #2
0
 public Errand(ICanPerformErrand actor, ErrandType errandType)
 {
     Actor  = actor;
     Type   = errandType;
     Status = ErrandStatus.Not_Started;
 }
예제 #3
0
        public async Task <PerformErrandResult> PerformErrand(ICanPerformErrand actor, ErrandType errandType)
        {
            var errandToExecute = new Errand(actor, errandType)
            {
                Status = ErrandStatus.In_Progress
            };
            var performanceResult = new PerformErrandResult(actor, errandToExecute);

            await AttemptToFailErrand(actor, errandType, errandToExecute, performanceResult);

            if (ErrandDidNotFail(errandToExecute))
            {
                errandToExecute.Status = ErrandStatus.Completed;
            }
            await CompleteErrand(actor, errandToExecute);

            return(performanceResult);
        }