ncase.me-trust/js/slides/2_Slides_Iterated.js
2017-07-13 11:07:33 -04:00

71 lines
No EOL
1.3 KiB
JavaScript

SLIDES.push({
id: "iterated",
onjump: function(self){
// Iterated Simulation
self.add({id:"iterated", type:"Iterated", x:130, y:133});
self.objects.iterated.dehighlightPayoff();
},
onstart: function(self){
// ROUNDS
var ROUNDS = [
{id:"tft", num:5},
//{id:"all_d", num:4},
//{id:"all_c", num:4},
//{id:"grudge", num:5},
//{id:"prober", num:7}
];
ROUND_INDEX = 0;
ROUND_NUM = 0;
self.add({
id:"buttonCheat", type:"Button", x:275, y:403, uppercase:true,
text_id:"label_cheat",
message:"iterated/cheat"
});
self.add({
id:"buttonCooperate", type:"Button", x:495, y:400, uppercase:true,
text_id:"label_cooperate",
message:"iterated/cooperate"
});
listen(self, "iterated/round/start", function(){
publish("buttonCheat/deactivate");
publish("buttonCooperate/deactivate");
});
listen(self, "iterated/round/end", function(){
publish("buttonCheat/activate");
publish("buttonCooperate/activate");
// Next round
ROUND_NUM++;
if(ROUND_NUM >= ROUNDS[ROUND_INDEX].num){
// Next opponent
ROUND_NUM = 0;
ROUND_INDEX++;
if(ROUND_INDEX >= ROUNDS.length){
publish("slideshow/scratch"); // NEXT SLIDE, WHATEVER
}else{
publish("iterated/newOpponent",[ROUNDS[ROUND_INDEX].id]);
}
}
});
},
onend: function(self){
unlisten(self);
self.clear();
}
});