示例#1
0
        public static void BeginDuel(int duelId)
        {
            IDuelRepository duelRepo = new EFDuelRepository();
            var             duel     = duelRepo.Duels.FirstOrDefault(d => d.Id == duelId);

            duel.StartTurn = PvPWorldStatProcedures.GetWorldTurnNumber();
            duel.Status    = ACTIVE;

            var members     = GetPlayerViewModelsInDuel(duelId);
            var memberNames = "";

            foreach (var p in members)
            {
                memberNames += p.Player.GetFullName() + ", ";
            }

            foreach (var p in members)
            {
                duel.Combatants.FirstOrDefault(f => f.PlayerId == p.Player.Id).StartFormSourceId = p.Player.FormSourceId;
                PlayerProcedures.EnterDuel(p.Player.Id, duel.Id);
                var playerMessage = "<b>Your duel between " + memberNames + " has begun!</b>";
                PlayerLogProcedures.AddPlayerLog(p.Player.Id, playerMessage, true);
            }

            LocationLogProcedures.AddLocationLog(members.First().Player.dbLocationName, "<b class='playerAttackNotification'>A duel started here.</b>");

            duelRepo.SaveDuel(duel);
        }
示例#2
0
        public static void EndDuel(int duelId, string endStatus)
        {
            IDuelRepository duelRepo = new EFDuelRepository();
            var             duel     = duelRepo.Duels.FirstOrDefault(d => d.Id == duelId);

            duel.CompletionTurn = PvPWorldStatProcedures.GetWorldTurnNumber();
            duel.Status         = endStatus;

            duelRepo.SaveDuel(duel);

            foreach (var d in duel.Combatants)
            {
                PlayerProcedures.EnterDuel(d.PlayerId, 0);

                var message = "";

                if (endStatus == TIMEOUT)
                {
                    message = "<b class='bad'>Your duel has timed out, ending in a disappointing draw.  You feel as if some frustrated spirits have left you weakened by a curse...</b>";
                    EffectProcedures.GivePerkToPlayer(TimeoutCurseEffectSourceId, d.PlayerId);
                }
                else
                {
                    message = "<b>Your duel has ended.</b>";
                }

                PlayerLogProcedures.AddPlayerLog(d.PlayerId, message, true);
            }
        }