mirror of
https://github.com/mm201/pkmn-classic-framework.git
synced 2026-08-02 16:13:17 -05:00
Added support for pokeballs beyond Quick Ball. Solves most of #59.
This commit is contained in:
parent
5d729d2195
commit
174ba6308f
|
|
@ -351,28 +351,51 @@ namespace VeekunImport
|
|||
{
|
||||
string filename = String.Format("items{0}.txt", generation);
|
||||
ProcessTSV(filename, 3, row =>
|
||||
{
|
||||
string[] fields = row.Fields;
|
||||
int id, thisGenId;
|
||||
string name = fields[1];
|
||||
if (!Int32.TryParse(fields[0], out thisGenId) ||
|
||||
!Int32.TryParse(fields[2], out id))
|
||||
{
|
||||
string[] fields = row.Fields;
|
||||
int id, thisGenId;
|
||||
string name = fields[1];
|
||||
if (!Int32.TryParse(fields[0], out thisGenId) ||
|
||||
!Int32.TryParse(fields[2], out id))
|
||||
{
|
||||
Console.WriteLine("{0} line {1} has bad format, skipped.", filename, row.LineNumber);
|
||||
return;
|
||||
}
|
||||
ItemLoading theItem = null;
|
||||
if (!items.ContainsKey(id))
|
||||
{
|
||||
theItem = new ItemLoading(id, name);
|
||||
items.Add(id, theItem);
|
||||
}
|
||||
theItem = theItem ?? items[id];
|
||||
theItem.Name = name; // prefer newer names where available
|
||||
theItem.SetGenerationValue(thisGenId, generation);
|
||||
});
|
||||
Console.WriteLine("{0} line {1} has bad format, skipped.", filename, row.LineNumber);
|
||||
return;
|
||||
}
|
||||
ItemLoading theItem = null;
|
||||
if (!items.ContainsKey(id))
|
||||
{
|
||||
theItem = new ItemLoading(id, name);
|
||||
items.Add(id, theItem);
|
||||
}
|
||||
theItem = theItem ?? items[id];
|
||||
theItem.Name = name; // prefer newer names where available
|
||||
theItem.SetGenerationValue(thisGenId, generation);
|
||||
});
|
||||
}
|
||||
|
||||
// Pokeball IDs:
|
||||
ProcessTSV("items_balls.txt", 3, row =>
|
||||
{
|
||||
string[] fields = row.Fields;
|
||||
int id, ballId;
|
||||
string name = fields[1];
|
||||
if (!Int32.TryParse(fields[0], out ballId) ||
|
||||
!Int32.TryParse(fields[2], out id))
|
||||
{
|
||||
Console.WriteLine("{0} line {1} has bad format, skipped.", "items_balls.txt", row.LineNumber);
|
||||
return;
|
||||
}
|
||||
ItemLoading theItem = null;
|
||||
if (!items.ContainsKey(id))
|
||||
{
|
||||
theItem = new ItemLoading(id, name);
|
||||
items.Add(id, theItem);
|
||||
}
|
||||
theItem = theItem ?? items[id];
|
||||
if (theItem.Name == null) theItem.Name = name;
|
||||
theItem.PokeballValue = ballId;
|
||||
});
|
||||
|
||||
// lookup Veekun ID number against some generation or another.
|
||||
Dictionary<int, ItemLoading> items3 = items
|
||||
.Where(i => i.Value.Value3 != null && i.Value.NameLocalized == null)
|
||||
|
|
@ -435,7 +458,7 @@ namespace VeekunImport
|
|||
name = new LocalizedString() { { "EN", il.Name } };
|
||||
Console.WriteLine("Veekun database missing item {0} {1}. Non-English translations will be missing.", il.ID, name);
|
||||
}
|
||||
Item i = new Item(null, il.ID, il.Value3, il.Value4, il.Value5, il.Value6, il.Price, name);
|
||||
Item i = new Item(null, il.ID, il.Value3, il.Value4, il.Value5, il.Value6, il.PokeballValue, il.Price, name);
|
||||
db.PokedexInsertItem(i);
|
||||
Console.WriteLine("Inserted item {0} {1}", i.ID, i.Name.ToString());
|
||||
}
|
||||
|
|
@ -632,6 +655,7 @@ namespace VeekunImport
|
|||
Name = name;
|
||||
Value3 = Value4 = Value5 = Value6 = null;
|
||||
NameLocalized = null;
|
||||
PokeballValue = null;
|
||||
}
|
||||
|
||||
public int ID;
|
||||
|
|
@ -639,6 +663,7 @@ namespace VeekunImport
|
|||
public LocalizedString NameLocalized;
|
||||
public int? Value3, Value4, Value5, Value6;
|
||||
public int Price;
|
||||
public int? PokeballValue;
|
||||
|
||||
public void SetGenerationValue(int ? value, int generation)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -111,6 +111,9 @@
|
|||
<Content Include="families.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="items_balls.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="regions.txt">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
|
|||
26
VeekunImport/items_balls.txt
Normal file
26
VeekunImport/items_balls.txt
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
1 Master Ball 3001
|
||||
2 Ultra Ball 3002
|
||||
3 Great Ball 3003
|
||||
4 Poké Ball 3004
|
||||
5 Safari Ball 3005
|
||||
6 Net Ball 3006
|
||||
7 Dive Ball 3007
|
||||
8 Nest Ball 3008
|
||||
9 Repeat Ball 3009
|
||||
10 Timer Ball 3010
|
||||
11 Luxury Ball 3011
|
||||
12 Premier Ball 3012
|
||||
13 Dusk Ball 4013
|
||||
14 Heal Ball 4014
|
||||
15 Quick Ball 4015
|
||||
16 Cherish Ball 4016
|
||||
17 Fast Ball 4492
|
||||
18 Level Ball 4493
|
||||
19 Lure Ball 4494
|
||||
20 Heavy Ball 4495
|
||||
21 Love Ball 4496
|
||||
22 Friend Ball 4497
|
||||
23 Moon Ball 4498
|
||||
24 Sport Ball 4499
|
||||
#25 Park Ball 4500
|
||||
#26 Dream Ball 5576
|
||||
|
|
@ -3101,12 +3101,13 @@ namespace PkmnFoundations.Data
|
|||
insertParams.Add(new MySqlParameter("@value4", i.Value4));
|
||||
insertParams.Add(new MySqlParameter("@value5", i.Value5));
|
||||
insertParams.Add(new MySqlParameter("@value6", i.Value6));
|
||||
insertParams.Add(new MySqlParameter("@pokeball_value", i.PokeballValue));
|
||||
insertParams.Add(new MySqlParameter("@price", i.Price));
|
||||
CreateLocalizedStringQueryPieces(i.Name, insertParams);
|
||||
|
||||
db.ExecuteNonQuery("INSERT INTO pkmncf_pokedex_items (id, Value3, " +
|
||||
"Value4, Value5, Value6, " + INSERT_COLUMNS + ", Price) VALUES (" +
|
||||
"@id, @value3, @value4, @value5, @value6, " + INSERT_VALUES +
|
||||
"Value4, Value5, Value6, PokeballValue, " + INSERT_COLUMNS + ", Price) VALUES (" +
|
||||
"@id, @value3, @value4, @value5, @value6, @pokeball_value, " + INSERT_VALUES +
|
||||
", @price)", insertParams.ToArray());
|
||||
|
||||
db.Close();
|
||||
|
|
@ -3344,7 +3345,7 @@ namespace PkmnFoundations.Data
|
|||
db.Open();
|
||||
|
||||
using (MySqlDataReader reader = (MySqlDataReader)db.ExecuteReader("SELECT " +
|
||||
"id, Value3, Value4, Value5, Value6, " + INSERT_COLUMNS +
|
||||
"id, Value3, Value4, Value5, Value6, PokeballValue, " + INSERT_COLUMNS +
|
||||
", Price " +
|
||||
"FROM pkmncf_pokedex_items"))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace PkmnFoundations.Pokedex
|
|||
public class Item : PokedexRecordBase
|
||||
{
|
||||
public Item(Pokedex pokedex, int id, int ? value3, int ? value4,
|
||||
int ? value5, int ? value6, int price, LocalizedString name)
|
||||
int ? value5, int ? value6, int ? pokeball_value, int price, LocalizedString name)
|
||||
: base(pokedex)
|
||||
{
|
||||
ID = id;
|
||||
|
|
@ -21,6 +21,7 @@ namespace PkmnFoundations.Pokedex
|
|||
Value4 = value4;
|
||||
Value5 = value5;
|
||||
Value6 = value6;
|
||||
PokeballValue = pokeball_value;
|
||||
Price = price;
|
||||
Name = name;
|
||||
}
|
||||
|
|
@ -33,6 +34,7 @@ namespace PkmnFoundations.Pokedex
|
|||
reader["Value4"] is DBNull ? null : (int?)Convert.ToInt32(reader["Value4"]),
|
||||
reader["Value5"] is DBNull ? null : (int?)Convert.ToInt32(reader["Value5"]),
|
||||
reader["Value6"] is DBNull ? null : (int?)Convert.ToInt32(reader["Value6"]),
|
||||
reader["PokeballValue"] is DBNull ? null : (int?)Convert.ToInt32(reader["PokeballValue"]),
|
||||
Convert.ToInt32(reader["Price"]),
|
||||
LocalizedStringFromReader(reader, "Name_")
|
||||
)
|
||||
|
|
@ -68,9 +70,7 @@ namespace PkmnFoundations.Pokedex
|
|||
|
||||
public int ? PokeballValue
|
||||
{
|
||||
// fixme: this needs to be its own field in the database.
|
||||
// (see full comment at Pokedex.Pokeballs)
|
||||
get { return Value6; }
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public static LazyKeyValuePair<int, Item> CreatePair(Pokedex pokedex)
|
||||
|
|
@ -90,7 +90,7 @@ namespace PkmnFoundations.Pokedex
|
|||
public static LazyKeyValuePair<int, Item> CreatePairPokeball(Pokedex pokedex)
|
||||
{
|
||||
return new LazyKeyValuePair<int, Item>(
|
||||
k => k == 0 ? null : (pokedex == null ? null : pokedex.Pokeballs(k)),
|
||||
k => k == 0 ? null : (pokedex == null ? null : pokedex.Pokeballs[k]),
|
||||
v => v == null ? 0 : v.ID);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ namespace PkmnFoundations.Pokedex
|
|||
m_items_generations.Add(Generations.Generation4, items4);
|
||||
m_items_generations.Add(Generations.Generation5, items5);
|
||||
m_items_generations.Add(Generations.Generation6, items6);
|
||||
m_pokeballs = new Dictionary<int, Item>();
|
||||
|
||||
foreach (var pair in m_items)
|
||||
{
|
||||
|
|
@ -88,6 +89,7 @@ namespace PkmnFoundations.Pokedex
|
|||
if (i.Value4 != null) items4.Add((int)i.Value4, i);
|
||||
if (i.Value5 != null) items5.Add((int)i.Value5, i);
|
||||
if (i.Value6 != null) items6.Add((int)i.Value6, i);
|
||||
if (i.PokeballValue != null) m_pokeballs.Add((int)i.PokeballValue, i);
|
||||
}
|
||||
|
||||
m_ribbon_positions_generations = new Dictionary<Generations, Dictionary<int, Ribbon>>();
|
||||
|
|
@ -164,6 +166,7 @@ namespace PkmnFoundations.Pokedex
|
|||
private Dictionary<int, Ribbon> m_ribbons;
|
||||
|
||||
private Dictionary<Generations, Dictionary<int, Item>> m_items_generations;
|
||||
private Dictionary<int, Item> m_pokeballs;
|
||||
private Dictionary<Generations, Dictionary<int, Ribbon>> m_ribbon_positions_generations;
|
||||
private Dictionary<Generations, Dictionary<int, Ribbon>> m_ribbon_values_generations;
|
||||
|
||||
|
|
@ -220,12 +223,12 @@ namespace PkmnFoundations.Pokedex
|
|||
return m_items_generations[generation];
|
||||
}
|
||||
|
||||
public Item Pokeballs(int value)
|
||||
public IDictionary<int, Item> Pokeballs
|
||||
{
|
||||
// fixme: fact check the values for apricorn pokeballs.
|
||||
// What's used here is most assuredly wrong (and probably quite silly)
|
||||
// todo: add a PokeballValue field to the Items table and a dictionary here
|
||||
return m_items_generations[Generations.Generation5][value];
|
||||
get
|
||||
{
|
||||
return m_pokeballs;
|
||||
}
|
||||
}
|
||||
|
||||
public IDictionary<int, Move> Moves
|
||||
|
|
|
|||
|
|
@ -262,7 +262,8 @@ namespace PkmnFoundations.Structures
|
|||
{
|
||||
if (m_pokeball != null) return m_pokeball;
|
||||
int pokeballId = IsHgss() ? PokeBallID_Hgss : PokeBallID;
|
||||
m_pokeball = m_pokedex.Pokeballs(pokeballId);
|
||||
if (!m_pokedex.Pokeballs.ContainsKey(pokeballId)) return null;
|
||||
m_pokeball = m_pokedex.Pokeballs[pokeballId];
|
||||
return m_pokeball;
|
||||
}
|
||||
set
|
||||
|
|
|
|||
|
|
@ -268,7 +268,8 @@ namespace PkmnFoundations.Structures
|
|||
get
|
||||
{
|
||||
if (m_pokeball != null) return m_pokeball;
|
||||
m_pokeball = m_pokedex.Pokeballs(PokeBallID);
|
||||
if (!m_pokedex.Pokeballs.ContainsKey(PokeBallID)) return null;
|
||||
m_pokeball = m_pokedex.Pokeballs[PokeBallID];
|
||||
return m_pokeball;
|
||||
}
|
||||
set
|
||||
|
|
|
|||
|
|
@ -564,6 +564,7 @@ CREATE TABLE IF NOT EXISTS `pkmncf_pokedex_items` (
|
|||
`Value4` int(10) unsigned DEFAULT NULL,
|
||||
`Value5` int(10) unsigned DEFAULT NULL,
|
||||
`Value6` int(10) unsigned DEFAULT NULL,
|
||||
`PokeballValue` int(10) unsigned DEFAULT NULL,
|
||||
`Name_JA` varchar(30) DEFAULT '',
|
||||
`Name_EN` varchar(30) DEFAULT NULL,
|
||||
`Name_FR` varchar(30) DEFAULT NULL,
|
||||
|
|
@ -577,7 +578,8 @@ CREATE TABLE IF NOT EXISTS `pkmncf_pokedex_items` (
|
|||
KEY `Value3` (`Value3`),
|
||||
KEY `Value4` (`Value4`),
|
||||
KEY `Value5` (`Value5`),
|
||||
KEY `Value6` (`Value6`)
|
||||
KEY `Value6` (`Value6`),
|
||||
KEY `ValueBall` (`PokeballValue`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=5639 DEFAULT CHARSET=utf8;
|
||||
|
||||
-- Data exporting was unselected.
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace PkmnFoundations.GTS
|
|||
txtLevelMax.Attributes["onchange"] = "changedMax(\'" + txtLevelMin.ClientID + "\', \'" + txtLevelMax.ClientID + "\');";
|
||||
}
|
||||
|
||||
private String FormatLevels(byte min, byte max)
|
||||
private string FormatLevels(byte min, byte max)
|
||||
{
|
||||
if (min == 0 && max == 0)
|
||||
{
|
||||
|
|
@ -68,7 +68,7 @@ namespace PkmnFoundations.GTS
|
|||
}
|
||||
}
|
||||
|
||||
protected String CreateOfferImage(object DataItem)
|
||||
protected string CreateOfferImage(object DataItem)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -83,14 +83,14 @@ namespace PkmnFoundations.GTS
|
|||
}
|
||||
}
|
||||
|
||||
protected String CreatePokeball(object DataItem)
|
||||
protected string CreatePokeball(object DataItem)
|
||||
{
|
||||
try
|
||||
{
|
||||
GtsRecordBase record = (GtsRecordBase)DataItem;
|
||||
// Hide pokeballs with incorrect numbers until we catalog them.
|
||||
if (record.Pokemon.Pokeball.Value4 > 15) return "";
|
||||
String itemName = Common.HtmlEncode(record.Pokemon.Pokeball.Name.ToString());
|
||||
if (record.Pokemon.Pokeball == null) return "";
|
||||
string itemName = Common.HtmlEncode(record.Pokemon.Pokeball.Name.ToString());
|
||||
return "<img src=\"" + ResolveUrl(WebFormat.ItemImage(record.Pokemon.Pokeball)) +
|
||||
"\" alt=\"" + itemName + "\" title=\"" + itemName +
|
||||
"\" class=\"sprite item\" width=\"24px\" height=\"24px\" />";
|
||||
|
|
@ -101,7 +101,7 @@ namespace PkmnFoundations.GTS
|
|||
}
|
||||
}
|
||||
|
||||
protected String CreatePokerus(object DataItem)
|
||||
protected string CreatePokerus(object DataItem)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -122,19 +122,19 @@ namespace PkmnFoundations.GTS
|
|||
}
|
||||
}
|
||||
|
||||
protected String CreateLevel(object DataItem)
|
||||
protected string CreateLevel(object DataItem)
|
||||
{
|
||||
GtsRecordBase record = (GtsRecordBase)DataItem;
|
||||
return record.Level.ToString();
|
||||
}
|
||||
|
||||
protected String CreateGender(object DataItem)
|
||||
protected string CreateGender(object DataItem)
|
||||
{
|
||||
GtsRecordBase record = (GtsRecordBase)DataItem;
|
||||
return Format.GenderSymbol(record.Gender);
|
||||
}
|
||||
|
||||
protected String CreateNickname(object DataItem)
|
||||
protected string CreateNickname(object DataItem)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -147,7 +147,7 @@ namespace PkmnFoundations.GTS
|
|||
}
|
||||
}
|
||||
|
||||
protected String CreateSpecies(object DataItem)
|
||||
protected string CreateSpecies(object DataItem)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -161,7 +161,7 @@ namespace PkmnFoundations.GTS
|
|||
}
|
||||
}
|
||||
|
||||
protected String CreatePokedex(object DataItem)
|
||||
protected string CreatePokedex(object DataItem)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -174,13 +174,13 @@ namespace PkmnFoundations.GTS
|
|||
}
|
||||
}
|
||||
|
||||
protected String CreateHeldItem(object DataItem)
|
||||
protected string CreateHeldItem(object DataItem)
|
||||
{
|
||||
try
|
||||
{
|
||||
GtsRecordBase record = (GtsRecordBase)DataItem;
|
||||
if (record.Pokemon.HeldItem == null) return "";
|
||||
String itemName = Common.HtmlEncode(record.Pokemon.HeldItem.Name.ToString());
|
||||
string itemName = Common.HtmlEncode(record.Pokemon.HeldItem.Name.ToString());
|
||||
return "<img src=\"" + ResolveUrl(WebFormat.ItemImage(record.Pokemon.HeldItem)) +
|
||||
"\" alt=\"" + itemName + "\" class=\"sprite item\" width=\"24px\" height=\"24px\" />" +
|
||||
itemName;
|
||||
|
|
@ -191,7 +191,7 @@ namespace PkmnFoundations.GTS
|
|||
}
|
||||
}
|
||||
|
||||
protected String CreateNature(object DataItem)
|
||||
protected string CreateNature(object DataItem)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -204,7 +204,7 @@ namespace PkmnFoundations.GTS
|
|||
}
|
||||
}
|
||||
|
||||
protected String CreateAbility(object DataItem)
|
||||
protected string CreateAbility(object DataItem)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -217,13 +217,13 @@ namespace PkmnFoundations.GTS
|
|||
}
|
||||
}
|
||||
|
||||
protected String CreateTrainer(object DataItem)
|
||||
protected string CreateTrainer(object DataItem)
|
||||
{
|
||||
GtsRecordBase record = (GtsRecordBase)DataItem;
|
||||
return Common.HtmlEncode(record.TrainerName);
|
||||
}
|
||||
|
||||
protected String CreateWantedSpecies(object DataItem)
|
||||
protected string CreateWantedSpecies(object DataItem)
|
||||
{
|
||||
Pokedex.Pokedex pokedex = AppStateHelper.Pokedex(Application);
|
||||
GtsRecordBase record = (GtsRecordBase)DataItem;
|
||||
|
|
@ -237,19 +237,19 @@ namespace PkmnFoundations.GTS
|
|||
record.RequestedSpecies);
|
||||
}
|
||||
|
||||
protected String CreateWantedGender(object DataItem)
|
||||
protected string CreateWantedGender(object DataItem)
|
||||
{
|
||||
GtsRecordBase record = (GtsRecordBase)DataItem;
|
||||
return Format.GenderSymbol(record.RequestedGender);
|
||||
}
|
||||
|
||||
protected String CreateWantedLevel(object DataItem)
|
||||
protected string CreateWantedLevel(object DataItem)
|
||||
{
|
||||
GtsRecordBase record = (GtsRecordBase)DataItem;
|
||||
return FormatLevels(record.RequestedMinLevel, record.RequestedMaxLevel);
|
||||
}
|
||||
|
||||
protected String CreateDate(object DataItem)
|
||||
protected string CreateDate(object DataItem)
|
||||
{
|
||||
GtsRecordBase record = (GtsRecordBase)DataItem;
|
||||
if (record.TimeDeposited == null) return "";
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user