public void setallavailablecards(Message msg) { // get all available cards, save them! helpf.setarrays(msg); prcs.resetarrays(helpf.cardids.Length); if (helpf.nicks) { helpf.readnicksfromfile(); } mssgprsr.searchscrollsnicks.Clear(); prcs.wtbpricelist1.Clear(); prcs.wtspricelist1.Clear(); this.fullBuyOwnList.Clear(); Console.WriteLine("add cards to fullbuyownList"); for (int j = 0; j < helpf.cardnames.Length; j++) { prcs.wtspricelist1.Add(helpf.cardids[j], ""); prcs.wtbpricelist1.Add(helpf.cardids[j], ""); CardType type = CardTypeManager.getInstance().get(helpf.cardids[j]); Card card = new Card(helpf.cardids[j], type, true); //aucitem ai = new aucitem(); //ai.card = card; //ai.price = ""; //ai.priceinint = helpf.allcardsavailable.Count; //ai.seller = "me"; Auction ai = new Auction(" ", DateTime.Now, Auction.OfferType.BUY, card, ""); if (App.MyProfile.ProfileInfo.name != null) { ai = new Auction(App.MyProfile.ProfileInfo.name, DateTime.Now, Auction.OfferType.BUY, card, ""); } this.fullBuyOwnList.Add(ai); nickelement nele; nele.nick = helpf.cardnames[j]; nele.cardname = helpf.cardnames[j]; mssgprsr.searchscrollsnicks.Add(nele); } ; mssgprsr.searchscrollsnicks.AddRange(helpf.loadedscrollsnicks); this.fullBuyOwnList.Sort(delegate(Auction p1, Auction p2) { return((p1.card.getName()).CompareTo(p2.card.getName())); }); this.buyOwnCardsFilter.filtersChanged = true; try { prcs.totalpricecheck();//helpf.cardids } catch { } // set cardIDToNumberOwned to zeros, or the mod will crash, if you got an offer, but dont visit the deckbuilder /store etc (where you get your own cards) before helpf.cardIDToNumberOwned.Clear(); Console.WriteLine("zeros cardIDToNumberOwned"); foreach (Auction ai in this.fullBuyOwnList) //fullbuyownlist == all cards in game { if (!helpf.cardIDToNumberOwned.ContainsKey(ai.card.getType())) { helpf.cardIDToNumberOwned.Add(ai.card.getType(), 0); } } }
public void addDataToPlayerStore() { this.pstore.removeAllMessages(); List <Auction> auctionsToAdd = new List <Auction>(); foreach (sharedItem si in this.pStoreItems) { Console.WriteLine("parsing: " + si.time + " " + si.status + " " + si.id); /*DateTime d = DateTime.ParseExact(si.time, "M/d/yyyy H:mm:ss", System.Globalization.CultureInfo.CurrentCulture); * if (si.status.StartsWith("active:")) * { * int hours = Convert.ToInt32(si.status.Split(':')[1]); * d = d.AddMinutes(hours); * } */ DateTime d = UnixTimeStampToDateTime(Convert.ToInt32(si.id.Split(';')[4])); int level = 0; if (si.id.Split(';').Length == 6) { level = Convert.ToInt32(si.id.Split(';')[5]); } int id = Convert.ToInt32(si.id.Split(';')[0]); int price = Convert.ToInt32(si.id.Split(';')[2]); CardType type = CardTypeManager.getInstance().get(id); Card card = new Card(id, type, true); card.level = level; string text = si.id; if (si.status == "SOLD" || si.status == "BUY") { text = "sold;" + text; d = DateTime.Now.AddYears(-10); } else { text = "active;" + text; } Auction a = new Auction(si.seller, d, Auction.OfferType.SELL, card, text, price); auctionsToAdd.Add(a); } this.pstore.addAuctions(auctionsToAdd); this.pstore.removeOldEntrys(); this.dataisready = false; }
public void createcard(int arrindex, int cardid) { CardType type = CardTypeManager.getInstance().get(cardid); Card card = new Card(cardid, type, false); UnityEngine.Object.Destroy(this.cardRule); cardRule = PrimitiveFactory.createPlane(); cardRule.name = "CardRule"; CardView cardView = cardRule.AddComponent <CardView>(); cardView.init(this, card, -1); cardView.applyHighResTexture(); cardView.setLayer(8); Vector3 vccopy = Camera.main.transform.localPosition; Camera.main.transform.localPosition = new Vector3(0f, 1f, -10f); cardRule.transform.localPosition = Camera.main.ScreenToWorldPoint(new Vector3((float)Screen.width * 0.3f, (float)Screen.height * 0.6f, 0.9f));; cardRule.transform.localEulerAngles = new Vector3(90f, 180f, 0f); cardRule.transform.localScale = new Vector3(9.3f, 0.1f, 15.7f);// CardView.CardLocalScale(100f); cardtext = cardRule.renderer.material.mainTexture; Vector3 ttvec1 = Camera.main.WorldToScreenPoint(cardRule.renderer.bounds.min); Vector3 ttvec2 = Camera.main.WorldToScreenPoint(cardRule.renderer.bounds.max); Rect ttrec = new Rect(ttvec1.x, Screen.height - ttvec2.y, ttvec2.x - ttvec1.x, ttvec2.y - ttvec1.y); scalefactor = (float)(Screen.height / 1.9) / ttrec.height; cardRule.transform.localScale = new Vector3(cardRule.transform.localScale.x * scalefactor, cardRule.transform.localScale.y, cardRule.transform.localScale.z * scalefactor); ttvec1 = Camera.main.WorldToScreenPoint(cardRule.renderer.bounds.min); ttvec2 = Camera.main.WorldToScreenPoint(cardRule.renderer.bounds.max); ttrec = new Rect(ttvec1.x, Screen.height - ttvec2.y, ttvec2.x - ttvec1.x, ttvec2.y - ttvec1.y); cardrect = ttrec; gettextures(cardView); this.cardReadyToDraw = true; Camera.main.transform.localPosition = vccopy; //Console.WriteLine("CARD: " + clink); this.clicked = 0; }
/*private void additemtolist(Card c, string from, int gold, bool wts, string wholemsg) * { * if (wts) * { * this.addingcards.Add(new Auction(from, DateTime.Now, Auction.OfferType.SELL, c, wholemsg, gold)); * } * else * { * * this.addingcards.Add(new Auction(from, DateTime.Now, Auction.OfferType.BUY, c, wholemsg, gold)); * } * * }*/ private static void GetAuctionsFromShortIntoList(string shortList, string from, Auction.OfferType offerType, List <Auction> outList) { string[] words = shortList.Split(';'); for (int i = 0; i < words.Length; i++) { if (words[i] == "" || words[i] == " ") { break; } string price; string ids; if (words[i].Contains(' ')) { price = words[i].Split(' ')[1]; if (price == "") { price = "0"; } ids = words[i].Split(' ')[0]; } else { price = "0"; ids = words[i]; } string[] ideen = ids.Split(','); //When string does not contain a , the whole string is the first element of the returned array. foreach (string idd in ideen) { int id = Convert.ToInt32(idd); CardType type = CardTypeManager.getInstance().get(id); Card card = new Card(id, type, true); outList.Add(new Auction(from, DateTime.Now, offerType, card, "(Network Auction)", Convert.ToInt32(price))); } } }
public List <Auction> GetAuctionsFromMessage(string msgg, string from, string room) { string msg = Regex.Replace(msgg, @"(<color=#[A-Za-z0-9]{0,6}>)|(</color>)", String.Empty); // todo: delete old msgs from author if (msg.StartsWith("aucs ") || msg.StartsWith("aucb ")) { return(GetAuctionsFromShortMessage(msg, from)); } //if (msg.StartsWith("aucc ")) { respondtocommand(msg,from); return; } Auction.OfferType currentOfferType = Auction.OfferType.BUY; //Will be overwritten //string[] words=msg.Split(' '); List <Auction> addingAuctions = new List <Auction>(); List <char> delimiters = new List <char>(); //{ '\r', '\n', ' ', ',', ';' }; foreach (char a in msg) { if (!char.IsLetterOrDigit(a)) { delimiters.Add(a); } } string[] words = msg.Split(delimiters.ToArray(), StringSplitOptions.RemoveEmptyEntries); //words = Regex.Split(msg, @""); if (!msg.ToLower().Contains("wts") && !msg.ToLower().Contains("wtb") && !msg.ToLower().Contains("sell") && !msg.ToLower().Contains("buy")) { return(addingAuctions); } bool wtxfound = false; DateTime now1 = DateTime.Now; for (int i = 0; i < words.Length; i++) { Card c; int price = 0; string word = words[i].ToLower(); // save in wts or wtb? if (word.Contains("wts") || word.Contains("sell")) { currentOfferType = Auction.OfferType.SELL; wtxfound = true; } ; if (word.Contains("wtb") || word.Contains("buy")) { currentOfferType = Auction.OfferType.BUY; wtxfound = true; } ; if (!wtxfound) { continue; // if no wts or wtb was found, skip card search } //int arrindex = Array.FindIndex(this.cardnames, element => word.Contains(element.Split(' ')[0])); // changed words[i] and element! int arrindex = this.searchscrollsnicks.FindIndex(element => word.Contains(element.nick.Split(' ')[0])); int iadder = 0; if (arrindex >= 0) // wort in cardlist enthalten { //Console.WriteLine(word + " " + arrindex); //string[] possiblecards = Array.FindAll(this.cardnames, element => word.Contains(element.Split(' ')[0])); List <nickelement> possibnics = this.searchscrollsnicks.FindAll(element => word.Contains(element.nick.Split(' ')[0])); bool findcard = false; string foundedcard = ""; string textplace = ""; for (int ii = 0; ii < possibnics.Count; ii++) { //string match = possiblecards[ii].ToLower(); string match = possibnics[ii].nick.ToLower(); int posleng = Math.Min(match.Split(' ').Length, words.Length - i); string searchob = string.Join(" ", words, i, posleng).ToLower(); if (searchob.Contains(match)) { findcard = true; foundedcard = possibnics[ii].cardname.ToLower(); iadder = posleng; textplace = searchob; break; } ; } // i = i + iadder; if (findcard) { //CardType type = CardTypeManager.getInstance().get(cardnametoid(foundedcard.ToLower())); CardType type = CardTypeManager.getInstance().get(helpf.cardnamesToID[foundedcard.ToLower()]); //int realarrindex = Array.FindIndex(helpf.cardnames, element => foundedcard.Equals(element)); int realarrindex = helpf.cardnameToArrayIndex(foundedcard); c = new Card(helpf.cardids[realarrindex], type, true); //Console.WriteLine("found " + foundedcard + " in " + textplace); string tmpgold = pricetestfirst((textplace.Split(' '))[(textplace.Split(' ')).Length - 1]); if (!(tmpgold == "")) // && iadder >1 { // case: cardnamegold //Console.WriteLine("found " + this.numberregx.Match(tmpgold).Value); price = Convert.ToInt32(this.numberregx.Match(tmpgold).Value); } else if (i < words.Length) { int j = i; tmpgold = pricetest(words[j]); while (tmpgold == "") { if (j + 1 < words.Length) { j++; tmpgold = pricetest(words[j]); } else { tmpgold = "fail"; } } if (!(tmpgold == "fail")) { // cardname gold //Console.WriteLine("found gold " + this.numberregx.Match(tmpgold).Value); price = Convert.ToInt32(this.numberregx.Match(tmpgold).Value); } } now1 = now1.AddMilliseconds(1); addingAuctions.Add(new Auction(from, now1, currentOfferType, c, msgg, price)); //additemtolist(c, from, price, wts, msgg); i--; }//if (find) ende } } return(addingAuctions); }
public void handleMessage(Message msg) { if (msg is MessageMessage) { MessageMessage omsg = (MessageMessage)msg; if (omsg.type == MessageMessage.Type.SOLD_MARKET_SCROLLS) { this.needSoldAucs = true; App.Communicator.send(new MarketplaceSoldListViewMessage()); } } if (msg is OkMessage) { OkMessage omsg = (OkMessage)msg; if (Helpfunktions.Instance.createAuctionMenu) { if (omsg.op == "MarketplaceCreateOffer" && this.sellingCard != null) { Helpfunktions.Instance.cardIDToNumberOwned[this.sellingType]--; Helpfunktions.Instance.cardIDToNumberOwnedTiered[this.sellingType] -= (int)Math.Pow(3, sellingTypeLevel); PlayerStore.Instance.createCardsFilter.filtersChanged = true; PlayerStore.Instance.sellOfferFilter.filtersChanged = true; this.dataOffer = 0; this.sellingCard = null; App.Communicator.send(new MarketplaceOffersViewMessage()); //App.Communicator.send(new MarketplaceSoldListViewMessage()); App.Communicator.sendRequest(new LibraryViewMessage()); } if (omsg.op == "MarketplaceCancelOffer") { Helpfunktions.Instance.cardIDToNumberOwned[this.cancelType]++; Helpfunktions.Instance.cardIDToNumberOwnedTiered[this.cancelType] += (int)Math.Pow(3, cancelTypeLevel); PlayerStore.Instance.createCardsFilter.filtersChanged = true; PlayerStore.Instance.sellOfferFilter.filtersChanged = true; this.dataOffer = 0; App.Communicator.send(new MarketplaceOffersViewMessage()); //App.Communicator.send(new MarketplaceSoldListViewMessage()); App.Communicator.sendRequest(new LibraryViewMessage()); } if (omsg.op == "MarketplaceClaim") { if (transactionBeingClaimed == null) { return; } if (this.workthreadclaimall) { this.claimeditemstaxes += this.transactionBeingClaimed.fee; this.claimeditemsmoney += this.transactionBeingClaimed.sellPrice; System.Threading.Thread.Sleep(150); this.claimlast(); return; } App.AudioScript.PlaySFX("Sounds/hyperduck/UI/ui_coin_tally_end"); CardType cardType = CardTypeManager.getInstance().get(this.transactionBeingClaimed.cardType); this.dataOffer = 0; this.needSoldAucs = true; App.Communicator.send(new MarketplaceOffersViewMessage()); App.Communicator.send(new MarketplaceSoldListViewMessage()); App.Communicator.sendRequest(new LibraryViewMessage()); App.Popups.ShowOk(this, "claimgold", "Gold added", string.Concat(new object[] { "<color=#bbaa88>Tier ", (int)(this.transactionBeingClaimed.level + 1), " ", cardType.name, " sold for ", this.transactionBeingClaimed.sellPrice, " gold!\nEarned <color=#ffd055>", this.transactionBeingClaimed.sellPrice - this.transactionBeingClaimed.fee, " gold</color> (the fence collects ", this.transactionBeingClaimed.fee, ").</color>" }), "Ok"); this.transactionBeingClaimed = null; } } if (Helpfunktions.Instance.playerStoreMenu) { if (omsg.op == "MarketplaceMakeDeal") { App.Communicator.sendRequest(new GetStoreItemsMessage()); App.Communicator.sendRequest(new LibraryViewMessage()); App.Popups.ShowOk(this, "dealmade", "Purchase complete!", clickedItemName + " has been added to your collection.", "Ok"); Helpfunktions.Instance.cardIDToNumberOwned[this.clickedItemtypeid]++; Helpfunktions.Instance.cardIDToNumberOwnedTiered[this.clickedItemtypeid] += (int)Math.Pow(3, clickedItemLevel); PlayerStore.Instance.createCardsFilter.filtersChanged = true; PlayerStore.Instance.sellOfferFilter.filtersChanged = true; clickedItemBuyID = -1; } } } if (msg is FailMessage) { FailMessage failMessage = (FailMessage)msg; if (failMessage.isType(typeof(MarketplaceMakeDealMessage))) { App.Popups.ShowOk(this, "dealNOTmade", "Purchase failed", failMessage.info, "Ok"); PlayerStore.Instance.createCardsFilter.filtersChanged = true; PlayerStore.Instance.sellOfferFilter.filtersChanged = true; clickedItemBuyID = -1; } if (failMessage.isType(typeof(MarketplaceCreateOfferMessage)) && this.sellingCard != null) { App.Popups.ShowOk(this, "cantcreate", "Create failed", failMessage.info, "Ok"); this.sellingCard = null; } if (failMessage.isType(typeof(MarketplaceClaimMessage))) { if (transactionBeingClaimed == null) { return; } if (this.workthreadclaimall) { System.Threading.Thread.Sleep(150); this.claimlast(); return; } this.dataOffer = 0; this.needSoldAucs = true; App.Communicator.send(new MarketplaceOffersViewMessage()); App.Communicator.send(new MarketplaceSoldListViewMessage()); App.Communicator.sendRequest(new LibraryViewMessage()); transactionBeingClaimed = null; } } if (msg is CheckCardDependenciesMessage && sellingCard != null) { CheckCardDependenciesMessage checkCardDependenciesMessage = (CheckCardDependenciesMessage)msg; if (checkCardDependenciesMessage.dependencies == null || checkCardDependenciesMessage.dependencies.Length == 0) { this.GetCreateOfferInfo(); } else { App.Popups.ShowOkCancel(this, "deckinvalidationwarning", "Notice", "Selling this scroll will make the following decks illegal:\n\n" + DeckUtil.GetFormattedDeckNames(checkCardDependenciesMessage.GetDeckNames()), "Ok", "Cancel"); } } if (msg is MarketplaceCreateOfferInfoMessage && sellingCard != null) { MarketplaceCreateOfferInfoMessage marketplaceCreateOfferInfoMessage = (MarketplaceCreateOfferInfoMessage)msg; App.Popups.ShowSellCard(this, "sellcard", this.sellingCard, marketplaceCreateOfferInfoMessage.lowestPrice, marketplaceCreateOfferInfoMessage.suggestedPrice, marketplaceCreateOfferInfoMessage.copiesForSale, marketplaceCreateOfferInfoMessage.tax); } if (msg is MarketplaceOffersSearchViewMessage) { MarketplaceOffersSearchViewMessage marketplaceOffersViewMessage = (MarketplaceOffersSearchViewMessage)msg; clickedItemForSales = marketplaceOffersViewMessage.copiesForSale; clickedItemLevel = marketplaceOffersViewMessage.offer.card.level; clickedItemPrice = marketplaceOffersViewMessage.offer.price; clickedItemBuyID = marketplaceOffersViewMessage.offer.id; clickedItemName = marketplaceOffersViewMessage.offer.card.getName(); clickedItemtypeid = marketplaceOffersViewMessage.offer.card.getType(); } if (msg is MarketplaceOffersViewMessage) { //if (this.dataisreadyOwnOffers) return; MarketplaceOffersViewMessage marketplaceOffersViewMessage = (MarketplaceOffersViewMessage)msg; MarketplaceOffer[] offers = marketplaceOffersViewMessage.offers; this.pstoreOwnAucs.Clear(); DateTime tme = DateTime.Now; tme = tme.AddMilliseconds(1000); for (int i = 0; i < offers.Length; i++) { MarketplaceOffer marketplaceOffer = offers[i]; Auction a = new Auction(App.MyProfile.ProfileInfo.name, tme, Auction.OfferType.SELL, marketplaceOffer.card, "" + marketplaceOffer.id, marketplaceOffer.price); tme = tme.AddMilliseconds(1); //Console.WriteLine("add owm auction: " + a.card.getName() + " " + a.price); this.pstoreOwnAucs.Add(a); } this.dataOffer++; if (this.dataOffer >= 2 || !this.needSoldAucs) { this.dataisreadyOwnOffers = true; } if (this.dataOffer >= 2) { this.needSoldAucs = false; } } if (msg is MarketplaceSoldListViewMessage) { //if (this.dataisreadyOwnOffers) return; MarketplaceSoldListViewMessage marketplaceOffersViewMessage = (MarketplaceSoldListViewMessage)msg; TransactionInfo[] offers = marketplaceOffersViewMessage.sold; this.pstoreSOLDAucs.Clear(); this.soldScrollTransactions.Clear(); DateTime tme = DateTime.Now; for (int i = 0; i < offers.Length; i++) { TransactionInfo marketplaceOffer = offers[i]; if (!marketplaceOffer.claimed) { this.soldScrollTransactions.Add(marketplaceOffer.cardId, marketplaceOffer); } CardType type = CardTypeManager.getInstance().get(marketplaceOffer.cardType); Card c = new Card(marketplaceOffer.cardId, type, true); string aucmessage = "sold " + marketplaceOffer.fee; if (marketplaceOffer.claimed) { aucmessage += " claimed"; continue; } Auction a = new Auction(App.MyProfile.ProfileInfo.name, tme, Auction.OfferType.SELL, c, aucmessage, marketplaceOffer.sellPrice, marketplaceOffer.cardId); tme = tme.AddMilliseconds(1); //Console.WriteLine("add owm auction: " + a.card.getName() + " " + a.price); this.pstoreSOLDAucs.Add(a); } this.dataOffer++; if (this.dataOffer >= 2) { this.dataisreadyOwnOffers = true; } this.needSoldAucs = false; } if (msg is MarketplaceAvailableOffersListViewMessage) { Prices.Instance.getBlackmarketPrices(msg as MarketplaceAvailableOffersListViewMessage); if (this.dataisready) { return; } MarketplaceAvailableOffersListViewMessage marketplaceAvailableOffersListViewMessage = (MarketplaceAvailableOffersListViewMessage)msg; MarketplaceTypeAvailability[] available = marketplaceAvailableOffersListViewMessage.available; this.pstoreAucs.Clear(); DateTime tme = DateTime.Now; for (int i = 0; i < available.Length; i++) { MarketplaceTypeAvailability mta = available[i]; CardType type = CardTypeManager.getInstance().get(mta.type); Card card = new Card(1, type, true); card.level = mta.level; Auction a = new Auction("BlackMarket", tme, Auction.OfferType.SELL, card, "", mta.price); tme = tme.AddMilliseconds(-1); //Console.WriteLine("add auction: " + a.card.getName() + " " + a.price); this.pstoreAucs.Add(a); } this.dataisready = true; } return; }