@@ -35,28 +35,22 @@ func (k msgServer) StructBuildInitiate(goCtx context.Context, msg *types.MsgStru
3535 return & types.MsgStructStatusResponse {}, permissionError
3636 }
3737
38- if owner .IsHalted () {
39- return & types.MsgStructStatusResponse {}, types .NewPlayerHaltedError (msg .PlayerId , "struct_build_initiate" )
40- }
41-
4238 // Load the Struct Type
43- structType , structTypeFound := k .GetStructType (ctx , msg .StructTypeId )
39+ structType , structTypeFound := cc .GetStructType (msg .StructTypeId )
4440 if ! structTypeFound {
4541 return & types.MsgStructStatusResponse {}, types .NewObjectNotFoundError ("struct_type" , "" ).WithIndex (msg .StructTypeId )
4642 }
4743
4844 // Check that the player can build more of this type of Struct
49- if (structType .GetBuildLimit () > 0 ) {
50- if (owner .GetBuiltQuantity (msg .StructTypeId ) >= structType .GetBuildLimit ()) {
51- owner .Discharge ()
52- return & types.MsgStructStatusResponse {}, types .NewPlayerPowerError (owner .GetPlayerId (), "capacity_exceeded" ).WithCapacity (structType .GetBuildLimit (), owner .GetBuiltQuantity (msg .StructTypeId ))
45+ if (structType .GetStructType ().BuildLimit > 0 ) {
46+ if (owner .GetBuiltQuantity (msg .StructTypeId ) >= structType .GetStructType ().BuildLimit ) {
47+ return & types.MsgStructStatusResponse {}, types .NewPlayerPowerError (owner .GetPlayerId (), "capacity_exceeded" ).WithCapacity (structType .GetStructType ().BuildLimit , owner .GetBuiltQuantity (msg .StructTypeId ))
5348 }
5449 }
5550
5651 // Check Player Charge
57- if (owner .GetCharge () < structType .BuildCharge ) {
58- err := types .NewInsufficientChargeError (owner .GetPlayerId (), structType .BuildCharge , owner .GetCharge (), "build" ).WithStructType (msg .StructTypeId )
59- owner .Discharge ()
52+ if (owner .GetCharge () < structType .GetStructType ().BuildCharge ) {
53+ err := types .NewInsufficientChargeError (owner .GetPlayerId (), structType .GetStructType ().BuildCharge , owner .GetCharge (), "build" ).WithStructType (msg .StructTypeId )
6054 return & types.MsgStructStatusResponse {}, err
6155 }
6256
@@ -66,21 +60,17 @@ func (k msgServer) StructBuildInitiate(goCtx context.Context, msg *types.MsgStru
6660 }
6761
6862
69- if ! owner .CanSupportLoadAddition (structType .BuildDraw ) {
70- owner .Discharge ()
71- return & types.MsgStructStatusResponse {}, types .NewPlayerPowerError (owner .GetPlayerId (), "capacity_exceeded" ).WithCapacity (structType .BuildDraw , owner .GetAvailableCapacity ())
63+ if ! owner .CanSupportLoadAddition (structType .GetStructType ().BuildDraw ) {
64+ return & types.MsgStructStatusResponse {}, types .NewPlayerPowerError (owner .GetPlayerId (), "capacity_exceeded" ).WithCapacity (structType .GetStructType ().BuildDraw , owner .GetAvailableCapacity ())
7265 }
7366
74-
75- k .logger .Info ("Struct Materializing" , "structType" , structType .Type , "ambit" , msg .OperatingAmbit , "slot" , msg .Slot )
76- structure , err := k .InitiateStruct (ctx , msg .Creator , owner , & structType , msg .OperatingAmbit , msg .Slot )
67+ k .logger .Info ("Struct Materializing" , "structType" , structType .GetStructType ().Type , "ambit" , msg .OperatingAmbit , "slot" , msg .Slot )
68+ structure , err := cc .InitiateStruct (msg .Creator , owner , structType , msg .OperatingAmbit , msg .Slot )
7769 if (err != nil ) {
7870 return & types.MsgStructStatusResponse {}, err
7971 }
80- cc .RegisterStruct (& structure )
8172
8273 owner .Discharge ()
8374
84-
8575 return & types.MsgStructStatusResponse {Struct : structure .GetStruct ()}, nil
8676}
0 commit comments