diff --git a/library/Library.csproj b/library/Library.csproj index d3de7e8f..aa9c0d29 100644 --- a/library/Library.csproj +++ b/library/Library.csproj @@ -86,6 +86,7 @@ + diff --git a/library/Structures/Format.cs b/library/Structures/Format.cs new file mode 100644 index 00000000..19ba218e --- /dev/null +++ b/library/Structures/Format.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace PkmnFoundations.Structures +{ + public static class Format + { + private static String[] m_marks = new String[] { "●", "▲", "■", "♥", "★", "♦" }; + + public static String Markings(Markings markings, String trueFormat, String falseFormat, String delimiter) + { + StringBuilder result = new StringBuilder(); + int marking = 1; + for (int value = 0; value < 6; value++) + { + if (marking > 1) result.Append(delimiter); + String format = (((int)markings & marking) != 0) ? trueFormat : falseFormat; + result.Append(String.Format(format, m_marks[value])); + + marking <<= 1; + } + + return result.ToString(); + } + + public static String GenderSymbol(Genders gender) + { + switch (gender) + { + case Genders.Male: + return "♂"; + case Genders.Female: + return "♀"; + default: + return ""; + } + } + } +} diff --git a/web/src/WebFormat.cs b/web/src/WebFormat.cs new file mode 100644 index 00000000..fb996c48 --- /dev/null +++ b/web/src/WebFormat.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Web; +using PkmnFoundations.Structures; + +namespace PkmnFoundations.Web +{ + public static class WebFormat + { + public static String Markings(Markings markings) + { + return Format.Markings(markings, "{0}", "{0}", ""); + } + + public static String PokemonImage(PokemonPartyBase pokemon) + { + return (pokemon.IsShiny ? "~/images/pkmn-lg-s/" : "~/images/pkmn-lg/") + + PokemonImage2(pokemon) + ".png"; + } + + private static String PokemonImage2(PokemonPartyBase pkmn) + { + // todo: spinda + StringBuilder builder = new StringBuilder(); + builder.Append(pkmn.SpeciesID); + if (pkmn.Form.Suffix.Length > 0) + { + builder.Append('-'); + builder.Append(pkmn.Form.Suffix); + } + if (pkmn.Species.GenderVariations && pkmn.Gender == Genders.Female) + builder.Append("-f"); + + return builder.ToString(); + } + } +} \ No newline at end of file diff --git a/web/web.csproj b/web/web.csproj index 96decb84..73714ab7 100644 --- a/web/web.csproj +++ b/web/web.csproj @@ -3587,6 +3587,7 @@ + BoxUp.aspx ASPXCodeBehind