Continuing Work
This commit is contained in:
parent
a4cb7de2fc
commit
d186d4da6e
3
.gitignore
vendored
3
.gitignore
vendored
@ -23,4 +23,5 @@ build/*
|
||||
go.work
|
||||
|
||||
# Ignore fonts for now
|
||||
*.otf
|
||||
*.otf
|
||||
*.ttf
|
1
game/config.go
Normal file
1
game/config.go
Normal file
@ -0,0 +1 @@
|
||||
package game
|
128
game/entities.go
Normal file
128
game/entities.go
Normal file
@ -0,0 +1,128 @@
|
||||
package game
|
||||
|
||||
// Attributes
|
||||
type stat struct {
|
||||
name string
|
||||
short string
|
||||
value int
|
||||
}
|
||||
|
||||
type attributes struct {
|
||||
health stat
|
||||
strength stat
|
||||
endurance stat
|
||||
dexterity stat
|
||||
wisdom stat
|
||||
intelligence stat
|
||||
}
|
||||
|
||||
// Levels
|
||||
type level struct {
|
||||
experience int
|
||||
points int
|
||||
}
|
||||
|
||||
// Inventory
|
||||
type Item struct {
|
||||
name string
|
||||
id int
|
||||
drop int
|
||||
}
|
||||
|
||||
type Slot struct {
|
||||
amount int
|
||||
content Item
|
||||
}
|
||||
|
||||
// Player and Non Player Characters
|
||||
type Player struct {
|
||||
name string
|
||||
levels []level
|
||||
money int
|
||||
stats attributes
|
||||
inventory []Slot
|
||||
}
|
||||
|
||||
type Enemy struct {
|
||||
name string
|
||||
stats attributes
|
||||
loot []Item
|
||||
money int
|
||||
}
|
||||
|
||||
// Initialization Functions
|
||||
func makeAttributes() attributes {
|
||||
return attributes{
|
||||
health: stat{
|
||||
name: "Health",
|
||||
short: "HP",
|
||||
value: 10,
|
||||
},
|
||||
strength: stat{
|
||||
name: "Strength",
|
||||
short: "Str",
|
||||
value: 1,
|
||||
},
|
||||
endurance: stat{
|
||||
name: "Endurance",
|
||||
short: "End",
|
||||
value: 1,
|
||||
},
|
||||
dexterity: stat{
|
||||
name: "Dexterity",
|
||||
short: "Dex",
|
||||
value: 1,
|
||||
},
|
||||
wisdom: stat{
|
||||
name: "Wisdom",
|
||||
short: "Wis",
|
||||
value: 1,
|
||||
},
|
||||
intelligence: stat{
|
||||
name: "Intelligence",
|
||||
short: "Int",
|
||||
value: 1,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func makeLevelTable() []level {
|
||||
var ourLevels = make([]level, 0, 10)
|
||||
|
||||
for i := 0; i < 11; i++ {
|
||||
var baseXP int = 100
|
||||
var ourPoints int = 0
|
||||
|
||||
if i > 0 && i%2 == 0 {
|
||||
ourPoints = 5
|
||||
} else if i > 0 && i%2 == 1 {
|
||||
ourPoints = 4
|
||||
}
|
||||
|
||||
ourLevels = append(ourLevels, level{
|
||||
experience: baseXP*i,
|
||||
points: ourPoints,
|
||||
})
|
||||
}
|
||||
|
||||
return ourLevels
|
||||
}
|
||||
|
||||
func MakeNewPlayer(playerName string) Player {
|
||||
return Player{
|
||||
name: playerName,
|
||||
levels: makeLevelTable(),
|
||||
money: 0,
|
||||
stats: makeAttributes(),
|
||||
inventory: make([]Slot, 0, 15),
|
||||
}
|
||||
}
|
||||
|
||||
func MakeNewEnemy(enemyName string) Enemy {
|
||||
return Enemy{
|
||||
name: enemyName,
|
||||
stats: makeAttributes(),
|
||||
loot: make([]Item, 0, 5),
|
||||
money: 0,
|
||||
}
|
||||
}
|
39
game/logic.go
Normal file
39
game/logic.go
Normal file
@ -0,0 +1,39 @@
|
||||
package game
|
||||
|
||||
import (
|
||||
"git.vertinext.com/roryejinn/Ultralight/game"
|
||||
"strings"
|
||||
"math/rand/v2"
|
||||
)
|
||||
|
||||
func (p *Player) AdjustStats(which string, newvalue int) *Player {
|
||||
switch strings.ToLower(which) {
|
||||
case "strength","str":
|
||||
p.stats.strength.value = newvalue
|
||||
case "endurance","end":
|
||||
p.stats.endurance.value = newvalue
|
||||
p.stats.health.value = 5 + (5*newvalue)
|
||||
case "wisdom","wis":
|
||||
p.stats.wisdom.value = newvalue
|
||||
case "intelligence","int":
|
||||
p.stats.intelligence.value = newvalue
|
||||
case "dexterity","dex":
|
||||
p.stats.dexterity.value = newvalue
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func (p *Player) AdjustMoney(adjustment int) *Player {
|
||||
p.money += adjustment
|
||||
return p
|
||||
}
|
||||
|
||||
func (i Item) GetAmount() int {
|
||||
chance := rand.IntN(100)+1
|
||||
|
||||
if chance <= i.drop {
|
||||
return 2
|
||||
} else {
|
||||
return 1
|
||||
}
|
||||
}
|
83
ui/theme.go
Normal file
83
ui/theme.go
Normal file
@ -0,0 +1,83 @@
|
||||
package ui
|
||||
|
||||
import (
|
||||
"github.com/charmbracelet/lipgloss"
|
||||
)
|
||||
|
||||
// base - background
|
||||
// surface - not active popups, inputs, etc
|
||||
// overlay - active popups, inputs ,etc
|
||||
// muted - ignored, not needed
|
||||
// subtle - inactive tabs, items, etc
|
||||
// text - text color
|
||||
// err - errors
|
||||
// info - informational messages
|
||||
// cyan, green, blue, magenta - accessory colors for styling
|
||||
|
||||
type rosepine struct {
|
||||
base lipgloss.AdaptiveColor
|
||||
surface lipgloss.AdaptiveColor
|
||||
overlay lipgloss.AdaptiveColor
|
||||
muted lipgloss.AdaptiveColor
|
||||
subtle lipgloss.AdaptiveColor
|
||||
text lipgloss.AdaptiveColor
|
||||
err lipgloss.AdaptiveColor
|
||||
info lipgloss.AdaptiveColor
|
||||
cyan lipgloss.AdaptiveColor
|
||||
green lipgloss.AdaptiveColor
|
||||
blue lipgloss.AdaptiveColor
|
||||
magenta lipgloss.AdaptiveColor
|
||||
}
|
||||
|
||||
func MakeTheme() rosepine {
|
||||
return rosepine{
|
||||
base: lipgloss.AdaptiveColor{
|
||||
Light:"#faf4ed",
|
||||
Dark:"#232136",
|
||||
},
|
||||
surface: lipgloss.AdaptiveColor{
|
||||
Light:"#fffaf3",
|
||||
Dark:"#2a273f",
|
||||
},
|
||||
overlay: lipgloss.AdaptiveColor{
|
||||
Light:"#f2e9e1",
|
||||
Dark:"#393552",
|
||||
},
|
||||
muted: lipgloss.AdaptiveColor{
|
||||
Light:"#9893a5",
|
||||
Dark:"#6e6a86",
|
||||
},
|
||||
subtle: lipgloss.AdaptiveColor{
|
||||
Light:"#797593",
|
||||
Dark:"#908caa",
|
||||
},
|
||||
text: lipgloss.AdaptiveColor{
|
||||
Light:"#575279",
|
||||
Dark:"#e0def4",
|
||||
},
|
||||
err: lipgloss.AdaptiveColor{
|
||||
Light:"#b4637a",
|
||||
Dark:"#eb6f92",
|
||||
},
|
||||
info: lipgloss.AdaptiveColor{
|
||||
Light:"#ea9d34",
|
||||
Dark:"#f6c177",
|
||||
},
|
||||
cyan: lipgloss.AdaptiveColor{
|
||||
Light:"#d7827e",
|
||||
Dark:"#ea9a97",
|
||||
},
|
||||
green: lipgloss.AdaptiveColor{
|
||||
Light:"#286983",
|
||||
Dark:"#3e8fb0",
|
||||
},
|
||||
blue: lipgloss.AdaptiveColor{
|
||||
Light:"#56949f",
|
||||
Dark:"#9ccfd8",
|
||||
},
|
||||
magenta: lipgloss.AdaptiveColor{
|
||||
Light:"#907aa9",
|
||||
Dark:"#c4a7e7",
|
||||
},
|
||||
}
|
||||
}
|
@ -38,7 +38,7 @@ func (m model) View() string {
|
||||
}
|
||||
|
||||
func main() {
|
||||
fonts, err := crt.LoadFaces("FiraMonoNerdFont-Regular.otf", "FiraMonoNerdFont-Bold.otf", "FiraMonoNerdFont-Medium.otf", crt.GetFontDPI(), 16.0)
|
||||
fonts, err := crt.LoadFaces("assets/fonts/IosevkaTerm-Extended.ttf", "assets/fonts/IosevkaTerm-ExtendedBold.ttf", "assets/fonts/IosevkaTerm-ExtendedMedium.ttf", crt.GetFontDPI(), 16.0)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user