-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
105 changed files
with
1,125 additions
and
1,205 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package ogame | ||
|
||
// AntiBallisticMissiles ... | ||
type antiBallisticMissiles struct { | ||
BaseDefense | ||
} | ||
|
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package ogame | ||
|
||
// ArmourTechnology ... | ||
type armourTechnology struct { | ||
BaseTechnology | ||
} | ||
|
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
package ogame | ||
|
||
// Astrophysics ... | ||
type astrophysics struct { | ||
BaseTechnology | ||
} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package ogame | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/magiconair/properties/assert" | ||
) | ||
|
||
func TestAttackEvent_String(t *testing.T) { | ||
a := AttackEvent{ | ||
MissionType: 3, | ||
Origin: Coordinate{1, 2, 3}, | ||
Destination: Coordinate{4, 5, 6}, | ||
ArrivalTime: time.Date(2018, 9, 11, 1, 2, 3, 4, time.UTC), | ||
AttackerID: 456, | ||
Missiles: 0, | ||
Ships: &ShipsInfos{LargeCargo: 10}, | ||
} | ||
expected := "" + | ||
"Mission Type: 3\n" + | ||
" Origin: [1:2:3]\n" + | ||
" Destination: [4:5:6]\n" + | ||
" ArrivalTime: 2018-09-11 01:02:03.000000004 +0000 UTC\n" + | ||
" AttackerID: 456\n" + | ||
" Missiles: 0" | ||
assert.Equal(t, expected, a.String()) | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package ogame | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestBaseBuilding_GetLevel(t *testing.T) { | ||
var bb struct { | ||
BaseBuilding | ||
} | ||
bb.ID = ID(123456) | ||
assert.Equal(t, 0, bb.GetLevel(ResourcesBuildings{}, Facilities{}, Researches{})) | ||
} |
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,50 @@ | ||
package ogame | ||
|
||
import ( | ||
"math" | ||
"time" | ||
) | ||
|
||
// BaseDefender base for defender units (ships, defenses) | ||
type BaseDefender struct { | ||
Base | ||
StructuralIntegrity int | ||
ShieldPower int | ||
WeaponPower int | ||
RapidfireFrom map[ID]int | ||
Price Resources | ||
} | ||
|
||
// GetStructuralIntegrity returns structural integrity of a defender unit | ||
func (b BaseDefender) GetStructuralIntegrity(researches Researches) int { | ||
return int(float64(b.StructuralIntegrity) * (1 + float64(researches.ArmourTechnology)*0.1)) | ||
} | ||
|
||
// GetShieldPower returns shield power of a defender unit | ||
func (b BaseDefender) GetShieldPower(researches Researches) int { | ||
return int(float64(b.ShieldPower) * (1 + float64(researches.ShieldingTechnology)*0.1)) | ||
} | ||
|
||
// GetWeaponPower returns weapon power of a defender unit | ||
func (b BaseDefender) GetWeaponPower(researches Researches) int { | ||
return int(float64(b.WeaponPower) * (1 + float64(researches.WeaponsTechnology)*0.1)) | ||
} | ||
|
||
// GetRapidfireFrom returns which ships have rapid fire against the defender unit | ||
func (b BaseDefender) GetRapidfireFrom() map[ID]int { | ||
return b.RapidfireFrom | ||
} | ||
|
||
// ConstructionTime returns the duration it takes to build nbr defender units | ||
func (b BaseDefender) ConstructionTime(nbr, universeSpeed int, facilities Facilities) time.Duration { | ||
shipyardLvl := float64(facilities.Shipyard) | ||
naniteLvl := float64(facilities.NaniteFactory) | ||
hours := float64(b.StructuralIntegrity) / (2500 * (1 + shipyardLvl) * float64(universeSpeed) * math.Pow(2, naniteLvl)) | ||
secs := hours * 3600 | ||
return time.Duration(int(math.Floor(secs))*nbr) * time.Second | ||
} | ||
|
||
// GetPrice returns the price of nbr defender units | ||
func (b BaseDefender) GetPrice(nbr int) Resources { | ||
return b.Price.Mul(nbr) | ||
} |
Oops, something went wrong.