diff --git a/domain/character.cat.go b/domain/character.cat.go deleted file mode 100644 index 1a23857..0000000 --- a/domain/character.cat.go +++ /dev/null @@ -1,18 +0,0 @@ -package domain - -import ( - "image/color" - - p "git.teletypegames.org/games/pncdsl" -) - -func defineCat(g *p.Game) { - g.CharacterManager.Register(p.Character{ - Name: "cat", - Sprite: "spr/cat", - Speed: 40, - SpeechColor: color.RGBA{200, 200, 255, 255}, - W: 34, - H: 20, - }) -} diff --git a/domain/character.player.go b/domain/character.player.go deleted file mode 100644 index b6a2d47..0000000 --- a/domain/character.player.go +++ /dev/null @@ -1,18 +0,0 @@ -package domain - -import ( - "image/color" - - p "git.teletypegames.org/games/pncdsl" -) - -func definePlayer(g *p.Game) { - g.CharacterManager.Register(p.Character{ - Name: "player", - Sprite: "spr/player", - Speed: 80, - SpeechColor: color.RGBA{255, 230, 160, 255}, - W: 28, - H: 62, - }) -} diff --git a/domain/dialog.cat_morning.go b/domain/dialog.cat_morning.go deleted file mode 100644 index 36934f5..0000000 --- a/domain/dialog.cat_morning.go +++ /dev/null @@ -1,45 +0,0 @@ -package domain - -import p "git.teletypegames.org/games/pncdsl" - -func defineCatMorning(g *p.Game) { - g.DialogueManager.Register(p.Dialogue{ - Name: "cat_morning", - Start: "start", - Nodes: []p.DialogueNode{ - { - Name: "start", - Lines: []p.DialogueLine{ - {Speaker: "cat", Text: "Mióóóóóóóóu. Késő van."}, - }, - Choices: []p.DialogueChoice{ - { - Text: "Mindjárt megy a kávé.", - Actions: []p.Action{p.SetFlag(FlagPromisedCoffee), p.EndDialogue()}, - }, - { - Text: "Te etted meg a babot?", - Show: p.Not(p.Flag(FlagCupboardOpen)), - Actions: []p.Action{p.GotoNode("beans")}, - }, - { - Text: "Hagyj békén.", - Actions: []p.Action{p.EndDialogue()}, - }, - }, - }, - { - Name: "beans", - Lines: []p.DialogueLine{ - {Speaker: "cat", Text: "A szekrényben van. Mindig ott szokott lenni."}, - }, - Choices: []p.DialogueChoice{ - { - Text: "Köszi.", - Actions: []p.Action{p.EndDialogue()}, - }, - }, - }, - }, - }) -} diff --git a/domain/domain.asset.go b/domain/domain.asset.go deleted file mode 100644 index 6d5bd71..0000000 --- a/domain/domain.asset.go +++ /dev/null @@ -1,31 +0,0 @@ -package domain - -import p "git.teletypegames.org/games/pncdsl" - -// registerAssets declares every asset the game references. Files don't -// need to exist on disk — the library will substitute deterministic -// colored placeholders for anything missing. -func registerAssets(g *p.Game) { - imgs := []string{ - "bg/bedroom", "bg/kitchen", - "spr/key", "spr/beans", "spr/mug", - "spr/player", "spr/cat", - } - for _, name := range imgs { - g.AssetManager.Register(p.Asset{ - Name: name, - Path: "assets/" + name + ".png", - Kind: p.AssetImage, - }) - } - audios := []string{ - "mus/wakeup", "mus/calm", "snd/coffee_done", - } - for _, name := range audios { - g.AssetManager.Register(p.Asset{ - Name: name, - Path: "assets/" + name + ".ogg", - Kind: p.AssetAudio, - }) - } -} diff --git a/domain/item.beans.go b/domain/item.beans.go deleted file mode 100644 index ae5071e..0000000 --- a/domain/item.beans.go +++ /dev/null @@ -1,11 +0,0 @@ -package domain - -import p "git.teletypegames.org/games/pncdsl" - -func defineBeans(g *p.Game) { - g.ItemManager.Register(p.Item{ - Name: "beans", - Sprite: "spr/beans", - Description: "őrölt kávébab", - }) -} diff --git a/domain/item.key.go b/domain/item.key.go deleted file mode 100644 index 8b670cc..0000000 --- a/domain/item.key.go +++ /dev/null @@ -1,20 +0,0 @@ -package domain - -import p "git.teletypegames.org/games/pncdsl" - -func defineKey(g *p.Game) { - g.ItemManager.Register(p.Item{ - Name: "key", - Sprite: "spr/key", - Description: "rozsdás kulcs", - OnUseWith: map[string]p.Action{ - "cupboard": p.Seq( - p.Say("player", "Klikk."), - p.SetFlag(FlagCupboardOpen), - p.Give("beans"), - p.TakeAway("key"), - p.Say("player", "Bab van benne. Pont, ami kell."), - ), - }, - }) -} diff --git a/domain/item.mug.go b/domain/item.mug.go deleted file mode 100644 index 0395968..0000000 --- a/domain/item.mug.go +++ /dev/null @@ -1,11 +0,0 @@ -package domain - -import p "git.teletypegames.org/games/pncdsl" - -func defineMug(g *p.Game) { - g.ItemManager.Register(p.Item{ - Name: "mug", - Sprite: "spr/mug", - Description: "kedvenc bögréje", - }) -} diff --git a/domain/scene.bedroom.go b/domain/scene.bedroom.go deleted file mode 100644 index 603b6ff..0000000 --- a/domain/scene.bedroom.go +++ /dev/null @@ -1,72 +0,0 @@ -package domain - -import p "git.teletypegames.org/games/pncdsl" - -func defineBedroom(g *p.Game) { - g.SceneManager.Register(p.Scene{ - Name: "bedroom", - Title: "Hálószoba", - Background: "bg/bedroom", - Music: "mus/wakeup", - Actors: []p.SceneActor{ - {CharacterName: "player", At: p.Point{X: 160, Y: 145}}, - }, - // Floor strip — Walk targets get clipped to this band, so clicks - // on the bed or nightstand send the player to the floor in front - // of them instead of letting them clip through furniture. - Walkboxes: []p.Polygon{ - p.Poly( - p.Point{X: 10, Y: 135}, - p.Point{X: 310, Y: 135}, - p.Point{X: 310, Y: 160}, - p.Point{X: 10, Y: 160}, - ), - }, - Hotspots: []p.Hotspot{ - { - Name: "bed", - Area: p.Rect(20, 70, 90, 60), - Label: "ágy", - OnLook: p.Say("player", "A párnám még meleg."), - OnUse: p.Say("player", "Most keltem fel. Nem alszom vissza."), - }, - { - Name: "nightstand", - Area: p.Rect(115, 80, 35, 50), - Label: "éjjeliszekrény", - OnLook: p.If(p.Flag(FlagKeyTaken), - p.Say("player", "Üres a tetején."), - p.Say("player", "Egy rozsdás kulcs az éjjeliszekrényemen."), - ), - OnTake: p.If(p.Flag(FlagKeyTaken), - p.Say("player", "Már elvittem."), - p.Seq( - p.Walk("player", p.Point{X: 130, Y: 145}), - p.Give("key"), - p.SetFlag(FlagKeyTaken), - p.Say("player", "Pont jól jöhet."), - ), - ), - OnUse: p.If(p.Flag(FlagKeyTaken), - p.Say("player", "Már elvittem a kulcsot."), - p.Seq( - p.Walk("player", p.Point{X: 130, Y: 145}), - p.Give("key"), - p.SetFlag(FlagKeyTaken), - p.Say("player", "Megvan a kulcs."), - ), - ), - }, - { - Name: "door", - Area: p.Rect(260, 50, 40, 90), - Label: "ajtó", - OnLook: p.Say("player", "Az ajtó a konyhába vezet."), - OnUse: p.Seq( - p.Walk("player", p.Point{X: 260, Y: 145}), - p.GoTo("kitchen"), - ), - }, - }, - }) -} diff --git a/domain/scene.kitchen.go b/domain/scene.kitchen.go deleted file mode 100644 index c3ea5a8..0000000 --- a/domain/scene.kitchen.go +++ /dev/null @@ -1,137 +0,0 @@ -package domain - -import p "git.teletypegames.org/games/pncdsl" - -func defineKitchen(g *p.Game) { - g.SceneManager.Register(p.Scene{ - Name: "kitchen", - Title: "Konyha", - Background: "bg/kitchen", - Music: "mus/calm", - Actors: []p.SceneActor{ - {CharacterName: "player", At: p.Point{X: 60, Y: 145}}, - {CharacterName: "cat", At: p.Point{X: 215, Y: 142}}, - }, - // Floor strip. Same shape as the bedroom — keeps movement on a - // consistent Y band and clips destinations away from the cupboard - // and coffee machine. - Walkboxes: []p.Polygon{ - p.Poly( - p.Point{X: 10, Y: 135}, - p.Point{X: 310, Y: 135}, - p.Point{X: 310, Y: 160}, - p.Point{X: 10, Y: 160}, - ), - }, - // First time the player walks into the kitchen with the key in - // hand, drop a hint. The trigger arms on scene enter; the - // rising-edge fires once per arming because Once: true. - Triggers: []p.Trigger{ - { - Name: "kitchen_with_key_hint", - Once: true, - When: p.And(p.HasItem("key"), p.Not(p.Flag(FlagCupboardOpen))), - Do: p.Say("player", "A kulcs jól jöhet a szekrényhez."), - }, - }, - Hotspots: []p.Hotspot{ - { - Name: "cupboard", - Area: p.Rect(30, 40, 80, 80), - Label: "szekrény", - OnLook: p.Say("player", "Konyhaszekrény. Zárva."), - OnUse: p.If(p.Flag(FlagCupboardOpen), - p.Say("player", "Már nyitva van."), - p.If(p.HasItem("key"), - p.Seq( - p.Walk("player", p.Point{X: 70, Y: 145}), - p.Say("player", "Klikk."), - p.SetFlag(FlagCupboardOpen), - p.Give("beans"), - p.TakeAway("key"), - ), - p.Say("player", "Zárva. Kéne egy kulcs."), - ), - ), - OnUseWith: map[string]p.Action{ - "key": p.Seq( - p.Walk("player", p.Point{X: 70, Y: 145}), - p.Say("player", "Klikk."), - p.SetFlag(FlagCupboardOpen), - p.Give("beans"), - p.TakeAway("key"), - ), - }, - }, - { - Name: "shelf", - Area: p.Rect(115, 45, 35, 50), - Label: "polc", - OnLook: p.Say("player", "A polc tele bögrékkel."), - OnTake: p.If(p.Flag(FlagMugTaken), - p.Say("player", "Tiszta már mind elfogyott."), - p.Seq( - p.Walk("player", p.Point{X: 125, Y: 145}), - p.Give("mug"), - p.SetFlag(FlagMugTaken), - p.Say("player", "Egy bögre, kérem."), - ), - ), - OnUse: p.If(p.Flag(FlagMugTaken), - p.Say("player", "Már elvettem egyet."), - p.Seq( - p.Walk("player", p.Point{X: 125, Y: 145}), - p.Give("mug"), - p.SetFlag(FlagMugTaken), - p.Say("player", "Egy bögre, kérem."), - ), - ), - }, - { - Name: "coffee_machine", - Area: p.Rect(160, 75, 50, 55), - Label: "kávéfőző", - OnLook: p.Say("player", "A jó öreg kávéfőző."), - OnUse: p.If(p.And(p.Flag(FlagCoffeeHasBeans), p.Flag(FlagCoffeeHasMug)), - p.RunScript("victory"), - p.Say("player", "Még hiányzik valami. Bab? Bögre?"), - ), - OnUseWith: map[string]p.Action{ - "beans": p.Seq( - p.Walk("player", p.Point{X: 180, Y: 145}), - p.SetFlag(FlagCoffeeHasBeans), - p.TakeAway("beans"), - p.Say("player", "Bab a helyén."), - p.If(p.And(p.Flag(FlagCoffeeHasBeans), p.Flag(FlagCoffeeHasMug)), - p.RunScript("victory")), - ), - "mug": p.Seq( - p.Walk("player", p.Point{X: 180, Y: 145}), - p.SetFlag(FlagCoffeeHasMug), - p.TakeAway("mug"), - p.Say("player", "Bögre a helyén."), - p.If(p.And(p.Flag(FlagCoffeeHasBeans), p.Flag(FlagCoffeeHasMug)), - p.RunScript("victory")), - ), - }, - }, - { - Name: "cat", - Area: p.Rect(195, 118, 35, 22), - Label: "Cirmos", - OnLook: p.Say("player", "Cirmos, a házikedvencem."), - OnTalk: p.RunDialogue("cat_morning"), - }, - { - Name: "door", - Area: p.Rect(0, 40, 22, 90), - Label: "ajtó", - OnLook: p.Say("player", "Vissza a hálóba."), - OnUse: p.Seq( - p.Walk("player", p.Point{X: 20, Y: 145}), - p.GoTo("bedroom"), - ), - }, - }, - }) -} diff --git a/domain/script.intro.go b/domain/script.intro.go deleted file mode 100644 index c8c710b..0000000 --- a/domain/script.intro.go +++ /dev/null @@ -1,16 +0,0 @@ -package domain - -import p "git.teletypegames.org/games/pncdsl" - -func defineIntroScript(g *p.Game) { - g.ScriptManager.Register(p.Script{ - Name: "intro", - Actions: p.Seq( - p.Wait(0.4), - p.Say("player", "Brr, hideg van."), - p.Say("player", "Egy kávé kéne, mielőtt szétszakad a fejem."), - p.Walk("player", p.Point{X: 200, Y: 145}), - p.SetVar("player.mood", "Eltökélt"), - ), - }) -} diff --git a/domain/script.victory.go b/domain/script.victory.go deleted file mode 100644 index 6c4c2ec..0000000 --- a/domain/script.victory.go +++ /dev/null @@ -1,20 +0,0 @@ -package domain - -import p "git.teletypegames.org/games/pncdsl" - -func defineVictoryScript(g *p.Game) { - g.ScriptManager.Register(p.Script{ - Name: "victory", - Actions: p.Seq( - p.Say("player", "Készen is van!"), - p.PlaySound("snd/coffee_done"), - p.Wait(0.6), - p.Say("cat", "Mióóóóu. *boldog macska*"), - p.Say("player", "Reggeli kávé: megmentve."), - p.SetVar("score", 100), - p.SetVar("player.mood", "Boldog"), - p.SetVar("cat.mood", "Boldog"), - p.ShowEnd("Vége — kösz, hogy játszottál!"), - ), - }) -} diff --git a/lib/assets.go b/lib/assets.go new file mode 100644 index 0000000..83460f6 --- /dev/null +++ b/lib/assets.go @@ -0,0 +1,20 @@ +package lib + +import p "git.teletypegames.org/games/pncdsl" + +// Assets lists every asset the game references. Files don't need to +// exist on disk — the library substitutes deterministic colored +// placeholders for anything missing. +var Assets = []p.Asset{ + {Name: "bg/bedroom", Path: "assets/bg/bedroom.png", Kind: p.AssetImage}, + {Name: "bg/kitchen", Path: "assets/bg/kitchen.png", Kind: p.AssetImage}, + {Name: "spr/key", Path: "assets/spr/key.png", Kind: p.AssetImage}, + {Name: "spr/beans", Path: "assets/spr/beans.png", Kind: p.AssetImage}, + {Name: "spr/mug", Path: "assets/spr/mug.png", Kind: p.AssetImage}, + {Name: "spr/player", Path: "assets/spr/player.png", Kind: p.AssetImage}, + {Name: "spr/cat", Path: "assets/spr/cat.png", Kind: p.AssetImage}, + + {Name: "mus/wakeup", Path: "assets/mus/wakeup.ogg", Kind: p.AssetAudio}, + {Name: "mus/calm", Path: "assets/mus/calm.ogg", Kind: p.AssetAudio}, + {Name: "snd/coffee_done", Path: "assets/snd/coffee_done.ogg", Kind: p.AssetAudio}, +} diff --git a/domain/build_test.go b/lib/build_test.go similarity index 74% rename from domain/build_test.go rename to lib/build_test.go index c96cbb4..2bf024f 100644 --- a/domain/build_test.go +++ b/lib/build_test.go @@ -1,10 +1,10 @@ -package domain +package lib import "testing" -// TestBuildValidates is the headless smoke test described in PLAN.md: -// it composes the full game and asks the library to cross-check every -// name reference between managers. No window opens. +// TestBuildValidates is the headless smoke test: it composes the full +// game and asks the library to cross-check every name reference +// between managers. No window opens. func TestBuildValidates(t *testing.T) { g := Build() if err := g.Validate(); err != nil { diff --git a/lib/character.cat.go b/lib/character.cat.go new file mode 100644 index 0000000..9387c40 --- /dev/null +++ b/lib/character.cat.go @@ -0,0 +1,16 @@ +package lib + +import ( + "image/color" + + p "git.teletypegames.org/games/pncdsl" +) + +var Cat = p.Character{ + Name: "cat", + Sprite: "spr/cat", + Speed: 40, + SpeechColor: color.RGBA{200, 200, 255, 255}, + W: 34, + H: 20, +} diff --git a/lib/character.player.go b/lib/character.player.go new file mode 100644 index 0000000..9ea235e --- /dev/null +++ b/lib/character.player.go @@ -0,0 +1,16 @@ +package lib + +import ( + "image/color" + + p "git.teletypegames.org/games/pncdsl" +) + +var Player = p.Character{ + Name: "player", + Sprite: "spr/player", + Speed: 80, + SpeechColor: color.RGBA{255, 230, 160, 255}, + W: 28, + H: 62, +} diff --git a/lib/dialog.cat_morning.go b/lib/dialog.cat_morning.go new file mode 100644 index 0000000..b219f1a --- /dev/null +++ b/lib/dialog.cat_morning.go @@ -0,0 +1,43 @@ +package lib + +import p "git.teletypegames.org/games/pncdsl" + +var CatMorning = p.Dialogue{ + Name: "cat_morning", + Start: "start", + Nodes: []p.DialogueNode{ + { + Name: "start", + Lines: []p.DialogueLine{ + {Speaker: "cat", Text: "Mióóóóóóóóu. Késő van."}, + }, + Choices: []p.DialogueChoice{ + { + Text: "Mindjárt megy a kávé.", + Actions: []p.Action{p.SetFlag(FlagPromisedCoffee), p.EndDialogue()}, + }, + { + Text: "Te etted meg a babot?", + Show: p.Not(p.Flag(FlagCupboardOpen)), + Actions: []p.Action{p.GotoNode("beans")}, + }, + { + Text: "Hagyj békén.", + Actions: []p.Action{p.EndDialogue()}, + }, + }, + }, + { + Name: "beans", + Lines: []p.DialogueLine{ + {Speaker: "cat", Text: "A szekrényben van. Mindig ott szokott lenni."}, + }, + Choices: []p.DialogueChoice{ + { + Text: "Köszi.", + Actions: []p.Action{p.EndDialogue()}, + }, + }, + }, + }, +} diff --git a/domain/domain.flag.go b/lib/flags.go similarity index 94% rename from domain/domain.flag.go rename to lib/flags.go index e924f36..aae4bdb 100644 --- a/domain/domain.flag.go +++ b/lib/flags.go @@ -1,4 +1,4 @@ -package domain +package lib const ( FlagKeyTaken = "key_taken" diff --git a/lib/item.beans.go b/lib/item.beans.go new file mode 100644 index 0000000..1ad9a26 --- /dev/null +++ b/lib/item.beans.go @@ -0,0 +1,9 @@ +package lib + +import p "git.teletypegames.org/games/pncdsl" + +var Beans = p.Item{ + Name: "beans", + Sprite: "spr/beans", + Description: "őrölt kávébab", +} diff --git a/lib/item.key.go b/lib/item.key.go new file mode 100644 index 0000000..c5439eb --- /dev/null +++ b/lib/item.key.go @@ -0,0 +1,18 @@ +package lib + +import p "git.teletypegames.org/games/pncdsl" + +var Key = p.Item{ + Name: "key", + Sprite: "spr/key", + Description: "rozsdás kulcs", + OnUseWith: map[string]p.Action{ + "cupboard": p.Seq( + p.Say("player", "Klikk."), + p.SetFlag(FlagCupboardOpen), + p.Give("beans"), + p.TakeAway("key"), + p.Say("player", "Bab van benne. Pont, ami kell."), + ), + }, +} diff --git a/lib/item.mug.go b/lib/item.mug.go new file mode 100644 index 0000000..bc61f3f --- /dev/null +++ b/lib/item.mug.go @@ -0,0 +1,9 @@ +package lib + +import p "git.teletypegames.org/games/pncdsl" + +var Mug = p.Item{ + Name: "mug", + Sprite: "spr/mug", + Description: "kedvenc bögréje", +} diff --git a/lib/scene.bedroom.go b/lib/scene.bedroom.go new file mode 100644 index 0000000..ca6fa80 --- /dev/null +++ b/lib/scene.bedroom.go @@ -0,0 +1,70 @@ +package lib + +import p "git.teletypegames.org/games/pncdsl" + +var Bedroom = p.Scene{ + Name: "bedroom", + Title: "Hálószoba", + Background: "bg/bedroom", + Music: "mus/wakeup", + Actors: []p.SceneActor{ + {CharacterName: "player", At: p.Point{X: 160, Y: 145}}, + }, + // Floor strip — Walk targets get clipped to this band, so clicks + // on the bed or nightstand send the player to the floor in front + // of them instead of letting them clip through furniture. + Walkboxes: []p.Polygon{ + p.Poly( + p.Point{X: 10, Y: 135}, + p.Point{X: 310, Y: 135}, + p.Point{X: 310, Y: 160}, + p.Point{X: 10, Y: 160}, + ), + }, + Hotspots: []p.Hotspot{ + { + Name: "bed", + Area: p.Rect(20, 70, 90, 60), + Label: "ágy", + OnLook: p.Say("player", "A párnám még meleg."), + OnUse: p.Say("player", "Most keltem fel. Nem alszom vissza."), + }, + { + Name: "nightstand", + Area: p.Rect(115, 80, 35, 50), + Label: "éjjeliszekrény", + OnLook: p.If(p.Flag(FlagKeyTaken), + p.Say("player", "Üres a tetején."), + p.Say("player", "Egy rozsdás kulcs az éjjeliszekrényemen."), + ), + OnTake: p.If(p.Flag(FlagKeyTaken), + p.Say("player", "Már elvittem."), + p.Seq( + p.Walk("player", p.Point{X: 130, Y: 145}), + p.Give("key"), + p.SetFlag(FlagKeyTaken), + p.Say("player", "Pont jól jöhet."), + ), + ), + OnUse: p.If(p.Flag(FlagKeyTaken), + p.Say("player", "Már elvittem a kulcsot."), + p.Seq( + p.Walk("player", p.Point{X: 130, Y: 145}), + p.Give("key"), + p.SetFlag(FlagKeyTaken), + p.Say("player", "Megvan a kulcs."), + ), + ), + }, + { + Name: "door", + Area: p.Rect(260, 50, 40, 90), + Label: "ajtó", + OnLook: p.Say("player", "Az ajtó a konyhába vezet."), + OnUse: p.Seq( + p.Walk("player", p.Point{X: 260, Y: 145}), + p.GoTo("kitchen"), + ), + }, + }, +} diff --git a/lib/scene.kitchen.go b/lib/scene.kitchen.go new file mode 100644 index 0000000..6ca7c52 --- /dev/null +++ b/lib/scene.kitchen.go @@ -0,0 +1,135 @@ +package lib + +import p "git.teletypegames.org/games/pncdsl" + +var Kitchen = p.Scene{ + Name: "kitchen", + Title: "Konyha", + Background: "bg/kitchen", + Music: "mus/calm", + Actors: []p.SceneActor{ + {CharacterName: "player", At: p.Point{X: 60, Y: 145}}, + {CharacterName: "cat", At: p.Point{X: 215, Y: 142}}, + }, + // Floor strip. Same shape as the bedroom — keeps movement on a + // consistent Y band and clips destinations away from the cupboard + // and coffee machine. + Walkboxes: []p.Polygon{ + p.Poly( + p.Point{X: 10, Y: 135}, + p.Point{X: 310, Y: 135}, + p.Point{X: 310, Y: 160}, + p.Point{X: 10, Y: 160}, + ), + }, + // First time the player walks into the kitchen with the key in + // hand, drop a hint. The trigger arms on scene enter; the + // rising-edge fires once per arming because Once: true. + Triggers: []p.Trigger{ + { + Name: "kitchen_with_key_hint", + Once: true, + When: p.And(p.HasItem("key"), p.Not(p.Flag(FlagCupboardOpen))), + Do: p.Say("player", "A kulcs jól jöhet a szekrényhez."), + }, + }, + Hotspots: []p.Hotspot{ + { + Name: "cupboard", + Area: p.Rect(30, 40, 80, 80), + Label: "szekrény", + OnLook: p.Say("player", "Konyhaszekrény. Zárva."), + OnUse: p.If(p.Flag(FlagCupboardOpen), + p.Say("player", "Már nyitva van."), + p.If(p.HasItem("key"), + p.Seq( + p.Walk("player", p.Point{X: 70, Y: 145}), + p.Say("player", "Klikk."), + p.SetFlag(FlagCupboardOpen), + p.Give("beans"), + p.TakeAway("key"), + ), + p.Say("player", "Zárva. Kéne egy kulcs."), + ), + ), + OnUseWith: map[string]p.Action{ + "key": p.Seq( + p.Walk("player", p.Point{X: 70, Y: 145}), + p.Say("player", "Klikk."), + p.SetFlag(FlagCupboardOpen), + p.Give("beans"), + p.TakeAway("key"), + ), + }, + }, + { + Name: "shelf", + Area: p.Rect(115, 45, 35, 50), + Label: "polc", + OnLook: p.Say("player", "A polc tele bögrékkel."), + OnTake: p.If(p.Flag(FlagMugTaken), + p.Say("player", "Tiszta már mind elfogyott."), + p.Seq( + p.Walk("player", p.Point{X: 125, Y: 145}), + p.Give("mug"), + p.SetFlag(FlagMugTaken), + p.Say("player", "Egy bögre, kérem."), + ), + ), + OnUse: p.If(p.Flag(FlagMugTaken), + p.Say("player", "Már elvettem egyet."), + p.Seq( + p.Walk("player", p.Point{X: 125, Y: 145}), + p.Give("mug"), + p.SetFlag(FlagMugTaken), + p.Say("player", "Egy bögre, kérem."), + ), + ), + }, + { + Name: "coffee_machine", + Area: p.Rect(160, 75, 50, 55), + Label: "kávéfőző", + OnLook: p.Say("player", "A jó öreg kávéfőző."), + OnUse: p.If(p.And(p.Flag(FlagCoffeeHasBeans), p.Flag(FlagCoffeeHasMug)), + p.RunScript("victory"), + p.Say("player", "Még hiányzik valami. Bab? Bögre?"), + ), + OnUseWith: map[string]p.Action{ + "beans": p.Seq( + p.Walk("player", p.Point{X: 180, Y: 145}), + p.SetFlag(FlagCoffeeHasBeans), + p.TakeAway("beans"), + p.Say("player", "Bab a helyén."), + p.If(p.And(p.Flag(FlagCoffeeHasBeans), p.Flag(FlagCoffeeHasMug)), + p.RunScript("victory")), + ), + "mug": p.Seq( + p.Walk("player", p.Point{X: 180, Y: 145}), + p.SetFlag(FlagCoffeeHasMug), + p.TakeAway("mug"), + p.Say("player", "Bögre a helyén."), + p.If(p.And(p.Flag(FlagCoffeeHasBeans), p.Flag(FlagCoffeeHasMug)), + p.RunScript("victory")), + ), + }, + }, + { + Name: "cat", + Area: p.Rect(195, 118, 35, 22), + Label: "Cirmos", + OnLook: p.Say("player", "Cirmos, a házikedvencem."), + OnTalk: p.RunDialogue("cat_morning"), + }, + { + Name: "door", + Area: p.Rect(0, 40, 22, 90), + Label: "ajtó", + OnLook: p.Say("player", "Vissza a hálóba."), + OnUse: p.Seq( + p.Walk("player", p.Point{X: 20, Y: 145}), + p.GoTo("bedroom"), + ), + }, + }, +} diff --git a/lib/script.intro.go b/lib/script.intro.go new file mode 100644 index 0000000..2c70ce8 --- /dev/null +++ b/lib/script.intro.go @@ -0,0 +1,14 @@ +package lib + +import p "git.teletypegames.org/games/pncdsl" + +var IntroScript = p.Script{ + Name: "intro", + Actions: p.Seq( + p.Wait(0.4), + p.Say("player", "Brr, hideg van."), + p.Say("player", "Egy kávé kéne, mielőtt szétszakad a fejem."), + p.Walk("player", p.Point{X: 200, Y: 145}), + p.SetVar("player.mood", "Eltökélt"), + ), +} diff --git a/lib/script.victory.go b/lib/script.victory.go new file mode 100644 index 0000000..4a0bf62 --- /dev/null +++ b/lib/script.victory.go @@ -0,0 +1,18 @@ +package lib + +import p "git.teletypegames.org/games/pncdsl" + +var VictoryScript = p.Script{ + Name: "victory", + Actions: p.Seq( + p.Say("player", "Készen is van!"), + p.PlaySound("snd/coffee_done"), + p.Wait(0.6), + p.Say("cat", "Mióóóóu. *boldog macska*"), + p.Say("player", "Reggeli kávé: megmentve."), + p.SetVar("score", 100), + p.SetVar("player.mood", "Boldog"), + p.SetVar("cat.mood", "Boldog"), + p.ShowEnd("Vége — kösz, hogy játszottál!"), + ), +} diff --git a/domain/game.go b/lib/setup.go similarity index 63% rename from domain/game.go rename to lib/setup.go index 018ddb1..00501e1 100644 --- a/domain/game.go +++ b/lib/setup.go @@ -1,29 +1,43 @@ -package domain +package lib -import p "git.teletypegames.org/games/pncdsl" +import ( + "log" -// Build assembles the full Reggeli Kávé game by registering every entity -// into its matching manager on a fresh *Game. The order matters only for -// readability — Validate() runs after Build to cross-check references. + p "git.teletypegames.org/games/pncdsl" +) + +// Run builds the game and hands it to the pncdsl engine. It is the +// single entry point referenced from main.go. +func Run() { + if err := p.Run(Build()); err != nil { + log.Fatal(err) + } +} + +// Build wires every entity declared in the sibling files into a fresh +// *Game. Validate() runs from p.Run() to cross-check name references +// between managers. func Build() *p.Game { g := p.NewGame("Reggeli Kávé", 320, 200) - registerAssets(g) + for _, a := range Assets { + g.AssetManager.Register(a) + } - definePlayer(g) - defineCat(g) + g.CharacterManager.Register(Player) + g.CharacterManager.Register(Cat) - defineKey(g) - defineBeans(g) - defineMug(g) + g.ItemManager.Register(Key) + g.ItemManager.Register(Beans) + g.ItemManager.Register(Mug) - defineCatMorning(g) + g.DialogueManager.Register(CatMorning) - defineIntroScript(g) - defineVictoryScript(g) + g.ScriptManager.Register(IntroScript) + g.ScriptManager.Register(VictoryScript) - defineBedroom(g) - defineKitchen(g) + g.SceneManager.Register(Bedroom) + g.SceneManager.Register(Kitchen) // Story-rich HUD: top bar + NPC character panel + chat log + permanent // verb wheel + small inventory. The player panel is skipped — the @@ -52,7 +66,7 @@ func Build() *p.Game { }, }) g.UIManager.Register(&p.Cursor{Name: "cursor"}) - g.UIManager.Register(&saveKeys{}) + g.UIManager.Register(&SaveKeys{}) g.MaxLogLines = 64 // initial HUD vars diff --git a/domain/widget.savekeys.go b/lib/widget.savekeys.go similarity index 70% rename from domain/widget.savekeys.go rename to lib/widget.savekeys.go index 2026a6d..03ed2ec 100644 --- a/domain/widget.savekeys.go +++ b/lib/widget.savekeys.go @@ -1,4 +1,4 @@ -package domain +package lib import ( "github.com/hajimehoshi/ebiten/v2" @@ -7,14 +7,14 @@ import ( p "git.teletypegames.org/games/pncdsl" ) -// saveKeys is a no-draw widget that binds F5 → Save(slot 0) and +// SaveKeys is a no-draw widget that binds F5 → Save(slot 0) and // F9 → Load(slot 0). Errors are surfaced via FlashLine so the player // sees them in the status strip. -type saveKeys struct{} +type SaveKeys struct{} -func (s *saveKeys) GetName() string { return "save_keys" } +func (s *SaveKeys) GetName() string { return "save_keys" } -func (s *saveKeys) Tick(ctx *p.UICtx) { +func (s *SaveKeys) Tick(ctx *p.UICtx) { g := ctx.Game if inpututil.IsKeyJustPressed(ebiten.KeyF5) { if err := g.Save(0); err != nil { @@ -32,4 +32,4 @@ func (s *saveKeys) Tick(ctx *p.UICtx) { } } -func (s *saveKeys) Draw(_ *ebiten.Image, _ *p.UICtx) {} +func (s *SaveKeys) Draw(_ *ebiten.Image, _ *p.UICtx) {} diff --git a/main.go b/main.go index 70ecec7..06b9317 100644 --- a/main.go +++ b/main.go @@ -1,14 +1,7 @@ package main -import ( - "log" - - "git.teletypegames.org/games/pncdsl-demo/domain" - "git.teletypegames.org/games/pncdsl" -) +import "git.teletypegames.org/games/pncdsl-demo/lib" func main() { - if err := pncdsl.Run(domain.Build()); err != nil { - log.Fatal(err) - } + lib.Run() }