diff --git a/TODO b/TODO index 0ba2c21..f5982ba 100644 --- a/TODO +++ b/TODO @@ -19,5 +19,4 @@ Bug / missing feature list: Bugs: - Cannot move from magic wood tree to dark citadel - Players can attack walls? - - Magic wood, make it gift players with a spell sometimes if they are mounted. - Line of sight calculation seems a bit harsh currently diff --git a/screen/grow.go b/screen/grow.go index 03c730e..d965441 100644 --- a/screen/grow.go +++ b/screen/grow.go @@ -10,6 +10,7 @@ import ( "github.com/bobtfish/mayhem/player" "github.com/bobtfish/mayhem/rand" screeniface "github.com/bobtfish/mayhem/screen/iface" + spelliface "github.com/bobtfish/mayhem/spells/iface" ) const GrowChance = 15 @@ -76,7 +77,8 @@ func (screen *GrowScreen) Step(ctx screeniface.GameCtx) screeniface.GameScreen { // FIXME - lots of puke worthy type casting in here, should not need this special casing really.... func (screen *GrowScreen) IterateGrowVanish(ctx screeniface.GameCtx) { grid := ctx.GetGrid() - for screen.Consider.X < grid.MaxX() && screen.Consider.Y < grid.MaxY() { + for screen.Consider.X <= grid.MaxX() && screen.Consider.Y <= grid.MaxY() { + fmt.Printf("Consider %d x %d\n", screen.Consider.X, screen.Consider.Y) // If the current tile contains a character char, ok := grid.GetGameObject(screen.Consider).(*character.Character) if ok { @@ -145,11 +147,20 @@ func (screen *GrowScreen) IterateGrowVanish(ctx screeniface.GameCtx) { } } } + if char.Name == "Magic Wood" { + if char.CarryingPlayer && rand.Intn(9)+1 <= 2 { // 20% chance + screen.Grew = true + grid.GetGameObjectStack(screen.Consider).RemoveTopObject() + grid.PlaceGameObject(screen.Consider, char.BelongsTo) // Put the wizard back down + player := char.BelongsTo + player.Spells = append(player.Spells, spelliface.ChooseSpell()) + } + } } // Bump tile counter screen.Consider.X++ - if screen.Consider.X == grid.MaxX() { + if screen.Consider.X > grid.MaxX() { screen.Consider.X = 0 screen.Consider.Y++ } diff --git a/spells/iface/main.go b/spells/iface/main.go index c607260..d794091 100644 --- a/spells/iface/main.go +++ b/spells/iface/main.go @@ -49,12 +49,16 @@ func CreateSpell(s Spell) { AllSpells = append(AllSpells, s) } +func ChooseSpell() Spell { + idx := rand.Intn(len(AllSpells)-1) + 1 + return AllSpells[idx] +} + 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] + spells[i] = ChooseSpell() } for i := 0; i < len(AllSpells); i++ { diff --git a/spellswithscreen/magic_wood.go b/spellswithscreen/magic_wood.go index 14d07c7..8e36d4d 100644 --- a/spellswithscreen/magic_wood.go +++ b/spellswithscreen/magic_wood.go @@ -31,9 +31,8 @@ func (screen *MagicWoodSpellScreen) Enter(ctx screeniface.GameCtx) { func (screen *MagicWoodSpellScreen) Step(ctx screeniface.GameCtx) screeniface.GameScreen { if len(screen.MaybeTiles) == 0 || screen.LaidTiles == 8 { screen.CleanupFunc() - return &screens.Pause{ - NextScreen: screen.NextScreen, - } + // We already paused before reentry + return screen.NextScreen } batch := DrawBoard(ctx)