public void GetAllTest() { cardDB = new CardDB(); List <CardModel> cards = (List <CardModel>)cardDB.GetAll(); Assert.IsTrue(cards.Count > 0); }
public void GetCardsByUserIdTest() { cardDB = new CardDB(); var testCard1 = new CardModel(CardModel.CardType.DEFENSE, "Attack UpdateTest card", "It can attack", 2); var testCard2 = new CardModel(CardModel.CardType.DEFENSE, "Attack UpdateTest card", "It can attack", 2); var testCard3 = new CardModel(CardModel.CardType.DEFENSE, "Attack UpdateTest card", "It can attack", 2); var testCard4 = new CardModel(CardModel.CardType.DEFENSE, "Attack UpdateTest card", "It can attack", 2); var testCard5 = new CardModel(CardModel.CardType.DEFENSE, "Attack UpdateTest card", "It can attack", 2); testCard1.Id = cardDB.InsertWithIdentity(testCard1); testCard2.Id = cardDB.InsertWithIdentity(testCard2); testCard3.Id = cardDB.InsertWithIdentity(testCard3); testCard4.Id = cardDB.InsertWithIdentity(testCard4); testCard5.Id = cardDB.InsertWithIdentity(testCard5); List <CardModel> cards = new List <CardModel>() { testCard1, testCard2, testCard3, testCard4, testCard5 }; ICGUserDBIF userDB = new CGUserDB(); CGUserModel user = userDB.GetById("Test"); userDB.InsertHand(cards, user); List <CardModel> cardList = (List <CardModel>)cardDB.GetCardsByUserId("Test"); Assert.IsTrue(cardList.Count > 0); userDB.DeleteHand(user); cardDB.Delete(testCard1); cardDB.Delete(testCard2); cardDB.Delete(testCard3); cardDB.Delete(testCard4); cardDB.Delete(testCard5); }
public void GetCardsByDeckIdTest() { cardDB = new CardDB(); List <CardModel> cardList = (List <CardModel>)cardDB.GetCardsByDeckId(2); Assert.IsTrue(cardList.Count > 0); }
public void DealCardsTest() { //Arrange GameController gameController = new GameController(); ICGUserDBIF cGUserDB = new CGUserDB(); IDeckDBIF deckDB = new DeckDB(); ICardDBIF cardDB = new CardDB(); UserManagement userManagement = new UserManagement(); List <CardModel> cardModels = (List <CardModel>)cardDB.GetAll(); List <Card> cards = CardConverter.ConvertFromListOfCardModelToListOfCard(cardModels); Deck deck = DeckConverter.ConvertFromDeckModelToDeck(deckDB.GetById(2)); List <CGUser> users = new List <CGUser>(); CGUser user = CGUserConverter.convertFromCGUserModelToCGUser(cGUserDB.GetById("Test")); users.Add(user); userManagement.DeleteHand(user); //Act gameController.DealCards(deck, users); List <Card> userCards = user.cards; //Assert Assert.IsTrue(userCards.Count > 0); //Cleanup userManagement.DeleteHand(user); }
public void InsertHandTest() { //Arrange cgUserDB = new CGUserDB(); CardDB cardDB = new CardDB(); //Act var userModel = cgUserDB.GetById("Test"); List <CardModel> cardsOnHand = cardDB.GetCardsByDeckId(2); List <CardModel> filteredCardsOnHand = new List <CardModel>(); for (int i = 0; i < 5; i++) { CardModel card = cardsOnHand[i]; filteredCardsOnHand.Add(card); } cgUserDB.InsertHand(filteredCardsOnHand, userModel); CGUser user = CGUserConverter.convertFromCGUserModelToCGUser(cgUserDB.GetById("Test")); //Assert Assert.IsTrue(user.cards.Count > 0); //CleanUp CGUserModel revertedUser = CGUserConverter.ConvertFromCGUserToCGUserModel(user); cgUserDB.DeleteHand(revertedUser); }
public static int setQuota(double chf, int uid) { int quota; quota = CardDB.setQuota(chf, uid); return(quota); }
public static void LoadDB(CardDB db) { instance = new Cards(); instance.cards = new Dictionary <string, ICardData>(); foreach (ICardData data in db.cards) { instance.cards.Add(data.cardName, data); } }
private void btn_cardGenerate_Click(object sender, EventArgs e) { crd = new Card(); CardDB.GenerateCard(crd); lbl_generatedCard.Text = crd.CardNumber.ToString(); lbl_generatedCardPrice.Text = crd.Price.ToString(); }
public IEnumerator startDeck(GameObject cardPrefab) { //Multiplier to put each card on top of the other int increment = 0; //TODO: Find a better way to do this string previousCardCode = null; Texture2D imgCarta = new Texture2D(0, 0); foreach (CardDBEntry card in ListOfCards) { if (previousCardCode != card.code) { string img_url = CardDB.GetBaseImgUrl().Replace("{code}", card.code); WWW url = new WWW(img_url); Debug.Log("Downloading image for " + card.title); while (!url.isDone) { //Debug.Log("Downloading image: " + url.progress * 100 + "%"); yield return(null); } imgCarta = url.texture; Debug.Log("Done!"); } else { Debug.Log("Using the same image."); } previousCardCode = card.code; Vector3 YincrementVector = new Vector3(0, 0.01f); Vector3 FlipCardRotation = new Vector3(0, 0, 180f); //Create the card GO GameObject cardGO = Instantiate(cardPrefab, this.transform.position + YincrementVector * increment, this.transform.rotation).gameObject; cardGO.transform.Rotate(FlipCardRotation, Space.World); cardGO.transform.SetParent(this.transform); cardGO.name = card.title; //Use the image downloaded cardGO.transform.Find("Card_model").Find("front").GetComponent <Renderer>().material.mainTexture = imgCarta; //Put the correct back image of the card depending on which side the card is(Runner or Corp) if (card.side_code == "runner") { cardGO.transform.Find("Card_model").Find("back").GetComponent <Renderer>().material.mainTexture = Resources.Load <Texture2D>("Textures/Runner_back"); } else if (card.side_code == "corp") { cardGO.transform.Find("Card_model").Find("back").GetComponent <Renderer>().material.mainTexture = Resources.Load <Texture2D>("Textures/Corp_back"); } increment++; } Debug.Log(DeckSide.ToString() + " side finished downloading card images"); }
public PlayViewModel(Deck deck) { Deck = deck; CardDatabase = new CardDB(deck); GetHand(); this.navigation = navigation; RightAnswer = new Command(Right); WrongAnswer = new Command(Wrong); Flip = new Command(FlipIt); }
public void InsertTest() { cardDB = new CardDB(); List <CardModel> cardList = (List <CardModel>)cardDB.GetAll(); var testCard = new CardModel(CardModel.CardType.ATTACK, "Attack card", "It can attack", 10); cardDB.Insert(testCard); List <CardModel> updatedCardList = (List <CardModel>)cardDB.GetAll(); Assert.IsTrue(cardList.Count < updatedCardList.Count); }
/*Generate a random hand from the deck selected. Hand size is altered in the settings. If there are any new cards added, * populate the hand with these first, then, 1/2 chance of a card with score = 1, 1/3 chance of a card with score = 2 and * a 1/6 chance of a card with score = 3.*/ public void GetHand() { Random = new Random(); CardDatabase = new CardDB(Deck); Hand = new ObservableCollection <Card>(); var RandomNumber = 0; var CardDict = new Dictionary <int, ObservableCollection <Card> > { { 0, new ObservableCollection <Card>(CardDatabase.GetCardsWithScore(0)) }, { 1, new ObservableCollection <Card>(CardDatabase.GetCardsWithScore(1)) }, { 2, new ObservableCollection <Card>(CardDatabase.GetCardsWithScore(2)) }, { 3, new ObservableCollection <Card>(CardDatabase.GetCardsWithScore(3)) } }; HandSize = Math.Min(Settings.HandSize, CardDict[0].Count + CardDict[1].Count + CardDict[2].Count + CardDict[3].Count); int Ones = CardDict[1].Count > 0 ? 5 : 0; int Twos = CardDict[2].Count > 0 ? 3 + Ones : 0; int Three = CardDict[3].Count > 0 ? Ones > 0 ? Twos > 0 ? 1 + Twos : Ones + 1 : Twos > 0 ? Twos + 1 : 1 : 0; var OnesRange = Enumerable.Range(0, Ones); var TwosRange = Enumerable.Range(Ones, Twos); var ThreesRange = Enumerable.Range(Twos, Three); while (CardDict[0].Count > 0 && Hand.Count < HandSize) { RandomNumber = Random.Next(0, CardDict[0].Count); Hand.Add(CardDict[0][RandomNumber]); CardDict[0].RemoveAt(RandomNumber); } while (Hand.Count < HandSize) { RandomNumber = Random.Next(0, Three + 1); if (OnesRange.Contains(RandomNumber) && CardDict[1].Count > 0) { RandomNumber = Random.Next(0, CardDict[1].Count); Hand.Add(CardDict[1][RandomNumber]); CardDict[1].RemoveAt(RandomNumber); } else if (TwosRange.Contains(RandomNumber) && CardDict[2].Count > 0) { RandomNumber = Random.Next(0, CardDict[2].Count); Hand.Add(CardDict[2][RandomNumber]); CardDict[2].RemoveAt(RandomNumber); } else if (ThreesRange.Contains(RandomNumber) && CardDict[3].Count > 0) { RandomNumber = Random.Next(0, CardDict[3].Count); Hand.Add(CardDict[3][RandomNumber]); CardDict[3].RemoveAt(RandomNumber); } } }
public PlayViewModel(int DeckID) { DeckDatabase = new DeckDB(); Deck = DeckDatabase.GetDeck(DeckID); CardDatabase = new CardDB(Deck); GetHand(); this.navigation = navigation; RightAnswer = new Command(Right); WrongAnswer = new Command(Wrong); Flip = new Command(FlipIt); }
public void ControlTest() { CardDB.Initialize(); BoardTester bt = new BoardTester(); Control behave = new Control(); Cast bc = behave.GetBestCast(bt.btPlayfield); Assert.Equal(0, bc.Position.X); Assert.Equal(0, bc.Position.Y); }
void RenameDeck(object s) { var NewName = s as string; CardDatabase = new CardDB(Deck); CardDatabase.MigrateCards(Deck, NewName); Deck.Name = NewName; DeckDatabase.UpdateDeck(Deck); PopupNavigation.PopAsync(); }
public MultiChoiceViewModel(Deck Deck) { this.Deck = Deck; CardDatabase = new CardDB(Deck); Cards = CardDatabase.GetCards(); GetHand(); Answers = new ObservableCollection <AnswerCard>(); Pick = new Command(Picked); Position = 0; index = 0; Setup(); }
public ByScoreViewModel(int DeckID) { DeckDatabase = new DeckDB(); this.Deck = DeckDatabase.GetDeck(DeckID); CardDatabase = new CardDB(Deck); HandSize = Settings.HandSize; RightAnswer = new Command(Right); WrongAnswer = new Command(Wrong); Flip = new Command(FlipIt); Random = new Random(); GetCards(); }
public void DeleteTest() { cardDB = new CardDB(); var testCard = new CardModel(CardModel.CardType.ATTACK, "Attack DeleteTest card", "It can attack", 10); testCard.Id = cardDB.InsertWithIdentity(testCard); List <CardModel> cardList = (List <CardModel>)cardDB.GetAll(); cardDB.Delete(testCard); List <CardModel> updatedCardList = (List <CardModel>)cardDB.GetAll(); Assert.IsTrue(cardList.Count > updatedCardList.Count); }
private void btn_AddCard_Click(object sender, EventArgs e) { this.label1.Text = ""; CardDB.AddCard(crd); foreach (Card item in CardDB.Cards) { this.label1.Text += item.CardNumber.ToString() + " " + item.Price.ToString() + "\n"; } this.AutoScroll = true; }
public static Deck ConvertFromDeckModelToDeck(DeckModel deckModel) { ICardDBIF cardDB = new CardDB(); List <CardModel> deckCards = cardDB.GetCardsByDeckId(deckModel.Id); Deck deck = new Deck() { Id = deckModel.Id, DeckName = deckModel.DeckName, cards = CardConverter.ConvertFromListOfCardModelToListOfCard(deckCards) }; return(deck); }
public void ApolloTest() { CardDB.Initialize(); BoardTester bt = new BoardTester(); Apollo behave = new Apollo(); Apollo.FillSettings(); Cast bc = behave.GetBestCast(bt.btPlayfield); bt.btPlayfield.print(); //Assert.Equal(0, bc.Position.X); //Assert.Equal(0, bc.Position.Y); }
public EditCardsViewModel(Deck deck) { this.Deck = deck; CardDatabase = new CardDB(deck); Add = new Command(AddCard); Done = new Command(DoneEdit); PageDisappearingCommand = new Command(PageDisappearing); Cards = CardDatabase.GetCards(); if (Cards.Count == 0) { EmptyDeck(); } }
void Start() { //Register the 'api downloaded' callback function apiDownloadedCB += OnAPIDownloaded; //Download the api data CardDB.SetApiUrl(api_url); StartCoroutine(CardDB.DownloadAPI(apiDownloadedCB)); //Get the game areas GO RunnerAreaGO = GameObject.FindGameObjectWithTag("Runner"); CorpAreaGO = GameObject.FindGameObjectWithTag("Corp"); setupDecks(); }
public static CGUser convertFromCGUserModelToCGUser(CGUserModel cGUserModel) { ICardDBIF cardDB = new CardDB(); List <CardModel> userCards = cardDB.GetCardsByUserId(cGUserModel.Id); CGUser cGUser = new CGUser() { Id = cGUserModel.Id, UserName = cGUserModel.UserName, Email = cGUserModel.Email, userType = (CGUser.UserType)cGUserModel.userType, userStatus = (CGUser.UserStatus)cGUserModel.userStatus, Health = cGUserModel.Health, cards = CardConverter.ConvertFromListOfCardModelToListOfCard(userCards) }; return(cGUser); }
public void UpdateTest() { cardDB = new CardDB(); var testCard = new CardModel(CardModel.CardType.DEFENSE, "Attack UpdateTest card", "It can attack", 2); CardModel compareCard = null; testCard.Id = cardDB.InsertWithIdentity(testCard); testCard.Name = "Hans"; cardDB.Update(testCard); List <CardModel> updatedCardList = (List <CardModel>)cardDB.GetAll(); foreach (var card in updatedCardList) { if (card.Name == testCard.Name) { compareCard = card; } } Assert.AreEqual(testCard.Name, compareCard.Name); }
void instantiateCards() { if (getLength(cards) != getLength(tempCard)) { for (int i = 0; i < tempCard.Length; i++) { if (tempCard[i] != null) { GameObject.Destroy(tempCard[i].gameObject); } } tempCard = new CardContainer[getLength(cards)]; for (int i = 0; i < cards.Length; i++) { if (cards[i] != null) { CardContainer tempCardContainer = cards[i].gameObject.GetComponent <CardContainer>(); CardDB tempCardDB = tempCardContainer.card; prefab.GetComponent <CardContainer>().SetCardDB(tempCardDB); GameObject tempGameObject = Instantiate( prefab, new Vector3(0, 0, 0), Quaternion.identity) as GameObject; tempGameObject.transform.SetParent( parentGameObject.transform, false); tempGameObject.GetComponent <CardContainer>().FaceUpCard(); tempCard[i] = tempGameObject.GetComponent <CardContainer>(); } } } }
public virtual void onCardWasPlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion) { return; }
public static List <Card> GetAllCards() { return(CardDB.GetAllCards()); }
public static int UpdateCardData(Card c) { // Returns the number of affected rows (-1 if an error occured) return(CardDB.UpdateCardData(c)); }
public static List <string> GetAllCardIDs(string field) { // Returns the number of affected rows (-1 if an error occured) return(CardDB.GetAllCardIDs(field)); }
public virtual void onCardIsGoingToBePlayed(Playfield p, CardDB.Card c, bool wasOwnCard, Minion triggerEffectMinion, Minion target) { return; }
public static List <Dictionary <string, object> > GetCardsTable() { return(CardDB.GetCardsTable()); }
public virtual void onCardIsDiscarded(Playfield p, CardDB.Card card, bool own) { return; }