//
//     _____  __                           __
//    / ___/ / /_ _____ ____ _ ____   ____/ /
//    \__ \ / __// ___// __ `// __ \ / __  / 
//   ___/ // /_ / /   / /_/ // / / // /_/ /  
//  /____/ \__//_/    \__,_//_/ /_/ \__,_/   
//                                           
//  Copyright (©) Strand Games 2023.
//
//  This program is free software: you can redistribute it and/or modify it
//  under the terms of the GNU Lesser General Public License (LGPL) as published
//  by the Free Software Foundation, either version 3 of the License, or (at
//  your option) any later version.
// 
//  This program is distributed in the hope that it will be useful, but WITHOUT
//  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
//  for more details.
// 
//  You should have received a copy of the GNU Lesser General Public License
//  along with this program. If not, see <http://www.gnu.org/licenses/>.
// 
//
//  info@strandgames.com
//

// Strand Core library

CORE_VERSION
1.09

GAME_DETAILS
\n\n**GAME_TITLE** by _GAME_AUTHOR_, GAME_VERSION.
\nStrand SYSTEM_VERSION, Core CORE_VERSION.

TOP_BEGIN
*?!BEGIN BEGIN

GAMEOVER

// NB: TICK can change GAMEOVER
MAIN$
*?!GAMEOVER TICK
*?!GAMEOVER CMD MAIN

MORE?
*+ Continue

YOUNAME
You

// third person flag
PERSON3   

YOUDONT=
*?PERSON3 YOUNAME doesn't
* You don't

STUFFHERE > what is in here
*
> be LAST

WHATSHERE STUFFHERE
* them
\nYOUNAME can see LAST.

WHATSEE > what is in here
*
> see LAST

CMD?>
*

OK
\OK

TV
\TV

INITCORE
{
    (setq make-item
          (fn (x)  (tree (list 'id (termid x)) (list 'name (textify x)))
              ))

    (setq get-title
          (fn (t) (tree (list 'title (capswords (textify t))))
              ))
}

UPDATEINV > what is in player
* them
{
    (ifisend (tree (list 'items (map make-item LAST))))
}
*
{ (ifisend (tree (list 'items ()))) }

UPDATETITLE > what is player in
*
{ (ifisend (get-title LAST)) }

UPDATEMAP MAP_BACKIMAGE
* them
{ (ifisend (tree (list 'map (tree (list 'backimage (textify LAST)))))) }

CREDITS_PLAIN
{ (printf (HTMLToPlain (runterm "GAME_CREDITS_HTML"))) } \n\n


// save & load
POSTLOAD_OK
Game Loaded.
> look
MAIN

POSTLOAD_FAIL
Load Game Failed!

POSTSAVE_OK
Game Saved.

POSTSAVE_FAIL
Cannot Save Game.

CHOICE_OPT?
Do you prefer choices over text input?
* yes
\nChoices On
* no
CHOICE_OPT_OFF
\nChoices Off

// these can be called via "subcommand" on the UI.
// but when called, produce no output.
CHOICE_OPT_ON
{ (elevatechoices 1) }

CHOICE_OPT_OFF
{ (elevatechoices 0) }


CONCEPT@
* name
concept
* x it
BORING
* examine it
> x it
* look it
> x it
* l it
> x it
* enter it
> go it
* go in it
> go it
* go into it
> go it
* go to it
> go it

BORING
* YOUDONT find anything useful.
* There's nothing special about it.

THING@ CONCEPT
* name
a thing
* name
something
* be it
NULL
* see it
NULL
* get it
YOUNAME can't get that.
* take it
> get it
* move it
MOVEIT
* push it
> move it
* pull it
> move it
* smell it
BORING
* sniff it
> smell it
* eat it
YOUNAME can't eat IT.
* search it
BORING
* hit it
HITIT
* break it
> hit it
* kick it
> hit it
* touch it
> feel it
* feel it
FEELIT
* listen it
LISTENCOP
* listen
LISTENCOP
* taste it
BORING
* pick up it
> get it

HITIT
Trying to break things won't help.

MOVEIT
* That doesn't get any result.
* That doesn't help.

FEELIT
That won't help.

XHERE
\
UPDATETITLE
> x here
WHATSEE
WHATSHERE

// NB: player is not a person!
PLAYER@ THING
> set player score 0
* name
the player
* name
me
* name
YOUNAME
* x it
XPLAYER
* i
INV
* inv
INV
* inventory
INV
* go west
> w
* go east
> e
* go north
> n
* go south
> s
* go up
> up
* u
> up
* go down
> down
* d
> down
* go in
> in
* enter
> in
* get in
> in
* go out
> out
* get out
> out
* exit
> out
* leave
> out
* go northeast
> ne
* go ne
> ne
* go northwest
> nw
* go nw
> nw
* go southeast
> se
* go se
> se
* go southwest
> sw
* go sw
> sw
* score
DOSCORE
* z
WAIT
* wait
WAIT
* quit
GAME_QUIT
* credits
GAME_CREDITS
* about
GAME_CREDITS
* undo
Undoing...
UNDO
XHERE
* help
HELPME
* hint
HELPME
* hints
HELPME
* jump
JUMPCOP
* cheat
GAME_CHEAT

// if there's a maxscore use that otherwise just the number
DOSCORE > is (PLAYER(maxscore) > 0)
Your score is
* yes
> what is (PLAYER(score)*100/PLAYER(maxscore))
%.
* 
> what is player score
.

XPLAYER=
*?PERSON3 YOUNAME thinks he looks good!
* You're looking good!

LISTENCOP
YOUDONT hear anything unusual.

JUMPCOP=
*?PERSON3 YOUNAME jumps up and down, just for fun.
* You jump up and down, just for fun.

WAIT
* Zzz...
* time passes...
* pom-de pom...

INCSCORE
\nYou scored a point!
> set player score PLAYER(score)+1

NOWAY1=
*?PERSON3 YOUNAME can't go that way.
* You can't go that way

NOWAY
* NOWAY1
* There's no exit in that direction.

ERROR_NOCANDO=
*?PERSON3 YOUNAME can't do that.
* You can't do that.

ERROR_NOSUCH
There is no such thing here.

ERROR_SYNTAX
* Sorry, I don't understand.
* I can't make sense of that.

ROOM@ THING
* name
room
* look
XHERE
* l
> look
* n
NOWAY
* w
NOWAY
* e
NOWAY
* s
NOWAY
* up
NOWAY
* down
NOWAY
* in
NOWAY
* out
NOWAY
* ne
NOWAY
* nw
NOWAY
* se
NOWAY
* sw
NOWAY

EAST@ 
* name
East
* name
e

WEST@ 
* name
West
* name
w

NORTH@
* name
North
* name
n

SOUTH@
* name
South
* name
s

UP@
* name
up
* name
u

DOWN@
* name
down
* name
d

NORTHEAST@
* name
Northeast
* name
ne

NORTHWEST@
* name
Northwest
* name
nw

SOUTHEAST@
* name
Southeast
* name
se

SOUTHWEST@
* name
Southwest
* name
sw

////////////////////////////////////////////////////////////

PMOLEST@
* kiss it
> molest it
* feel it
> molest it
* touch it
> molest it
* rape it
> molest it
* fuck it
MOLESTATIONPART
* eat it
> molest it
* smell it
> molest it
* stroke it
> molest it

PATTACK@
* hit it
> attack it
* punch it
> attack it
* kick it
> attack it
* fight it
> attack it
* kill it
> attack it
* push it
> attack it

PERSONAL@ THING PMOLEST PATTACK
* attack it
ATTACKPERSON
* molest it
MOLESTATIONPART
* bite it
MOLESTATIONPART
* grab it
MOLESTATIONPART

ASKABOUTMAN
* \n"I know nothing about him."
* \n"Sorry, I don't know him."

ASKABOUTWOMAN
* \n"I know nothing about her."
* \n"Sorry, I don't know her."

ANIMAL@ THING PATTACK
* name
animal
* kiss it
> pet it
* feel it
> pet it
* touch it
> pet it
* stroke it
> pet it
* rape it
> molest it
* smell it
YOUDONT want to do that.
* molest it
MOLESTATION
* attack it
ATTACKPERSON
* bite it
ATTACKPERSON
* give this GETTABLE to it
THAT doesn't want it.
* pet it
PETANIMAL IT.

PETANIMAL=
*?PERSON3 YOUNAME pets
* You pet

PERSON@ THING PMOLEST PATTACK
* name
person
* molest it
MOLESTATION
* attack it
ATTACKPERSON
* grab it
ATTACKPERSON
* bite it
ATTACKPERSON
* beat up it
ATTACKPERSON
* give this GETTABLE to it
THAT doesn't want it.
* ask it about MAN
ASKABOUTMAN
* ask it about WOMAN
ASKABOUTWOMAN

MOLESTATION
I don't think IT would take too kindly to that!

MOLESTATIONPART
Yeah right!

ATTACKPERSON
* Violence is not the answer.
* Not a good idea.

MAN@ PERSON
* name
men
* name
man

WOMAN@ PERSON
* name
women
* name
woman
* name
girl
* name
lady

///////////// BODY PARTS ///////////////////////////////////////

UFEET@ THING
> put it in player
* name
the feet
* name
foot
* x it
The feet are size 9.
* smell it
Poo!

UHANDS@ THING
> put it in player
* name
hands
* x it
Your hands are as hammy as ever.

UFACE@ THING
> put it in player
* name
your face
* x it
It's your ugly mug.

UHEAD@ THING
> put it in player
* name
your head


HEAD@ PERSONAL
> put it in PERSON
* name
head

HANDS@ PERSONAL
> put it in PERSON
* name
hands

////////////////////////////////////////////////////////////


GETTABLE@ THING
* be it
IT
* get it
DOGET
* drop it
DODROP
* postget it
NULL
* postdrop it
NULL

// dummy
NULL

YOUTAKE=
*?PERSON3 YOUNAME takes
* You take

YOUDROP=
*?PERSON3 YOUNAME drops
* You drop

DOGET > put it in player
* ok
YOUTAKE IT.
UPDATEINV
> postget it
*
YOUNAME can't get IT.

DODROP > put it in here
* ok
YOUDROP IT.
> postdrop it
UPDATEINV
XHERE
*
YOUNAME can't do that.


YOURSTUFF > what is in player
*
> be LAST

YOURCLOTHES > what is on me
*
> be LAST
* null

INV
INV1 INV2

YOUARE=
*?PERSON3 YOUNAME is
* You are

INV1 YOURSTUFF
* them
YOUARE carrying, LAST.
*
YOUARE empty handed.

INV2 YOURCLOTHES
* them
YOUARE wearing LAST.


/////////////////////////////////////

WALLS@ THING
* name
the walls
* name
wall

FLOOR@ THING
* name
the floor
* name
ground

SKY@ THING
* name
the blue sky
* name
the sun

CEILING@ THING
* name
the ceiling


XFLOOR
* It keeps you from falling down!
* Don't bother with the ground, it's beneath you!

XWALLS
* The walls aren't really interesting.
* Looking at the walls won't help!

XCEILING
* Not much up there really.
* Staring at the ceiling wont help you.

INSIDE@ ROOM
* x walls
XWALLS
* x wall
XWALLS
* x floor
XFLOOR
* x ceiling
XCEILING

OUTSIDE@ ROOM
* x sky
It's up there.
* x ground
XFLOOR

/////// DOORS

OPENABLE@ THING
* open it
OPENTHING
* close it
CLOSETHING

YOUOPEN=
*?PERSON3 YOUNAME opens
* You open

YOUCLOSE=
*?PERSON3 YOUNAME closes
* You close

OPENTHING > what is it state
* open
It's already open!
*
> set it state open
YOUOPEN IT.

CLOSETHING > what is it state
* open
> set it state closed
YOUCLOSE IT.
*
It's already closed.

DOOR@ OPENABLE


// GARMENTS

GARMENT@ GETTABLE
* take off it
> remove it
* remove it
REMOVEGARMENT
* put on it
> wear it
* wear it
WEARGARMENT
* postremove it
NULL

YOUPUT=
*?PERSON3 YOUNAME puts
* You put

WEARGARMENT > put it on me
* ok
YOUPUT on IT.
*
YOUNAME can't wear that.


REMOVEGARMENT > is it on me
* yes
REMOVEGARMENT2
*
YOUARE not wearing IT.

REMOVEGARMENT2 > put it in me
* ok
YOUTAKE off IT.
> postremove it
*
YOUNAME can't remove that.



/// CONTAINERS

CONTAINERLIKE@ THING
* look in it
WHATSIN
* x it
WHATSALSOIN

CONTAINER@ CONTAINERLIKE
* put this GETTABLE in it
DOPUTIN

DOPUTIN > put it in that
* ok
YOUPUT IT in THAT.
*
YOUNAME can't.

STUFFIN > what is in it
*
> be LAST
* null


WHATSIN STUFFIN
* them
IT contains, LAST.
*
There's nothing there.

WHATSALSOIN STUFFIN
* them
IT contains, LAST.
*

// SURFACES aka supporters

SURFACE@ THING
* look on it
WHATSON
* x it
WHATSALSOON
* put this GETTABLE on it
DOPUTON
* sit on it
Not a good idea.

DOPUTON > put it on that
* ok
YOUPUT IT on THAT.
*
YOUNAME can't.

YOUFIND=
*?PERSON3 YOUNAME sees
* You see

WHATSON > what is on it
* them
On IT YOUFIND, LAST.
*
There's nothing there.

WHATSALSOON > what is on it
* them
On IT YOUFIND, LAST.

// Garment hooks

GARMENTHOOK@ THING
* look on it
GWHATSON
* x it
GWHATSALSOON
* put my GARMENT on it
GDOPUTON
* sit on it
Not a good idea.

GDOPUTON > put it on that
* ok
YOUPUT IT on THAT.
*
YOUNAME can't.

GWHATSON > what is on it
* them
On it YOUFIND, LAST.
*
There's nothing there.

GWHATSALSOON > what is on it
* them
On IT YOUFIND, LAST.
*


// give something

YOUHAVE=
*?PERSON3 YOUNAME has
* You have

GIVESTUFF YOURSTUFF
YOUHAVE, LAST.

GIVEWHAT
GIVESTUFF
*<< Give what?

UNAME!
*< What is your name?


/// Food

EDIBLE@
* eat it
Yum!
> put it in HELL

/// Places

HELL@ INSIDE
* name
hell



