Long week (or float week? or maybe int week?)
April 29th, 2005 by darylIt’s been a long week of code-writing, to the point that I almost can’t help thinking of my week in terms of a little script. Here’s what I did this week:
var days=array('Monday','Tuesday','Wednesday','Thursday','Friday');
var daryl=new Person('Daryl');
for(var idx=0; idx < days.length; idx++){
var hour=0;
while(hour <= 24){
var on_break=false;
if(hour >= 6 && hour <=24){
if(days[idx]=='Wednesday'){
if(hour > 11.5 && hour < 1){
daryl.eat();
on_break=true;
}
}
elseif(days[idx]=='Friday'){
if(hour > 12.5 && hour < 2){
daryl.eat();
on_break=true;
}
}
else{
if(hour > 12 && hour < 12.5){
daryl.eat();
on_break=true;
}
}
if(hour >= 18 && hour <= 20.5){
if(hour > 18.5 && hour < 19){
daryl.eat();
on_break=true;
}
else{
daryl.play_with_baby();
on_break=true;
}
}
if(on_break == false){
daryl.work();
}
}
else{
$daryl.sleep();
on_break=true;
}
}
}
function Person(name){
this.name=name;
this.nutrition_quota=0;
this.sleep_quota=0;
this.baby_playtime_quota=0;
this.eat=_eat;
this.sleep=_sleep;
this.play_with_baby=_play_with_baby;
}
function _eat(){
while(this.belly_full_percentage < 100){
this.nutrition_quota++;
}
}
function _sleep(){
var dog_bathroom=Math.floor(Math.random()*65+1);
var dog_bathroom_again=Math.floor(Math.random()*65+1);
//Note that this isn't 100 percent by a long shot.
while(this.sleep_quota < 85){
this.sleep_quota++;
//The dog makes me let him out at least twice a night at a cost of five minutes of sleep each time.
if(this.sleep_quota==dog_bathroom || this.sleep_quota==dog_bathroom_again){
this.sleep_quota+=5;
}
}
}
function _play_with_baby(){
while(this.baby_playtime_quota < 100){
this.baby_playtime_quota++;
}
}