Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.57 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.                 cloneNigs[crutch2].programKnown.next = new Deck<int>(int.Parse(crutch[2]), cloneNigs[crutch2].programKnown, true);
  17.                 cloneNigs[crutch2].programKnown = cloneNigs[crutch2].programKnown.next;
  18.             }
  19.             if (nigga.Contains(":rollback"))
  20.             {
  21.                 string[] crutch = nigga.Split(' ');
  22.                 var crutch2 = int.Parse(crutch[1]) - 1;
  23.                 if (cloneNigs[crutch2].programKnown.previous != null)
  24.                 {
  25.                     //if (!cloneNigs[crutch2].cloned)
  26.                     cloneNigs[crutch2].programKnown = cloneNigs[crutch2].programKnown.previous;
  27.                     //else
  28.                     //{
  29.                     //    cloneNigs[crutch2].programKnown = new Deck<int> { Value = cloneNigs[crutch2].programKnown.previous.Value, next = cloneNigs[crutch2].programKnown };
  30.                     //}
  31.                 }
  32.             }
  33.             if (nigga.Contains(":relearn"))
  34.             {
  35.                 string[] crutch = nigga.Split(' ');
  36.                 var crutch2 = int.Parse(crutch[1]) - 1;
  37.                 cloneNigs[crutch2].programKnown = cloneNigs[crutch2].programKnown.next;
  38.             }
  39.             if (nigga.Contains(":clone"))
  40.             {
  41.                 string[] crutch = nigga.Split(' ');
  42.                 var crutch2 = int.Parse(crutch[1]) - 1; ;
  43.                 cloneNigs.Add(cloneNigs[crutch2].Clone());
  44.             }
  45.             if (nigga.Contains(":check"))
  46.             {
  47.                 string[] crutch = nigga.Split(' ');
  48.                 var crutch2 = int.Parse(crutch[1]) - 1;
  49.                 if (cloneNigs[crutch2].programKnown.previous != null)
  50.                 {
  51.                     return cloneNigs[crutch2].programKnown.Value.ToString();
  52.                 }
  53.                 else
  54.                 {
  55.                     return "basic";
  56.                 }
  57.             }
  58.             return null;
  59.         }
  60.     }
  61.  
  62.     public class CloneNigga
  63.     {
  64.         public Deck<int> programKnown = new Deck<int>();
  65.         public bool cloned = false;
  66.  
  67.         public CloneNigga Clone()
  68.         {
  69.             return new CloneNigga { programKnown = Deck<int>.CopyDeck(this.programKnown), cloned = true };
  70.         }
  71.     }
  72.  
  73.     public class Deck<T>
  74.     {
  75.         public Deck<T> previous = null;
  76.         public Deck<T> next = null;
  77.  
  78.         public T Value
  79.         {
  80.             get; set;
  81.         }
  82.  
  83.         public Deck()
  84.         {
  85.             this.Value = default(T);
  86.         }
  87.  
  88.         public Deck(T value)
  89.         {
  90.             this.Value = value;
  91.         }
  92.  
  93.         public Deck(T value, Deck<T> nigga, bool what = true)
  94.         {
  95.             this.Value = value;
  96.             if (what)
  97.                 previous = nigga;
  98.             else
  99.                 next = nigga;
  100.         }
  101.  
  102.         public static Deck<T> CopyDeck(Deck<T> nigga)
  103.         {
  104.             //if (nigga == null)
  105.             //    return nigga;
  106.             //Deck<T> flask = new Deck<T>(nigga.Value);
  107.             //switch (marker)
  108.             //{
  109.             //    case 0:
  110.             //        flask.next = CopyDeck(nigga.next, 1);
  111.             //        flask.previous = CopyDeck(nigga.previous, -1);
  112.             //        if (flask.next != null)
  113.             //            flask.next.previous = flask;
  114.             //        if (flask.previous != null)
  115.             //            flask.previous.next = flask;
  116.             //        break;
  117.             //    case 1:
  118.             //        flask.next = CopyDeck(nigga.next, 1);
  119.             //        if(flask.next != null)
  120.             //            flask.next.previous = flask;
  121.             //        break;
  122.             //    case -1:
  123.             //        flask.previous = CopyDeck(nigga.previous, -1);
  124.             //        if (flask.previous != null)
  125.             //            flask.previous.next = flask;
  126.             //        break;
  127.             //}
  128.             //return flask;
  129.  
  130.             if (nigga == new Deck<T>())
  131.                 return nigga;
  132.             Deck<T> flask = new Deck<T>(nigga.Value);
  133.             var crutch = nigga.previous;
  134.             var crutch2 = new Deck<T>();
  135.             if (crutch != null)
  136.             {
  137.                 crutch2 = flask.previous = new Deck<T>();
  138.                 crutch2.next = flask;
  139.             }
  140.             while (crutch != null)
  141.             {
  142.                 crutch2.Value = crutch.Value;
  143.                 crutch2.previous = new Deck<T>();
  144.                 crutch2.previous.next = crutch2;
  145.                 crutch2 = crutch2.previous;
  146.                 crutch = crutch.previous;
  147.             }
  148.             crutch = nigga.next;
  149.             if (crutch != null)
  150.             {
  151.                 crutch2 = flask.next = new Deck<T>();
  152.                 crutch2.previous = flask;
  153.             }
  154.             while (crutch != null)
  155.             {
  156.                 crutch2.Value = crutch.Value;
  157.                 crutch2.next = new Deck<T>();
  158.                 crutch2.next.previous = crutch2;
  159.                 crutch2 = crutch2.next;
  160.                 crutch = crutch.next;
  161.             }
  162.             return flask;
  163.         }
  164.     }
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement