Add data structures, it requires tons of refactor but it's more or less working

This commit is contained in:
Héctor Giménez
2023-03-11 21:28:33 +09:00
parent 73978a702c
commit 8600c2e2f6
17 changed files with 4383 additions and 0 deletions

24
pkg/data/belt.go Normal file
View File

@@ -0,0 +1,24 @@
package game
import "strings"
const (
HealingPotion PotionType = "HealingPotion"
ManaPotion PotionType = "ManaPotion"
RejuvenationPotion PotionType = "RejuvenationPotion"
)
type Belt []Item
func (b Belt) GetFirstPotion(potionType PotionType) (Position, bool) {
for _, i := range b {
// Ensure potion is in row 0 and one of the four columns
if strings.Contains(string(i.Name), string(potionType)) && i.Position.Y == 0 && (i.Position.X == 0 || i.Position.X == 1 || i.Position.X == 2 || i.Position.X == 3) {
return i.Position, true
}
}
return Position{}, false
}
type PotionType string