예제 #1
0
 private static void ConfiscateSwag(Thief thief, Police police)
 {
     for (int i = 0; i < thief.Swag.Count; i++)
     {
         police.ConfiscatedItems[i].NoOfItems += thief.Swag[i].NoOfItems;
         thief.Swag[i].NoOfItems = 0;
     }
 }
예제 #2
0
        public static string PrintThief(Thief t)
        {
            string s = $"xdir: {t.XDirection}, ydir: {t.YDirection}, " +
                       $"xpos: {t.XPosition}, ypos: {t.YPosition}, ";

            for (int i = 0; i < t.Swag.Count; i++)
            {
                s += $"{t.Swag[i]}, ";
            }
            return(s);
        }
예제 #3
0
 private static void PerformTheft(Citizen citizen, Thief thief)
 {
     if (CheckBelongings(citizen))
     {
         int selectedItem = r.Next(0, citizen.Belongings.Count);
         while (citizen.Belongings[selectedItem].NoOfItems < 1)
         {
             selectedItem = r.Next(0, citizen.Belongings.Count);
         }
         thief.Swag[selectedItem].NoOfItems++;
         citizen.Belongings[selectedItem].NoOfItems--;
     }
 }
예제 #4
0
        private static bool CheckSwag(Thief thief)
        {
            bool hasSwag = false;

            for (int i = 0; i < 4; i++)
            {
                if (thief.Swag[i].NoOfItems > 0)
                {
                    hasSwag = true;
                    break;
                }
            }
            return(hasSwag);
        }
예제 #5
0
 private static void SendToFreedom(Thief thief, List <Thief> prison)
 {
     prison.Remove(thief);
     thief.IsInPrison = false; // Samma tjuv som jag skickade hit genom prison-listan finns väl även i Thief-listan ? dvs båda listorna pekar på samma tjuv?
 }
예제 #6
0
 private static double GetPrisonTime(Thief thief)
 {
     return((DateTime.Now - thief.TimeOfCapture).TotalSeconds);
 }
예제 #7
0
 private static void SendToPrison(Thief thief, List <Thief> prison)
 {
     thief.TimeOfCapture = DateTime.Now;
     prison.Add(thief);
     thief.IsInPrison = true;
 }