-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added building and resources entities * Fixed incorrect building spawning * Refactored building creation
- Loading branch information
Showing
5 changed files
with
227 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package component | ||
|
||
type BuildingType string | ||
type EffectsType string | ||
|
||
const ( | ||
Main BuildingType = "Main" | ||
Woodcutter BuildingType = "Woodcutter" | ||
Quarry BuildingType = "Quarry" | ||
FishermanHut BuildingType = "FishermanHut" | ||
Shipyard BuildingType = "Shipyard" | ||
Warehouse BuildingType = "Warehouse" | ||
UnitLimitHouse BuildingType = "UnitLimitHouse" | ||
) | ||
|
||
const ( | ||
Ship EffectsType = "Ship" | ||
) | ||
|
||
type Building struct { | ||
Level int `json:"level"` | ||
Type BuildingType `json:"type"` | ||
FarmingResource ResourceType `json:"farmingResource,omitempty"` | ||
FarmingSpeed float32 `json:"farmingSpeed,omitempty"` | ||
Effect EffectsType `json:"effect,omitempty"` | ||
EffectAmount int `json:"effectAmount,omitempty"` | ||
UnitLimit int `json:"unitLimit"` | ||
StorageCapacity int `json:"storageCapacity"` | ||
} | ||
|
||
func (Building) Name() string { | ||
return "Building" | ||
} | ||
|
||
const ( | ||
InitialBuildingLevel int = 1 | ||
MainBuildingUnitLimit int = 5 | ||
MainBuildingStorageCapacity int = 200 | ||
QuarryFarmingSpeed float32 = 10.0 | ||
QuarryUnitLimit int = 0 | ||
QuarryStorageCapacity int = 200 | ||
FishermanHutFarmingSpeed float32 = 8.0 | ||
FishermanHutUnitLimit int = 0 | ||
FishermanHutStorageCapacity int = 150 | ||
ShipyardUnitLimit int = 100 | ||
ShipyardStorageCapacity int = 300 | ||
) | ||
|
||
func GetBuilding(buildingType BuildingType) Building { | ||
switch buildingType { | ||
case Main: | ||
return Building{ | ||
Level: InitialBuildingLevel, | ||
Type: Main, | ||
UnitLimit: MainBuildingUnitLimit, | ||
StorageCapacity: MainBuildingStorageCapacity, | ||
} | ||
case Quarry: | ||
return Building{ | ||
Level: InitialBuildingLevel, | ||
Type: Quarry, | ||
FarmingResource: Stone, | ||
FarmingSpeed: QuarryFarmingSpeed, | ||
UnitLimit: QuarryUnitLimit, | ||
StorageCapacity: QuarryStorageCapacity, | ||
} | ||
case FishermanHut: | ||
return Building{ | ||
Level: InitialBuildingLevel, | ||
Type: FishermanHut, | ||
FarmingResource: Fish, | ||
FarmingSpeed: FishermanHutFarmingSpeed, | ||
UnitLimit: FishermanHutUnitLimit, | ||
StorageCapacity: FishermanHutStorageCapacity, | ||
} | ||
case Shipyard: | ||
return Building{ | ||
Level: InitialBuildingLevel, | ||
Type: Shipyard, | ||
UnitLimit: ShipyardUnitLimit, | ||
StorageCapacity: ShipyardStorageCapacity, | ||
} | ||
|
||
// todo: refactor | ||
case Woodcutter: | ||
return Building{ | ||
Level: InitialBuildingLevel, | ||
Type: Shipyard, | ||
UnitLimit: ShipyardUnitLimit, | ||
StorageCapacity: ShipyardStorageCapacity, | ||
} | ||
// todo: refactor | ||
case UnitLimitHouse: | ||
return Building{ | ||
Level: InitialBuildingLevel, | ||
Type: Shipyard, | ||
UnitLimit: ShipyardUnitLimit, | ||
StorageCapacity: ShipyardStorageCapacity, | ||
} | ||
// todo: refactor | ||
case Warehouse: | ||
return Building{ | ||
Level: InitialBuildingLevel, | ||
Type: Shipyard, | ||
UnitLimit: ShipyardUnitLimit, | ||
StorageCapacity: ShipyardStorageCapacity, | ||
} | ||
default: | ||
return Building{ | ||
Level: 0, | ||
Type: buildingType, | ||
UnitLimit: 0, | ||
StorageCapacity: 0, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package component | ||
|
||
type ResourceType string | ||
|
||
const ( | ||
Wood ResourceType = "Wood" | ||
Stone ResourceType = "Stone" | ||
Fish ResourceType = "Fish" | ||
Iron ResourceType = "Iron" | ||
Cotton ResourceType = "Cotton" | ||
) | ||
|
||
type Resource struct { | ||
Type ResourceType `json:"type"` | ||
Amount int `json:"amount"` | ||
} | ||
|
||
func (Resource) Name() string { | ||
return "Resource" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters