コード例 #1
0
        public static string GetProspectsMessage(Player player)
        {
            IInanimateXPRepository inanimXpRepo = new EFInanimateXPRepository();
            IItemRepository        itemRep      = new EFItemRepository();

            var inanimateMe = DomainRegistry.Repository.FindSingle(new GetItemByFormerPlayer {
                PlayerId = player.Id
            });

            if (inanimateMe == null)
            {
                return("");
            }

            var meItem   = itemRep.Items.FirstOrDefault(i => i.Id == inanimateMe.Id);
            var myItemXP = inanimXpRepo.InanimateXPs.FirstOrDefault(i => i.OwnerId == player.Id);

            if (meItem == null || myItemXP == null)
            {
                return(null);
            }

            var turnsSinceLastAction = Math.Max(0, PvPWorldStatProcedures.GetWorldTurnNumber() - myItemXP.LastActionTurnstamp);

            // Time until lock - at 2% per turn  (negative threshold)
            var turnsUntilLocked = (myItemXP.TimesStruggled - TurnTimesStatics.GetStruggleXPBeforeItemPermanentLock()) / 2 - turnsSinceLastAction;

            if (!meItem.IsPermanent && turnsUntilLocked <= TurnTimesStatics.GetItemMaxTurnsBuildup())
            {
                if (turnsUntilLocked <= 1)
                {
                    return("<b style=\"color: red;\">Be careful!</b>  Just one more move and you might never be human again!");
                }
                else
                {
                    var time = turnsUntilLocked * TurnTimesStatics.GetTurnLengthInSeconds();

                    return($"If you keep enjoying your current form you might find yourself locked into it forever!  That could happen in as little as <b>{SecondsToDurationString(time)}</b> or so!");
                }
            }

            // Time until chance of escaping - at 1% per turn outside Chaos
            var turnsUntilAbleToStruggle = 1 - myItemXP.TimesStruggled - turnsSinceLastAction;

            if (ItemProcedures.ItemIncursDungeonPenalty(inanimateMe))
            {
                turnsUntilAbleToStruggle *= 3;
            }

            if (!PvPStatics.ChaosMode && turnsUntilAbleToStruggle > 1 && turnsUntilAbleToStruggle <= TurnTimesStatics.GetItemMaxTurnsBuildup())
            {
                var time = turnsUntilAbleToStruggle * TurnTimesStatics.GetTurnLengthInSeconds();

                return($"You could be free in approximately <b>{SecondsToDurationString(time)}</b> if you keep fighting!");
            }

            return(null);
        }