Skip to content

Commit

Permalink
Not sure if this split helps
Browse files Browse the repository at this point in the history
  • Loading branch information
bobtfish committed Jan 1, 2021
1 parent 8177cd7 commit a50f743
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions spells/iface/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package iface

import (
"math/rand"

"github.com/bobtfish/mayhem/fx"
"github.com/bobtfish/mayhem/grid"
"github.com/bobtfish/mayhem/logical"
)

type Spell interface {
GetName() string
GetLawRating() int
GetCastingChance(int) int
GetCastRange() int
CanCast(grid.GameObject) bool
CanCastAsIllusion() bool
DoCast(bool, logical.Vec, *grid.GameGrid, grid.GameObject) (bool, *fx.Fx)
CastQuantity() int
CastSucceeds(bool, int) bool
IsReuseable() bool
CastFx() *fx.Fx
NeedsLineOfSight() bool
}

func LawRatingSymbol(s Spell) string {
if s == nil {
panic("nil spell")
}
if s.GetLawRating() == 0 {
return "-"
}
if s.GetLawRating() < 0 {
return "*"
}
return "^"
}

var AllSpells []Spell

func CreateSpell(s Spell) {
if AllSpells == nil {
AllSpells = make([]Spell, 1) // Deliberately leave room for disbelieve spell as number 0
}
AllSpells = append(AllSpells, s)
}

func ChooseSpells() []Spell {
spells := make([]Spell, 14)
spells[0] = AllSpells[0]
for i := 1; i < 14; i++ {
idx := rand.Intn(len(AllSpells)-1) + 1
spells[i] = AllSpells[idx]
}
/*
for i := 0; i < len(AllSpells); i++ {
if AllSpells[i].GetName() == "Magic Bolt" {
spells[1] = AllSpells[i]
}
}*/
return spells
}

0 comments on commit a50f743

Please sign in to comment.