intfiction.org

The Interactive Fiction Community Forum
It is currently Fri Nov 16, 2018 6:26 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2, 3
Author Message
 Post subject: Re: Negative Money :(
PostPosted: Fri Sep 28, 2018 10:05 am 
Offline
User avatar

Joined: Sun May 21, 2017 4:59 pm
Posts: 298
Location: Michigan
No problem. :)

Hmmm... Maybe change things around a bit so edibles have a number called stock. I'm specifically using the candy bar here, but you could have a kind of liquid called Potion and do it that way for multiple potions. As you can see, I've slimmed this down to a "candy bar only vending machine" to try to keep the example clearer.

Basically, we're intercepting things to keep the player always with a candy bar with at least a stock of 0. We only allow eating, dropping, other things when the stock is over 0. We increment when buying, decrement when eating or dropping, we stop attempts to give away our precious 3,000 year old candy bar ;)

There are probably more elegant ways to handle this, but it seems to work. You'll need to add some spit and polish:

Code:
The store is a room.

Percy is a man in the store.

Price is a kind of value. $10.99 specifies a price with parts dollars and cents (optional, preamble optional).

A person has a price called wealth. The wealth of the player is $15.

A thing has a price. The price of a thing is usually $5.00.

Buying it from is an action applying to two things. Understand "buy [something] from [something]" as buying it from.

Vending machine is an unopenable container in the store.

A candy bar is an edible thing. The player carries a candy bar. The price of the candy bar is $1.50.
A candy bar has a number called stock. The stock is usually 0.

Rule for printing inventory details of a candy bar:
   say "(x[stock of the candy bar])".

Before doing anything with a candy bar when the stock of a candy bar is 0:
   if trying buying a candy bar from a vending machine:
      continue the action;
   else:
      say "You don't have one";
      stop the action.

Instead of dropping a candy bar:
   say "You drop a candy bar. A vermin of some sort runs off with it.";
   decrement the stock of the candy bar.
   
Instead of giving a candy bar to someone:
   say "No, that's yours.".   

Instead of eating a candy bar:
   say "It would be delicious, if it weren't 3,000 years old...";
   say "Your health goes up by 5 points!";
   decrement the stock of the candy bar.

Carry out buying it from:
   if the wealth of the player is greater than the price of the noun:
      decrease the wealth of the player by the price;
      if the player does not have the noun:
         move the noun to the player;
      else:
         increment the stock of the noun;
      say "You bought [the noun].";
   else:
      say "You can't buy that! The price is [price of the noun] and you only have [wealth of the player]!";
      stop the action.

After taking inventory, say "You have [the wealth of the player]."

When play begins: now right hand status line is "Cash: [wealth of the player]".




Example output:

Code:
store
You can see Percy and Vending machine (empty) here.

>buy candy bar from vending machine
You bought the candy bar.

>buy candy bar from vending machine
You bought the candy bar.

>buy candy bar from vending machine
You bought the candy bar.

>buy candy bar from vending machine
You bought the candy bar.

>i
You are carrying:
  a candy bar(x4)

You have $9.

>drop candy bar
You drop a candy bar. A vermin of some sort runs off with it.

>drop candy bar
You drop a candy bar. A vermin of some sort runs off with it.

>drop candy bar
You drop a candy bar. A vermin of some sort runs off with it.

>drop candy bar
You drop a candy bar. A vermin of some sort runs off with it.

>drop candy bar
You don't have one
>drop candy bar
You don't have one
>i
You are carrying:
  a candy bar(x0)

You have $9.

>buy candy bar from vending machine
You bought the candy bar.

>eat candy bar
It would be delicious, if it weren't 3,000 years old...
Your health goes up by 5 points!

>i
You are carrying:
  a candy bar(x0)

You have $7.50.

>buy candy bar from vending machine
You bought the candy bar.

>give candy bar to percy
No, that's yours.

_________________
~~~
My ebooks on Amazon
My ebooks on Smashwords


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Negative Money :(
PostPosted: Fri Sep 28, 2018 11:53 am 
Offline

Joined: Wed Sep 26, 2018 10:10 am
Posts: 12
Oooh thanks! That'll work nicely. I was thinking that I had to do a machine that has just only one item, actually. I'll pull something off like this. You're great, man! This is really helping my game! With some of the cool code I came up with, you'd think I would have figured this one out. Awesome. My game's gonna be great!


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Negative Money :(
PostPosted: Fri Sep 28, 2018 12:00 pm 
Offline
User avatar

Joined: Sun May 21, 2017 4:59 pm
Posts: 298
Location: Michigan
Glad to help :)

Feel free to shine a little light my way in the credits, if you feel like it :)

_________________
~~~
My ebooks on Amazon
My ebooks on Smashwords


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Negative Money :(
PostPosted: Fri Sep 28, 2018 2:48 pm 
Offline

Joined: Wed Sep 26, 2018 10:10 am
Posts: 12
I will!!


Top
 Profile Send private message  
Reply with quote  
 Post subject: Re: Negative Money :(
PostPosted: Fri Sep 28, 2018 3:13 pm 
Offline
User avatar

Joined: Sun May 21, 2017 4:59 pm
Posts: 298
Location: Michigan
CrazyFlitz wrote:
I will!!


Thanks :) I appreciate the egoboo. :)

_________________
~~~
My ebooks on Amazon
My ebooks on Smashwords


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ]  Go to page Previous  1, 2, 3

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 26 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group