/// TODO: Populate the credit cards from the JSON private async Task <(IEnumerable <Card> cards, float price)> GetCards(FlightsQuery searchQuery) { CardFinder cardFinder = new CardFinder(); cardFinder.PopulateAirports(); cardFinder.PopulateAirlines(); cardFinder.PopulateCards(); DateTime departureDate = searchQuery.DepartDate; DateTime returnDate = searchQuery.ReturnDate; Location origin = await cardFinder.GetPlace(searchQuery.Origin); Location destination = await cardFinder.GetPlace(searchQuery.Destination); float minPrice = await cardFinder.GetFlightPriceAsync(origin, destination, departureDate, returnDate); List <string> fromAirports = new List <string>(); List <string> toAirports = new List <string>(); cardFinder.AddAirports(fromAirports, origin, searchQuery.Origin); cardFinder.AddAirports(toAirports, destination, searchQuery.Destination); List <Card> creditCards = await cardFinder.GetAwardCreditCards(fromAirports, toAirports); if (minPrice > 0) { creditCards.AddRange(cardFinder.GetCashBackCreditCards(minPrice)); } // Where the recommendation engine comes into play. // Filter for the recommended credit cards. List <Card> recommendedCreditCards = GenerateRecommendations(creditCards); return(cards : recommendedCreditCards, price : minPrice); }
void PlaceCard() // 알아서 4번 돌림 { CardBase card = gm.GetRandomCard(gm.useCardList); // 랜덤으로 하나 뽑고 CardGrid grid = CardFinder.GetSameMonthCardsGrid(gm.cardGrids, card); if (grid == null) { grid = gm.GetNullGrid(); } grid.Set(card); card.gameObject.SetActive(true); }
public void Putcard() { CardBase followCard = GameManager.Instance.followUpCardQueue.Dequeue(); followCard.gameObject.SetActive(true); CardGrid followCardTargetGrid = CardFinder.GetSameMonthCardsGrid(GameManager.Instance.cardGrids, followCard); if (followCardTargetGrid == null) // 같은 월이 깔린게 없으면 그냥 비어있는데에 내려놓습니다. { followCardTargetGrid = GameManager.Instance.GetNullGrid(); followCardTargetGrid.Set(followCard); } else { int count = followCardTargetGrid.placedCards.Count; switch (count) { case 1: // 뒷패를 깠는데 하나만 있다는 거면, 무조건 가져오면 됨. GameManager.Instance.OnScored(followCard); GameManager.Instance.OnScored(followCardTargetGrid.placedCards[0], followCardTargetGrid); followCardTargetGrid.Reset(); break; case 2: // 두 개가 있다는 거면 둘 중 하나를 선택하게 하면 됨. followCard.MoveCardToGrid(followCardTargetGrid); GameManager.Instance.choiceCallBackQueue.Enqueue(() => GameManager.Instance.ChoiceCard(followCardTargetGrid.placedCards[0], followCardTargetGrid.placedCards[1], followCardTargetGrid)); GameManager.Instance.putCardQueue.Enqueue(followCard); break; case 3: // 3개 있으면 다 가져오고 while (followCardTargetGrid.placedCards.Count > 0) { GameManager.Instance.OnScored(followCardTargetGrid.placedCards[0], followCardTargetGrid); } GameManager.Instance.OnScored(followCard); // 내가 낸 것도 가져오기. GameManager.Instance.choiceCallBackQueue.Clear(); followCardTargetGrid.Reset(); break; } } GameManager.Instance.TryExecuteChoiceCallback(); }
void CheckMyCards(UserData userData) // 내가 가진 패 중, 같은 월 카드가 몇개인지 -> 폭탄 흔들기 체크용임 { foreach (var card in userData.ownCards) { int sameWithItemMonth = CardManager.Instance.GetSameMonthCards(card).Count; if (sameWithItemMonth > 3) { //첫 턴인지 아닌지 체크해서 처음이면 총통 if (GameManager.Instance.isFirstChecking) { // 총통, 승리 처리 후 게임 데이터 등에 static으로 박아놔서 Double! 박아두기 GameManager.Instance.isFirstChecking = false; } else { // 여기는 흔들기 100% } } else if (sameWithItemMonth > 2) { // 폭탄 or 흔들기인데 이제 if (CardFinder.GetSameMonthCardsGrid(GameManager.Instance.cardGrids, card) != null) { // 여기는 폭탄 } else { // 여기는 흔들기 } } else if (IsTakenMonthCard(card)) { // 카드 위 커서, 살아 있는 패 커서로 } else if (CardFinder.GetSameMonthCardsGrid(GameManager.Instance.cardGrids, card) != null) { // 죽은 패 } else { // 당장은 못 쓰는 패 } } }
}//함수의 끝. public void FollowCord(CardBase putCard) { CardBase followCard = followUpCardQueue.Dequeue(); followCard.gameObject.SetActive(true); CardGrid followCardTargetGrid = CardFinder.GetSameMonthCardsGrid(cardGrids, followCard); if (followCardTargetGrid == null) // 같은 월이 깔린게 없으면 그냥 비어있는데에 내려놓습니다. { followCardTargetGrid = GetNullGrid(); followCardTargetGrid.Set(followCard); } else { int count = followCardTargetGrid.placedCards.Count; switch (count) { case 1: // 뒷패를 깠는데 하나만 있다는 거면, 무조건 가져오면 됨. if (putCard.cardData.cardMonth == followCard.cardData.cardMonth) { rule.Kiss(); } OnScored(followCard); OnScored(followCardTargetGrid.placedCards[0], followCardTargetGrid); followCardTargetGrid.Reset(); break; case 2: // 두 개가 있다는 거면 둘 중 하나를 선택하게 하면 됨. followCard.MoveCardToGrid(followCardTargetGrid); if (putCard.cardData.cardMonth == followCard.cardData.cardMonth) //뻑임 { rule.Paulk(); } else { choiceCallBackQueue.Enqueue(() => ChoiceCard(followCardTargetGrid.placedCards[0], followCardTargetGrid.placedCards[1], followCardTargetGrid)); putCardQueue.Enqueue(followCard); } break; case 3: // 3개 있으면 다 가져오고 if (putCard.cardData.cardMonth == followCard.cardData.cardMonth) { //따닥 } while (followCardTargetGrid.placedCards.Count > 0) { OnScored(followCardTargetGrid.placedCards[0], followCardTargetGrid); } OnScored(followCard); // 내가 낸 것도 가져오기. choiceCallBackQueue.Clear(); followCardTargetGrid.Reset(); TakeOtherPlayerCard(); break; } } CardManager.Instance.TakePairCard(targetGrid); TryExecuteChoiceCallback(); targetGrid = null; }
public void PutCard(CardBase card) // 내가 낸 그리드를 가지고 있으면 좋을듯?ai.scoreData { SetTargetUserData(); targetGrid = CardFinder.GetSameMonthCardsGrid(cardGrids, card); List <CardBase> cardList = CardManager.Instance.GetSameMonthCards(card); if (targetGrid == null) // 같은 월이 깔린게 없으면 그냥 비어있는데에 내려놓습니다. { targetGrid = GetNullGrid(); OnShakedCallback = () => FollowCord(card); if (cardList.Count >= 3) { targetUserData.utilizeCards.Remove(card); UIManager.Instance.shakeUI.SetData(card, targetGrid); rule.Shake(); } else { targetUserData.utilizeCards.Remove(card); targetGrid.Set(card); FollowCord(card); } } else // 이 경우 자연스럽게 뒷 패도 깜. { int count = targetGrid.placedCards.Count; switch (count) { case 1: // 하나 있으면 그 친구한테 우선 가기. -> 뻑 가능성 if (cardList.Count == 3) // 폭탄 { foreach (var item in cardList) { targetUserData.utilizeCards.Remove(item); } rule.Bomb(2); // 연출같은거 여기서? OnScored(targetGrid.placedCards[0], targetGrid); // 바닥 패 먹고 while (cardList.Count > 0) { OnScored(cardList[0]); cardList.RemoveAt(0); } TakeOtherPlayerCard(); } else { targetUserData.utilizeCards.Remove(card); card.MoveCardToGrid(targetGrid); } break; case 2: // 두개 있으면 거기로 우선 가기 -> 따닥 가능성 if (cardList.Count == 2) { foreach (var item in cardList) { targetUserData.utilizeCards.Remove(item); } rule.Bomb(1); while (targetGrid.placedCards.Count > 0) { OnScored(targetGrid.placedCards[0], targetGrid); } while (cardList.Count > 0) { OnScored(cardList[0]); cardList.RemoveAt(0); } TakeOtherPlayerCard(); } else { targetUserData.utilizeCards.Remove(card); card.MoveCardToGrid(targetGrid); choiceCallBackQueue.Enqueue(() => ChoiceCard(targetGrid.placedCards[0], targetGrid.placedCards[1], targetGrid)); putCardQueue.Enqueue(card); } break; case 3: // 3개 있으면 다 가져오고 targetUserData.utilizeCards.Remove(card); while (targetGrid.placedCards.Count > 0) { OnScored(targetGrid.placedCards[0], targetGrid); } OnScored(card); rule.Shake(); targetGrid.Reset(); TakeOtherPlayerCard(); break; } FollowCord(card); } }//함수의 끝.
public static void Run() { //StreamReader reader = new StreamReader(@"data\cards.xml"); //string buffer = reader.ReadToEnd(); //reader.Close(); //reader.Dispose(); //XmlDocument doc = new XmlDocument(); //doc.LoadXml(buffer); int index = 0; bool setsLoaded = false; XmlNodeList mainNodeList = _xmlDoc.SelectNodes("//cockatrice_carddatabase"); int globalIndex = 0; foreach (XmlNode node in mainNodeList) { if (node.HasChildNodes) { foreach (XmlNode sub in node.ChildNodes) { switch (sub.Name) { case "sets": /* * SETS * */ if (sub.HasChildNodes) { foreach (XmlNode item in sub.ChildNodes) { XmlNode nameNode = item.ChildNodes[0]; XmlNode longNameNode = item.ChildNodes[1]; // correct some edition short names string shortName = nameNode.InnerText; //if(shortName == "COM") { // shortName = "CMD"; //} Edition edition = new Edition(); edition.Id = index; edition.Name = longNameNode.InnerText; edition.Shortname = shortName; index++; Toenda.Lhurgoyf.Data.CardBase.Editions.Add(edition); // raise event if (LoaderResponse != null) { LoaderResponse(new LoaderEventArgs( null, edition, globalIndex, MaxItems )); } } } break; case "cards": /* * CARDS * */ if (!setsLoaded) { index = 0; } setsLoaded = true; if (sub.HasChildNodes) { foreach (XmlNode item in sub.ChildNodes) { if (item.HasChildNodes) { Card card = new Card(); card.Id = index; //card.Color = ""; foreach (XmlNode single in item.ChildNodes) { switch (single.Name) { case "name": card.Name = single.InnerText; break; case "set": string editionShortName = single.InnerText; //if(editionShortName == "COM") { // editionShortName = "CMD"; //} string picture = single.Attributes["picURL"].InnerText; List <Edition> editions = CardFinder.FindEditionByName(editionShortName); if (editions != null && editions.Count > 0) { foreach (Edition edition in editions) { card.EditionPictures.Add( edition, new EditionImage() { Url = new Uri(picture), Edition = edition, Card = card } ); //var ediPics = // from ediItem in card.EditionPictures // where ediItem.Key.Id == edition.Id // && ediItem.Key.Name == edition.Name // && ediItem.Key.Shortname == edition.Shortname // select ediItem; //if(ediPics.Count() == 0) { // card.EditionPictures.Add( // edition, // new EditionImage() { // Url = new Uri(picture), // //BitmapStream = file, // Edition = edition, // Card = card // } // ); //} //else { // card.EditionPictures[edition] = new EditionImage() { // Url = new Uri(picture), // //BitmapStream = file, // Edition = edition, // Card = card // }; //} } } break; case "color": card.Color.Add(new CardColor() { Symbol = single.InnerText.ToEnum <ColorSymbol>() }); break; case "manacost": card.CastingCost = single.InnerText; break; case "type": card.Type = single.InnerText; break; case "pt": card.PowerThoughness = single.InnerText; break; case "tablerow": break; case "text": card.Text = single.InnerText; break; default: break; } } index++; //card = AddAdditionalInformation(card); Toenda.Lhurgoyf.Data.CardBase.Cards.Add(card); // raise event if (LoaderResponse != null) { LoaderResponse(new LoaderEventArgs( card, null, globalIndex, MaxItems )); } } } } break; } globalIndex++; } } } //XmlNodeList setNodeList = doc.SelectNodes("//cockatrice_carddatabase/sets/set"); //foreach(XmlNode node in setNodeList) { // if(node.HasChildNodes) { // /* // * Nodes look like this: // * // <set> // <name>5E</name> // <longname>Fifth Edition</longname> // </set> // * */ // XmlNode nameNode = node.ChildNodes[0]; // XmlNode longNameNode = node.ChildNodes[1]; // // correct some edition short names // string shortName = nameNode.InnerText; // //if(shortName == "COM") { // // shortName = "CMD"; // //} // Edition edition = new Edition(); // edition.Id = index; // edition.Name = longNameNode.InnerText; // edition.Shortname = shortName; // index++; // Toenda.Lhurgoyf.Data.CardBase.Editions.Add(edition); // } //} //index = 0; //XmlNodeList cardNodeList = doc.SelectNodes("//cockatrice_carddatabase/cards/card"); //foreach(XmlNode node in cardNodeList) { // if(node.HasChildNodes) { // /* // * Nodes look like this: // * // <card> // <name>Counterspell</name> // <set picURL="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=14511&type=card" picURLHq="" picURLSt="">6E</set> // <set picURL="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=185820&type=card" picURLHq="" picURLSt="">DD2</set> // <set picURL="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=3898&type=card" picURLHq="" picURLSt="">5E</set> // <set picURL="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=2148&type=card" picURLHq="" picURLSt="">4E</set> // <set picURL="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=2500&type=card" picURLHq="" picURLSt="">IA</set> // <set picURL="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=102&type=card" picURLHq="" picURLSt="">A</set> // <set picURL="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=397&type=card" picURLHq="" picURLSt="">B</set> // <set picURL="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=19570&type=card" picURLHq="" picURLSt="">MM</set> // <set picURL="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=1196&type=card" picURLHq="" picURLSt="">R</set> // <set picURL="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=11214&type=card" picURLHq="" picURLSt="">7E</set> // <set picURL="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=20382&type=card" picURLHq="" picURLSt="">ST</set> // <set picURL="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=25503&type=card" picURLHq="" picURLSt="">ST2K</set> // <set picURL="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=4693&type=card" picURLHq="" picURLSt="">TE</set> // <set picURL="http://gatherer.wizards.com/Handlers/Image.ashx?multiverseid=699&type=card" picURLHq="" picURLSt="">U</set> // <color>U</color> // <manacost>UU</manacost> // <type>Instant</type> // <tablerow>3</tablerow> // <text>Counter target spell.</text> // </card> // * */ // Card card = new Card(); // card.Id = index; // //card.Color = ""; // foreach(XmlNode sub in node.ChildNodes) { // switch(sub.Name) { // case "name": // card.Name = sub.InnerText; // break; // case "set": // string editionShortName = sub.InnerText; // //if(editionShortName == "COM") { // // editionShortName = "CMD"; // //} // string picture = sub.Attributes["picURL"].InnerText; // List<Edition> editions = CardFinder.FindEditionByName(editionShortName); // if(editions != null // && editions.Count > 0) { // foreach(Edition edition in editions) { // var ediPics = // from item in card.EditionPictures // where item.Key.Id == edition.Id // && item.Key.Name == edition.Name // && item.Key.Shortname == edition.Shortname // select item; // //Assembly thisExe = Assembly.GetExecutingAssembly(); // //Stream file = thisExe.GetManifestResourceStream("Toenda.Lhurgoyf.Resources.EmptyCard.bmp"); // if(ediPics.Count() == 0) { // card.EditionPictures.Add( // edition, // new EditionImage() { // Url = new Uri(picture), // //BitmapStream = file, // Edition = edition, // Card = card // } // ); // } // else { // card.EditionPictures[edition] = new EditionImage() { // Url = new Uri(picture), // //BitmapStream = file, // Edition = edition, // Card = card // }; // } // } // } // break; // case "color": // card.Color.Add(new CardColor() { Symbol = sub.InnerText.ToEnum<ColorSymbol>() }); // //card.Color += sub.InnerText; // break; // case "manacost": // card.CastingCost = sub.InnerText; // break; // case "type": // card.Type = sub.InnerText; // break; // case "pt": // card.PowerThoughness = sub.InnerText; // break; // case "tablerow": // break; // case "text": // card.Text = sub.InnerText; // break; // default: // break; // } // } // index++; // Toenda.Lhurgoyf.Data.CardBase.Cards.Add(card); // //Console.WriteLine("card {0} of {1} added...", index, cardNodeList.Count); // } //} if (LoaderFinish != null) { LoaderFinish(new LoaderFinishEventArgs("Card database successfull loaded!")); } }