Skip to content

Commit

Permalink
More cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
bobtfish committed Aug 29, 2020
1 parent 2b01cdc commit 8de98ea
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 64 deletions.
9 changes: 9 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
---
linters-settings:
govet:
check-shadowing: true
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped

linters:
enable:
- bodyclose
Expand Down
14 changes: 7 additions & 7 deletions character/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type CharacterType struct {

func LoadCharacterTemplates() {
cl := make([]CharacterType, 0)
err := yaml.Unmarshal([]byte(character_yaml), &cl)
err := yaml.Unmarshal([]byte(characterYaml), &cl)
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -163,7 +163,7 @@ func (s CharacterSpell) IsReuseable() bool {
}

func (s CharacterSpell) CastFx() *fx.Fx {
return fx.FxSpellCast()
return fx.SpellCast()
}

func (s CharacterSpell) CanCastAsIllusion() bool {
Expand Down Expand Up @@ -373,9 +373,9 @@ func (c *Character) GetAttackRange() int {

func (c *Character) GetAttackFx() *fx.Fx {
if c.RangedAttackIsFire {
return fx.FxFire()
return fx.Fire()
}
return fx.FxRemoteAttack()
return fx.RemoteAttack()
}

func (c *Character) CanAttackUndead() bool {
Expand Down Expand Up @@ -425,13 +425,13 @@ func ExplodeCreatures(target logical.Vec, grid *grid.GameGrid) bool {
for y := 0; y < grid.Height(); y++ {
vec := logical.V(x, y)
if target.Equals(vec) {
grid.PlaceGameObject(vec, fx.FxDisbelieve())
grid.PlaceGameObject(vec, fx.Disbelieve())
} else {
otherA, otherIsAttackable := grid.GetGameObject(vec).(movable.Attackable)
if otherIsAttackable {
if otherA.CheckBelongsTo(player) {
grid.GetGameObjectStack(vec).RemoveTopObject()
grid.PlaceGameObject(vec, fx.FxDisbelieve())
grid.PlaceGameObject(vec, fx.Disbelieve())
}
}
}
Expand All @@ -440,7 +440,7 @@ func ExplodeCreatures(target logical.Vec, grid *grid.GameGrid) bool {
} else {
// Just explode this character
grid.GetGameObjectStack(target).RemoveTopObject()
grid.PlaceGameObject(target, fx.FxDisbelieve())
grid.PlaceGameObject(target, fx.Disbelieve())
}
return true
}
Expand Down
4 changes: 2 additions & 2 deletions character/spells.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (s DisbelieveSpell) DoCast(illusion bool, target logical.Vec, grid *grid.Ga
character := grid.GetGameObject(target).(*Character)
if character.IsIllusion {
grid.GetGameObjectStack(target).RemoveTopObject()
anim := fx.FxDisbelieve()
anim := fx.Disbelieve()
grid.PlaceGameObject(target, anim)
return true, anim
}
Expand Down Expand Up @@ -75,7 +75,7 @@ func init() {
})
/*spells.CreateSpell(spells.OtherSpell{
ASpell: spells.ASpell{ // 1 chance only, makes creatures belonging to player explode
Name: "Vengence",
Name: "Vengeance",
CastingChance: 80,
CastRange: 20,
},
Expand Down
10 changes: 5 additions & 5 deletions fx/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,39 +54,39 @@ func (f *Fx) SetBoardPosition(v logical.Vec) {}

// Fx Constructors

func FxSpellCast() *Fx {
func SpellCast() *Fx {
return &Fx{
SpriteVec: logical.V(0, 28),
SpriteCount: 8,
Color: render.GetColor(0, 255, 255),
}
}

func FxRemoteAttack() *Fx {
func RemoteAttack() *Fx {
return &Fx{
SpriteVec: logical.V(0, 27),
SpriteCount: 8,
Color: render.GetColor(255, 255, 255),
}
}

func FxFire() *Fx {
func Fire() *Fx {
return &Fx{
SpriteVec: logical.V(0, 26),
SpriteCount: 8,
Color: render.GetColor(255, 255, 255),
}
}

func FxDisbelieve() *Fx {
func Disbelieve() *Fx {
return &Fx{
SpriteVec: logical.V(0, 25),
SpriteCount: 7,
Color: render.GetColor(255, 255, 255),
}
}

func FxAttack() *Fx {
func Attack() *Fx {
return &Fx{
SpriteVec: logical.V(0, 24),
SpriteCount: 4,
Expand Down
2 changes: 1 addition & 1 deletion player/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (p *Player) GetAttackRange() int {
}

func (p *Player) GetAttackFx() *fx.Fx {
return fx.FxRemoteAttack()
return fx.RemoteAttack()
}

func (p *Player) CanAttackUndead() bool {
Expand Down
1 change: 1 addition & 0 deletions rand/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
var rnd *mrand.Rand

func init() {
// nolint // This is explicitly OK as we hand math/rand a strong random source
rnd = mrand.New(cryptoSource{})
}

Expand Down
2 changes: 1 addition & 1 deletion screen/grow.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (screen *GrowScreen) IterateGrowVanish() {
screen.Grew = true
screen.WithBoard.Grid.GetGameObjectStack(screen.Consider).RemoveTopObject()
screen.WithBoard.Grid.PlaceGameObject(screen.Consider, char.BelongsTo) // Put the wizard back down
f := fx.FxDisbelieve()
f := fx.Disbelieve()
screen.Fx = f
screen.WithBoard.Grid.PlaceGameObject(screen.Consider, f) // Also put a nice animation down
}
Expand Down
2 changes: 1 addition & 1 deletion screen/move.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ func DoAttackMaybe(from, to logical.Vec, playerIdx int, withBoard *WithBoard, mo
}
}
fmt.Printf("Target square belongs to a different player do attack\n")
fx := fx.FxAttack()
fx := fx.Attack()
withBoard.Grid.PlaceGameObject(to, fx)
return AttackStatus{
NotEmpty: true,
Expand Down
2 changes: 1 addition & 1 deletion screen/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func KillIfPlayer(g grid.GameObject, grid *grid.GameGrid) bool {
if ob.CheckBelongsTo(player) {
stack := grid.GetGameObjectStack(vec)
stack.RemoveTopObject()
stack.PlaceObject(fx.FxRemoteAttack())
stack.PlaceObject(fx.RemoteAttack())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion spells/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (s ASpell) CastFx() *fx.Fx {
if s.NoCastFx {
return nil
}
return fx.FxSpellCast()
return fx.SpellCast()
}
func (s ASpell) GetName() string {
return s.Name
Expand Down
44 changes: 0 additions & 44 deletions utils.go

This file was deleted.

2 changes: 1 addition & 1 deletion utils/character_gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
const HEREDOC = string('`')

func main() {
fmt.Printf("package character\n\nconst character_yaml = " + HEREDOC)
fmt.Printf("package character\n\nconst characterYaml = " + HEREDOC)
dat, err := ioutil.ReadFile("character/characters.yaml")
if err != nil {
panic(err)
Expand Down

0 comments on commit 8de98ea

Please sign in to comment.