mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-10-01 05:36:56 -05:00
Added formatter classes
This commit is contained in:
@@ -86,6 +86,7 @@
|
||||
<Compile Include="Structures\ByteStatValues.cs" />
|
||||
<Compile Include="Structures\ContestStatValues.cs" />
|
||||
<Compile Include="Structures\DressupRecord4.cs" />
|
||||
<Compile Include="Structures\Format.cs" />
|
||||
<Compile Include="Structures\GtsRecord5.cs" />
|
||||
<Compile Include="Structures\Enums.cs" />
|
||||
<Compile Include="Structures\GtsRecord4.cs" />
|
||||
|
||||
41
library/Structures/Format.cs
Normal file
41
library/Structures/Format.cs
Normal file
@@ -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 "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
39
web/src/WebFormat.cs
Normal file
39
web/src/WebFormat.cs
Normal file
@@ -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, "<span class=\"m\">{0}</span>", "<span>{0}</span>", "");
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3587,6 +3587,7 @@
|
||||
<Compile Include="src\RetinaImage.cs" />
|
||||
<Compile Include="src\RetinaImageBase.cs" />
|
||||
<Compile Include="src\WebException.cs" />
|
||||
<Compile Include="src\WebFormat.cs" />
|
||||
<Compile Include="test\BoxUp.aspx.cs">
|
||||
<DependentUpon>BoxUp.aspx</DependentUpon>
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
|
||||
Reference in New Issue
Block a user