Show more pokemon stats.

This commit is contained in:
Greg Edwards 2015-03-11 21:22:04 -04:00
parent 91fef43978
commit af97c2e6df
8 changed files with 321 additions and 64 deletions

View File

@ -98,6 +98,7 @@ namespace PkmnFoundations.Data
reader.Close();
return result;
}
reader.Close();
if (allowHistory)
{
@ -1089,6 +1090,7 @@ namespace PkmnFoundations.Data
reader.Close();
return result;
}
reader.Close();
if (allowHistory)
{

View File

@ -38,5 +38,14 @@ namespace PkmnFoundations.Pokedex
k => k == 0 ? null : (pokedex == null ? null : pokedex.Types(k)),
v => v == null ? 0 : v.ID);
}
public String Identifier
{
get
{
// xxx: this is a hack. Should database this field instead.
return Name["EN"].ToLowerInvariant();
}
}
}
}

View File

@ -23,7 +23,7 @@ namespace PkmnFoundations.Structures
public byte RemainingPP { get; set; } // todo: validate range (against pokedex data and pp ups)
// todo: should have a MoveID/Move LazyKeyValuePair.
public Move Move { get { return m_pokedex.Moves(MoveID); } }
public Move Move { get { return MoveID == 0 ? null : m_pokedex.Moves(MoveID); } }
public int PP { get { return Move.PP * (5 + PPUps) / 5; } }
}
}

View File

@ -102,10 +102,10 @@ namespace PkmnFoundations.Structures
{
byte[] block = blocks[1];
Moves[0] = new MoveSlot(m_pokedex, BitConverter.ToUInt16(block, 0), block[8], block[12]);
Moves[1] = new MoveSlot(m_pokedex, BitConverter.ToUInt16(block, 2), block[9], block[13]);
Moves[2] = new MoveSlot(m_pokedex, BitConverter.ToUInt16(block, 4), block[10], block[14]);
Moves[3] = new MoveSlot(m_pokedex, BitConverter.ToUInt16(block, 6), block[11], block[15]);
Moves[0] = new MoveSlot(m_pokedex, BitConverter.ToUInt16(block, 0), block[12], block[8]);
Moves[1] = new MoveSlot(m_pokedex, BitConverter.ToUInt16(block, 2), block[13], block[9]);
Moves[2] = new MoveSlot(m_pokedex, BitConverter.ToUInt16(block, 4), block[14], block[10]);
Moves[3] = new MoveSlot(m_pokedex, BitConverter.ToUInt16(block, 6), block[15], block[11]);
int ivs = BitConverter.ToInt32(block, 16);
IVs = new IvStatValues(ivs & 0x3fffffff);
@ -170,8 +170,8 @@ namespace PkmnFoundations.Structures
for (int pos = 0; pos < 100; pos += 2)
{
rand = DecryptRNG(rand);
block[pos] ^= (byte)(rand >> 24);
block[pos + 1] ^= (byte)(rand >> 16);
block[pos] ^= (byte)(rand >> 16);
block[pos + 1] ^= (byte)(rand >> 24);
}
StatusAffliction = block[0];
@ -339,9 +339,7 @@ namespace PkmnFoundations.Structures
private bool IsHgss()
{
return !(Version == Versions.Diamond ||
Version == Versions.Pearl ||
Version == Versions.Platinum);
return (Version == Versions.HeartGold || Version == Versions.SoulSilver);
}
private bool IsHgssPokeball(int pokeballId)

View File

@ -56,7 +56,9 @@ namespace PkmnFoundations.Support
{
ushort gamecode = BitConverter.ToUInt16(data, i);
if (gamecode == 0xffff) { break; }
char ch = Generation4TextLookupTable[gamecode];
char ch = Generation4TextLookupTable.ContainsKey(gamecode) ?
Generation4TextLookupTable[gamecode] :
'?';
sb.Append(ch);
}

View File

@ -1,5 +1,7 @@
<%@ Page Title="" Language="C#" MasterPageFile="~/masters/MasterPage.master" AutoEventWireup="true" CodeBehind="Pokemon.aspx.cs" Inherits="PkmnFoundations.Web.gts.Pokemon" %>
<%@ Register TagPrefix="pf" Namespace="PkmnFoundations.Web" Assembly="PkmnFoundations.Web" %>
<%@ Import Namespace="PkmnFoundations.Pokedex" %>
<%@ Import Namespace="PkmnFoundations.Structures" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cpHead" runat="server">
<pf:RequireCss Key="form" CssUrl="~/css/form.css" runat="server" />
@ -44,55 +46,59 @@
<asp:Literal ID="litGender" runat="server" />
</li>
</ul>
<p>Met December 19, 2014<br />
in Slateport City at Lv. 20</p>
<p>Capable of taking hits.</p>
<p><asp:Literal ID="litTrainerMemo" Text="Trainer memo todo" runat="server" /></p>
<p><asp:Literal ID="litCharacteristic" Text="Characteristic todo" runat="server" /></p>
</div>
<div class="col colBasic2">
<table class="summaryItems">
<tr>
<th>Species</th>
<td>Pikachu</td>
<td><asp:Literal ID="litSpecies" runat="server" /></td>
</tr>
<tr>
<th>Pokédex</th>
<td>025</td>
<td>#<asp:Literal ID="litPokedex" runat="server" /></td>
</tr>
<tr>
<th>Type</th>
<td><span class="type electric">Electric</span></td>
<td>
<asp:Literal ID="litType1" runat="server" />&nbsp;
<asp:Literal ID="litType2" runat="server" />
</td>
</tr>
<tr>
<th>OT</th>
<td>Ash</td>
<td><asp:Literal ID="litOtName" runat="server" /></td>
</tr>
<tr>
<th>ID No.</th>
<td>12345</td>
<td><asp:Literal ID="litTrainerId" runat="server" /></td>
</tr>
<tr>
<th>Exp.</th>
<td>8000
<td><asp:Literal ID="litExperience" runat="server" />
<div class="nextIn">next in 1261</div>
<div class="nextIn">next in ??? todo</div>
<div class="gtsProgress expBar">
<div class="progress" style="width: 50%;"></div>
<asp:Literal ID="litExpProgress" runat="server">
<div class="progress" style="width: 50%;"></div>
</asp:Literal>
</div>
</td>
</tr>
<tr>
<th>Held item</th>
<td><asp:Image ID="imgItem" CssClass="sprite item" ImageUrl="~/images/item-sm/3202.png" Width="24" Height="24" runat="server" />
Light Ball</td>
<td><asp:Image ID="imgHeldItem" CssClass="sprite item" ImageUrl="~/images/item-sm/3202.png" Width="24" Height="24" runat="server" />
<asp:Literal ID="litHeldItem" runat="server" /></td>
</tr>
<tr>
<th>Nature</th>
<td>Naive</td>
<td><asp:Literal ID="litNature" runat="server" /></td>
</tr>
<tr>
<th>Ability</th>
<td>Lightning Rod<sup>dw</sup>
<td><asp:Literal ID="litAbility" runat="server" />
</td>
</tr>
</table>
@ -102,63 +108,55 @@
<table class="summaryItems">
<tr>
<th>HP</th>
<td>50 / 50<br />
<td><asp:Literal ID="litHpCurr" runat="server" /> / <asp:Literal ID="litHp" runat="server" /><br />
<div class="gtsProgress hpBar">
<div class="progress" style="width: 90%;"></div>
<asp:Literal ID="litHpProgress" runat="server">
<div class="progress" style="width: 50%;"></div>
</asp:Literal>
</div>
</td>
</tr>
<tr>
<th>Attack</th>
<td>27</td>
<td><asp:Literal ID="litAtk" runat="server" /></td>
</tr>
<tr>
<th>Defense</th>
<td>27</td>
<td><asp:Literal ID="litDef" runat="server" /></td>
</tr>
<tr>
<th>Sp. Atk</th>
<td>31</td>
<td><asp:Literal ID="litSAtk" runat="server" /></td>
</tr>
<tr>
<th>Sp. Def</th>
<td>23</td>
<td><asp:Literal ID="litSDef" runat="server" /></td>
</tr>
<tr>
<th>Speed</th>
<td>50</td>
<td><asp:Literal ID="litSpeed" runat="server" /></td>
</tr>
</table>
<table class="moves">
<tr class="move normal">
<th class="type normal">Normal</th>
<td>
<span class="name">Quick Attack</span>
<span class="pp">30 / 30</span>
</td>
</tr>
<tr class="move electric">
<th class="type electric">Electric</th>
<td>
<span class="name">Electro Ball</span>
<span class="pp">10 / 10</span>
</td>
</tr>
<tr class="move electric">
<th class="type electric">Electric</th>
<td>
<span class="name">Thunder Wave</span>
<span class="pp">20 / 20</span>
</td>
</tr>
<tr class="move fairy">
<th class="type fairy">Fairy</th>
<td>
<span class="name">Drainging Kiss</span>
<span class="pp">10 / 10</span>
</td>
</tr>
<asp:Repeater ID="rptMoves" runat="server">
<ItemTemplate>
<tr class="move <%# ((MoveSlot)Container.DataItem).Move == null ? "" : ((MoveSlot)Container.DataItem).Move.Type.Identifier %>">
<th class="type <%# ((MoveSlot)Container.DataItem).Move == null ? "" : ((MoveSlot)Container.DataItem).Move.Type.Identifier %>">
<%# ((MoveSlot)Container.DataItem).Move == null ? "" : ((MoveSlot)Container.DataItem).Move.Type.Name.ToString() %>
</th>
<td>
<span class="name">
<%# ((MoveSlot)Container.DataItem).Move == null ? "&nbsp;" : ((MoveSlot)Container.DataItem).Move.Name.ToString() %>
</span>
<span class="pp">
<%# ((MoveSlot)Container.DataItem).Move == null ? "" : ((MoveSlot)Container.DataItem).RemainingPP.ToString() + " / " %>
<%# ((MoveSlot)Container.DataItem).Move == null ? "" : ((MoveSlot)Container.DataItem).PP.ToString() %>
</span>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</div>

View File

@ -6,6 +6,7 @@ using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using PkmnFoundations.Data;
using PkmnFoundations.Pokedex;
using PkmnFoundations.Structures;
using PkmnFoundations.Support;
@ -92,10 +93,43 @@ namespace PkmnFoundations.Web.gts
phPkrs.Visible = false;
phPkrsCured.Visible = false;
litMarks.Text = CreateMarks(pkmn.Markings);
imgPokeball.ImageUrl = "~/images/item-sm/" + pkmn.Pokeball.ID.ToString() + ".png";
imgPokeball.ImageUrl = ItemFilename(pkmn.Pokeball);
imgPokeball.AlternateText = pkmn.Pokeball.Name.ToString();
imgPokeball.ToolTip = pkmn.Pokeball.Name.ToString();
litLevel.Text = pkmn.Level.ToString();
litGender.Text = CreateGender(pkmn.Gender);
litSpecies.Text = pkmn.Species.Name.ToString();
litPokedex.Text = pkmn.SpeciesID.ToString("000");
FormStats fs = pkmn.Form.BaseStats(Generations.Generation4);
litType1.Text = fs.Type1 == null ? "" : CreateType(fs.Type1);
litType2.Text = fs.Type2 == null ? "" : CreateType(fs.Type2);
litOtName.Text = Common.HtmlEncode(pkmn.TrainerName);
litTrainerId.Text = (pkmn.TrainerID & 0xffff).ToString("00000");
litExperience.Text = pkmn.Experience.ToString();
if (pkmn.HeldItem != null)
{
imgHeldItem.Visible = true;
imgHeldItem.ImageUrl = ItemFilename(pkmn.HeldItem);
litHeldItem.Text = pkmn.HeldItem.Name.ToString();
}
else
{
imgHeldItem.Visible = false;
litHeldItem.Text = "";
}
litNature.Text = pkmn.Nature.ToString(); // todo: i18n
litAbility.Text = pkmn.Ability == null ? "None" : pkmn.Ability.Name.ToString();
litHpCurr.Text = pkmn.HP.ToString();
litHp.Text = pkmn.Stats[Stats.Hp].ToString();
litHpProgress.Text = CreateProgress(pkmn.HP, pkmn.Stats[Stats.Hp]);
litAtk.Text = pkmn.Stats[Stats.Attack].ToString();
litDef.Text = pkmn.Stats[Stats.Defense].ToString();
litSAtk.Text = pkmn.Stats[Stats.SpecialAttack].ToString();
litSDef.Text = pkmn.Stats[Stats.SpecialDefense].ToString();
litSpeed.Text = pkmn.Stats[Stats.Speed].ToString();
rptMoves.DataSource = pkmn.Moves;
rptMoves.DataBind();
}
private String[] m_marks = new String[] { "●", "▲", "■", "♥", "★", "♦" };
@ -141,6 +175,11 @@ namespace PkmnFoundations.Web.gts
return builder.ToString();
}
private String ItemFilename(Item item)
{
return "~/images/item-sm/" + item.ID.ToString() + ".png";
}
private String CreateGender(Genders gender)
{
switch (gender)
@ -153,5 +192,16 @@ namespace PkmnFoundations.Web.gts
return "";
}
}
private String CreateType(Pokedex.Type type)
{
return "<span class=\"type " + type.Identifier + "\">" + type.Name.ToString() + "</span>";
}
private String CreateProgress(int curr, int max)
{
float percent = (float)curr * 100.0f / (float)max;
return "<div class=\"progress\" style=\"width: " + percent.ToString() + "%;\"></div>";
}
}
}

View File

@ -103,12 +103,210 @@ namespace PkmnFoundations.Web.gts {
protected global::System.Web.UI.WebControls.Literal litGender;
/// <summary>
/// imgItem control.
/// litTrainerMemo control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Image imgItem;
protected global::System.Web.UI.WebControls.Literal litTrainerMemo;
/// <summary>
/// litCharacteristic control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litCharacteristic;
/// <summary>
/// litSpecies control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litSpecies;
/// <summary>
/// litPokedex control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litPokedex;
/// <summary>
/// litType1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litType1;
/// <summary>
/// litType2 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litType2;
/// <summary>
/// litOtName control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litOtName;
/// <summary>
/// litTrainerId control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litTrainerId;
/// <summary>
/// litExperience control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litExperience;
/// <summary>
/// litExpProgress control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litExpProgress;
/// <summary>
/// imgHeldItem control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Image imgHeldItem;
/// <summary>
/// litHeldItem control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litHeldItem;
/// <summary>
/// litNature control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litNature;
/// <summary>
/// litAbility control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litAbility;
/// <summary>
/// litHpCurr control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litHpCurr;
/// <summary>
/// litHp control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litHp;
/// <summary>
/// litHpProgress control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litHpProgress;
/// <summary>
/// litAtk control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litAtk;
/// <summary>
/// litDef control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litDef;
/// <summary>
/// litSAtk control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litSAtk;
/// <summary>
/// litSDef control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litSDef;
/// <summary>
/// litSpeed control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Literal litSpeed;
/// <summary>
/// rptMoves control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Repeater rptMoves;
}
}