camelot-unchained
Version:
Camelot Unchained Client Library
1,089 lines (978 loc) • 1.35 MB
JavaScript
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var client_1 = require('../core/client');
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {
baseURL: client_1.default.webAPIHost,
headers: {
'api-version': client_1.default.apiVersion,
'loginToken': client_1.default.loginToken
}
};
},{"../core/client":50}],2:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var apisauce_1 = require('apisauce');
var createOptions_1 = require('./createOptions');
var api = apisauce_1.create(createOptions_1.default);
var groupsAPI = {
getInvitesForCharacter: function getInvitesForCharacter(shard, characterID) {
return api.call('groups/getInvitesForCharacter', {
shardID: shard,
characterID: characterID
});
},
getInvitesForGroup: function getInvitesForGroup(shard, groupID) {
return api.call('groups/getInvitesForGroup', {
shardID: shard,
groupID: groupID
});
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = groupsAPI;
},{"./createOptions":1,"apisauce":121}],3:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var warband_1 = require('./warband');
var groups_1 = require('./groups');
var client_1 = require('../core/client');
var combined = Object.assign({
loginToken: client_1.default.loginToken,
shardID: 1
}, groups_1.default, warband_1.default);
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = combined;
},{"../core/client":50,"./groups":2,"./warband":4}],4:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var apisauce_1 = require('apisauce');
var createOptions_1 = require('./createOptions');
var api = apisauce_1.create(createOptions_1.default);
var warbandAPI = {
createWarband: function createWarband(shard, characterID) {
var name = arguments.length <= 2 || arguments[2] === undefined ? '' : arguments[2];
var params = {
shardID: shard,
characterID: characterID
};
if (name.length > 0) {
params.name = name;
}
return api.call('groups/createWarband', params);
},
inviteCharacterToWarbandByID: function inviteCharacterToWarbandByID(shard, warbandID, characterID, targetID) {
return api.call('groups/inviteCharacterToWarband', {
shardID: shard,
warbandID: warbandID,
characterID: characterID,
targetID: targetID
});
},
inviteCharacterToWarbandByName: function inviteCharacterToWarbandByName(shard, characterID, targetName) {
var warbandID = arguments.length <= 3 || arguments[3] === undefined ? '' : arguments[3];
var params = {
shardID: shard,
characterID: characterID,
targetName: targetName
};
if (warbandID.length > 0) {
params.warbandID = warbandID;
}
return api.call('groups/inviteCharacterToWarband', params);
},
joinWarbandByID: function joinWarbandByID(shard, warbandID, characterID) {
var inviteCode = arguments.length <= 3 || arguments[3] === undefined ? '' : arguments[3];
var params = {
shardID: shard,
warbandID: warbandID,
characterID: characterID
};
if (inviteCode.length > 0) {
params.inviteCode = inviteCode;
}
return api.call('groups/joinWarband', params);
},
joinWarbandByName: function joinWarbandByName(shard, warbandName, characterID) {
var inviteCode = arguments.length <= 3 || arguments[3] === undefined ? '' : arguments[3];
var params = {
shardID: shard,
warbandName: warbandName,
characterID: characterID
};
if (inviteCode.length > 0) {
params.inviteCode = inviteCode;
}
return api.call('groups/joinWarband', params);
},
getWarbandInfoByID: function getWarbandInfoByID(shard, warbandID) {
return api.call('groups/getWarbandInfo', {
shardID: shard,
warbandID: warbandID
});
},
getWarbandInfoByName: function getWarbandInfoByName(shard, warbandName) {
return api.call('groups/getWarbandInfo', {
shardID: shard,
warbandName: warbandName
});
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = warbandAPI;
},{"./createOptions":1,"apisauce":121}],5:[function(require,module,exports){
// Based on https://github.com/thiagoc7/react-animate.css which is under the MIT license
//
// The MIT License (MIT)
//
// Copyright (c) 2015 Ryan Florence
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = require('react');
var ReactCSSTransitionGroup = require('react-addons-css-transition-group');
var Animate = function (_React$Component) {
_inherits(Animate, _React$Component);
function Animate(props) {
_classCallCheck(this, Animate);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Animate).call(this, props));
_this.renderStyle = function (animationEnter, animationLeave, durationEnter, durationLeave) {
return '\n .default-enter {\n opacity: 0;\n }\n .default-enter.' + animationEnter + ' {\n animation-duration: ' + durationEnter / 1000 + 's;\n animation-fill-mode: both;\n opacity: 1;\n }\n .default-leave {\n opacity: 1;\n }\n .default-leave.' + animationLeave + ' {\n animation-duration: ' + durationLeave / 1000 + 's;\n animation-fill-mode: both;\n }\n ';
};
return _this;
}
_createClass(Animate, [{
key: 'render',
value: function render() {
var _props = this.props;
var children = _props.children;
var animationEnter = _props.animationEnter;
var animationLeave = _props.animationLeave;
var durationEnter = _props.durationEnter;
var durationLeave = _props.durationLeave;
return React.createElement("div", null, React.createElement("style", { dangerouslySetInnerHTML: { __html: this.renderStyle(animationEnter, animationLeave, durationEnter, durationLeave) } }), React.createElement(ReactCSSTransitionGroup, { component: "div", transitionName: {
enter: 'default-enter',
enterActive: animationEnter,
leave: 'default-leave',
leaveActive: animationLeave
}, transitionEnterTimeout: durationEnter, transitionLeaveTimeout: durationLeave }, children));
}
}]);
return Animate;
}(React.Component);
Animate.propTypes = {
animationEnter: React.PropTypes.string.isRequired,
animationLeave: React.PropTypes.string.isRequired,
durationEnter: React.PropTypes.number.isRequired,
durationLeave: React.PropTypes.number.isRequired
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Animate;
},{"react":307,"react-addons-css-transition-group":173}],6:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
// Unit Frame
var UnitFrame_1 = require('./unitframe/UnitFrame');
var Effects_1 = require('./unitframe/components/Effects');
var HealthBar_1 = require('./unitframe/components/HealthBar');
var HealthText_1 = require('./unitframe/components/HealthText');
var Name_1 = require('./unitframe/components/Name');
var Portrait_1 = require('./unitframe/components/Portrait');
var StaminaBar_1 = require('./unitframe/components/StaminaBar');
var StaminaText_1 = require('./unitframe/components/StaminaText');
var Injuries_1 = require('./unitframe/components/Injuries');
var Injury_1 = require('./unitframe/components/Injury');
var InjuryLocation_1 = require('./unitframe/components/InjuryLocation');
var InjuryBar_1 = require('./unitframe/components/InjuryBar');
var InjuryText_1 = require('./unitframe/components/InjuryText');
var InjuryWounds_1 = require('./unitframe/components/InjuryWounds');
// Wound Frame
var WoundFrame_1 = require('./woundframe/WoundFrame');
// Non-frame components
var QuickSelect_1 = require('./quickselect/QuickSelect');
var Animate_1 = require('./Animate');
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = {
UnitFrame: UnitFrame_1.default,
Effects: Effects_1.default,
HealthBar: HealthBar_1.default,
HealthText: HealthText_1.default,
Name: Name_1.default,
Portrait: Portrait_1.default,
StaminaBar: StaminaBar_1.default,
StaminaText: StaminaText_1.default,
Injuries: Injuries_1.default,
Injury: Injury_1.default,
InjuryLocation: InjuryLocation_1.default,
InjuryBar: InjuryBar_1.default,
InjuryText: InjuryText_1.default,
InjuryWounds: InjuryWounds_1.default,
WoundFrame: WoundFrame_1.default,
QuickSelect: QuickSelect_1.default,
Animate: Animate_1.default
};
},{"./Animate":5,"./quickselect/QuickSelect":7,"./unitframe/UnitFrame":8,"./unitframe/components/Effects":9,"./unitframe/components/HealthBar":10,"./unitframe/components/HealthText":11,"./unitframe/components/Injuries":12,"./unitframe/components/Injury":13,"./unitframe/components/InjuryBar":14,"./unitframe/components/InjuryLocation":15,"./unitframe/components/InjuryText":16,"./unitframe/components/InjuryWounds":17,"./unitframe/components/Name":18,"./unitframe/components/Portrait":19,"./unitframe/components/StaminaBar":20,"./unitframe/components/StaminaText":21,"./woundframe/WoundFrame":22}],7:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
/**
* Materialize dropdown inspired quickselect list.
*
* *requires materialize js & css to be included on your html page.
*
* USAGE:
*
* class MyQuickSelect extends React.Component<any, any> {
* generateActiveView = (item: any) => {
* return <div>{item.foo}</div>;
* }
* generateListView = (item: any) => {
* return <div>{item.foo}</div>;
* }
* onSelectedItemChanged = (item: any) => {
* console.log('selected item is ' + item.foo);
* }
* render() {
* let items = [{foo:'Hello'},{foo:'World'}];
* return <QuickSelect items={items} activeViewComponentGenerator={this.generateActiveView}
listViewComponentGenerator={this.generateListView} onSelectedItemChanged={this.onSelectedChannelChanged} />;
* }
* }
*
*/
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = require('react');
var QuickSelect = function (_React$Component) {
_inherits(QuickSelect, _React$Component);
function QuickSelect(props) {
_classCallCheck(this, QuickSelect);
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(QuickSelect).call(this, props));
_this.uniqueId = 'QuickSelect-' + QuickSelect.idCounter++;
_this.onItemSelect = function (item, itemIndex) {
_this.setState({ selectedIndex: itemIndex });
_this.props.onSelectedItemChanged(item);
};
_this.buildListItem = function (item, itemIndex) {
return React.createElement("div", { key: itemIndex, onClick: _this.onItemSelect.bind(_this, item, itemIndex), className: 'quickselect-auto-width' }, _this.props.listViewComponentGenerator(item));
};
_this.state = {
selectedIndex: 0
};
return _this;
}
_createClass(QuickSelect, [{
key: 'render',
value: function render() {
if (this.props.items.length == 0) return React.createElement("div", null, "No Elements");
var selectedIndex = this.props.selectedItemIndex !== undefined ? this.props.selectedItemIndex : this.state.selectedIndex;
return React.createElement("div", null, React.createElement("div", { className: 'dropdown-button quickselect-auto-width', "data-beloworigin": 'true', "data-constrainwidth": 'false', "data-verticaloffset": '0', "data-activates": this.uniqueId, "data-style": 'quickselect-default' }, this.props.activeViewComponentGenerator(this.props.items[selectedIndex])), React.createElement("div", { id: this.uniqueId, className: 'quickselect-default' }, this.props.items.map(this.buildListItem)));
}
}]);
return QuickSelect;
}(React.Component);
QuickSelect.idCounter = 0;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = QuickSelect;
},{"react":307}],8:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var React = require('react');
var Portrait_1 = require('./components/Portrait');
var Name_1 = require('./components/Name');
var HealthBar_1 = require('./components/HealthBar');
var HealthText_1 = require('./components/HealthText');
var StaminaBar_1 = require('./components/StaminaBar');
var StaminaText_1 = require('./components/StaminaText');
var Effects_1 = require('./components/Effects');
var Injuries_1 = require('./components/Injuries');
var UnitFrame = React.createClass({
getInitialState: function getInitialState() {
return {
healthWidth: 0,
staminaWidth: 0
};
},
componentDidMount: function componentDidMount() {
// get runtime widths of the health and stamina bars.
this.setState({
healthWidth: this.refs.healthText.getDOMNode().offsetWidth,
staminaWidth: this.refs.staminaText.getDOMNode().offsetWidth
});
},
render: function render() {
var portrait = void 0,
injuries = void 0,
visible = void 0;
// work out the amount of health and stamina to show
var healthWidth = this.props.maxHealth ? this.props.health / this.props.maxHealth * this.state.healthWidth : 0;
var staminaWidth = this.props.maxStamina ? this.props.stamina / this.props.maxStamina * this.state.staminaWidth : 0;
// If this unit frame includes a race (name) display a portrait.
if (this.props.race !== undefined) {
portrait = React.createElement(Portrait_1.default, { race: this.props.race });
}
// If the unit frame has an active target, make sure it is visible.
// By default Target Unit Frames are not visible (see styles)
if (this.props.name) {
visible = { visibility: 'visible' };
}
if (this.props.injuries && this.props.injuries.length) {
injuries = React.createElement(Injuries_1.default, { injuries: this.props.injuries });
}
// Render the unit frame
return React.createElement("div", { id: "unitframe", className: this.props.className, style: visible }, portrait, React.createElement(Name_1.default, { name: this.props.name }), React.createElement(HealthBar_1.default, { width: healthWidth }), React.createElement(HealthText_1.default, { ref: "healthText", health: this.props.health, maxHealth: this.props.maxHealth }), React.createElement(StaminaBar_1.default, { width: staminaWidth }), React.createElement(StaminaText_1.default, { ref: "staminaText", stamina: this.props.stamina, maxStamina: this.props.maxStamina }), injuries, React.createElement(Effects_1.default, null));
}
});
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = UnitFrame;
},{"./components/Effects":9,"./components/HealthBar":10,"./components/HealthText":11,"./components/Injuries":12,"./components/Name":18,"./components/Portrait":19,"./components/StaminaBar":20,"./components/StaminaText":21,"react":307}],9:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var React = require('react');
var Effects = React.createClass({
render: function render() {
return React.createElement("div", { id: "effects" });
}
});
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Effects;
},{"react":307}],10:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var React = require('react');
var HealthBar = React.createClass({
render: function render() {
return React.createElement("div", { id: "health-bar", style: { width: this.props.width } });
}
});
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = HealthBar;
},{"react":307}],11:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var React = require('react');
var HealthText = React.createClass({
render: function render() {
var text = '';
if (this.props.maxHealth) {
text = this.props.health + '/' + this.props.maxHealth;
}
return React.createElement("div", { id: "health-text" }, text);
}
});
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = HealthText;
},{"react":307}],12:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var React = require('react');
var Injury_1 = require('./Injury');
// Display list of injuries. Only injuries not 100% are shown
var Injuries = React.createClass({
render: function render() {
var injuries = [];
if (this.props && this.props.injuries) {
for (var i = 0; i < this.props.injuries.length; i++) {
var injury = this.props.injuries[i];
// TODO: should we only display if health < maxHealth or wounds > 0 ???
if (injury && (injury.health < injury.maxHealth || injury.wounds > 0)) {
injuries.push(React.createElement(Injury_1.default, { injury: injury }));
}
}
}
return React.createElement("div", { id: "injuries", className: "cse-injuries" }, injuries);
}
});
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Injuries;
},{"./Injury":13,"react":307}],13:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var React = require('react');
var InjuryLocation_1 = require('./InjuryLocation');
var InjuryBar_1 = require('./InjuryBar');
var InjuryText_1 = require('./InjuryText');
var InjuryWounds_1 = require('./InjuryWounds');
// Display list of injuries. Only injuries not 100% are shown
var Injury = React.createClass({
getInitialState: function getInitialState() {
return {
healthWidth: 0
};
},
componentDidMount: function componentDidMount() {
// get runtime widths of the health and stamina bars.
this.setState({
healthWidth: this.refs.injuryText.getDOMNode().offsetWidth
});
},
render: function render() {
var injury = this.props.injury;
var width = injury.maxHealth ? injury.health / injury.maxHealth * this.state.healthWidth : 0;
return React.createElement("div", { id: "injury-" + injury.part, className: "cse-injury" }, React.createElement(InjuryLocation_1.default, { part: injury.part }), React.createElement(InjuryBar_1.default, { width: width }), React.createElement(InjuryText_1.default, { ref: "injuryText", health: injury.health, maxHealth: injury.maxHealth }), React.createElement(InjuryWounds_1.default, { wounds: injury.wounds }));
}
});
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Injury;
},{"./InjuryBar":14,"./InjuryLocation":15,"./InjuryText":16,"./InjuryWounds":17,"react":307}],14:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var React = require('react');
var InjuryBar = React.createClass({
render: function render() {
return React.createElement("div", { id: "injury-bar", style: { width: this.props.width } });
}
});
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = InjuryBar;
},{"react":307}],15:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var React = require('react');
var InjuryLocation = React.createClass({
render: function render() {
var name = void 0;
switch (this.part) {
case 0:
name = "Torso";
break;
default:
name = "Torso";
break;
}
return React.createElement("div", { id: "injury-location" }, name);
}
});
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = InjuryLocation;
},{"react":307}],16:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var React = require('react');
var InjuryText = React.createClass({
render: function render() {
var text = '';
if (this.props.maxHealth) {
text = this.props.health + '/' + this.props.maxHealth;
}
return React.createElement("div", { id: "injury-text" }, text);
}
});
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = InjuryText;
},{"react":307}],17:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var React = require('react');
var InjuryWounds = React.createClass({
render: function render() {
return React.createElement("div", { id: "injury-wounds" }, this.props.wounds);
}
});
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = InjuryWounds;
},{"react":307}],18:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var React = require('react');
var Name = React.createClass({
render: function render() {
return React.createElement("div", { id: "name" }, this.props.name);
}
});
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Name;
},{"react":307}],19:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var React = require('react');
var race_1 = require('../../../core/constants/race');
var Portrait = React.createClass({
// Portrait maps race ID to name because the name is used to pick up
// the correct portrait image (a resource we own).
portrait: function portrait() {
switch (this.props.race) {
// case race.TUATHA: return "Tuatha";
case race_1.default.HAMADRYAD:
return "hamadryad";
case race_1.default.LUCHORPAN:
return "luchorpan";
case race_1.default.FIRBOG:
return "firbog";
case race_1.default.VALKYRIE:
return "valkyrie";
case race_1.default.HELBOUND:
return "helbound";
case race_1.default.FROSTGIANT:
return "frostgiant";
// case race.DVERGR: return "Dverger";
case race_1.default.STRM:
return "strm";
case race_1.default.CAITSITH:
return "caitsith";
case race_1.default.GOLEM:
return "golem";
// case race.GARGOYLE: return "Gargoyle";
case race_1.default.STORMRIDERT:
return "stormridert";
case race_1.default.STORMRIDERA:
return "stormridera";
case race_1.default.STORMRIDERV:
return "stormriderv";
case race_1.default.HUMANMALEV:
return "humanmalev";
case race_1.default.HUMANMALEA:
return "humanmalea";
case race_1.default.HUMANMALET:
return "humanmalet";
}
return "";
},
render: function render() {
var portrait = this.portrait();
return React.createElement("div", { id: "portrait", className: portrait });
}
});
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Portrait;
},{"../../../core/constants/race":74,"react":307}],20:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var React = require('react');
var StaminaBar = React.createClass({
render: function render() {
return React.createElement("div", { id: "stamina-bar", style: { width: this.props.width } });
}
});
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = StaminaBar;
},{"react":307}],21:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var React = require('react');
var StaminaText = React.createClass({
render: function render() {
var text = '';
if (this.props.maxStamina) {
text = this.props.stamina + '/' + this.props.maxStamina;
}
return React.createElement("div", { id: "stamina-text" }, text);
}
});
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = StaminaText;
},{"react":307}],22:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var React = require('react');
var DisplayName_1 = require('./components/DisplayName');
var Doll_1 = require('./components/Doll');
var Stats_1 = require('./components/Stats');
var Buffs_1 = require('./components/Buffs');
var WoundsProps = function WoundsProps() {
_classCallCheck(this, WoundsProps);
};
exports.WoundsProps = WoundsProps;
var WoundsState = function WoundsState() {
_classCallCheck(this, WoundsState);
};
exports.WoundsState = WoundsState;
var WoundFrame = function (_React$Component) {
_inherits(WoundFrame, _React$Component);
function WoundFrame(props) {
_classCallCheck(this, WoundFrame);
return _possibleConstructorReturn(this, Object.getPrototypeOf(WoundFrame).call(this, props));
}
_createClass(WoundFrame, [{
key: 'render',
value: function render() {
return React.createElement("div", null, React.createElement(DisplayName_1.default, { name: this.props.name }), React.createElement(Doll_1.default, { injuries: this.props.injuries }), React.createElement(Buffs_1.default, { type: "boon" }), React.createElement(Buffs_1.default, { type: "bane" }), React.createElement(Stats_1.default, { blood: this.props.health, bloodMax: this.props.healthMax, stamina: this.props.stamina, staminaMax: this.props.staminaMax, panic: this.props.panic, panicMax: this.props.panicMax, temp: this.props.temp, tempMax: this.props.tempMax }));
}
}]);
return WoundFrame;
}(React.Component);
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = WoundFrame;
},{"./components/Buffs":24,"./components/DisplayName":25,"./components/Doll":26,"./components/Stats":30,"react":307}],23:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var defaultColors = ['#19b24b', '#feeb00', '#fe1e14', '#200000'];
var WoundColors = function () {
function WoundColors() {
_classCallCheck(this, WoundColors);
this.key = 'cse.wound.colors';
this.load();
}
_createClass(WoundColors, [{
key: 'load',
value: function load() {
var value = localStorage.getItem(this.key);
if (value && typeof value === 'string') {
this.colors = value.split(',');
// stored color validation
for (var i = 0; i < this.colors.length; i++) {
var color = this.colors[i];
var isValidColor = /(^#[0-9A-F]{6}$)/i.test(color) && color.length == 7;
if (!isValidColor) {
this.colors[i] = '#ffffff';
}
}
} else {
this.colors = defaultColors;
}
}
}, {
key: 'save',
value: function save() {
localStorage.setItem(this.key, this.colors.join(','));
}
}, {
key: 'getColorForWound',
value: function getColorForWound(wound) {
return this.colors[wound] || defaultColors[0];
}
}]);
return WoundColors;
}();
exports.WoundColors = WoundColors;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = WoundColors;
},{}],24:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var React = require('react');
var Shapes_1 = require('../resources/Shapes');
var Svg_1 = require('./Svg');
var buffIcons = function () {
function buffIcons(count) {
_classCallCheck(this, buffIcons);
this.size = 0;
this.svg = [];
this.state = [];
if (count < 1) {
console.log("Number of icons must be (1) or greater.");
return;
}
this.size = count - 1;
for (var i = this.size; i >= 0; i--) {
this.setState(i, i == 2);
this.svg.push(this.build(i));
}
}
_createClass(buffIcons, [{
key: 'build',
value: function build(idx) {
var icon = Shapes_1.icons[idx];
var color = this.getState(idx) ? ['#19B24B', 'yellow'] : ['#202020', '#202020'];
return React.createElement(Svg_1.Svg, { key: "icon" + idx, id: "icon" + idx, className: "icon", stroke: color[1], strokeML: "10", color: color[0], box: icon.box, rect: icon.rect, polygon: icon.polygon, path: icon.path, circle: icon.circle });
}
}, {
key: 'checkIndex',
value: function checkIndex(idx) {
if (idx < 0 && idx > this.size) {
console.log("BuffIcon Index {$idx} not found.");
return false;
}
return true;
}
}, {
key: 'refresh',
value: function refresh(idx) {
if (!this.checkIndex(idx)) {
return;
}
this.svg[idx] = this.build(idx);
}
}, {
key: 'getState',
value: function getState(idx) {
if (!this.checkIndex(idx)) {
return false;
}
return this.state[idx];
}
}, {
key: 'setState',
value: function setState(idx, active) {
if (!this.checkIndex(idx)) {
return;
}
this.state[idx] = active;
}
}, {
key: 'getList',
value: function getList() {
return this.svg;
}
}]);
return buffIcons;
}();
var Buffs = function (_React$Component) {
_inherits(Buffs, _React$Component);
function Buffs(props) {
_classCallCheck(this, Buffs);
return _possibleConstructorReturn(this, Object.getPrototypeOf(Buffs).call(this, props));
}
_createClass(Buffs, [{
key: 'componentWillMount',
value: function componentWillMount(props, state) {
this.state = { buffList: new buffIcons(4) };
}
}, {
key: 'render',
value: function render() {
return React.createElement("div", { className: "buffs " + this.props.type }, this.state.buffList.getList());
}
}]);
return Buffs;
}(React.Component);
exports.Buffs = Buffs;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Buffs;
},{"../resources/Shapes":32,"./Svg":31,"react":307}],25:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var React = require('react');
var DisplayName = function (_React$Component) {
_inherits(DisplayName, _React$Component);
function DisplayName(props) {
_classCallCheck(this, DisplayName);
return _possibleConstructorReturn(this, Object.getPrototypeOf(DisplayName).call(this, props));
}
_createClass(DisplayName, [{
key: "render",
value: function render() {
return React.createElement("div", { className: 'name' }, React.createElement("label", { className: 'label' }, this.props.name));
}
}]);
return DisplayName;
}(React.Component);
exports.DisplayName = DisplayName;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = DisplayName;
},{"react":307}],26:[function(require,module,exports){
/**
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var React = require('react');
var core_1 = require('../../../core/core');
var Part_1 = require('./Part');
var Label_1 = require('./Label');
var WoundColors_1 = require('../classes/WoundColors');
var colors = new WoundColors_1.WoundColors();
var pct66 = 2.0 / 3.0;
var pct33 = 1.0 / 3.0;
function getState(damage, max) {
if (max == 0) return 0;
var pct = damage / max;
if (pct > pct66) return 0;
if (pct > pct33) return 1;
if (pct > 0.0) return 2;
return 3;
}
// TEMP: Until we know the official client Part ID map
function getPart(clientId) {
switch (clientId) {
case 0:
return 3;
case 1:
return 0;
case 2:
return 1;
case 3:
return 2;
case 4:
return 4;
case 5:
return 5;
}
return -1;
}
// Maps part IDs to injury objects. If an injury for a part is not availale, returns
// an injury that represents full health
var InjuryMap = function () {
function InjuryMap() {
_classCallCheck(this, InjuryMap);
this.map = [];
this.length = 6;
for (var i = 0; i < this.length; i++) {
this.map[i] = new core_1.Injury();
}
}
_createClass(InjuryMap, [{
key: 'addInjury',
value: function addInjury(injury) {
this.map[injury.part].refresh(injury);
}
}, {
key: 'getInjury',
value: function getInjury(i) {
if (this.length > i && i >= 0) {
return this.map[i];
}
var defaultInjury = new core_1.Injury();
return defaultInjury;
}
}]);
return InjuryMap;
}();
var Doll = function (_React$Component) {
_inherits(Doll, _React$Component);
function Doll() {
_classCallCheck(this, Doll);
return _possibleConstructorReturn(this, Object.getPrototypeOf(Doll).apply(this, arguments));
}
_createClass(Doll, [{
key: 'render',
value: function render() {
var injuries = this.props.injuries;
var parts = [];
var labels = [];
var map = new InjuryMap();
// Build all 6 parts, assumes full health
// TODO: Should be necessary when client is sending all parts
for (var i = 0; i < injuries.length; i++) {
map.addInjury(injuries[i]);
}
// Replace damaged body parts
for (var _i = 0; _i < map.length; _i++) {
var injury = map.