Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Starting armies use recruitable units #62

Merged
merged 15 commits into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ dotnet_diagnostic.CA1310.severity = suggestion
# IDE0220: Add explicit cast in foreach
dotnet_diagnostic.IDE0220.severity = suggestion

# Allow underscores in namespace
dotnet_diagnostic.CA1707.severity = none

# Allow constant array arguments
dotnet_diagnostic.CA1861.severity = none

csharp_style_prefer_top_level_statements = false

##########################################
Expand Down
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,6 @@ FodyWeavers.xsd

# VS Code files for those working on multiple tools
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
Expand Down
2 changes: 1 addition & 1 deletion RTWLibPlus/data/RemasterRome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class TWConfig
public static TWConfig LoadConfig(string path)
{
DepthParse dp = new();
string json = dp.ReadFileAsString(path);
string json = DepthParse.ReadFileAsString(path);
return JsonSerializer.Deserialize<TWConfig>(json);
}

Expand Down
18 changes: 9 additions & 9 deletions RTWLibPlus/data/unit/Unit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -332,16 +332,16 @@
float secCharge = Convert.ToInt16(this.SecWep[1]) * weights["attackBonus"];

string isRange = this.PriWep[2];
float range = 1f;

Check warning on line 335 in RTWLibPlus/data/unit/Unit.cs

View workflow job for this annotation

GitHub Actions / build-windows

The variable 'range' is assigned but its value is never used

Check warning on line 335 in RTWLibPlus/data/unit/Unit.cs

View workflow job for this annotation

GitHub Actions / build-windows

The variable 'range' is assigned but its value is never used

Check warning on line 335 in RTWLibPlus/data/unit/Unit.cs

View workflow job for this annotation

GitHub Actions / build-macos

The variable 'range' is assigned but its value is never used

Check warning on line 335 in RTWLibPlus/data/unit/Unit.cs

View workflow job for this annotation

GitHub Actions / build-macos

The variable 'range' is assigned but its value is never used

Check warning on line 335 in RTWLibPlus/data/unit/Unit.cs

View workflow job for this annotation

GitHub Actions / build-linux

The variable 'range' is assigned but its value is never used

Check warning on line 335 in RTWLibPlus/data/unit/Unit.cs

View workflow job for this annotation

GitHub Actions / build-linux

The variable 'range' is assigned but its value is never used

//if (isRange != "no")
//attk = CalcRangedWeapon(weights, ref finalmod);



float[] values = new float[] { attk, charg, secAttk, secCharge };
float[] values = [attk, charg, secAttk, secCharge];

this.AdjustFinalMod(ref finalmod, values, 0.05f);
AdjustFinalMod(ref finalmod, values, 0.05f);

return attk + charg + secAttk + secCharge;
}
Expand Down Expand Up @@ -431,9 +431,9 @@
longPike = 0f;
}

float[] values = new float[] { priap, pribp, area, secap, secbp, longPike, launch };
float[] values = [priap, pribp, area, secap, secbp, longPike, launch];

this.AdjustFinalMod(ref finalmod, values, 0.3f);
AdjustFinalMod(ref finalmod, values, 0.3f);


return priap + pribp + area + secap + secbp + longPike + launch;
Expand Down Expand Up @@ -471,9 +471,9 @@
command = 0f;
}

float[] values = new float[] { frightenFoot, frightenMounted, command };
float[] values = [frightenFoot, frightenMounted, command];

this.AdjustFinalMod(ref finalmod, values, 0.2f);
AdjustFinalMod(ref finalmod, values, 0.2f);

return frightenFoot + frightenMounted + command;
}
Expand Down Expand Up @@ -532,14 +532,14 @@
float armourD = Convert.ToInt16(this.PriArm[1]) * weights["armourDefence"];
float armourS = Convert.ToInt16(this.PriArm[2]) * weights["armourShield"];

float[] values = new float[] { armourF, armourD, armourS };
float[] values = [armourF, armourD, armourS];

this.AdjustFinalMod(ref finalmod, values, 0.05f);
AdjustFinalMod(ref finalmod, values, 0.05f);

return armourF + armourD + armourS;
}

private void AdjustFinalMod(ref float finalmod, float[] values, float scale = 0.1f)
private static void AdjustFinalMod(ref float finalmod, float[] values, float scale = 0.1f)
{
foreach (float val in values)
{
Expand Down
2 changes: 1 addition & 1 deletion RTWLibPlus/data/unit/UnitsWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

public class UnitsWrapper
{
private readonly List<Unit> units = new();
private readonly List<Unit> units = [];

public UnitsWrapper(EDU edu)
{
Expand Down
4 changes: 2 additions & 2 deletions RTWLibPlus/data/unit/unit_data/MountEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class MountEffect

public MountEffect()
{
this.mountType = new List<string>();
this.modifier = new List<int>();
this.mountType = [];
this.modifier = [];
}
}
34 changes: 17 additions & 17 deletions RTWLibPlus/dataWrappers/TGA/TGA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,29 +65,29 @@ public void Read(params string[] args)
}

// Display the Header fields
RefHeader.Idlength = (char)fptr.ReadByte();
this.RefHeader.Idlength = (char)fptr.ReadByte();
//Console.Error.WriteLine("ID length: {0}", Header.idlength);
RefHeader.Colourmaptype = (char)fptr.ReadByte();
this.RefHeader.Colourmaptype = (char)fptr.ReadByte();
//Console.Error.WriteLine("Colourmap type: {0}", Header.colourmaptype);
RefHeader.Datatypecode = (char)fptr.ReadByte();
this.RefHeader.Datatypecode = (char)fptr.ReadByte();
//Console.Error.WriteLine("Image type: {0}", Header.datatypecode);
RefHeader.Colourmaporigin = this.ReadShort(fptr);
this.RefHeader.Colourmaporigin = ReadShort(fptr);
// Console.Error.WriteLine("Colour map offset: {0}", Header.colourmaporigin);
RefHeader.Colourmaplength = this.ReadShort(fptr);
this.RefHeader.Colourmaplength = ReadShort(fptr);
//Console.Error.WriteLine("Colour map length: {0}", Header.colourmaplength);
RefHeader.Colourmapdepth = (char)fptr.ReadByte();
this.RefHeader.Colourmapdepth = (char)fptr.ReadByte();
//Console.Error.WriteLine("Colour map depth: {0}", Header.colourmapdepth);
RefHeader.Xorigin = this.ReadShort(fptr);
this.RefHeader.Xorigin = ReadShort(fptr);
//Console.Error.WriteLine("X origin: {0}", Header.x_origin);
RefHeader.Yorigin = this.ReadShort(fptr);
this.RefHeader.Yorigin = ReadShort(fptr);
// Console.Error.WriteLine("Y origin: {0}", Header.y_origin);
RefHeader.Width = this.ReadShort(fptr);
this.RefHeader.Width = ReadShort(fptr);
//Console.Error.WriteLine("Width: {0}", Header.width);
RefHeader.Height = this.ReadShort(fptr);
this.RefHeader.Height = ReadShort(fptr);
//Console.Error.WriteLine("Height: {0}", Header.height);
RefHeader.Bitsperpixel = (char)fptr.ReadByte();
this.RefHeader.Bitsperpixel = (char)fptr.ReadByte();
//Console.Error.WriteLine("Bits per pixel: {0}", Header.bitsperpixel);
RefHeader.Imagedescriptor = (char)fptr.ReadByte();
this.RefHeader.Imagedescriptor = (char)fptr.ReadByte();
//Console.Error.WriteLine("Descriptor: {0}", Header.imagedescriptor);

// Allocate space for the image
Expand Down Expand Up @@ -141,13 +141,13 @@ public void Read(params string[] args)
private int CompressedBlock(int n, out int i, out int j, int bytes2read, byte[] p, FileStream fptr)
{
j = p[0] & 0x7f;
this.MergeBytes(ref this.Pixels[n], p.AsSpan(1).ToArray(), bytes2read);
MergeBytes(ref this.Pixels[n], p.AsSpan(1).ToArray(), bytes2read);
n++;
if ((p[0] & 0x80) != 0)
{ // RLE chunk
for (i = 0; i < j; i++)
{
this.MergeBytes(ref this.Pixels[n], p.AsSpan(1).ToArray(), bytes2read);
MergeBytes(ref this.Pixels[n], p.AsSpan(1).ToArray(), bytes2read);
n++;
}
}
Expand All @@ -166,7 +166,7 @@ private int CompressedBlock(int n, out int i, out int j, int bytes2read, byte[]
private void UncompressedBlock(int n, int i, int bytes2read, byte[] p, FileStream fptr)
{
CheckEoF(i, bytes2read, 0, p, fptr);
this.MergeBytes(ref this.Pixels[n], p, bytes2read);
MergeBytes(ref this.Pixels[n], p, bytes2read);
}

private static void CheckEoF(int i, int bytes2read, int offset, byte[] p, FileStream fptr)
Expand Down Expand Up @@ -221,7 +221,7 @@ public string Output()
return "TGA Written to " + this.OutputPath;
}

public void MergeBytes(ref PIXEL pixel, byte[] p, int bytes)
public static void MergeBytes(ref PIXEL pixel, byte[] p, int bytes)
{
if (bytes == 4)
{
Expand All @@ -246,7 +246,7 @@ public void MergeBytes(ref PIXEL pixel, byte[] p, int bytes)
}
}

private short ReadShort(FileStream fptr)
private static short ReadShort(FileStream fptr)
{
byte[] buffer = new byte[2];
fptr.Read(buffer, 0, 2);
Expand Down
Loading
Loading