Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added some rendering logic

  • Loading branch information...
commit c02545e5677786c2587890367d98c90508b4c305 1 parent bc3192a
@aproctor authored
View
91 components/disasters.js
@@ -73,7 +73,98 @@ Crafty.c("ABStats",{
},
});
+Crafty.c("ABCommunication",{
+ init: function() {
+ this.addComponent("ABStats");
+
+ this.attr({
+ cost: 10,
+ exposure: 10,
+ ref: null,
+ title: '',
+ global: false
+ });
+ },
+
+ setup: function(ref) {
+ this.ref = ref;
+
+ if(ref == "ed") {
+ this.attr({
+ title: "Editorial",
+ cost: 3000,
+ exposure: 3000
+ });
+ } else if(ref == "int") {
+ this.attr({
+ title: "Internet",
+ cost: 800,
+ exposure: 100,
+ global: true
+ });
+ } else if(ref == "lobby") {
+ this.attr({
+ title: "Lobby Govt.",
+ cost: 5000000,
+ exposure: 5000000,
+ });
+ } else if(ref == "pamph") {
+ this.attr({
+ title: "Pamphlets",
+ cost: 100,
+ exposure: 100,
+ });
+ } else if(ref == "prop") {
+ this.attr({
+ title: "Lobby Govt.",
+ cost: 800000,
+ exposure: 100000,
+ global: true
+ });
+ } else if(ref == "radio") {
+ this.attr({
+ title: "Talk Radio",
+ cost: 2000,
+ exposure: 2000,
+ });
+ } else if(ref == "tele") {
+ this.attr({
+ title: "Television",
+ cost: 30000,
+ exposure: 10000,
+ global: true
+ });
+ } else if(ref == "verbal") {
+ this.attr({
+ title: "Verbal",
+ cost: 10,
+ exposure: 10,
+ });
+ }
+
+ ABGame.COMMS[ref] = this;
+
+ return this;
+ },
+
+ renderLink: function(global) {
+ var buff = [];
+
+ if(global === true && this.global === true || global === false && this.global === false) {
+ buff.push('<a href="#" onclick="ABGame.communication(\'');
+ buff.push(this.ref);
+ buff.push('\'); return false;">');
+ buff.push(this.title);
+ buff.push('<em>$');
+ buff.push(this.cost);
+ buff.push('</em></a>');
+ }
+
+ return buff.join('');
+ }
+});
+ABGame.COMMS = {};
ABGame.TAGS = {};
ABGame.TAGS.lib = Crafty.e("ABStats").updateStats({
p: -1,
View
2  components/regions.js
@@ -119,7 +119,9 @@ Crafty.c("ABRegion", {
this.titleEn = Crafty.e("ABRegText");
this.titleEn.text(this.title);
this.titleEn.setup(this);
+ console.log('1');
this.statsViewEn.setup(this);
+ console.log('2');
},
View
11 game.js
@@ -77,6 +77,8 @@ var ABGame = {
this.tickRate = val;
},
+ COMMS: [],
+
toString: function() {
return "ABGame";
}
@@ -90,4 +92,13 @@ window.onload = (function() {
Crafty.init(ABGame.width+324, ABGame.height);
Crafty.background('#000');
Crafty.scene("splash");
+
+ Crafty.e("ABCommunication").setup("verbal");
+ Crafty.e("ABCommunication").setup("pamph");
+ Crafty.e("ABCommunication").setup("int");
+ Crafty.e("ABCommunication").setup("radio");
+ Crafty.e("ABCommunication").setup("ed");
+ Crafty.e("ABCommunication").setup("tele");
+ Crafty.e("ABCommunication").setup("lobby");
+ Crafty.e("ABCommunication").setup("prop");
});
View
4 index.html
@@ -98,9 +98,9 @@
</div>
</div>
- <div class="ABRegStats vis">
+ <div class="ABRegStats">
<a href="#" style="float: right;">World Stats</a>
- <h3>down under</h3>
+ <h3>world </h3>
<div class="stats total">Total population: <em>30,000,000</em></div>
<div class="stats converted">Converted: <em>10,000</em></div>
<div class="stats disb">Disbelievers: <em>30,000</em></div>
View
65 scenes/ui.js
@@ -24,25 +24,66 @@ Crafty.c("ABDisasterChoice", {
}
});
-
Crafty.c("ABRegStats", {
- init: function() {
- this.attr({
- visible: false
- });
- },
+ region: null,
+ stats: null,
+ statBoxEl: null,
- setup: function(attrs) {
- this.attr(attrs);
+ init: function() {
},
-
-
- toString: function() {
- return "ABRegStats";
+ setup: function(region) {
+ this.region = region;
+ this.stats = region.statsEn;
+
+ var buffer = [];
+
+ buffer.push('<div id="reg_stats_');
+ buffer.push(region.reference);
+ buffer.push('" class="ABRegStats">');
+ buffer.push('<a href="#" style="float: right;" onclick="ABGame.world.selectRegion();">World</a>');
+ buffer.push('<h3>');
+ buffer.push(region.title.toLowerCase());
+ buffer.push('</h3>');
+ buffer.push('<div class="stats total">Total population: <em>');
+ buffer.push(region.population);
+ buffer.push('</em></div>');
+ buffer.push('<div class="stats converted">Converted: <em>');
+ //TODO buffer.push(10,000
+ buffer.push('</em></div>');
+ buffer.push('<div class="stats disb">Disbelievers: <em>');
+ //TODO buffer.push(30,000
+ buffer.push('</em></div>');
+ buffer.push('<div class="stats unexposed">Unexposed: <em>');
+ //TODO buffer.push(26,000,000
+ buffer.push('</em></div>');
+ buffer.push('<div class="stats ratio">Conv. Rate: <em>');
+ //TODO buffer.push(0.75
+ buffer.push('</em></div>');
+ buffer.push('<h4>actions</h4>');
+ buffer.push('<div class="actions">');
+
+
+ for(var c in ABGame.COMMS) {
+ buffer.push(ABGame.COMMS[c].renderLink(false));
+ }
+ //buffer.push('<a href="#" onclick="ABGame.communication(\'pamphlets\'); return false;">Buy Pamphlets<em>$300,000</em></a>');
+/* <a href="#" onclick="ABGame.communication('pamphlets'); return false;">Buy Pamphlets<em>$300,000</em></a>
+ <a href="#" onclick="ABGame.communication('pamphlets'); return false;">Buy Pamphlets<em>$300,000</em></a>
+ <a href="#" onclick="ABGame.communication('pamphlets'); return false;">Buy Pamphlets<em>$300,000</em></a>
+ <a href="#" onclick="ABGame.communication('pamphlets'); return false;">Buy Pamphlets<em>$300,000</em></a>
+ <a href="#" onclick="ABGame.communication('pamphlets'); return false;">Buy Pamphlets<em>$300,000</em></a>
+ <a href="#" onclick="ABGame.communication('pamphlets'); return false;">Buy Pamphlets<em>$300,000</em></a>
+ */
+ buffer.push('</div></div>');
+
+ $('body').append(buffer.join(''));
+
+ return this;
}
});
+
$('.intros > *').live('click', function(el){
$(this).toggle();
});
Please sign in to comment.
Something went wrong with that request. Please try again.