public static string RenderMessageTrainer( int playerID, PBS.Battle.View.Model myModel, int teamPerspectiveID = -1, string baseString = "", int myPlayerID = 0, PBS.Battle.View.WifiFriendly.Trainer myTrainer = null, PBS.Battle.View.WifiFriendly.Team myTeamPerspective = null) { if (teamPerspectiveID == -1) { teamPerspectiveID = myTeamPerspective.teamID; } PBS.Battle.View.WifiFriendly.Trainer trainer = myModel.GetMatchingTrainer(playerID); GameTextData textData = (trainer.teamPos != teamPerspectiveID)? GameTextDatabase.instance.GetGameTextData("trainer-perspective-opposing") : (myTrainer == null)? GameTextDatabase.instance.GetGameTextData("trainer-perspective-ally") : GameTextDatabase.instance.GetGameTextData("trainer-perspective-player"); string replaceString = textData.languageDict[GameSettings.language]; if (replaceString == "{{-trainer-}}") { replaceString = trainer.name; } string replaceStringPoss = replaceString; if (!string.IsNullOrEmpty(baseString)) { if (GameSettings.language == GameLanguages.English) { if (myPlayerID == playerID) { replaceStringPoss = "Your"; if (!baseString.StartsWith("{{-trainer-")) { replaceString = replaceString.ToLower(); replaceStringPoss = replaceStringPoss.ToLower(); } } else { replaceStringPoss += "'s"; } } } string newString = baseString; newString = newString.Replace("{{-trainer-}}", replaceString); newString = newString.Replace("{{-trainer-poss-}}", replaceStringPoss); return(newString); }
public static string RenderMessage( PBS.Battle.View.Events.MessageParameterized message, PBS.Battle.View.Model myModel, int myPlayerID = 0, PBS.Battle.View.WifiFriendly.Trainer myTrainer = null, PBS.Battle.View.WifiFriendly.Team myTeamPerspective = null) { GameTextData textData = GameTextDatabase.instance.GetGameTextData(message.messageCode); if (textData == null) { return(""); } string baseString = textData.languageDict[GameSettings.language]; string newString = baseString; PBS.Battle.View.WifiFriendly.Trainer trainerPerspective = (myTrainer == null)? myModel.GetMatchingTrainer(message.playerPerspectiveID) : myTrainer; PBS.Battle.View.WifiFriendly.Team teamPerspective = (myTeamPerspective == null)? myModel.GetMatchingTeam(message.teamPerspectiveID) : myTeamPerspective; // player newString = newString.Replace("{{-player-name-}}", PlayerSave.instance.name); if (!string.IsNullOrEmpty(message.pokemonID)) { PBS.Battle.View.WifiFriendly.Pokemon pokemon = myModel.GetMatchingPokemon(message.pokemonID); PokemonData pokemonData = PokemonDatabase.instance.GetPokemonData(pokemon.pokemonID); newString = newString.Replace("{{-pokemon-}}", pokemon.nickname); newString = newString.Replace("{{-pokemon-form-}}", pokemonData.formName); newString = newString.Replace("{{-pokemon-poss-}}", pokemon.nickname + ((pokemon.nickname.EndsWith("s")) ? "'" : "'s") ); } if (!string.IsNullOrEmpty(message.pokemonUserID)) { PBS.Battle.View.WifiFriendly.Pokemon pokemon = myModel.GetMatchingPokemon(message.pokemonUserID); PokemonData pokemonData = PokemonDatabase.instance.GetPokemonData(pokemon.pokemonID); newString = newString.Replace("{{-user-pokemon-}}", pokemon.nickname); newString = newString.Replace("{{-user-pokemon-form-}}", pokemonData.formName); newString = newString.Replace("{{-user-pokemon-poss-}}", pokemon.nickname + ((pokemon.nickname.EndsWith("s")) ? "'" : "'s") ); } if (!string.IsNullOrEmpty(message.pokemonTargetID)) { PBS.Battle.View.WifiFriendly.Pokemon pokemon = myModel.GetMatchingPokemon(message.pokemonTargetID); PokemonData pokemonData = PokemonDatabase.instance.GetPokemonData(pokemon.pokemonID); newString = newString.Replace("{{-target-pokemon-}}", pokemon.nickname); newString = newString.Replace("{{-target-pokemon-form-}}", pokemonData.formName); newString = newString.Replace("{{-target-pokemon-poss-}}", pokemon.nickname + ((pokemon.nickname.EndsWith("s")) ? "'" : "'s") ); } if (message.pokemonListIDs.Count > 0) { List <PBS.Battle.View.WifiFriendly.Pokemon> pokemonList = new List <Battle.View.WifiFriendly.Pokemon>(); for (int i = 0; i < message.pokemonListIDs.Count; i++) { pokemonList.Add(myModel.GetMatchingPokemon(message.pokemonListIDs[i])); } string pokemonNameList = GetPokemonNames(pokemonList, myModel); newString = newString.Replace("{{-pokemon-list-}}", pokemonNameList); } if (message.trainerID != 0) { newString = RenderMessageTrainer( message.trainerID, myModel, teamPerspective.teamID, newString, myPlayerID: myPlayerID, myTrainer: myTrainer, myTeamPerspective: myTeamPerspective); } if (message.teamID != 0) { newString = RenderMessageTeam( teamID: message.teamID, teamPerspectiveID: teamPerspective.teamID, baseString: newString, myPlayerID: myPlayerID, myTrainer: myTrainer, myTeamPerspective: myTeamPerspective); } if (!string.IsNullOrEmpty(message.typeID)) { TypeData typeData = TypeDatabase.instance.GetTypeData(message.typeID); newString = newString.Replace("{{-type-name-}}", typeData.typeName + "-type"); } if (message.typeIDs.Count > 0) { newString = newString.Replace("{{-type-list-}}", GameTextDatabase.ConvertTypesToString(message.typeIDs.ToArray())); } if (!string.IsNullOrEmpty(message.moveID)) { MoveData moveData = MoveDatabase.instance.GetMoveData(message.moveID); newString = newString.Replace("{{-move-name-}}", moveData.moveName); } if (message.moveIDs.Count > 0) { for (int i = 0; i < message.moveIDs.Count; i++) { MoveData moveXData = MoveDatabase.instance.GetMoveData(message.moveIDs[i]); string partToReplace = "{{-move-name-" + i + "-}}"; newString = newString.Replace(partToReplace, moveXData.moveName); } } if (!string.IsNullOrEmpty(message.abilityID)) { AbilityData abilityData = AbilityDatabase.instance.GetAbilityData(message.abilityID); newString = newString.Replace("{{-ability-name-}}", abilityData.abilityName); } if (message.abilityIDs.Count > 0) { for (int i = 0; i < message.abilityIDs.Count; i++) { AbilityData abilityXData = AbilityDatabase.instance.GetAbilityData(message.abilityIDs[i]); string partToReplace = "{{-ability-name-" + i + "-}}"; newString = newString.Replace(partToReplace, abilityXData.abilityName); } } if (!string.IsNullOrEmpty(message.itemID)) { ItemData itemData = ItemDatabase.instance.GetItemData(message.itemID); newString = newString.Replace("{{-item-name-}}", itemData.itemName); } if (!string.IsNullOrEmpty(message.statusID)) { StatusPKData statusData = StatusPKDatabase.instance.GetStatusData(message.statusID); newString = newString.Replace("{{-status-name-}}", statusData.conditionName); } if (!string.IsNullOrEmpty(message.statusTeamID)) { StatusTEData statusData = StatusTEDatabase.instance.GetStatusData(message.statusTeamID); newString = newString.Replace("{{-team-status-name-}}", statusData.conditionName); } if (!string.IsNullOrEmpty(message.statusEnvironmentID)) { StatusBTLData statusData = StatusBTLDatabase.instance.GetStatusData(message.statusEnvironmentID); newString = newString.Replace("{{-battle-status-name-}}", statusData.conditionName); } // swapping substrings for (int i = 0; i < message.intArgs.Count; i++) { string partToReplace = "{{-int-" + i + "-}}"; newString = newString.Replace(partToReplace, message.intArgs[i].ToString()); } if (message.statList.Count > 0) { newString = newString.Replace("{{-stat-types-}}", ConvertStatsToString(message.statList.ToArray())); if (GameSettings.language == GameLanguages.English) { newString = newString.Replace("{{-stat-types-was-}}", (message.statList.Count == 1)? "was" : "were"); } else { newString = newString.Replace("{{-stat-types-was-}}", ""); } newString = newString.Replace("{{-stat-types-LC-}}", ConvertStatsToString(message.statList.ToArray(), false)); } return(newString); }