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

fix: 🐛 rebuild ship #352

Merged
merged 4 commits into from
May 11, 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
4 changes: 2 additions & 2 deletions logic/Gaming/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public long AddPlayer(PlayerInitInfo playerInitInfo)
default:
return GameObj.invalidID;
}
Ship? newShip = shipManager.AddShip(playerInitInfo.teamID,
Ship? newShip = ShipManager.AddShip(playerInitInfo.teamID,
playerInitInfo.playerID,
playerInitInfo.shipType,
teamList[(int)playerInitInfo.teamID].MoneyPool);
Expand Down Expand Up @@ -95,7 +95,7 @@ public long ActivateShip(long teamID, ShipType shipType, int birthPointIndex = 0
birthPointIndex = teamList[(int)teamID].BirthPointList.Count - 1;
XY pos = teamList[(int)teamID].BirthPointList[birthPointIndex];
pos += new XY(((random.Next() & 2) - 1) * 1000, ((random.Next() & 2) - 1) * 1000);
if (ShipManager.ActivateShip(ship, pos))
if (shipManager.ActivateShip(ship, pos))
{
GameLogging.logger.ConsoleLogDebug($"Successfully activated {teamID} {shipType} at {pos}");
return ship.PlayerID;
Expand Down
6 changes: 3 additions & 3 deletions logic/Gaming/ShipManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ private class ShipManager(Game game, Map gameMap)
{
private readonly Game game = game;
private readonly Map gameMap = gameMap;
public Ship? AddShip(long teamID, long playerID, ShipType shipType, MoneyPool moneyPool)
public static Ship? AddShip(long teamID, long playerID, ShipType shipType, MoneyPool moneyPool)
{
Ship newShip = new(GameData.ShipRadius, shipType, moneyPool);
gameMap.Add(newShip);
newShip.TeamID.SetROri(teamID);
newShip.PlayerID.SetROri(playerID);
ShipManagerLogging.logger.ConsoleLogDebug(
Expand All @@ -32,12 +31,13 @@ private class ShipManager(Game game, Map gameMap)
+ $"{newShip.WeaponModuleType}");
return newShip;
}
public static bool ActivateShip(Ship ship, XY pos)
public bool ActivateShip(Ship ship, XY pos)
{
if (ship.ShipState != ShipStateType.Deceased)
{
return false;
}
gameMap.Add(ship);
ship.ReSetPos(pos);
ship.SetShipState(RunningStateType.Null, ShipStateType.Null);
ShipManagerLogging.logger.ConsoleLogDebug(
Expand Down
Loading