Esempio n. 1
0
 public void PutCardOnBottom_OrderedLibrary_CardOnBottom()
 {
     SelectableLinkedList<GameCard> cards = new SelectableLinkedList<GameCard>();
     for (int i = 0; i < 29; i++)
         cards.AddFirst(new MockCard());
     GameLibrary lib = new GameLibrary();
     lib.Add(cards);
     lib.AddBottom(new MockCardWithData(42));
     lib.TakeCards(29);
     Assert.IsTrue(((MockCardWithData)lib.TakeCards(1)[0]).data == 42);
 }
Esempio n. 2
0
 public void PutCardAtPosition_NonemptyLibrary_CardAtPosition()
 {
     SelectableLinkedList<GameCard> cards = new SelectableLinkedList<GameCard>();
     for (int i = 0; i < 29; i++)
         cards.AddFirst(new MockCard());
     GameLibrary lib = new GameLibrary();
     lib.Add(cards);
     lib.AddAt(new MockCardWithData(42), 10);
     lib.TakeCards(9);
     Assert.IsTrue(((MockCardWithData)lib.TakeCards(1)[0]).data == 42);
 }
Esempio n. 3
0
 public void ShuffleLibrary_OrderedLibrary_LibraryOrderReversed()
 {
     SelectableLinkedList<GameCard> cards = new SelectableLinkedList<GameCard>();
     for (int i = 0; i < 10; i++)
         cards.AddLast(new MockCardWithData(i + 1));
     GameLibrary lib = new GameLibrary();
     lib.Add(cards);
     lib.Shuffle(_ => 0);
     List<GameCard> newLib = lib.TakeCards(10);
     for (int i = 0; i < newLib.Count; i++)
     {
         Assert.IsTrue(((MockCardWithData)newLib[i]).data == 10 - i);
     }
 }
Esempio n. 4
0
 public Player(GameLibrary lib, Hand hand, ManaStorage manaStorage,LevelRewarder rewarder)
 {
     this.CurrentXP = 0;
     this.Rewarder = rewarder;
     if (this.Rewarder != null)
         Rewarder.Owner = this;
     Library = lib;
     if(lib!=null)
         Library.Owner = this;
     Hand = hand;
     ManaStorage = manaStorage;
     if(manaStorage != null)
         ManaStorage.Owner = this;
 }
Esempio n. 5
0
        public void DrawACard_EmptyHandNonemptyLibrary_CardsInHand()
        {
            bool cardDrawnEventTriggered = false;

            GameLibrary lib = new GameLibrary();
            SelectableLinkedList<GameCard> cards = new SelectableLinkedList<GameCard>();
            cards.AddFirst(new MockCardWithData(42));
            lib.Add(cards);
            Hand h = new Hand();
            Player p = new Player(lib, h,null,null);
            p.EventManager = this.EventManager;
            this.EventManager.Register(new Trigger<CardDrawnEvent>(_ => cardDrawnEventTriggered = true));
            Engine.AddActor(p);
            p.Draw(1);
            GameCard c = p.Hand.TakeCards(1)[0];
            Assert.IsTrue(cardDrawnEventTriggered);
            Assert.IsTrue(lib.IsEmpty());
            Assert.IsTrue(((MockCardWithData)c).data == 42);
        }
Esempio n. 6
0
 public void Discard_CardInHand_CardOnBottomOfLibrary()
 {
     bool cardDiscardedEventTriggered = false;
     GameLibrary lib = new GameLibrary();
     SelectableLinkedList<GameCard> cards = new SelectableLinkedList<GameCard>();
     for (int i = 0; i < 29; i++)
         cards.AddFirst(new MockCard());
     lib.Add(cards);
     Hand h = new Hand();
     cards = new SelectableLinkedList<GameCard>();
     cards.AddFirst(new MockCardWithData(42));
     h.Add(cards);
     Player p = new Player(lib, h, null,null);
     p.EventManager = this.EventManager;
     this.EventManager.Register(new Trigger<CardDiscardedEvent>(_ => cardDiscardedEventTriggered = true));
     Engine.AddActor(lib);
     p.Discard(0);
     GameCard c = p.Library.TakeCardAt(29);
     Assert.IsTrue(cardDiscardedEventTriggered);
     Assert.IsTrue(((MockCardWithData)c).data == 42);
 }
Esempio n. 7
0
 private GameLibrary ConstructLibrary()
 {
     GameLibrary lib = new GameLibrary();
     Hand h = new Hand();
     Player p = new Player(lib, h, null,null);
     Engine.AddActor(lib);
     return lib;
 }
        void Start()
        {
            UnityEngine.Object.DontDestroyOnLoad(this);

            var p1lib = new GameLibrary();
            Player p = new Player(p1lib,new Hand(), new ManaStorage(), new GameLevelRewards(Mana.Arcane));
            var cards1 = CreatePlayer1Deck();
            p1lib.Add(cards1);
            p1lib.Shuffle();
            p.Name = "player 1";
            this.mainPlayer = p;
            this.AddPlayer(p);

            var p2lib = new GameLibrary();
            p = new Player(p2lib, new Hand(), new ManaStorage(), new GameLevelRewards(Mana.Fury));
            var cards2 = CreatePlayer2Deck();
            p2lib.Add(cards2);
            p2lib.Shuffle();
            p.Name = "player 2";
            this.AddPlayer(p);
        }