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

Enhance remodeling tips in level panel #263

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions ElectronicObserver/Data/ShipData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,21 @@ public int ExpNextRemodel
}


/// <summary>
/// 最終改装まで必要な経験値
/// </summary>
public int ExpFinalRemodel
{
get
{
ShipDataMaster master = MasterShip;
if (master.FinalRemodelShipID <= 0)
return 0;
return Math.Max(ExpTable.ShipExp[master.FinalRemodelLevel].Total - ExpTotal, 0);
}
}


/// <summary>
/// 艦名
/// </summary>
Expand Down
70 changes: 70 additions & 0 deletions ElectronicObserver/Data/ShipDataMaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,76 @@ public class ShipDataMaster : ResponseWrapper, IIdentifiable
/// </summary>
public ShipDataMaster RemodelBeforeShip => RemodelBeforeShipID > 0 ? KCDatabase.Instance.MasterShips[RemodelBeforeShipID] : null;

/// <summary>
/// Backing field for FinalRemodelShip since it's not likely changing during runtime
/// </summary>
private ShipDataMaster finalRemodelShip = null;

/// <summary>
/// 最終改装の艦船
/// May be *this*, means already been the final remodel ship
/// </summary>
public ShipDataMaster FinalRemodelShip
{
get
{
if (finalRemodelShip != null) return finalRemodelShip;
if (RemodelAfterShipID <= 0)
{
// Currently being the final remodel ship
finalRemodelShip = this;
}

ShipDataMaster lastRemodel = this;
int lastRemodelLv = RemodelBeforeShip == null ? 0 : RemodelBeforeShip.RemodelAfterLevel;

while (lastRemodel != null && lastRemodel.RemodelAfterLevel > lastRemodelLv && lastRemodel.RemodelAfterShipID != this.ShipID)
{
//find the final remodel ship which has the largest remodeling level
lastRemodelLv = lastRemodel.RemodelAfterLevel;
lastRemodel = lastRemodel.RemodelAfterShip;
}
finalRemodelShip = lastRemodel;
return finalRemodelShip;
}
}

/// <summary>
/// 最終改装Lv
/// </summary>
public int FinalRemodelLevel => FinalRemodelShip == null ? 0 : FinalRemodelShip.RemodelBeforeShip.RemodelAfterLevel;

/// <summary>
/// 最終改装の艦船ID
/// 0=なし
/// </summary>
public int FinalRemodelShipID => FinalRemodelShip == null ? 0 : FinalRemodelShip.ShipID;

public bool CanConvertRemodel
{
get
{
if (FinalRemodelShip == null || FinalRemodelShip.RemodelAfterShip == null)
{
// If it cannot remodel after final-remodel, it cannot convert-remodel
return false;
}
if (ShipID == FinalRemodelShipID && RemodelAfterShipID != 0)
{
return true;
}

ShipDataMaster tmpShip = FinalRemodelShip.RemodelAfterShip;
bool result = false;
while(!result && tmpShip.ShipID != FinalRemodelShipID)
{
// if current ship can be remodeled from final-remodel, it can convert-remodel
result = tmpShip.RemodelAfterShipID == ShipID;
tmpShip = tmpShip.RemodelAfterShip;
}
return result;
}
}

/// <summary>
/// 改装に必要な弾薬
Expand Down
33 changes: 26 additions & 7 deletions ElectronicObserver/Window/FormFleet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,17 +504,36 @@ public void Update(int shipMasterID)
if (!Utility.Configuration.Config.FormFleet.ShowNextExp)
tip.AppendFormat("次のレベルまで: {0} exp.\r\n", ship.ExpNext);

if (ship.MasterShip.RemodelAfterShipID != 0 && ship.Level < ship.MasterShip.RemodelAfterLevel)
if (ship.MasterShip.RemodelAfterShipID != 0 && ship.MasterShip.RemodelAfterShipID != ship.MasterShip.FinalRemodelShipID && ship.Level < ship.MasterShip.RemodelAfterLevel)
{
tip.AppendFormat("改装まで: Lv. {0} / {1} exp.\r\n", ship.MasterShip.RemodelAfterLevel - ship.Level, ship.ExpNextRemodel);
}
else if (ship.Level <= 99)
{
tip.AppendFormat("Lv99まで: {0} exp.\r\n", Math.Max(ExpTable.GetExpToLevelShip(ship.ExpTotal, 99), 0));
else if (ship.MasterShip != ship.MasterShip.FinalRemodelShip && ship.Level < ship.MasterShip.FinalRemodelLevel)
{
if (ship.MasterShip.RemodelAfterShipID != ship.MasterShip.FinalRemodelShipID)
{
tip.Append("今改装可能.\r\n");
}
tip.AppendFormat("最終改装まで: Lv. {0} / {1} exp.\r\n", ship.MasterShip.FinalRemodelLevel - ship.Level, ship.ExpFinalRemodel);
}
else
{
tip.AppendFormat("Lv{0}まで: {1} exp.\r\n", ExpTable.ShipMaximumLevel, Math.Max(ExpTable.GetExpToLevelShip(ship.ExpTotal, ExpTable.ShipMaximumLevel), 0));
else
{
if (ship.ShipID != ship.MasterShip.FinalRemodelShipID)
{
tip.Append("今最終改装可能.\r\n");
}
else if (ship.MasterShip.CanConvertRemodel)
{
tip.Append("今コンバート改装可能.\r\n");
}
if (ship.Level <= 99)
{
tip.AppendFormat("Lv99まで: {0} exp.\r\n", Math.Max(ExpTable.GetExpToLevelShip(ship.ExpTotal, 99), 0));
}
else
{
tip.AppendFormat("Lv{0}まで: {1} exp.\r\n", ExpTable.ShipMaximumLevel, Math.Max(ExpTable.GetExpToLevelShip(ship.ExpTotal, ExpTable.ShipMaximumLevel), 0));
}
}

tip.AppendLine("(右クリックで必要Exp計算)");
Expand Down