Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var title = title || {};
- title.title = null;
- title.getValue = function(team) {
- var rst = 0;
- for(var player of intp.players) {
- if(player.side === team) {
- rst += player.money;
- for(var i in intp.things) {
- var thing = intp.things[i];
- if(thing.unit && thing.owner === player.number) {
- rst += thing.cost;
- }
- }
- }
- }
- return rst;
- }
- title.setTitle = function(t) {
- if(typeof(t) === "string" && t !== commander.faction) {
- commander.faction = t;
- account.rootRealSave();
- }
- }
- if(title.timer) {
- clearInterval(title.timer);
- }
- title.timer = setInterval(function() {
- if(!commander) return;
- if(title.title) {
- title.setTitle(title.title);
- return;
- }
- if((commander.side === "alpha" || commander.side === "beta") &&
- sim.state === "running" && !sim.local) {
- var myValue = title.getValue(commander.side);
- var enemyValue = title.getValue(commander.side === "alpha" ? "beta" : "alpha");
- var diff = myValue - enemyValue;
- if(diff > 0) {
- title.setTitle("WIN");
- } else if(diff < 0) {
- title.setTitle("LOSE");
- } else {
- title.setTitle("TIED");
- }
- } else {
- title.setTitle("R26");
- }
- }, 1000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement