mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-09-08 10:15:13 -05:00
Fixed a lot of crashes on pokemon stats viewer.
This commit is contained in:
@@ -129,14 +129,30 @@ namespace PkmnFoundations.Pokedex
|
||||
public static LazyKeyValuePair<int, Location> CreatePairForGeneration(Pokedex pokedex, Func<Generations> generationGetter)
|
||||
{
|
||||
return new LazyKeyValuePair<int, Location>(
|
||||
k => k == 0 ? null : (pokedex == null ? null : pokedex.Locations(GenerationToLocationNumbering(generationGetter()))[k]),
|
||||
k =>
|
||||
{
|
||||
if (k == 0) return null;
|
||||
if (pokedex == null) return null;
|
||||
var locations = pokedex.Locations(GenerationToLocationNumbering(generationGetter()));
|
||||
if (locations == null) return null;
|
||||
if (!locations.ContainsKey(k)) return null;
|
||||
return locations[k];
|
||||
},
|
||||
v => v == null ? 0 : (v.Value(generationGetter()) ?? -1));
|
||||
}
|
||||
|
||||
public static LazyKeyValuePair<int, Location> CreatePairForLocationNumbering(Pokedex pokedex, Func<LocationNumbering> generationGetter)
|
||||
{
|
||||
return new LazyKeyValuePair<int, Location>(
|
||||
k => k == 0 ? null : (pokedex == null ? null : pokedex.Locations(generationGetter())[k]),
|
||||
k =>
|
||||
{
|
||||
if (k == 0) return null;
|
||||
if (pokedex == null) return null;
|
||||
var locations = pokedex.Locations(generationGetter());
|
||||
if (locations == null) return null;
|
||||
if (!locations.ContainsKey(k)) return null;
|
||||
return locations[k];
|
||||
},
|
||||
v => v == null ? 0 : (v.Value(generationGetter()) ?? -1));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace PkmnFoundations.Structures
|
||||
public uint OT;
|
||||
public TrendyPhrase4 PhraseLeader;
|
||||
// Different from GTS, 0 = male, 2 = female, 1 = Plato????
|
||||
public byte Gender; // Probably trainer class.
|
||||
public byte Gender;
|
||||
|
||||
// 3: Lass
|
||||
// 6: Bug Catcher
|
||||
@@ -68,7 +68,7 @@ namespace PkmnFoundations.Structures
|
||||
// 57: Roughneck
|
||||
// 60: School Kid M
|
||||
// 85: Idol
|
||||
public byte Unknown;
|
||||
public byte Unknown; // Probably trainer class.
|
||||
|
||||
public byte[] Save()
|
||||
{
|
||||
|
||||
@@ -7,16 +7,16 @@ namespace PkmnFoundations.Structures
|
||||
{
|
||||
public static class Format
|
||||
{
|
||||
private static String[] m_marks = new String[] { "●", "▲", "■", "♥", "★", "♦" };
|
||||
private static string[] m_marks = new string[] { "●", "▲", "■", "♥", "★", "♦" };
|
||||
|
||||
public static String Markings(Markings markings, String trueFormat, String falseFormat, String delimiter)
|
||||
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;
|
||||
string format = (((int)markings & marking) != 0) ? trueFormat : falseFormat;
|
||||
result.Append(String.Format(format, m_marks[value]));
|
||||
|
||||
marking <<= 1;
|
||||
@@ -25,7 +25,7 @@ namespace PkmnFoundations.Structures
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
public static String GenderSymbol(Genders gender)
|
||||
public static string GenderSymbol(Genders gender)
|
||||
{
|
||||
switch (gender)
|
||||
{
|
||||
@@ -38,7 +38,7 @@ namespace PkmnFoundations.Structures
|
||||
}
|
||||
}
|
||||
|
||||
public static String ToIso639_1(Languages lang)
|
||||
public static string ToIso639_1(Languages lang)
|
||||
{
|
||||
switch (lang)
|
||||
{
|
||||
@@ -61,7 +61,7 @@ namespace PkmnFoundations.Structures
|
||||
}
|
||||
}
|
||||
|
||||
public static Languages FromIso639_1(String lang)
|
||||
public static Languages FromIso639_1(string lang)
|
||||
{
|
||||
switch (lang.ToUpperInvariant())
|
||||
{
|
||||
|
||||
@@ -307,6 +307,14 @@ namespace PkmnFoundations.Structures
|
||||
return pokeballId > 16;
|
||||
}
|
||||
|
||||
public override ushort HP
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ushort)Stats[Structures.Stats.Hp];
|
||||
}
|
||||
}
|
||||
|
||||
public override int Size
|
||||
{
|
||||
get { return 136; }
|
||||
|
||||
@@ -248,7 +248,7 @@ namespace PkmnFoundations.Structures
|
||||
eggLocationId = (plat && EggLocationID_Plat != 0) ? EggLocationID_Plat : EggLocationID;
|
||||
locationId = (plat && LocationID_Plat != 0) ? LocationID_Plat : LocationID;
|
||||
|
||||
return new TrainerMemo(m_pokedex, LocationNumbering.Generation4,
|
||||
return new TrainerMemo(m_pokedex, LocationNumbering.Generation5,
|
||||
TrainerMemoDateTime(EggDate), TrainerMemoDateTime(Date),
|
||||
eggLocationId, locationId, EncounterLevel == 0, EncounterLevel);
|
||||
}
|
||||
@@ -285,6 +285,14 @@ namespace PkmnFoundations.Structures
|
||||
}
|
||||
}
|
||||
|
||||
public override ushort HP
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ushort)Stats[Structures.Stats.Hp];
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsBw2()
|
||||
{
|
||||
return (Version == Versions.Black2 || Version == Versions.White2);
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace PkmnFoundations.Structures
|
||||
// todo: validate this against the computed level
|
||||
//Level = block[4];
|
||||
CapsuleIndex = block[5];
|
||||
HP = BitConverter.ToUInt16(block, 6);
|
||||
_HP = BitConverter.ToUInt16(block, 6);
|
||||
m_stats = new IntStatValues(BitConverter.ToUInt16(block, 8),
|
||||
BitConverter.ToUInt16(block, 10),
|
||||
BitConverter.ToUInt16(block, 12),
|
||||
@@ -77,7 +77,8 @@ namespace PkmnFoundations.Structures
|
||||
public byte Unknown5 { get; set; }
|
||||
public ushort Unknown6 { get; set; }
|
||||
public byte CapsuleIndex { get; set; }
|
||||
public ushort HP { get; set; } // remaining hp
|
||||
public override ushort HP { get { return _HP; } } // remaining hp
|
||||
public ushort _HP { get; set; }
|
||||
public byte[] Unknown7 { get; set; } // 56 bytes
|
||||
public byte[] Seals { get; set; } // 24 bytes
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ namespace PkmnFoundations.Structures
|
||||
// todo: validate this against the computed level
|
||||
//Level = block[4];
|
||||
CapsuleIndex = block[5];
|
||||
HP = BitConverter.ToUInt16(block, 6);
|
||||
_HP = BitConverter.ToUInt16(block, 6);
|
||||
// todo: validate this against computed stats
|
||||
m_stats = new IntStatValues(BitConverter.ToUInt16(block, 8),
|
||||
BitConverter.ToUInt16(block, 10),
|
||||
@@ -79,7 +79,8 @@ namespace PkmnFoundations.Structures
|
||||
public byte Unknown5 { get; set; }
|
||||
public ushort Unknown6 { get; set; }
|
||||
public byte CapsuleIndex { get; set; }
|
||||
public ushort HP { get; set; } // remaining hp
|
||||
public override ushort HP { get { return _HP; } } // remaining hp
|
||||
public ushort _HP { get; set; }
|
||||
public byte[] Mail { get; set; } // 56 bytes
|
||||
public byte[] Unknown7 { get; set; } // 8 bytes
|
||||
public byte[] Padding { get; set; } // 16 bytes. Pads the length to match the gen4 structure.
|
||||
|
||||
@@ -162,6 +162,8 @@ namespace PkmnFoundations.Structures
|
||||
}
|
||||
}
|
||||
|
||||
public abstract ushort HP { get; }
|
||||
|
||||
public static ushort ComputeChecksum(byte[] data)
|
||||
{
|
||||
ushort result = 0;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace PkmnFoundations.Web.gts
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
Pokedex.Pokedex pokedex = AppStateHelper.Pokedex(Application);
|
||||
PokemonParty4 pkmn = null;
|
||||
PokemonPartyBase pkmn = null;
|
||||
|
||||
if (Request.QueryString.Count == 0 || Request.QueryString.Count > 2) throw new WebException(400);
|
||||
if (Request.QueryString["offer"] != null ||
|
||||
@@ -66,7 +66,7 @@ namespace PkmnFoundations.Web.gts
|
||||
case "5":
|
||||
{
|
||||
GtsRecord5 record = Database.Instance.GtsGetRecord5(pokedex, tradeId, isExchanged, true);
|
||||
if (record != null) pkmn = new PokemonParty4(pokedex, record.Data.ToArray());
|
||||
if (record != null) pkmn = new PokemonParty5(pokedex, record.Data.ToArray());
|
||||
|
||||
} break;
|
||||
default:
|
||||
@@ -86,7 +86,7 @@ namespace PkmnFoundations.Web.gts
|
||||
Bind(pkmn);
|
||||
}
|
||||
|
||||
private void Bind(PokemonParty4 pkmn)
|
||||
private void Bind(PokemonPartyBase pkmn)
|
||||
{
|
||||
litNickname.Text = pkmn.Nickname;
|
||||
bool shiny = pkmn.IsShiny;
|
||||
@@ -103,7 +103,7 @@ namespace PkmnFoundations.Web.gts
|
||||
litCharacteristic.Text = pkmn.Characteristic.ToString();
|
||||
litSpecies.Text = pkmn.Species.Name.ToString();
|
||||
litPokedex.Text = pkmn.SpeciesID.ToString("000");
|
||||
FormStats fs = pkmn.Form.BaseStats(Generations.Generation4);
|
||||
FormStats fs = pkmn.Form.BaseStats(pkmn.Generation);
|
||||
litType1.Text = fs.Type1 == null ? "" : WebFormat.RenderType(fs.Type1);
|
||||
litType2.Text = fs.Type2 == null ? "" : WebFormat.RenderType(fs.Type2);
|
||||
litOtName.Text = Common.HtmlEncode(pkmn.TrainerName);
|
||||
|
||||
Reference in New Issue
Block a user