Advertisement
Guest User

Untitled

a guest
Apr 4th, 2020
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.11 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Clones
  4. {
  5.     public class CloneVersionSystem : ICloneVersionSystem
  6.     {
  7.         System.Collections.Generic.List<CloneNigga> cloneNigs = new System.Collections.Generic.List<CloneNigga> { new CloneNigga() };
  8.  
  9.         public string Execute(string nigga)
  10.         {
  11.             nigga = ':' + nigga;
  12.             if (nigga.Contains(":learn"))
  13.             {
  14.                 string[] crutch = nigga.Split(' ');
  15.                 var crutch2 = int.Parse(crutch[1]) - 1;
  16.                 if (cloneNigs[crutch2].programKnown == null)
  17.                 {
  18.                     cloneNigs[crutch2].programKnown = new Deck<int?>(int.Parse(crutch[2]), cloneNigs[crutch2].programKnown);
  19.                 }
  20.                 else
  21.                 {
  22.                     cloneNigs[crutch2].programKnown.next = new Deck<int?>(int.Parse(crutch[2]), cloneNigs[crutch2].programKnown, true);
  23.                     cloneNigs[crutch2].programKnown = cloneNigs[crutch2].programKnown.next;
  24.                 }
  25.             }
  26.             if (nigga.Contains(":rollback"))
  27.             {
  28.                 string[] crutch = nigga.Split(' ');
  29.                 var crutch2 = int.Parse(crutch[1]) - 1;
  30.                 if (cloneNigs[crutch2].programKnown != null)
  31.                 {
  32.                     if (cloneNigs[crutch2].programKnown.previous == null)
  33.                     {
  34.                         var crutchh = cloneNigs[crutch2].programKnown;
  35.                         cloneNigs[crutch2].programKnown = cloneNigs[crutch2].programKnown.previous = new Deck<int?>();
  36.                         cloneNigs[crutch2].programKnown.next = crutchh;
  37.                         cloneNigs[crutch2].programKnown.Value = null;
  38.                     }
  39.                     else
  40.                     {
  41.                         if (cloneNigs[crutch2].cloned == false)
  42.                             cloneNigs[crutch2].programKnown = cloneNigs[crutch2].programKnown.previous;
  43.                         else
  44.                         {
  45.                             var crutchh = cloneNigs[crutch2].programKnown;
  46.                             cloneNigs[crutch2].programKnown = cloneNigs[crutch2].programKnown.previous = new Deck<int?>() { Value = cloneNigs[crutch2].programKnown.Value ?? null, next = crutchh, previous = crutchh.previous.previous ?? null };
  47.                         }
  48.                     }
  49.                 }
  50.             }
  51.             if (nigga.Contains(":relearn"))
  52.             {
  53.                 string[] crutch = nigga.Split(' ');
  54.                 var crutch2 = int.Parse(crutch[1]) - 1;
  55.                 if (cloneNigs[crutch2].cloned == false)
  56.                     cloneNigs[crutch2].programKnown = cloneNigs[crutch2].programKnown.next;
  57.                 else
  58.                 {
  59.                     var crutchh = cloneNigs[crutch2].programKnown;
  60.                     cloneNigs[crutch2].programKnown = cloneNigs[crutch2].programKnown.next = new Deck<int?>() { Value = cloneNigs[crutch2].programKnown.next.Value ?? null, next = crutchh.next.next ?? null, previous = crutchh };
  61.                 }
  62.             }
  63.             if (nigga.Contains(":clone"))
  64.             {
  65.                 string[] crutch = nigga.Split(' ');
  66.                 var crutch2 = int.Parse(crutch[1]) - 1; ;
  67.                 cloneNigs.Add(cloneNigs[crutch2].Clone());
  68.             }
  69.             if (nigga.Contains(":check"))
  70.             {
  71.                 string[] crutch = nigga.Split(' ');
  72.                 var crutch2 = int.Parse(crutch[1]) - 1;
  73.                 if (cloneNigs[crutch2].programKnown != null && cloneNigs[crutch2].programKnown.Value != null)
  74.                 {
  75.                     return cloneNigs[crutch2].programKnown.Value.ToString();
  76.                 }
  77.                 else
  78.                 {
  79.                     return "basic";
  80.                 }
  81.             }
  82.             return null;
  83.         }
  84.     }
  85.  
  86.     public class CloneNigga
  87.     {
  88.         public Deck<int?> programKnown;
  89.         public bool cloned = false;
  90.  
  91.         public CloneNigga Clone()
  92.         {
  93.             if (programKnown != null)
  94.                 return new CloneNigga { programKnown = new Deck<int?>() { Value = this.programKnown.Value ?? null, next = this.programKnown.next ?? null, previous = this.programKnown.previous ?? null }, cloned = true };
  95.             else
  96.                 return new CloneNigga { cloned = true };
  97.         }
  98.     }
  99.  
  100.     public class Deck<T>
  101.     {
  102.         public Deck<T> previous = null;
  103.         public Deck<T> next = null;
  104.  
  105.         public T Value
  106.         {
  107.             get; set;
  108.         }
  109.  
  110.         public Deck()
  111.         {
  112.             this.Value = default(T);
  113.         }
  114.  
  115.         public Deck(T value)
  116.         {
  117.             this.Value = value;
  118.         }
  119.  
  120.         public Deck(T value, Deck<T> nigga, bool what = true)
  121.         {
  122.             this.Value = value;
  123.             if (what)
  124.                 previous = nigga;
  125.             else
  126.                 next = nigga;
  127.         }
  128.  
  129.         public static Deck<T> CopyDeck(Deck<T> nigga)
  130.         {
  131.             if (nigga == null)
  132.                 return nigga;
  133.  
  134.             //Deck<T> flask = new Deck<T>(nigga.Value);
  135.             //switch (marker)
  136.             //{
  137.             //    case 0:
  138.             //        flask.next = CopyDeck(nigga.next, 1);
  139.             //        flask.previous = CopyDeck(nigga.previous, -1);
  140.             //        if (flask.next != null)
  141.             //            flask.next.previous = flask;
  142.             //        if (flask.previous != null)
  143.             //            flask.previous.next = flask;
  144.             //        break;
  145.             //    case 1:
  146.             //        flask.next = CopyDeck(nigga.next, 1);
  147.             //        if(flask.next != null)
  148.             //            flask.next.previous = flask;
  149.             //        break;
  150.             //    case -1:
  151.             //        flask.previous = CopyDeck(nigga.previous, -1);
  152.             //        if (flask.previous != null)
  153.             //            flask.previous.next = flask;
  154.             //        break;
  155.             //}
  156.             //return flask;
  157.  
  158.             Deck<T> flask = new Deck<T>(nigga.Value);
  159.  
  160.             var crutch = nigga.previous;
  161.             var crutch2 = new Deck<T>();
  162.             if (crutch != null)
  163.             {
  164.                 crutch2 = flask.previous = new Deck<T>();
  165.                 crutch2.next = flask;
  166.             }
  167.             while (crutch != null)
  168.             {
  169.                 crutch2.Value = crutch.Value;
  170.                 crutch2.previous = new Deck<T>();
  171.                 crutch2.previous.next = crutch2;
  172.                 crutch2 = crutch2.previous;
  173.                 crutch = crutch.previous;
  174.             }
  175.             crutch = nigga.next;
  176.             if (crutch != null)
  177.             {
  178.                 crutch2 = flask.next = new Deck<T>();
  179.                 crutch2.previous = flask;
  180.             }
  181.             while (crutch != null)
  182.             {
  183.                 crutch2.Value = crutch.Value;
  184.                 crutch2.next = new Deck<T>();
  185.                 crutch2.next.previous = crutch2;
  186.                 crutch2 = crutch2.next;
  187.                 crutch = crutch.next;
  188.             }
  189.             return flask;
  190.         }
  191.     }
  192. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement