public void receiveCardlist(CardTypesMessage msg) { // create a libraryview message int id = 1000000; string libviw = "" ; this.alltypes.Clear(); foreach (CardType c in msg.cardTypes) { if (!alltypes.Contains(c.id)) alltypes.Add(c.id); } foreach (CardType ct in msg.cardTypes) { for (int i = 0; i < 3; i++) { if (libviw != "") libviw = libviw + ","; libviw= libviw + "{\"id\":"+ id+",\"typeId\":" + ct.id + ",\"tradable\":false,\"isToken\":false,\"level\":0}"; id++; } } libviw= "{\"cards\":[" + libviw +"],\"profileId\":\""+ App.MyProfile.ProfileInfo.id + "\",\"msg\":\"LibraryView\"}"; Console.WriteLine(libviw); libraryview = MessageFactory.create(MessageFactory.getMessageName(libviw),libviw); }
public void setarrays(Message msg) { /* * JsonReader jsonReader = new JsonReader(); * Dictionary<string, object> dictionary = (Dictionary<string, object>)jsonReader.Read(msg.getRawText()); * Dictionary<string, object>[] d = (Dictionary<string, object>[])dictionary["cardTypes"]; * this.cardids = new int[d.GetLength(0)]; * this.cardnames = new string[d.GetLength(0)]; * this.cardImageid = new int[d.GetLength(0)]; * this.cardType = new string[d.GetLength(0)]; */ CardTypesMessage cmsg = (CardTypesMessage)msg; this.cardids = new int[cmsg.cardTypes.Length]; this.cardnames = new string[cmsg.cardTypes.Length]; this.cardImageid = new int[cmsg.cardTypes.Length]; this.cardType = new string[cmsg.cardTypes.Length]; int i = 0; foreach (CardType c in cmsg.cardTypes) { this.cardids[i] = c.id; this.cardnames[i] = c.name.ToLower(); this.cardImageid[i] = c.cardImage; this.cardType[i] = c.kind.ToString(); i++; } /* * for (int i = 0; i < d.GetLength(0); i++) * { * this.cardids[i] = Convert.ToInt32(d[i]["id"]); * this.cardnames[i] = d[i]["name"].ToString().ToLower(); * this.cardImageid[i] = Convert.ToInt32(d[i]["cardImage"]); * this.cardType[i] = d[i]["kind"].ToString(); * }*/ generatedictionarys(); }
public void incommingCardTypesMessage(CardTypesMessage msg) { clearDictionaries(); this.orginalcards = msg; this.oid.Clear(); this.onames.Clear(); this.odesc.Clear(); this.oflavor.Clear(); this.otypes.Clear(); this.oactiveAbilitys.Clear(); this.opassiveAbilitys.Clear(); this.opassiveDescs.Clear(); foreach (CardType ct in this.orginalcards.cardTypes) // have to copy the orginal values { oid.Add(ct.id.ToString()); onames.Add(ct.name); odesc.Add(ct.description); oflavor.Add(ct.flavor); otypes.Add(new CardType.TypeSet(changePieceTypes(ct.types.ToString()).Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries))); string[] aa = new string[ct.abilities.Length]; int i = 0; foreach (ActiveAbility a in ct.abilities) { aa[i] = a.name; i++; } this.oactiveAbilitys.Add(aa); string[] pa = new string[ct.passiveRules.Length]; int j = 0; foreach (PassiveAbility a in ct.passiveRules) { pa[j] = a.displayName; j++; } this.opassiveAbilitys.Add(pa); string[] pd = new string[ct.passiveRules.Length]; int k = 0; foreach (PassiveAbility a in ct.passiveRules) { pd[k] = a.description; k++; } this.opassiveDescs.Add(pd); /*foreach ( ActiveAbility aa in ct.abilities) { Console.WriteLine("## Ability: "+aa.name); }*/ /*foreach (PassiveAbility aa in ct.passiveRules) { Console.WriteLine("## PassiveAbility: " + aa.displayName); }*/ } //do this after achivements now :D //new Thread(new ThreadStart(this.workthread)).Start(); }