Commit 50ea2be5 authored by nanahira's avatar nanahira

expansions replace

parent a019cfc9
...@@ -409,7 +409,7 @@ public class Program : MonoBehaviour ...@@ -409,7 +409,7 @@ public class Program : MonoBehaviour
{ {
if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".cdb") if (fileInfos[i].Name.Substring(fileInfos[i].Name.Length - 4, 4) == ".cdb")
{ {
YGOSharp.CardsManager.initialize("expansions/" + fileInfos[i].Name); YGOSharp.CardsManager.initialize("expansions/" + fileInfos[i].Name, false, true);
} }
} }
} }
......
...@@ -16,7 +16,7 @@ namespace YGOSharp ...@@ -16,7 +16,7 @@ namespace YGOSharp
public static string nullString = ""; public static string nullString = "";
internal static bool initialize(string databaseFullPath, bool test = false) internal static bool initialize(string databaseFullPath, bool test = false, bool replace = false)
{ {
if(!test) { if(!test) {
nullName = InterString.Get("未知卡片"); nullName = InterString.Get("未知卡片");
...@@ -41,7 +41,7 @@ namespace YGOSharp ...@@ -41,7 +41,7 @@ namespace YGOSharp
{ {
while (reader.Read()) while (reader.Read())
{ {
LoadCard(reader, test); LoadCard(reader, test, replace);
} }
} }
} }
...@@ -88,12 +88,21 @@ namespace YGOSharp ...@@ -88,12 +88,21 @@ namespace YGOSharp
return returnValue; return returnValue;
} }
private static void LoadCard(IDataRecord reader, bool test = false) private static void LoadCard(IDataRecord reader, bool test = false, bool replace = false)
{ {
Card card = new Card(reader); Card card = new Card(reader);
if (!_cards.ContainsKey(card.Id) && !test) if (test)
{
return;
}
if (!_cards.ContainsKey(card.Id))
{ {
_cards.Add(card.Id, card); _cards.Add(card.Id, card);
}
else if (replace)
{
_cards.Remove(card.Id);
_cards.Add(card.Id, card);
} }
} }
...@@ -581,9 +590,9 @@ namespace YGOSharp ...@@ -581,9 +590,9 @@ namespace YGOSharp
c.packFullName = reader.GetString(2); c.packFullName = reader.GetString(2);
string[] mats = temp.Split("-"); string[] mats = temp.Split("-");
if (mats.Length > 1) if (mats.Length > 1)
c.packShortNam = mats[0]; c.packShortNam = mats[0];
else else
c.packShortNam = c.packFullName.Length > 10 ? c.packFullName.Substring(0, 10) + "..." : c.packFullName; c.packShortNam = c.packFullName.Length > 10 ? c.packFullName.Substring(0, 10) + "..." : c.packFullName;
c.reality = reader.GetString(3); c.reality = reader.GetString(3);
temp = reader.GetString(4); temp = reader.GetString(4);
mats = temp.Split("/"); mats = temp.Split("/");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment