Skip to content
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
2 changes: 1 addition & 1 deletion x/structs/keeper/fleet_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ func (cache *FleetCache) MigrateToNewPlanet(destination *PlanetCache) {
cache.FleetLoaded = true

// Build an Initial Command Ship
structure := cache.K.InitialCommandShipStruct(cache.Ctx, cache.GetOwner())
structure := cache.K.InitialCommandShipStruct(cache.Ctx, cache)
// TODO Not a huge fan that this is committed separately
// Could change cache.commit() to comment the command struct too
// but that would need SetCommandStruct to accept the StructCache instead of Struct.
Expand Down
16 changes: 9 additions & 7 deletions x/structs/keeper/struct_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,25 @@ func (k *Keeper) GetStructCacheFromId(ctx context.Context, structId string) (Str
}


func (k *Keeper) InitialCommandShipStruct(ctx context.Context, owner *PlayerCache) (StructCache) {
func (k *Keeper) InitialCommandShipStruct(ctx context.Context, fleet *FleetCache) (StructCache) {

structType, _ := k.GetStructType(ctx, types.CommandStructTypeId)

structure := types.CreateBaseStruct(&structType, owner.GetPrimaryAddress(), owner.GetPlayerId(), structType.Category, types.Ambit_space)
structure := types.CreateBaseStruct(&structType, fleet.GetOwner().GetPrimaryAddress(), fleet.GetOwner().GetPlayerId(), structType.Category, types.Ambit_space)
structure = k.AppendStruct(ctx, structure)

owner.BuildQuantityIncrement(structType.GetId())
fleet.GetOwner().BuildQuantityIncrement(structType.GetId())

var structStatus types.StructState
if owner.CanSupportLoadAddition(structType.GetPassiveDraw()) {
owner.StructsLoadIncrement(structType.GetPassiveDraw())
if fleet.GetOwner().CanSupportLoadAddition(structType.GetPassiveDraw()) {
fleet.GetOwner().StructsLoadIncrement(structType.GetPassiveDraw())
structStatus = types.StructState(types.StructStateMaterialized | types.StructStateBuilt | types.StructStateOnline)
} else {
structStatus = types.StructState(types.StructStateMaterialized | types.StructStateBuilt )
}

structure.LocationId = fleet.GetFleetId()

// Start to put the pieces together
structCache := StructCache{
StructId: structure.Id,
Expand All @@ -140,10 +142,10 @@ func (k *Keeper) InitialCommandShipStruct(ctx context.Context, owner *PlayerCach
StructureChanged: false,
StructureLoaded: true,

Owner: owner,
Owner: fleet.GetOwner(),
OwnerLoaded: true,

Fleet: owner.GetFleet(),
Fleet: fleet,
FleetLoaded: true,

// Include the health value
Expand Down
Loading