private void setOrginalCardtexts() { clearDictionaries(); CardType[] cts = new CardType[this.orginalcards.cardTypes.Length]; this.orginalcards.cardTypes.CopyTo(cts, 0); MappedString[] newmappedstrings = new MappedString[this.orginalmappedstrings.strings.Length]; this.orginalmappedstrings.strings.CopyTo(newmappedstrings, 0); for (int i = 0; i < this.oid.Count; i++) { int cardid = Convert.ToInt32(this.oid[i]);//no need, but why not?:D string cardname = this.onames[i]; string description = this.odesc[i]; string flavor = this.oflavor[i]; CardType.TypeSet ts = this.otypes[i]; string[] aa = this.oactiveAbilitys[i]; string[] pa = this.opassiveAbilitys[i]; string[] pd = this.opassiveDescs[i]; //get index from cts int ctsindex = getindexfromcardtypearray(cts, cardid); //change description if (ctsindex >= 0) { cts[ctsindex].description = description; //change flavor cts[ctsindex].flavor = flavor; cts[ctsindex].types = ts; int j = 0; foreach (ActiveAbility a in cts[ctsindex].abilities) { a.name = aa[j]; j++; } int k = 0; foreach (PassiveAbility a in cts[ctsindex].passiveRules) { a.displayName = pa[k]; a.description = pd[k]; k++; } } } //reset mapped strings List<MappedString> mappedstringlist = new List<MappedString>(); foreach (MappedString ms in newmappedstrings) { string key = ms.key; string value = ms.value; mappedstringlist.Add(new MappedString(key, value)); } Console.WriteLine("reset stuffs"); //reset mappedstringmanager MappedStringManager.getInstance().reset(); //feed it with new mappedstrigns! //MappedStringManager.getInstance().feed(mappedstringlist.ToArray()); MappedStringManager.getInstance().feed(this.orginalmappedstrings.strings); //reset the keywords MethodInfo generateKeywords = typeof(CardType).GetMethod("generateKeywords", BindingFlags.NonPublic | BindingFlags.Instance); foreach (CardType ct in this.orginalcards.cardTypes) //cts) { generateKeywords.Invoke(ct, null); } //reset cardtypemanager CardTypeManager.getInstance().reset(); //feed with edited cardtypes CardTypeManager.getInstance().feed(cts); //reset achivements AchievementTypeManager.getInstance().reset(); AchievementTypeManager.getInstance().feed(this.orginalAchivements.achievementTypes); }
private void setCardtexts() { clearDictionaries(); CardType[] cts = new CardType[this.orginalcards.cardTypes.Length]; this.orginalcards.cardTypes.CopyTo(cts, 0); //mapped strings!!! MappedString[] newmappedstrings = new MappedString[this.orginalmappedstrings.strings.Length]; this.orginalmappedstrings.strings.CopyTo(newmappedstrings, 0); Console.WriteLine("copied mappped strings"); bool traDescs = false; if (this.translatedDesc.Count > 0) { traDescs = true; } this.untranslatedcard.Clear(); this.notTranslatedScrolls = false; for (int i = 0; i < this.id.Count; i++) { int cardid = Convert.ToInt32(this.id[i]);//no need, but why not?:D string cardname = this.names[i]; string description = this.desc[i]; string flavor = this.flavor[i]; string transDesc = ""; if (traDescs) { transDesc = translatedDesc[i]; } //get index from cts if (cardid == 99999)// its a kind we change { this.translatedPieceKind.Add(cardname, description); } if (cardid == 88888)// its a type we change { this.translatedPieceType.Add(cardname, description); } if (cardid == 77777)// its a ActiveAb. we change { this.translatedActiveAbility.Add(cardname, description); } if (cardid == 66666)// its a ActiveAb. we change { this.translatedPassiveAbility.Add(cardname, description); } if (cardid == 55555)// its a ActiveAb. we change { this.translatedPassiveDescription.Add(cardname, description); } if (cardid == 44444)// its a MappedString! { Console.WriteLine("add mapped string" + cardname); mappedstringding msd = new mappedstringding(); msd.key = cardname; msd.value = description; //flavor = orginal key-name bool foundDescription = false; foreach (string s in this.oMappedStrings.Values) { if (s == transDesc) { foundDescription = true; break; } } if (foundDescription) { //Console.WriteLine("add mapped string " + cardname + " " + description + " " + flavor); this.translatedMappedStrings.Add(msd); } else { Console.WriteLine("### " + flavor + " mappedstring was changed, so it is not translated"); } } int ctsindex = getindexfromcardtypearray(cts, cardid); //change description if (ctsindex >= 0) { if (transDesc == cts[ctsindex].description) { cts[ctsindex].description = description; } else { Console.WriteLine("## " + cardname + " description was changed, so it is not translated"); this.untranslatedcard.Add(cardname); this.notTranslatedScrolls = true; } //change flavor cts[ctsindex].flavor = flavor; } } Console.WriteLine("change cts"); for (int i = 0; i < this.id.Count; i++) { //change the other stuff of the cards (loaded with ids 66666-99999) int cardid = Convert.ToInt32(this.id[i]);//no need, but why not?:D int ctsindex = getindexfromcardtypearray(cts, cardid); //change description if (ctsindex >= 0) { cts[ctsindex].types = new CardType.TypeSet(changePieceTypes(cts[ctsindex].types.ToString()).Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries)); foreach (ActiveAbility a in cts[ctsindex].abilities) { a.name = this.changeActiveAbilities(a.name); } foreach (PassiveAbility a in cts[ctsindex].passiveRules) { a.displayName = this.changePassiveAbilities(a.displayName); a.description = this.changePassiveDescription(a.description); } } } //change mapped strings List<MappedString> mappedstringlist = new List<MappedString>(); Console.WriteLine("change mappedstringlist"); //add orginal mapped strings first foreach(MappedString ms in newmappedstrings) { string key = ms.key; string value = ms.value; /*if(translatedMappedStrings.ContainsKey(ms.key)) { key = translatedMappedStrings[ms.key].key; value = translatedMappedStrings[ms.key].value; } */ Console.WriteLine("add to list " + key + " " + value); mappedstringlist.Add(new MappedString(key, value)); } //add translated ones! foreach (mappedstringding ms in translatedMappedStrings) { string key = ms.key; string value = ms.value; Console.WriteLine("add to list " + key + " " + value); mappedstringlist.Add(new MappedString(key, value)); } Console.WriteLine("reset stuffs"); //reset mappedstringmanager MappedStringManager.getInstance().reset(); //feed it with new mappedstrigns! MappedStringManager.getInstance().feed(mappedstringlist.ToArray()); //reset the keywords MethodInfo generateKeywords = typeof(CardType).GetMethod("generateKeywords", BindingFlags.NonPublic | BindingFlags.Instance) ; foreach (CardType ct in cts) { generateKeywords.Invoke(ct, null); } //reset cardtypemanager CardTypeManager.getInstance().reset(); //feed with edited cardtypes CardTypeManager.getInstance().feed(cts); CardType ctype = CardTypeManager.getInstance().get("Plate Armor"); Card c = new Card((long)123, ctype); Console.WriteLine("plate aromor:"); foreach (KeywordDescription kd in c.getKeywords()) { Console.WriteLine("" + kd.keyword + " : " + kd.description); } }