Exemplo n.º 1
0
 public WeeklyController()
 {
     NfManager     = new NightFallManager();
     VendorManager = new VendorManager();
     PrisonManager = new PrisonManager();
     BountyManager = new BountyManager();
 }
Exemplo n.º 2
0
        public static void ReleaseFromPrison(CommandArgs args)
        {
            if (args.Parameters.Count < 1 || args.Parameters.Count > 1)
            {
                args.Player.SendMessage("Invalid syntax! Proper syntax: /releaseprisoner <user>", Color.Red);
                return;
            }

            PrisonManager manager = new PrisonManager(TShock.DB);

            PrisonHelper prisoner = manager.GetPrisonerUser(args.Parameters[0]);

            if (prisoner != null)
            {
                Release(manager, prisoner);

                if (args.Player != null)
                {
                    args.Player.SendMessage("Prisoner has been released.", Color.Green);
                }
            }
            else
            {
                if (args.Player != null)
                {
                    args.Player.SendMessage("No prisoner matched your query", Color.Red);
                }
            }
        }
        public IContainer GetContainerById(string id)
        {
            Container tempResult = null;
            Container result     = null;

            try
            {
                var prison = PrisonManager.LoadPrisonAndAttach(new Guid(id));
                if (prison == null)
                {
                    return(null);
                }

                tempResult = new Container(prison);
                result     = tempResult;
                tempResult = null;
            }
            finally
            {
                if (result != null)
                {
                    result.Dispose();
                }
            }

            return(result);
        }
Exemplo n.º 4
0
        public void LoadPrison()
        {
            // Arrange
            PrisonConfiguration prisonRules = new PrisonConfiguration();

            prisonRules.PrisonHomeRootPath = @"c:\prison_tests\p1";
            prisonRules.Rules = RuleTypes.WindowStation;

            prison.Lockdown(prisonRules);

            // Act
            var prisonLoaded = PrisonManager.LoadPrisonAndAttach(prison.Id);

            Process process = prison.Execute(
                @"c:\windows\system32\cmd.exe",
                @"/c exit 667");

            process.WaitForExit();


            // Assert
            Process process2 = prisonLoaded.Execute(
                @"c:\windows\system32\cmd.exe",
                @"/c exit 667");

            process2.WaitForExit();

            // Assert
            Assert.AreEqual(667, process.ExitCode);
        }
Exemplo n.º 5
0
        public static void ClearPrison(CommandArgs args)
        {
            PrisonManager manager = new PrisonManager(TShock.DB);

            foreach (PrisonHelper prioner in manager.GetAllCurrentPrisoners())
            {
                Release(manager, prioner);
            }
        }
        public void DestroyContainer(string id)
        {
            var p = PrisonManager.LoadPrisonAndAttach(new Guid(id));

            if (p == null)
            {
                throw new ArgumentException("Container ID not found");
            }

            p.Destroy();
        }
        public string[] ListContainerIds()
        {
            var res = new List <string>();
            var all = PrisonManager.ReadAllPrisonsNoAttach();

            foreach (var p in all)
            {
                res.Add(p.Id.ToString());
            }

            return(res.ToArray());
        }
Exemplo n.º 8
0
    public PrisonCell(PrisonManager manager, IMyMotorStator rotor)
    {
        this.rotor   = rotor;
        this.manager = manager;

        var m = Util.NameRegex(rotor, PrisonManager.CellPattern);

        if (m.Success)
        {
            this.id = int.Parse(m.Groups[1].Value);
            InitChambers();
        }
    }
Exemplo n.º 9
0
 override protected void Start()
 {
     _PersoManager  = GameObject.Find("GameManager").GetComponent <PersoManager>();
     _prisonManager = GameObject.Find("GameManager").GetComponent <PrisonManager>();
     _monSon        = GetComponent <AudioSource>();
     imgLevier      = transform.Find("AfficheLevier");
     if (_door)
     {
         if (_maPrison == PrisonManager.Prison.c0)
         {
             toggleLevier();
         }
     }
 }
Exemplo n.º 10
0
        private void ServerHooks_Join(int ply, HandledEventArgs args)
        {
            var tPlayer = TShock.Players[ply];
            var player  = new ExtendedTSPlayer(tPlayer);

            Players[ply] = player;

            PrisonManager prisonManager = new PrisonManager(TShock.DB);

            if (prisonManager.IPInPrison(player.Player.IP))
            {
                player.PrisonRecord = prisonManager.GetPrisonRecordByIP(player.Player.IP);
            }
        }
Exemplo n.º 11
0
        public void SavePrison()
        {
            // Arrange
            PrisonConfiguration prisonRules = new PrisonConfiguration();

            prisonRules.PrisonHomeRootPath = @"c:\prison_tests\p1";
            prisonRules.Rules = RuleTypes.None;

            // Act
            prison.Lockdown(prisonRules);

            // Assert
            Assert.IsTrue(PrisonManager.ReadAllPrisonsNoAttach().Any(p => p.Id == prison.Id));
        }
Exemplo n.º 12
0
        public static bool Prefix(ref NitrogenLevel __instance, Player player)
        {
            if (GameModeUtils.RequiresOxygen() && !PrisonManager.IsInsideAquarium(player.gameObject.transform.position))
            {
                float depthOf = Ocean.main.GetDepthOf(player.gameObject);

                // Player's personal crush depth
                if (crushEnabled)
                {
                    if (Player.main.GetDepthClass() == Ocean.DepthClass.Crush)
                    {
                        if (!crushed)
                        {
                            ErrorMessage.AddMessage("Personal crush depth exceeded. Return to safe depth!");
                            crushed = true;
                        }
                        if (UnityEngine.Random.value < 0.5f)
                        {
                            float crushDepth = DeathRun.saveData.playerSave.crushDepth;
                            if (depthOf > crushDepth)
                            {
                                float crush = depthOf - crushDepth;
                                if (crush < 50)
                                {
                                    DamagePlayer(4);
                                }
                                else if (crush < 100)
                                {
                                    DamagePlayer(8);
                                }
                                else if (crush < 200)
                                {
                                    DamagePlayer(16);
                                }
                                else
                                {
                                    DamagePlayer(32); // "Okay, Sparky..."
                                }
                            }
                        }
                    }
                    else
                    {
                        crushed = false;
                    }
                }
            }
            return(false);
        }
Exemplo n.º 13
0
        public static void ExtendSentence(CommandArgs args)
        {
            if (args.Parameters.Count < 2 || args.Parameters.Count > 2)
            {
                args.Player.SendMessage("Invalid syntax! Proper syntax: /extendsentence <player> <minutes>", Color.Red);
                return;
            }

            var player = TShock.Utils.FindPlayer(args.Parameters[0]);

            if (player.Count == 0)
            {
                args.Player.SendMessage("No player found with that query.", Color.Red);
                return;
            }

            if (player.Count > 1)
            {
                args.Player.SendMessage("More than one player matched query.", Color.Red);
                return;
            }

            if (args.Parameters[1].ToIntegerOrDefault(-1) < 1)
            {
                args.Player.SendMessage("Invalid number of minutes.", Color.Red);
                return;
            }

            PrisonManager manager = new PrisonManager(TShock.DB);

            if (manager.IPInPrison(player[0].IP))
            {
                manager.ExtendSentence(player[0], args.Parameters[1].ToIntegerOrDefault(-1));

                var ePlayer = ExtendedAdmin.Players[player[0].Index];

                ePlayer.PrisonRecord.Until = ePlayer.PrisonRecord.Until.AddMinutes(args.Parameters[1].ToIntegerOrDefault(-1));

                ePlayer.Player.SendMessage(string.Format("Your sentence has been extended by {0} minute(s)", args.Parameters[1].ToIntegerOrDefault(-1)), Color.Red);

                TShock.Utils.Broadcast(string.Format("{0}'s sentence has been extended!", ePlayer.Player.Name), Color.Goldenrod);
            }
            else
            {
                args.Player.SendMessage("Player is not currently in prison.", Color.Red);
                return;
            }
        }
Exemplo n.º 14
0
        public void LoadedPrisonIsLocked()
        {
            // Arrange
            PrisonConfiguration prisonRules = new PrisonConfiguration();

            prisonRules.PrisonHomeRootPath = @"c:\prison_tests\p1";
            prisonRules.Rules = RuleTypes.WindowStation;

            prison.Lockdown(prisonRules);

            // Act
            var prisonLoaded = PrisonManager.LoadPrisonAndAttach(prison.Id);

            // Assert
            Assert.IsTrue(prisonLoaded.IsLocked);
        }
Exemplo n.º 15
0
    public PrisonCell(PrisonManager manager, IMyMotorStator rotor)
    {
        this.rotor   = rotor;
        this.manager = manager;

        var m = Util.NameRegex(rotor, PrisonManager.CellPattern);

        if (m.Success)
        {
            this.id = int.Parse(m.Groups[1].Value);
            InitChambers();
            InitIndicator();
            UpdateIndicator();
        }
        else
        {
            throw ArgumentException("Unable to create Prison Cell for " + rotor);
        }
    }
Exemplo n.º 16
0
        private static void Release(PrisonManager manager, PrisonHelper prioner)
        {
            manager.Release(prioner.PrisonID);

            var player = TShock.Players.FirstOrDefault(p => p != null && p.UserAccountName == prioner.User && p.RealPlayer);

            UpdateGroup(player, prioner.User, prioner.Group);

            if (player != null)
            {
                var ePlayer = ExtendedAdmin.Players[player.Index];

                ePlayer.PrisonRecord = null;

                player.Teleport(Main.spawnTileX, Main.spawnTileY);
                player.SendMessage("You have been freed from prison", Color.Green);
                TShock.Utils.Broadcast(string.Format("{0} has been released from prison!", player.Name), Color.Goldenrod);
            }
        }
Exemplo n.º 17
0
        public ActionResult Destiny1Index(bool noLayout = false)
        {
            if (CacheExpired)
            {
                var featuredRaid       = VendorManager.GetFeaturedRaid();
                var weekly             = NfManager.GetWeekly();
                var weeklyBounties     = BountyManager.GetBounties("Strike");
                var raidChallenges     = VendorManager.GetRaidChallenges();
                var challengeElders    = PrisonManager.GetDetailedChallenge();
                var weeklyCrucible     = NfManager.GetDetailedCrucibleWeekly();
                var ironBannerBounties = BountyManager.GetWeeklyBounties("IronBanner");
                var ironBannerRewards  = BountyManager.GetWeeklyRewards("IronBanner");
                var weeklyPlaylist     = NfManager.GetWeeklyStory();

                Cache = new WeeklyDataModel()
                {
                    ThisWeekly         = weekly,
                    StrikeBounties     = weeklyBounties,
                    RaidChallenges     = raidChallenges,
                    EldersChallenge    = challengeElders,
                    WeeklyCrucible     = weeklyCrucible,
                    IronBannerBounties = ironBannerBounties,
                    IronBannerRewards  = ironBannerRewards,
                    FeaturedRaid       = featuredRaid,
                    WeeklyPlaylist     = weeklyPlaylist,
                    ExpiryTime         = DateTime.Now.AddHours(1),
                    StartTime          = DateTime.Now
                };
            }

            if (noLayout)
            {
                return(View("Destiny1/PartialIndex", Cache));
            }
            else
            {
                ViewBag.HtmlTagOverride = @"data-redirect=""/#weekly""";
                return(View("Destiny1/Index", Cache));
            }
        }
Exemplo n.º 18
0
 void Start()
 {
     manager   = GameObject.Find("GameStateManager").GetComponent <PrisonManager> ();
     inventory = GameObject.Find("FirstPersonCharacter").GetComponent <Interact> ();
     player    = GameObject.Find("Player");
 }
Exemplo n.º 19
0
        public static void SendToPrison(CommandArgs args)
        {
            if (args.Parameters.Count < 2 || args.Parameters.Count > 2)
            {
                args.Player.SendMessage("Invalid syntax! Proper syntax: /sendtoprison <player> <minutes>", Color.Red);
                return;
            }

            var player = TShock.Utils.FindPlayer(args.Parameters[0]);

            if (player == null || player.Count == 0)
            {
                args.Player.SendMessage("No player matched your query.", Color.Red);
                return;
            }

            if (player.Count > 1)
            {
                args.Player.SendMessage("More than one player matched your query.", Color.Red);
                return;
            }

            int minutes = args.Parameters[1].ToIntegerOrDefault(-1);

            if (minutes < 1)
            {
                args.Player.SendMessage("Invalid number of minutes.", Color.Red);
                return;
            }

            ExtendedTSPlayer ePlayer = ExtendedAdmin.Players[player[0].Index];

            PrisonManager manager = new PrisonManager(TShock.DB);

            manager.AddPrisonRecord(player[0], DateTime.Now.AddMinutes(minutes));

            ServerPointSystem.ServerPointSystem.Deduct(new CommandArgs("deduct", player[0], new List <string>()
            {
                player[0].Name,
                ExtendedAdmin.Config.PrisonShards.ToString()
            }));

            UpdateGroup(player[0], player[0].UserAccountName, ExtendedAdmin.Config.PrisonGroup);

            ePlayer.PrisonRecord = manager.GetPrisonerUser(player[0].UserAccountName);

            var warp = TShock.Warps.FindWarp(ExtendedAdmin.Config.PrisonWarp);

            if (warp.WarpPos != Vector2.Zero)
            {
                player[0].Teleport((int)warp.WarpPos.X, (int)warp.WarpPos.Y + 3);
            }
            else
            {
                player[0].Spawn();
            }

            args.Player.SendMessage("Player sent to prison.", Color.Green);
            player[0].SendMessage(string.Format("You have been sent to prison for {0} minute(s)", minutes), Color.Red);
            TShock.Utils.Broadcast(string.Format("{0} has been sent to prison!", player[0].Name), Color.Goldenrod);
        }
Exemplo n.º 20
0
 void Start()
 {
     inventoryScript = GameObject.Find("Player").transform.GetChild(0).GetComponent <Interact> ();
     manager         = GameObject.Find("GameStateManager").GetComponent <PrisonManager> ();
 }
Exemplo n.º 21
0
 // Start is called before the first frame update
 void Start()
 {
     manager = GameObject.Find("GameStateManager").GetComponent <PrisonManager> ();
 }
Exemplo n.º 22
0
 void Start()
 {
     playerTransform = GameObject.Find("Player").transform;
     manager         = GameObject.Find("GameStateManager").GetComponent <PrisonManager> ();
     InvokeRepeating("Wander", wanderRate, wanderRate);
 }