Finish up some of the entities, add creation functions for items and slots
This commit is contained in:
		@@ -1 +1,17 @@
 | 
			
		||||
package game
 | 
			
		||||
package game
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/spf13/viper"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func LoadConfig(path string) bool {
 | 
			
		||||
	viper.SetConfigName("Ultralight.yaml")
 | 
			
		||||
	viper.SetConfigType("yaml")
 | 
			
		||||
	viper.AddConfigPath("assets")
 | 
			
		||||
	err := viper.ReadInConfig()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	} else {
 | 
			
		||||
		return true
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -26,7 +26,6 @@ type level struct {
 | 
			
		||||
// Inventory
 | 
			
		||||
type Item struct {
 | 
			
		||||
	name string
 | 
			
		||||
	id   int
 | 
			
		||||
	drop int
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -37,11 +36,11 @@ type Slot struct {
 | 
			
		||||
 | 
			
		||||
// Player and Non Player Characters
 | 
			
		||||
type Player struct {
 | 
			
		||||
	name      string
 | 
			
		||||
	levels    []level
 | 
			
		||||
	money     int
 | 
			
		||||
	stats     attributes
 | 
			
		||||
	inventory []Slot
 | 
			
		||||
	Name      string
 | 
			
		||||
	Levels    []level
 | 
			
		||||
	Money     int
 | 
			
		||||
	Stats     attributes
 | 
			
		||||
	Inventory []Slot
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type Enemy struct {
 | 
			
		||||
@@ -111,11 +110,11 @@ func makeLevelTable() []level {
 | 
			
		||||
 | 
			
		||||
func MakeNewPlayer(playerName string) Player {
 | 
			
		||||
	return Player{
 | 
			
		||||
		name: playerName,
 | 
			
		||||
		levels: makeLevelTable(),
 | 
			
		||||
		money: 0,
 | 
			
		||||
		stats: makeAttributes(),
 | 
			
		||||
		inventory: make([]Slot, 0, 15),
 | 
			
		||||
		Name: playerName,
 | 
			
		||||
		Levels: makeLevelTable(),
 | 
			
		||||
		Money: 0,
 | 
			
		||||
		Stats: makeAttributes(),
 | 
			
		||||
		Inventory: make([]Slot, 0, 15),
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,6 @@
 | 
			
		||||
package game
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"git.vertinext.com/roryejinn/Ultralight/game"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"math/rand/v2"
 | 
			
		||||
)
 | 
			
		||||
@@ -9,23 +8,23 @@ import (
 | 
			
		||||
func (p *Player) AdjustStats(which string, newvalue int) *Player {
 | 
			
		||||
	switch strings.ToLower(which) {
 | 
			
		||||
	case "strength","str":
 | 
			
		||||
		p.stats.strength.value = newvalue
 | 
			
		||||
		p.Stats.strength.value = newvalue
 | 
			
		||||
	case "endurance","end":
 | 
			
		||||
		p.stats.endurance.value = newvalue
 | 
			
		||||
		p.stats.health.value = 5 + (5*newvalue)
 | 
			
		||||
		p.stats.health.current = 5 + (5*newvalue)
 | 
			
		||||
		p.Stats.endurance.value = newvalue
 | 
			
		||||
		p.Stats.health.value = 5 + (5*newvalue)
 | 
			
		||||
		p.Stats.health.current = 5 + (5*newvalue)
 | 
			
		||||
	case "wisdom","wis":
 | 
			
		||||
		p.stats.wisdom.value = newvalue
 | 
			
		||||
		p.Stats.wisdom.value = newvalue
 | 
			
		||||
	case "intelligence","int":
 | 
			
		||||
		p.stats.intelligence.value = newvalue
 | 
			
		||||
		p.Stats.intelligence.value = newvalue
 | 
			
		||||
	case "dexterity","dex":
 | 
			
		||||
		p.stats.dexterity.value = newvalue
 | 
			
		||||
		p.Stats.dexterity.value = newvalue
 | 
			
		||||
	}
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (p *Player) AdjustMoney(adjustment int) *Player {
 | 
			
		||||
	p.money += adjustment
 | 
			
		||||
	p.Money += adjustment
 | 
			
		||||
	return p
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -37,4 +36,18 @@ func (i Item) GetAmount() int {
 | 
			
		||||
	} else {
 | 
			
		||||
		return 1
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func CreateItem(thisName string, rate int) Item {
 | 
			
		||||
	return Item{
 | 
			
		||||
		name: thisName,
 | 
			
		||||
		drop: rate,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (i Item) CreateSlot(number int) Slot {
 | 
			
		||||
	return Slot {
 | 
			
		||||
		amount: number,
 | 
			
		||||
		content: i,
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user