-
Notifications
You must be signed in to change notification settings - Fork 0
/
Recipe.cs
130 lines (115 loc) · 4.8 KB
/
Recipe.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using System;
using System.Collections.Generic;
namespace TheInfiniteBlack2CraftingCalculator
{
public class Recipe
{
public string Name { get; private set; }
public int OutputQuantity { get; private set; }
public Dictionary<string, int> Ingredients { get; private set; }
public Dictionary<string, int> FactionRequirements { get; private set; }
public bool RequiresEliteRank { get; set; } // New property
public bool RequiresFactionSelection { get; set; }
public string SelectedFaction { get; set; }
public Dictionary<string, int> EliteSkullCosts { get; private set; } // New property for elite skull costs
public string DefaultShipMod { get; private set; } // For Emperor class ships
private decimal defaultModCost;
public Recipe(string name, int outputQuantity)
{
Name = name;
OutputQuantity = outputQuantity;
Ingredients = new Dictionary<string, int>();
FactionRequirements = new Dictionary<string, int>();
EliteSkullCosts = new Dictionary<string, int>
{
{ "Elite 0", 0 },
{ "Elite 1", 100 },
{ "Elite 2", 500 },
{ "Elite 3", 1000 },
{ "Elite 4", 2000 },
{ "Elite 5", 3000 }
};
RequiresFactionSelection = false;
RequiresEliteRank = false;
// Set default Paladin mod for Emperor class ships
if (name.Contains("Emperor"))
{
DefaultShipMod = "Paladin";
defaultModCost = 300000m;
}
}
public decimal CalculateModCostAdjustment(string selectedMod, ResourceManager resourceManager)
{
if (DefaultShipMod == "Paladin")
{
// For Emperor ships, subtract Paladin cost and add new mod cost
return resourceManager.GetShipModPrice(selectedMod) - defaultModCost;
}
return resourceManager.GetShipModPrice(selectedMod);
}
public int CalculateCumulativeSkullCost(string eliteRank)
{
int totalSkulls = 0;
int targetRank = int.Parse(eliteRank.Replace("Elite ", ""));
// Add up all skull costs up to and including the selected rank
for (int i = 1; i <= targetRank; i++)
{
totalSkulls += EliteSkullCosts[$"Elite {i}"];
}
return totalSkulls;
}
public void AddFactionRequirement(string item, int quantity)
{
if (!FactionRequirements.ContainsKey(item))
{
FactionRequirements.Add(item, quantity);
}
}
public void AddIngredient(string itemName, int quantity)
{
string key = itemName.ToLower();
if (Ingredients.ContainsKey(key))
{
Ingredients[key] += quantity;
}
else
{
Ingredients.Add(key, quantity);
}
}
public (Dictionary<string, int> materials, decimal creditCost) CalculateRequirements(
int desiredQuantity, ResourceManager resourceManager)
{
Dictionary<string, int> materials = new Dictionary<string, int>();
decimal totalCredits = 0m;
foreach (var ingredient in Ingredients)
{
int requiredAmount = (int)Math.Ceiling((double)desiredQuantity / OutputQuantity) * ingredient.Value;
materials.Add(ingredient.Key, requiredAmount);
totalCredits += requiredAmount * resourceManager.GetResourcePrice(ingredient.Key);
}
return (materials, totalCredits);
}
public (Dictionary<string, int> materials, decimal creditCost) CalculateRequirementsWithElite(
int desiredQuantity, ResourceManager resourceManager, string eliteRank)
{
// First get base requirements
var (materials, totalCredits) = CalculateRequirements(desiredQuantity, resourceManager);
// Add skull costs for elite rank if applicable
if (eliteRank != "Elite 0")
{
int skullCost = CalculateCumulativeSkullCost(eliteRank);
if (materials.ContainsKey("skull"))
{
materials["skull"] += skullCost;
}
else
{
materials.Add("skull", skullCost);
}
totalCredits += skullCost * resourceManager.GetResourcePrice("skull");
}
return (materials, totalCredits);
}
}
}