Browse Source

Temperature loss, refined model

pull/2/head
Robert Chen 11 years ago
parent
commit
be8ce4c28d
  1. 63
      js/model.js
  2. 10
      js/screens.js
  3. 9
      js/ui.js

63
js/model.js

@ -6,11 +6,12 @@ function TurkeyLayer( name, layerNumber1, turkeyModel, ovenModel ){ @@ -6,11 +6,12 @@ function TurkeyLayer( name, layerNumber1, turkeyModel, ovenModel ){
this.waterLost = 0;
this.finalTemperature = 20;
this.cookCondition = "Raw";
this.highestTemp = 0;
return {
updateTemperatureTick: function(){
that.finalTemperature = turkeyModel.globTemp[that.layerNumber]
console.log(turkeyModel.globTemp)
if(DEBUG) console.log(turkeyModel.globTemp);
that.highestTemp = that.finalTemperature > that.highestTemp ? that.finalTemperature : that.highestTemp;
that.waterLost = that.waterLost + UtilityFunctions.waterLoss( that.finalTemperature );
that.cookCondition = UtilityFunctions.cookCondition(that.waterLost, that.name);
if(DEBUG) console.log( that.name + ": "+ that.waterLost + " " + that.cookCondition + " " + that.finalTemperature + " C" );
@ -20,6 +21,9 @@ function TurkeyLayer( name, layerNumber1, turkeyModel, ovenModel ){ @@ -20,6 +21,9 @@ function TurkeyLayer( name, layerNumber1, turkeyModel, ovenModel ){
},
getTemperature: function(){
return that.finalTemperature;
},
getHighestTemp: function(){
return that.highestTemp;
}
}
@ -40,8 +44,8 @@ function TurkeyModel( weight, ovenModel ){ @@ -40,8 +44,8 @@ function TurkeyModel( weight, ovenModel ){
this.totalLayers = [ new TurkeyLayer("Skin", this.splitsNum-1, this, ovenModel ),
new TurkeyLayer("Body", this.splitsNum-4, this, ovenModel ),
new TurkeyLayer("Core", 0, this, ovenModel ) ];
new TurkeyLayer("Body", this.splitsNum-10, this, ovenModel ),
new TurkeyLayer("Core", 1, this, ovenModel ) ];
// Whenever temperature is changed
this.updateLayerTemps = function() {
@ -113,15 +117,18 @@ function OvenModel( turkeyWeight, gameState ) { @@ -113,15 +117,18 @@ function OvenModel( turkeyWeight, gameState ) {
return {
"skin" : {
"temp": turkey.totalLayers[0].getTemperature(),
"cond": turkey.totalLayers[0].getCondition()
"cond": turkey.totalLayers[0].getCondition(),
"highest" : turkey.totalLayers[0].getHighestTemp()
},
"body" : {
"temp": turkey.totalLayers[1].getTemperature(),
"cond": turkey.totalLayers[1].getCondition()
"cond": turkey.totalLayers[1].getCondition(),
"highest" : turkey.totalLayers[1].getHighestTemp()
},
"core" : {
"temp": turkey.totalLayers[2].getTemperature(),
"cond": turkey.totalLayers[2].getCondition()
"cond": turkey.totalLayers[2].getCondition(),
"highest" : turkey.totalLayers[2].getHighestTemp()
}
};
},
@ -252,28 +259,28 @@ UtilityFunctions = { @@ -252,28 +259,28 @@ UtilityFunctions = {
},
cookCondition: function(cookValue, layerName){
if( layerName == "skin" ){
if( layerName == "Skin" || layerName == "Body" ){
var multiplier = 1;
if (cookValue>=multiplier*600000) {
if (cookValue>=multiplier*400000) {
return ["Fire", (cookValue-600000)/(multiplier*600000),"fire"];
}
else if(cookValue>=multiplier*250000) {
else if(cookValue>=multiplier*350000) {
return ["Burnt", (cookValue-250000)/(multiplier*600000), "burnt"];
}
else if (cookValue>=multiplier*150000) {
else if (cookValue>=multiplier*300000) {
return ["Dry", (cookValue-150000)/(multiplier*250000), "dry"];
}
else if (cookValue>=multiplier*85000){
else if (cookValue>=multiplier*250000){ // >250000
return ["Cooked", (cookValue-12000)/(multiplier*150000), "overcooked"];
}
else if (cookValue>=multiplier*12000) {
else if (cookValue>=multiplier*80000) { // >50000
return ["Cooked", (cookValue-12000)/(multiplier*150000), "cooked"];
}
else if (cookValue>=multiplier*10000){
return ["Undercooked", (cookValue-5000)/(multiplier*12000), "slightly cooked"];
else if (cookValue>=multiplier*50000){
return ["Undercooked", (cookValue-5000)/(multiplier*10000), "slightly cooked"];
}
else if (cookValue>=multiplier*5000) {
return ["Undercooked", (cookValue-5000)/(multiplier*12000), "undercooked"];
else if (cookValue>=multiplier*25000) { //
return ["Undercooked", (cookValue-5000)/(multiplier*10000), "undercooked"];
}
else {
return ["Raw", 1, "raw"];
@ -281,26 +288,26 @@ UtilityFunctions = { @@ -281,26 +288,26 @@ UtilityFunctions = {
}
else{
var multiplier = 1;
if (cookValue>=multiplier*600000) {
if (cookValue>=multiplier*45000) { //
return ["Fire", (cookValue-600000)/(multiplier*600000),"fire"];
}
else if(cookValue>=multiplier*250000) {
else if(cookValue>=multiplier*35000){//
return ["Burnt", (cookValue-250000)/(multiplier*600000), "burnt"];
}
else if (cookValue>=multiplier*150000) {
else if (cookValue>=multiplier*25000){ //
return ["Dry", (cookValue-150000)/(multiplier*250000), "dry"];
}
else if (cookValue>=multiplier*85000){
return ["Cooked", (cookValue-12000)/(multiplier*150000), "overcooked"];
else if (cookValue>=multiplier*22000){ //
return ["Cooked", (cookValue-22000)/(multiplier*150000), "overcooked"];
}
else if (cookValue>=multiplier*12000) {
return ["Cooked", (cookValue-12000)/(multiplier*150000), "cooked"];
else if (cookValue>=multiplier*12000){ //
return ["Cooked", (cookValue-12000)/(multiplier*85000), "cooked"];
}
else if (cookValue>=multiplier*10000){
return ["Undercooked", (cookValue-5000)/(multiplier*12000), "slightly cooked"];
else if (cookValue>=multiplier*7000){ //
return ["Undercooked", (cookValue-7000)/(multiplier*7000), "slightly cooked"];
}
else if (cookValue>=multiplier*5000) {
return ["Undercooked", (cookValue-5000)/(multiplier*12000), "undercooked"];
else if (cookValue>=multiplier*3000) {
return ["Undercooked", (cookValue-3000)/(multiplier*7000), "undercooked"];
}
else {
return ["Raw", 1, "raw"];

10
js/screens.js

@ -405,7 +405,7 @@ function ScoreScreen( stage, gameState ){ @@ -405,7 +405,7 @@ function ScoreScreen( stage, gameState ){
var totalScore = 0;
var skinScoreChart = {
"raw": 0,
"raw": -1000,
"undercooked": -100,
"slightly cooked": 75,
"cooked": 500,
@ -419,7 +419,7 @@ function ScoreScreen( stage, gameState ){ @@ -419,7 +419,7 @@ function ScoreScreen( stage, gameState ){
"undercooked": 125,
"slightly cooked": 750,
"cooked": 1000,
"overcooked": 1000,
"overcooked": 600,
"dry": 400,
"burnt": 0
};
@ -444,7 +444,7 @@ function ScoreScreen( stage, gameState ){ @@ -444,7 +444,7 @@ function ScoreScreen( stage, gameState ){
var outerTemp = UtilityFunctions.C2F(turkeyState.skin.temp).toFixed(2);
var coreTemp = UtilityFunctions.C2F(turkeyState.core.temp).toFixed(2);
var outerTempScore = that.scoreDistribution( outerTemp ) * 200;
var outerTempScore = that.scoreDistribution( outerTemp, "skin" ) * 200;
var coreTempScore = that.scoreDistribution( coreTemp ) * 200;
totalScore += parseInt(skinScoreChart[ turkeyState.skin.cond[2]]);
@ -594,14 +594,14 @@ function ScoreScreen( stage, gameState ){ @@ -594,14 +594,14 @@ function ScoreScreen( stage, gameState ){
// Modifiers
var turkeyMod = typeToMod[gameState.turkeyType];
var turkeyTypeModifierText = new createjs.Text( "+"+(Math.abs(turkeyMod-1)*100).toFixed(0) + "%", "20px Arial", "black" );
var turkeyTypeModifierText = new createjs.Text( ((1-turkeyMod)*100).toFixed(0) + "%", "20px Arial", "black" );
turkeyTypeModifierText.x = 310;
turkeyTypeModifierText.y = 437;
totalScore *= turkeyMod;
var stuffingTypeModifierText = new createjs.Text( "+"+(Math.abs(gameState.stuffingTypeModifier-1)*100).toFixed(0)+"%" , "20px Arial", "black" );
var stuffingTypeModifierText = new createjs.Text( ((1-gameState.stuffingTypeModifier-1)*100).toFixed(0)+"%" , "20px Arial", "black" );
stuffingTypeModifierText.x = 310
stuffingTypeModifierText.y = 457;

9
js/ui.js

@ -523,7 +523,7 @@ function OvenUI( stage, gameState ){ @@ -523,7 +523,7 @@ function OvenUI( stage, gameState ){
gameState.pubsub.publish("Death","");
gameState.pubsub.publish( "ShowDialog", {seq:"custom", autoAdvance:true, customText:evalSkin[turkeyState["skin"]["cond"][2]] + "." } );
gameState.pubsub.publish( "AddRecord", {type:"Open ", text:"The turkey looked " + turkeyState["skin"]["cond"][2]} );
//gameState.ovenModel.setRawTemp( (gameState.ovenModel.getRawTemp() - 25) < 150 ? 150 : gameState.ovenModel.getRawTemp() - 25 );
gameState.ovenModel.setRawTemp( (gameState.ovenModel.getRawTemp() - 3 ) < 20 ? 20 : gameState.ovenModel.getRawTemp() - 3 );
gameState.ovenOpened++;
}
@ -595,8 +595,13 @@ function OvenUI( stage, gameState ){ @@ -595,8 +595,13 @@ function OvenUI( stage, gameState ){
this.secondTick = function(diff){
// check if oven door is open
if( that.ovenDoor == OVEN_OPEN ){
gameState.ovenModel.setRawTemp( (gameState.ovenModel.getRawTemp() - 1 ) < 20 ? 20 : gameState.ovenModel.getRawTemp() - 1 );
}
gameState.ovenModel.secondTick();
gameState.currentTime += diff;
gameState.turkeyCookCounter++;
}
gameState.pubsub.subscribe( "SkipTime", function(){
@ -765,9 +770,9 @@ function WindowUI( stage, gameState ){ @@ -765,9 +770,9 @@ function WindowUI( stage, gameState ){
stage.addChild( dayNight );
stage.addChild( ground );
stage.addChild( houses );
stage.addChild( stars );
stage.addChild( animation );
stage.addChild( mood );
stage.addChild( stars );
for( var i in smallWindows ){
smallWindows[i].visible = UtilityFunctions.randRange(0,1);

Loading…
Cancel
Save