Following on yesterday's idea (changing the levelup screen to just a ShowCustomConfirm popup). Documentation is here (https://pkg.go.dev/fyne.io/fyne/v2/dialog#ShowCustomConfirm)
func ShowCustomConfirm(title, confirm, dismiss string, content fyne.CanvasObject,
callback func(bool), parent fyne.Window)
I just have to implement callback (which is code from the Validate button in my previous levelup.go screen). Basically it's just player.RefreshStats()
dialog.ShowCustomConfirm("Level up!", "Validate", "Close", levelUpPopup, func(validate bool) {
if validate {
player.RefreshStats()
updateStatsBox()
}
}, currentWindow)
Easy peasy
Since GoCastle is now "playable" (even though really boring + short), I've added goreleaser and my first release . I'm a bit disappointed though because Windows + Mac + ARM64 targets all failed
imports github.com/go-gl/gl/v3.2-core/gl: build constraints exclude all Go files in /home/zwindler/go/pkg/mod/github.com/go-gl/[email protected]/v3.2-core/gl
There seem to be a closed issue about this and it should be resolved so I'm a bit confused... fyne-io/fyne#1739
Now that we have a first 0.0.1 version, it's time to start to think about inventory, which is going to be painful, I think.
In "Castle of the wind", the inventory is a separate screen divided in 3 parts : On the left, a drawing of the player, surrounded by boxes showing everywhere you can put objects on. The right side is divided in 2 vertical boxes : one for what's on the floor, the other for your "containers" (backpack, belts, purses). You equip items from tle floor or your containers by drag and dropping to the right location on the left side.
I could try to reproduce this but I already know there is no drag-n-drop support is not functional in fyne for now. fyne-io/fyne#142
Since I have no real idea on how to workaround this, I'm going to do something very crude for now:
- items automatically go into your items list
- I'll just make dropdown lists to select which object for a given category you choose to equip
I've created a new file called object.go to create the necessary structs / functions.
WeaponCategory = Category{
Name: "Weapon",
Description: "Weapons used for combat.",
}
[...]
Knife = Object{
Name: "Common knife",
Category: "Weapon",
Stats: []ObjectStat{
{
Name: "physicalDamage",
Modifier: 2,
},
},
}
I've created various functions to add/remove items from inventory, check that categories exists, ...
I've then modified the DeterminePhysicalDamage() function (previously called DetermineBaseDamage())
// DeterminePhysicalDamage changes physicalDamage stat depending on str, dex and gear
func (player *CharacterStats) DeterminePhysicalDamage() {
damage := basePhysicalDamage + (player.StrengthValue-10)/5*2 + (player.DexterityValue-10)/5*2
// search in inventory items modifying the physicalDamage
for _, item := range player.Inventory {
for _, stat := range item.Stats {
if stat.Name == "physicalDamage" {
damage += stat.Modifier
}
}
}
player.PhysicalDamage = int(damage)
}