LWWidget.Beta5.Player = LWWidget.Game.Page.inherits({ setData: function (data) { var _d = data.getChildren('Player')[0]; // Player name and cash this.playerName = _d.getAttribute('name'); this.cash = _d.getAttribute('cash'); // Alliance status var _a = _d.getChildren('Alliance'); if (_a.length) { _a = _a[0]; this.alliance = { joined: (_a.getAttribute('inalliance') == '1'), tag: _a.getAttribute('tag') }; } else { this.alliance = null; } // General rankings _a = _d.getChildren('Rankings')[0]; var _r = _a.getChildren('Ranking'); for (var i in _r) { if (_r[i].getText() != 'General Ranking') { continue; } this.points = _r[i].getAttribute('points'); this.rank = _r[i].getAttribute('rank'); break; } // Planets / planets under attack _d = data.getChildren('Empire')[0].getChildren('Planets')[0]; this.planets = parseInt(_d.getAttribute('count'), 10); this.underAttack = parseInt(_d.getAttribute('siege'), 10); // Fleets / fleets in battle _d = data.getChildren('Empire')[0].getChildren('Fleets')[0]; this.fleets = parseInt(_d.getAttribute('count'), 10); this.inBattle = parseInt(_d.getAttribute('inBattle'), 10); }, draw: function (_e) { if (!this.playerName) { return; } var str = '

Player ' + this.playerName + ''; if (this.alliance && this.alliance.joined) { str += ' [' + this.alliance.tag + ']'; } else if (this.alliance && !this.alliance.joined) { str += '
Requesting to join alliance [' + this.alliance.tag + ']'; } str += '

Cash: €' + Base.Util.formatNumber(this.cash) + '' + '
General ranking: #' + Base.Util.formatNumber(this.rank) + ' (' + Base.Util.formatNumber(this.points) + ' points)

'; if (this.planets == 0) { str += "No planets"; } else { str += '' + Base.Util.formatNumber(this.planets) + ' planet' + (this.planets > 1 ? 's' : ''); if (this.underAttack > 0) { str += ' (' + Base.Util.formatNumber(this.underAttack) + ' under attack!)'; } } str += '
'; if (this.fleets == 0) { str += "No fleets"; } else { str += '' + Base.Util.formatNumber(this.fleets) + ' fleet' + (this.fleets > 1 ? 's' : ''); if (this.inBattle > 0) { str += ' (' + Base.Util.formatNumber(this.inBattle) + ' in battle)'; } } str += '

'; _e.innerHTML = str; } });