[[Initialize]]: @title What's on the Table: A Doting Sim @clear @set not hat @set not eating @set weight=150 @set dispWeight=150 @set fill=0 @set capacity=2 @set dispCapacity=2 @set hardcap=2 @set speed=2 @set hunger=1 @set spread=0 @set status=hungry @set mood=0 @set assistance=0
//define constructor function for foods
function consfood(added, eaten, singular, plural, toTable, emoji) {
return {
toTable: toTable,
singular: singular,
plural: plural,
added: added,
eaten: eaten,
emoji: emoji,
amount: 0
}
}
//initialize the table
squiffy.set('foods',
{
eggs: consfood(2, 0.5, 'a scrambled egg', 'scrambled eggs', 'some scrambled eggs', 'π³'),
toast: consfood(2, 0.5, 'a slice of toast', 'slices of toast', 'some toast', 'π'),
bacon: consfood(8, 2, 'a strip of bacon', 'strips of bacon', 'a plate of bacon', 'π₯'),
pancakes: consfood(4, 1, 'a pancake', 'pancakes', 'a stack of pancakes', 'π₯'),
milk: consfood(1, 0.5, 'a glass of milk', 'glasses of milk', 'some milk', 'π₯'),
burger: consfood(1, 0.25, 'a burger', 'burgers', 'a burger', 'π'),
fries: consfood(1, 0.25, 'a serving of fries', 'servings of fries', 'some fries', 'π'),
pizza: consfood(8, 1, 'a slice of pizza', 'slices of pizza', 'a whole pizza', 'π'),
sandwich: consfood(1, 0.25, 'a sandwich', 'sandwiches', 'a sandwich', 'π₯ͺ'),
soda: consfood(1, 0.25, 'a bottle of soda', 'bottles of soda', 'a bottle of soda', 'π₯€'),
chicken: consfood(1, 0.125, 'a whole chicken', 'chickens', 'a roasted chicken', 'π'),
pasta: consfood(1, 0.25, 'a bowl of pasta', 'bowls of pasta', 'a bowl of pasta', 'π'),
soup: consfood(1, 0.25, 'a bowl of soup', 'bowls of soup', 'a bowl of soup', 'π²'),
fish: consfood(1, 0.25, 'a fish', 'fish', 'a grilled fish', 'π'),
beer: consfood(6, 1, 'a beer', 'beers', 'a 6-pack of beer', 'πΊ'),
donuts: consfood(6, 1, 'a donut', 'donuts', 'a box of donuts', 'π©'),
cookies: consfood(8, 2, 'a cookie', 'cookies', 'a box of cookies', 'πͺ'),
cake: consfood(8, 1, 'a slice of cake', 'slices of cake', 'a whole cake', 'π'),
fudge: consfood(16, 2, 'a piece of fudge', 'pieces of fudge', 'a tray of fudge', 'π«'),
milkshake: consfood(1, 0.25, 'a milkshake', 'milkshakes', 'a milkshake', 'π¦'),
//: consfood(2, 0.5, 'a ', 's', 'a '),
})
squiffy.set('sounds', [[
['B','B','BUR',''],
['URP','URP','UOORP','URRP','ORP'],
],[
['shl','sl','sl'],
['urp','urp','urrrp','rp'],
],[
['n','mn',''],
['mm','om','omnom','omf','umf'],
],[
['ch'],
['omp','ompf'],
],[
['n','mn',''],
['mm','om','omnom','omf','umf'],
],[
['ch'],
['omp','ompf'],
]])
//format stuff and turn links inside <td>s into proper buttons
var document = $('document').context
var style = document.createElement('style')
console.log('hey', style)
style.type = 'text/css';
style.appendChild(document.createTextNode(`blockquote {
margin: 10px 0;
padding: 5px 10px;
font-style: italic;
font-size: 17px
}
td { padding: 0 5px }
h3:not(:first-of-type) { margin-top: 10px }
hr { margin: 15px 0 }
td .squiffy-link {
display: block;
height: 100%;
padding: 3px 6px;
border: 3px inset silver;
border-radius: 10px;
margin: 3px;
background-color: #eee;
text-decoration: none;
min-width: 50px
}`))
document.head.appendChild(style)
##What's on the Table ###A Doting Sim
####Pick your Pronouns
Dotee: | {rotate doteePronoun:They:She:He:You:I} |
Doter: | {rotate doterPronoun:You:I:They:She:He} |
[[BEGIN]] |
[[BEGIN]]: var pronouns = { They: ['They', 'Them', 'Their', 'Theirs', ''], She: ['She', 'Her', 'Her', 'Hers', 's'], He: ['He', 'Him', 'His', 'His', 's'], You: ['You', 'You', 'Your', 'Yours', ''], I: ['I', 'Me', 'My', 'Mine', ''] } window.squiffy = squiffy var dotee = pronouns[squiffy.get('doteePronoun')] var doter = pronouns[squiffy.get('doterPronoun')]; //inflections of the pronouns, as well as whether they add an "s" to verbs //are put into separate variables instead of an array for easy access in the text [0,1,2,3,4].forEach(i=>{ squiffy.set('dotee'+i, dotee[i]) squiffy.set('doter'+i, doter[i]) })
Let's get started!
[[Encourage]]:
var rand = Math.random, r = rand()
var g = squiffy.get
var status = g('status'), fill = g('fill'), capacity = g('capacity'); var hcap = g('hardcap'), spread = g('spread'), room = (capacity + 0.5*(capacity-2) - fill) / capacity, speed = g('speed'), mood = g('mood')
function qs(q, s, e) {squiffy.set('quote1', q); s && squiffy.set('status', s); e != undefined && squiffy.set('eating',e)}
switch (status) {
case 'starving':
case 'hungry':
qs('Finally!', room > 0.5 ? 'gorging' : 'digging in', true)
break
case 'satisfied':
if (room > -r/2) qs('Sure, I could go for a some more!', room > 0 ? 'digging in' : 'slowing down', true)
else qs('Nah, I think I\'m good for now.')
break
case 'stuffed':
if (room >= -hcap*r) qs('I really shouldn\'t, but...', room > -hcap*(r+0.1) ? 'slowing down' : 'persevering', true)
else qs('Ugh...no thanks...')
break
case 'glutted':
qs('Oog, no way.')
break
default:
mood = mood + 0.25
qs(`[Mood bonus +0.25 (now ${mood})]`)
squiffy.set('mood', mood)
break
}
{quote1}
[[Feed]]: γFπππππππππππππγ
[[Assist]]: γπππππππππππππγ
[[Wait]]: {doter0} sit{doter4} and watch.
[[Rest]]:
var g = squiffy.get, s = squiffy.set
var weight = g('weight'), capacity = g('capacity'), fill = g('fill'), status = g('status'), dispWeight, dispCapacity
var statuses = ['starving','starving','hungry','satisfied', 'stuffed', 'glutted']
var statusIndex = statuses.lastIndexOf(status)
if (statusIndex === -1) squiffy.story.go("Wait")
else {
s('mood', 0)
capacity = Math.max(capacity, (capacity*15.1+fill)/16)
dispCapacity = Math.round(capacity*10)/10
var digest = Math.round(fill*4)/8
fill -= digest
weight += digest/8
dispWeight = Math.round(weight*10)/10
status = statuses[statusIndex-1]
s('weight',weight), s('dispWeight',dispWeight), s('capacity',capacity), s('dispCapacity',dispCapacity), s('fill', fill), s('status',status)
}
{dotee0} take{dotee4} some time to sleep it off.
[[bring]]:
var whichfood = squiffy.get('f'), foods = squiffy.get('foods')
if (foods.hasOwnProperty(whichfood)) {
squiffy.set('foodstring', foods[whichfood].toTable)
foods[whichfood].amount += foods[whichfood].added
squiffy.set('spread', squiffy.get('spread')+foods[whichfood].added/foods[whichfood].eaten)
squiffy.set('foods',foods)
}
else squiffy.set('foodstring', 'γπΌπππππππ½π: '+whichfood+'γ')
{doter0} bring{doter4} {foodstring} to the table.
[[]]: @clear
///////////
// SETUP //
///////////
//variable getting
var g = squiffy.get, s = squiffy.set
var foods = g('foods'), foodarray=[], status = g('status'), fill = g('fill'), capacity = g('capacity'); var hcap = g('hardcap'), spread = g('spread'), speed = g('speed'), wasEating = g('eating'), sounds = g('sounds'), p0 = squiffy.get('dotee0'), p2 = squiffy.get('dotee2'), ps = squiffy.get('dotee4'), mood = Math.max(g('mood') - 0.05, 0)
s('dispEating', wasEating)
var room = (capacity + 0.5*(capacity-2) - fill) / capacity
var greed = Math.round(Math.log2(capacity)) / 2 + 0.5
//Notes about `room`:
//can sometimes be not a sum of powers of two, therefore not suitable for display
//use only internally
//chart of room values for capacity = 2 and capacity >> 2
// | 2 | big |
// ----------+-------+-------|
// empty| 1 | 1.5 |
// half full | 0.5 | 1 |
// full | 0 | 0.5 |
// 2x full | -1 | -0.5 |
//
//chart of 1/(2-room) values for capacity = 2 and capacity >> 2
// | 2 | big |
// ----------+-------+-------|
// empty | 1 | 2 |
// half full | 0.7 | 1 |
// full | 0.5 | 0.7 |
// 2x full | 0.3 | 0.4 |
//utility and brevity functions
var rand = Math.random
function pickfrom(arr) {return arr[~~(rand()*arr.length)]}
function lwr(s) {return s.toLowerCase()}
function eat(max, eaten, loop=1000) {
if (!eaten) {
eaten = {_amount:0,_wanted:max}
max = Math.ceil(max*(0.75+rand()/2))
}
if (foodarray.length == 0) return eaten
var which = pickfrom(foodarray)
var clampedMax = Math.min(max, foods[which].amount/foods[which].eaten)
var unitHowMuch = ~~rand()*(clampedMax-1)+1
max -= unitHowMuch
fill += unitHowMuch*0.25
spread -= unitHowMuch
eaten
var howMuch = unitHowMuch*foods[which].eaten
foods[which].amount -= howMuch
if (eaten.hasOwnProperty(which)) eaten[which] += howMuch
else eaten[which] = howMuch
if (unitHowMuch == clampedMax) foodarray.splice(which,1)
if (max === 0 || loop === 0) return eaten
if (foodarray.length === 0) {
eaten._more = max
return eaten
}
else return eat(max, eaten, loop-1)
}
function chooseGulp() {
var gulp = pickfrom([[' gulp', ' down '],[' gobble', ' up '],[' chew', ' through '],[' wolf', ' down '],[' devour', ' '],[' scarf', ' down '],[' gorge', ' on ']])
gulp = gulp[0] + ps + gulp[1]
return p0+gulp
}
function createChomp(num=3, delim = ' ') {
var c = '', s
for (var i = 0; i<num; i++) {
s = rand()>0.1 ? pickfrom(sounds) : pickfrom([[['gulp'],['']],[['glug'],['']]])
c+= pickfrom(s[0])+pickfrom(s[1]) + pickfrom(delim)
}
return c
}
//////////
// STEP //
//////////
//figure out what's on the table and put it there
if (foods !== null) {
foodarray = Object.keys(foods).filter(f=>(foods[f].amount>0 && f[0]!='_'))
if (foodarray.length) {
var ts = 'The table contains '
var last = foodarray.length-1
foodarray.forEach((f, i) => {
f = foods[f]
if (f.amount == 1) ts += f.singular
else ts += f.amount+' '+f.plural
if (i == last) ts += '.'
else if (last > 1) ts += ', '
if (i == last-1) ts += ' and '
})
squiffy.set('tablestring', ts)
}
else squiffy.set('tablestring', 'The table is empty.')
}
function qs(q, s, e) {squiffy.set('quote0', q); s && squiffy.set('status', s); e != undefined && squiffy.set('eating',e)}
var r=rand()
var eaten
switch (status) {
case 'starving':
if (r<0.1) qs('Arrrg, I can\'t take it anymore!', room > 0.75 ? 'gorging' : 'digging in', true)
else qs('Ughhh, I\'m so hungry...')
break
case 'hungry':
if (r<0.02) qs('...I\'m just gonna start.', room > 1 ? 'gorging' : 'digging in', true)
else if (r<0.05) qs('Ughhh, I\'m so hungry...' , 'starving')
else qs(spread < 8? 'I can\'t wait!' : 'Oooh, everything looks so gooood...')
break
case 'satisfied':
if (r<0.005 && fill<hcap) qs('Hmm, maybe I could go for a *bit* more...', 'slowing down', true)
else qs('Mmm, that was good!')
break
case 'stuffed':
if (r<0.001 && fill<hcap) qs('...is it possible to be full and still be hungry?', 'persevering', true)
qs('Oof, I think I ate a bit too much.')
break
case 'glutted':
qs('So...fullll...')
break
default:
var zeal, nextCond, next, chompiness, eatingNext = true
switch (status) {
case 'gorging':
zeal = 1.5
nextCond = r > 1/((2.01-room)**2)
next = 'digging in'
chompiness = 6
break
case 'digging in':
zeal = 1.0
nextCond = r > 1/((2.01-room)**2)
next = 'slowing down'
chompiness = 4
break
case 'slowing down':
zeal = 0.5
nextCond = r > 1/((2.01-room)**2)
next = 'persevering'
chompiness = 3
break
case 'persevering':
zeal = 0.25
nextCond = r > 1/((2.01-room)**2)
next = 'stuffed'
chompiness = 2
eatingNext = false
break
}
eaten = eat(greed * speed * (zeal + mood))
if (!eaten._more || eaten._more < speed*0.75/1.5) {
if (room <= -hcap) {
qs(createChomp(
Math.ceil(chompiness/2),
['...oof...','...hng...','...huf...','...urg...',' ']),
'glutted',false
)
squiffy.set('eating',false)
}
else if (nextCond) {
qs(createChomp(chompiness - 1), next)
squiffy.set('eating',eatingNext)
}
else qs(createChomp(chompiness))
}
}
if (eaten !== null && eaten !== undefined) {
var eatenarray = Object.keys(eaten).filter(f=>f[0]!='_')
if (eatenarray.length) {
var es = chooseGulp()
var last = eatenarray.length-1
eatenarray.forEach((f, i) => {
var official = foods[f]
if (eaten[f] == 1) es += official.singular
else es += eaten[f]+' '+official.plural
if (i == last) es += '.'
else if (last > 1) es += ', '
if (i == last-1) es += ' and '
})
let eatenmod = ''
switch (squiffy.get('status')){
case 'starving':
eatenmod = ` But then...${lwr(p0)} mysteriously stop${ps}! Even the narrator doesn\'t know why.`
break;
case 'hungry':
eatenmod = ` But then, oddly, ${lwr(p0)} stop${ps}! Even the narrator isn\'t sure why.`
break;
case 'satisfied':
eatenmod = ` Then ${lwr(p0)} stop${ps}, apparently satisfied.`
break;
case 'stuffed':
eatenmod = ` Then ${lwr(p0)} stop${ps} with a grunt, and pat${ps} ${lwr(p2)} bloated belly.`
break;
case 'glutted':
eatenmod = ` Then ${lwr(p0)} stop${ps} with a groan, ${lwr(p2)} hand on ${lwr(p2)} bloated, aching belly.`
break;
}
squiffy.set('eatenstring', es + eatenmod)
}
else squiffy.set('eatenstring', `The table is empty. ${p0} look${ps} at it forlornly.`)
}
else squiffy.set('dispEating', false)
s('fill', fill); s('spread', spread); s('foods', foods); s('mood', mood)
###Stats
Weight: | {dispWeight} |
Stomach: | {fill}/{dispCapacity} |
Status: | {status} |
{quote0}
###The Table
{tablestring}
[[Add Eggs]](bring, f=eggs) | [[Add Toast]](bring, f=toast) | [[Add Bacon]](bring, f=bacon) | [[Add Pancakes]](bring, f=pancakes) | [[Add Milk]](bring, f=milk) |
[[Add Burger]](bring, f=burger) | [[Add Fries]](bring, f=fries) | [[Add Pizza]](bring, f=pizza) | [[Add Sandwich]](bring, f=sandwich) | [[Add Soda]](bring, f=soda) |
[[Add Chicken]](bring, f=chicken) | [[Add Pasta]](bring, f=pasta) | [[Add Soup]](bring, f=soup) | [[Add Fish]](bring, f=fish) | [[Add Beer]](bring, f=beer) |
[[Add Donuts]](bring, f=donuts) | [[Add Cookies]](bring, f=cookies) | [[Add Cake]](bring, f=cake) | [[Add Fudge]](bring, f=fudge) | [[Add Milkshake]](bring, f=milkshake) |
{if dispEating:{eatenstring}}
###Actions
{if eating:
[[Encourage]] | [[Assist]] | [[Wait]] |
[Start] | [[Wait]] | [[Rest]] |