static void Main(string[] args) { PlayerManager player = new PlayerManager(); EventBus eventBus = new EventBus(); DeckManager deckManager = new DeckManager(); PlayerEventHandler playerEventHandlerA = new PlayerEventHandler(); PlayerEventHandler playerEventHandlerB = new PlayerEventHandler(); PlayerEventHandler winner = new PlayerEventHandler(); var playerA = player.CreatePlayerDeck(1, deckManager.CreateDeck()); var playerB = player.CreatePlayerDeck(2, deckManager.CreateDeck()); PlayerModel testPlayerA = player.CreatePlayer(1, "playerA", -4); PlayerModel testPlayerB = player.CreatePlayer(2, "playerB", 4); eventBus.CheckPlayerLuck(playerEventHandlerA, player, testPlayerA); eventBus.CheckPlayerDeck(playerEventHandlerA, playerA); eventBus.ShowMessage(playerEventHandlerA); eventBus.CheckPlayerLuck(playerEventHandlerB, player, testPlayerB); eventBus.CheckPlayerDeck(playerEventHandlerB, playerB); eventBus.ShowMessage(playerEventHandlerB); eventBus.CheckWinner(winner, playerA, playerB); eventBus.ShowMessage(winner); Console.ReadKey(); }
public void GetDecks() { DeckManager dm = createDM(); var deck1ID = dm.CreateDeck("测试卡组1"); var deck2ID = dm.CreateDeck("测试卡组2"); var decks = dm.GetDecks(); Assert.AreEqual(decks.Count, 2); Assert.AreEqual("测试卡组1", decks[deck1ID]); Assert.AreEqual("测试卡组2", decks[deck2ID]); }
public void DeckCreate() { DeckManager dm = createDM(); var id = dm.CreateDeck("测试卡组"); var name = dm.GetDeckName(id); Assert.AreEqual("测试卡组", name); GameObject.Destroy(dm.gameObject); }
public void CardsAdd() { DeckManager dm = createDM(); var deckID = dm.CreateDeck("测试卡组"); var instID1 = dm.AddCard(deckID, 1000); var instID2 = dm.AddCard(deckID, 1001); Assert.AreEqual(1000, dm.GetCardID(instID1)); Assert.AreEqual(1001, dm.GetCardID(instID2)); }
public void GetDeckCards() { DeckManager dm = createDM(); var deckID = dm.CreateDeck("测试卡组"); var instID1 = dm.AddCard(deckID, 1000); var instID2 = dm.AddCard(deckID, 1001); var cards = dm.GetDeckCards(deckID); Assert.AreEqual(cards.Count, 2); Assert.AreEqual(1000, cards[instID1]); Assert.AreEqual(1001, cards[instID2]); }
public void CardRemove() { DeckManager dm = createDM(); var deckID = dm.CreateDeck("测试卡组"); var instID1 = dm.AddCard(deckID, 1000); var instID2 = dm.AddCard(deckID, 1001); dm.RemoveCard(instID2); System.Threading.Thread.Sleep(50); Assert.AreEqual(1000, dm.GetCardID(instID1)); Assert.AreEqual(-1, dm.GetCardID(instID2)); }
public void CardsTransation() { DeckManager dm = createDM(); var deckID = dm.CreateDeck("测试卡组"); var instID1 = dm.AddCard(deckID, 1000); var instID2 = dm.AddCard(deckID, 1001); // 进入事务 dm.EnterTransaction(); var instID3 = dm.AddCard(deckID, 1003); dm.RemoveCard(instID1); Assert.AreEqual(-1, dm.GetCardID(instID1)); Assert.AreEqual(1003, dm.GetCardID(instID3)); // 尝试回滚 dm.Rollback(); Assert.AreEqual(1000, dm.GetCardID(instID1)); Assert.AreEqual(-1, dm.GetCardID(instID3)); // 进入事务 dm.EnterTransaction(); instID3 = dm.AddCard(deckID, 1003); dm.RemoveCard(instID2); Assert.AreEqual(-1, dm.GetCardID(instID2)); Assert.AreEqual(1003, dm.GetCardID(instID3)); // 提交 dm.Commit(); Assert.AreEqual(-1, dm.GetCardID(instID2)); Assert.AreEqual(1003, dm.GetCardID(instID3)); }