Skip to content

Commit

Permalink
refactorings:
Browse files Browse the repository at this point in the history
- fixed petcount
- renamed groupboxes
- commented quickslots out
  • Loading branch information
tolik518 committed Feb 19, 2024
1 parent 93e2dbf commit af22c7b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 34 deletions.
6 changes: 5 additions & 1 deletion SoG_SGreader.Test/DataReaderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ private static Player GetSaveGame(int saveGameNumber)
if (Environment.GetEnvironmentVariable("GITHUB_WORKSPACE") != null) {
projectDirectory = Environment.GetEnvironmentVariable("GITHUB_WORKSPACE");
}

else
{
projectDirectory = Path.Combine(projectDirectory, "SoG_SGreader");
}

string filePath = Path.Combine(projectDirectory, "SoG_SGreader.Test", "SaveGames", saveGameNumber + ".cha");

return DataReader.ReadFromFile(filePath, fakeTextBox);
Expand Down
12 changes: 10 additions & 2 deletions SoG_SGreader.Test/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ private static string GetExePath()
projectDirectory = Environment.GetEnvironmentVariable("GITHUB_WORKSPACE");
return Path.Combine(projectDirectory, "SoG_SGreader", "bin", "Release", "SoG_SGreader.exe");
}

else
{
projectDirectory = Path.Combine(projectDirectory, "SoG_SGreader");
}

return Path.Combine(projectDirectory, "SoG_SGreader", "bin", "Debug", "SoG_SGreader.exe");
}

Expand All @@ -27,6 +31,10 @@ private static string GetSaveGamePath(string saveGameNumber)
// Exception for GitHub Actions Test Runner
if (Environment.GetEnvironmentVariable("GITHUB_WORKSPACE") != null) {
projectDirectory = Environment.GetEnvironmentVariable("GITHUB_WORKSPACE");
}
else
{
projectDirectory = Path.Combine(projectDirectory,"SoG_SGreader");
}

return Path.Combine(projectDirectory, "SoG_SGreader.Test", "SaveGames", saveGameNumber + ".cha");
Expand Down Expand Up @@ -54,7 +62,7 @@ public void TestBadPath()
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();

Assert.Contains("Could not find file", output);
Assert.Contains("Could not read savegame", output);
Assert.Contains(Path.Combine("SaveGames", "doesntexist.cha"), output);
}

Expand Down
4 changes: 2 additions & 2 deletions SoG_SGreader/DataWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ public void WriteToFile(string fileName)
writeBinary.Write(playerObject.SkillGoldPoints);
writeBinary.Write(playerObject.Cash);

writeBinary.Write(playerObject.PetsCount);
for (var i = 0; i != playerObject.PetsCount; i++)
writeBinary.Write(playerObject.Pets.Count);
for (var i = 0; i != playerObject.Pets.Count; i++)
{
var currentPet = playerObject.Pets[i];

Expand Down
48 changes: 24 additions & 24 deletions SoG_SGreader/Forms/FrmMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions SoG_SGreader/Forms/FrmMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ private void InitElements() // Designer Items
Size = new Size(79, 21),
Enabled = false
};
groupBox3.Controls.Add(cbQuickslotType[i]);
groupBox3.Controls.Add(cbQuickslot[i]);
cbQuickslotType[i].SelectedIndexChanged += new System.EventHandler(QuickslotType_SelectedIndexChanged);
grpQuickslots.Controls.Add(cbQuickslotType[i]);
grpQuickslots.Controls.Add(cbQuickslot[i]);

iQuickslotYpos -= 27;
}
Expand Down Expand Up @@ -309,6 +308,7 @@ private void GetDataFromFields()
playerObject.Style.Weapon = (int)Enum.Parse(typeof(SogItems), cbStyleWeapon.Text);
playerObject.Style.Shield = (int)Enum.Parse(typeof(SogItems), cbStyleShield.Text);

/* TODO: Quickslots are not being saved correctly, we need to fix this
for (int i = 0; i < 10; i++)
{
if (cbQuickslotType[i].Text == nameof(SogItems))
Expand All @@ -323,9 +323,10 @@ private void GetDataFromFields()
}
else
{
playerObject.Quickslots[i] = (int)0;
}
//playerObject.Quickslots[i] = 0;
playerObject.Quickslots[i] = playerObject.Quickslots[i];
}
}*/

playerObject.ItemsCount = lstInventory.Items.Count;
playerObject.Inventory.Clear();
Expand Down

0 comments on commit af22c7b

Please sign in to comment.