Refactor content editor - Add support for editing items and item categories.

This commit is contained in:
Oskar Wiksten
2013-01-28 20:06:58 +01:00
parent 8570d4d760
commit f80157a0d0
9 changed files with 487 additions and 240 deletions

View File

@@ -57,7 +57,109 @@ var ATEditor = (function(ATEditor, model, importExport) {
};
controllers.ItemController = function($scope, $routeParams) {
$scope.datasource = model.items;
$scope.obj = $scope.datasource.findById($routeParams.id);
var obj = $scope.datasource.findById($routeParams.id);
$scope.obj = obj;
if (_.isString($scope.obj.category)) {
$scope.obj.category = model.itemCategories.findById($scope.obj.category);
}
$scope.itemCategories = model.itemCategories.items;
function calculateItemCost(o) {
var v = function(i) { return i ? i : 0; }
var sgn = function(v) {
if (v < 0) return -1;
else if (v > 0) return 1;
else return 0;
}
var averageHPBoost = (v(o.useEffect.increaseCurrentHP.min) + v(o.useEffect.increaseCurrentHP.max)) / 2;
var costBoostHP = Math.round(0.1*sgn(averageHPBoost)*Math.pow(Math.abs(averageHPBoost), 2) + 3*averageHPBoost);
var itemUsageCost = costBoostHP;
var isWeapon = false;
if ($scope.obj.category) {
isWeapon = $scope.obj.category.inventorySlot == 0;
}
var equip_blockChance = v(obj.equipEffect.increaseBlockChance);
var equip_attackChance = v(obj.equipEffect.increaseAttackChance);
var equip_attackCost = v(obj.equipEffect.increaseAttackCost);
var equip_damageResistance = v(obj.equipEffect.increaseDamageResistance);
var equip_attackDamage_Min = v(obj.equipEffect.increaseAttackDamage.min);
var equip_attackDamage_Max = v(obj.equipEffect.increaseAttackDamage.max);
var equip_criticalChance = v(obj.equipEffect.increaseCriticalSkill);
var equip_criticalMultiplier = v(obj.equipEffect.setCriticalMultiplier);
var costBC = Math.round(3*Math.pow(Math.max(0,equip_blockChance), 2.5) + 28*equip_blockChance);
var costAC = Math.round(0.4*Math.pow(Math.max(0,equip_attackChance), 2.5) - 6*Math.pow(Math.abs(Math.min(0,equip_attackChance)),2.7));
var costAP = isWeapon ?
Math.round(0.2*Math.pow(10/equip_attackCost, 8) - 25*equip_attackCost)
: -3125 * equip_attackCost;
var costDR = 1325*equip_damageResistance;
var costDMG_Min = isWeapon ?
Math.round(10*Math.pow(equip_attackDamage_Min, 2.5))
:Math.round(10*Math.pow(equip_attackDamage_Min, 3) + equip_attackDamage_Min*80);
var costDMG_Max = isWeapon ?
Math.round(2*Math.pow(equip_attackDamage_Max, 2.1))
:Math.round(2*Math.pow(equip_attackDamage_Max, 3) + equip_attackDamage_Max*20);
var costCC = Math.round(2.2*Math.pow(equip_criticalChance, 3));
var costCM = Math.round(50*Math.pow(Math.max(0, equip_criticalMultiplier), 2));
if (!obj.equipEffect.hasCritical) {
costCC = 0;
costCM = 0;
}
var costCombat = costBC + costAC + costAP + costDR + costDMG_Min + costDMG_Max + costCC + costCM;
var equip_boostMaxHP = v(obj.equipEffect.increaseMaxHP);
var equip_boostMaxAP = v(obj.equipEffect.increaseMaxAP);
var equip_moveCostPenalty = v(obj.equipEffect.increaseMoveCost);
var costMaxHP = Math.round(30*Math.pow(Math.max(0,equip_boostMaxHP), 1.2) + 70*equip_boostMaxHP);
var costMaxAP = Math.round(50*Math.pow(Math.max(0,equip_boostMaxAP), 3) + 750*equip_boostMaxAP);
var costMovement = Math.round(510*Math.pow(Math.max(0,-equip_moveCostPenalty), 2.5) - 350*equip_moveCostPenalty);
var itemEquipCost = costCombat + costMaxHP + costMaxAP + costMovement;
if (!obj.hasEquipEffect) { itemEquipCost = 0; }
if (!obj.hasUseEffect) { itemUsageCost = 0; }
return itemEquipCost + itemUsageCost;
}
$scope.recalculateStorePrice = function() {
var val = parseInt(obj.baseMarketCost);
if (obj.hasManualPrice === "0") {
val = calculateItemCost(obj);
obj.baseMarketCost = val;
}
$scope.marketCost_Sell = Math.round(val * (100 + 15) / 100);
$scope.marketCost_Buy = Math.round(val * (100 - 15) / 100);
};
$scope.recalculateStorePrice();
$scope.$watch('obj.useEffect.increaseCurrentHP.min', $scope.recalculateStorePrice);
$scope.$watch('obj.useEffect.increaseCurrentHP.max', $scope.recalculateStorePrice);
$scope.$watch('obj.category', $scope.recalculateStorePrice);
$scope.$watch('obj.equipEffect.increaseBlockChance', $scope.recalculateStorePrice);
$scope.$watch('obj.equipEffect.increaseAttackChance', $scope.recalculateStorePrice);
$scope.$watch('obj.equipEffect.increaseAttackCost', $scope.recalculateStorePrice);
$scope.$watch('obj.equipEffect.increaseDamageResistance', $scope.recalculateStorePrice);
$scope.$watch('obj.equipEffect.increaseAttackDamage.min', $scope.recalculateStorePrice);
$scope.$watch('obj.equipEffect.increaseCriticalSkill', $scope.recalculateStorePrice);
$scope.$watch('obj.equipEffect.setCriticalMultiplier', $scope.recalculateStorePrice);
$scope.$watch('obj.equipEffect.hasCritical', $scope.recalculateStorePrice);
$scope.$watch('obj.equipEffect.increaseMaxHP', $scope.recalculateStorePrice);
$scope.$watch('obj.equipEffect.increaseMaxAP', $scope.recalculateStorePrice);
$scope.$watch('obj.equipEffect.increaseMoveCost', $scope.recalculateStorePrice);
$scope.$watch('obj.hasEquipEffect', $scope.recalculateStorePrice);
$scope.$watch('obj.hasUseEffect', $scope.recalculateStorePrice);
$scope.$watch('obj.baseMarketCost', $scope.recalculateStorePrice);
$scope.$watch('obj.hasManualPrice', $scope.recalculateStorePrice);
$scope.addCondition = function(list) {
list.push({magnitude:1});
};
$scope.removeCondition = function(list, cond) {
var idx = list.indexOf(cond);
list.splice(idx, 1);
};
};
controllers.DropListController = function($scope, $routeParams) {
$scope.datasource = model.droplists;
@@ -88,7 +190,11 @@ var ATEditor = (function(ATEditor, model, importExport) {
var attacksPerTurn = Math.floor(v(obj.maxAP) / v(obj.attackCost));
var avgDamagePotential = 0;
if (obj.attackDamage) { avgDamagePotential = (v(obj.attackDamage.min) + v(obj.attackDamage.max)) / 2; }
var avgAttackHP = attacksPerTurn * div100(v(obj.attackChance)) * avgDamagePotential * (1 + div100(v(obj.criticalSkill)) * v(obj.criticalMultiplier));
var avgCrit = 0;
if (obj.hasCritical) {
avgCrit = div100(v(obj.criticalSkill)) * v(obj.criticalMultiplier);
}
var avgAttackHP = attacksPerTurn * div100(v(obj.attackChance)) * avgDamagePotential * (1 + avgCrit);
var avgDefenseHP = v(obj.maxHP) * (1 + div100(v(obj.blockChance))) + EXP_FACTOR_DAMAGERESISTANCE * v(obj.damageResistance);
var attackConditionBonus = 0;
if (obj.hitEffect && obj.hitEffect.conditionsTarget && v(obj.hitEffect.conditionsTarget.length) > 0) {
@@ -107,6 +213,7 @@ var ATEditor = (function(ATEditor, model, importExport) {
$scope.$watch('obj.attackDamage.min', $scope.recalculateExperience);
$scope.$watch('obj.attackDamage.max', $scope.recalculateExperience);
$scope.$watch('obj.attackChance', $scope.recalculateExperience);
$scope.$watch('obj.hasCritical', $scope.recalculateExperience);
$scope.$watch('obj.criticalSkill', $scope.recalculateExperience);
$scope.$watch('obj.criticalMultiplier', $scope.recalculateExperience);
$scope.$watch('obj.maxHP', $scope.recalculateExperience);

View File

@@ -46,9 +46,10 @@ var ATEditor = (function(ATEditor, _) {
ATEditor.defaults = {
addDefaults: function(type, o) {
if (defaults[type]) {
var copyOfDefaults = ATEditor.utils.deepClone(defaults[type]);
_.defaults(o, copyOfDefaults);
var def = defaults[type];
if (def) {
var copyOfDefaults = ATEditor.utils.deepClone(def);
ATEditor.utils.copyDefaults(o, copyOfDefaults);
}
},
removeDefaults: function(type, o) {

View File

@@ -13,6 +13,7 @@
<th id="quantity_Min">Min quantity</th>
<th id="quantity_Max">Max quantity</th>
<th id="chance">Chance</th>
<th></th>
</tr></thead>
<tbody>
<tr ng-repeat="dropItem in obj.items">

View File

@@ -1,5 +1,281 @@
<div>
<p>id: {{obj.id}}</p>
<input type="text" ng-model="obj.id"><br />
<input type="text" ng-model="obj.name"><br />
</div>
<div id="editItem">
<h3>Item</h3>
<fieldset class="fieldSet">
<legend>General</legend>
<div class="fieldWithLabel">
<div id="itemimage" class="field"><input type="hidden" id="iconID" ng-model="obj.iconID" /></div>
</div>
<div class="fieldWithLabel">
<label for="name" class="label">Display name:</label>
<input class="field" type="text" size="30" id="name" class="fieldInput" ng-model="obj.name" />
</div>
<div class="fieldWithLabel">
<label for="id" class="label">Internal ID:</label>
<input class="field" type="text" size="30" id="id" class="fieldInput" ng-model="obj.id" />
</div>
<div class="fieldWithLabel">
<label for="category" class="label">Category:</label>
<select class="field" id="category" ng-model="obj.category" ng-options="s.name for s in itemCategories">
</select>
</div>
<div class="fieldWithLabel">
<label for="displaytype" class="label">Display as:</label>
<select class="field" id="displaytype" ng-model="obj.displaytype">
<option value="0">Ordinary item</option>
<option value="1">Quest item (yellow)</option>
<option value="2">Legendary (green)</option>
<option value="3">Extraordinary (blue)</option>
<option value="4">Rare (purple)</option>
</select>
</div>
<div class="fieldWithLabel">
<label for="baseMarketCost" class="label">Base market cost (gold):</label>
<input class="field" type="text" size="7" id="baseMarketCost" ng-readonly="obj.hasManualPrice == 0" class="fieldInput integer" ng-model="obj.baseMarketCost" title="The actual price is adjusted 15% depending on if the item is being bought or sold. Set to 0 to prohibit selling this item type (for example, for a quest item)." />
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasManualPrice" ng-model="obj.hasManualPrice" ng-true-value="1" ng-false-value="0" />Item has manually specified store price</div>
</div>
<div class="fieldWithLabel">
<label for="marketCost_Sell" class="label">Actual price (gold):</label>
<div class="field">
<span>Sell: <input type="text" size="7" id="marketCost_Sell" class="fieldInput integer" ng-model="marketCost_Sell" readonly="readonly" /></span>
<span>Buy: <input type="text" size="7" id="marketCost_Buy" class="fieldInput integer" ng-model="marketCost_Buy" readonly="readonly" /></span>
</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasEquipEffect" ng-model="obj.hasEquipEffect" />Has equip effect</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasUseEffect" ng-model="obj.hasUseEffect" />Has use effect</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasHitEffect" ng-model="obj.hasHitEffect" />Has effect on every hit</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasKillEffect" ng-model="obj.hasKillEffect" />Has effect on every kill</div>
</div>
</fieldset>
<fieldset class="fieldSet" id="hasEquipEffectDisplay" ng-ds-fade="obj.hasEquipEffect">
<legend>When equipped</legend>
<div class="fieldWithLabel">
<label for="equip_boostMaxHP" class="label">Boost max HP:</label>
<input type="text" size="5" id="equip_boostMaxHP" class="field fieldInput integer" ng-model="obj.equipEffect.increaseMaxHP" />
</div>
<div class="fieldWithLabel">
<label for="equip_boostMaxAP" class="label">Boost max AP:</label>
<input type="text" size="5" id="equip_boostMaxAP" class="field fieldInput integer" ng-model="obj.equipEffect.increaseMaxAP" />
</div>
<div class="fieldWithLabel">
<label for="equip_moveCostPenalty" class="label">Move cost penalty (AP):</label>
<input type="text" size="5" id="equip_moveCostPenalty" class="field fieldInput integer" ng-model="obj.equipEffect.increaseMoveCost" />
</div>
<div class="fieldWithLabel">
<label for="equip_increaseUseItemCost" class="label">Increase use item cost (AP):</label>
<input class="field" type="text" size="5" id="equip_increaseUseItemCost" class="fieldInput integer" ng-model="obj.equipEffect.increaseUseItemCost" />
</div>
<div class="fieldWithLabel">
<label for="equip_increaseReequipCost" class="label">Increase re-equip cost (AP):</label>
<input class="field" type="text" size="5" id="equip_increaseReequipCost" class="fieldInput integer" ng-model="obj.equipEffect.increaseReequipCost" />
</div>
<div class="fieldWithLabel">
<label for="equip_attackCost" class="label">Attack cost (AP):</label>
<input class="field" type="text" size="5" id="equip_attackCost" class="fieldInput integer" ng-model="obj.equipEffect.increaseAttackCost" />
</div>
<div class="fieldWithLabel">
<label for="equip_attackChance" class="label">Attack chance:</label>
<div class="field"><input type="text" size="5" id="equip_attackChance" class="fieldInput integer" ng-model="obj.equipEffect.increaseAttackChance" />%</div>
</div>
<div class="fieldWithLabel">
<label for="equip_attackDamage" class="label">Attack damage (range):</label>
<div class="field">
<input type="text" size="3" id="equip_attackDamage_Min" class="fieldInput integer" ng-model="obj.equipEffect.increaseAttackDamage.min" />
-
<input type="text" size="3" id="equip_attackDamage_Max" class="fieldInput integer" ng-model="obj.equipEffect.increaseAttackDamage.max" />
</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="equip_hasCritical" ng-model="obj.equipEffect.hasCritical" />Has critical chance</div>
</div>
<div id="equip_hasCriticalDisplay" ng-ds-fade="obj.equipEffect.hasCritical">
<div class="fieldWithLabel">
<label for="equip_criticalChance" class="label">Critical skill:</label>
<div class="field"><input type="text" size="5" id="equip_criticalChance" class="fieldInput integer" ng-model="obj.equipEffect.increaseCriticalSkill" />%</div>
</div>
<div class="fieldWithLabel">
<label for="equip_criticalMultiplier" class="label">Critical multiplier:</label>
<input class="field" type="text" size="5" id="equip_criticalMultiplier" class="fieldInput integer" ng-model="obj.equipEffect.setCriticalMultiplier" />
</div>
</div>
<div class="fieldWithLabel">
<label for="equip_blockChance" class="label">Block chance:</label>
<div class="field"><input type="text" size="5" id="equip_blockChance" class="fieldInput integer" ng-model="obj.equipEffect.increaseBlockChance" />%</div>
</div>
<div class="fieldWithLabel">
<label for="equip_damageResistance" class="label">Damage resistance:</label>
<input class="field" type="text" size="5" id="equip_damageResistance" class="fieldInput integer" ng-model="obj.equipEffect.increaseDamageResistance" />
</div>
<div class="fieldWithLabel">
<label for="equip_conditions" class="label">Apply actor condition</label>
<table class="field" id="equip_conditions">
<thead><tr>
<th id="condition">Condition</th>
<th id="magnitude">Magnitude</th>
<th></th>
</tr></thead>
<tbody>
<tr ng-repeat="condition in obj.equipEffect.addedConditions">
<td><input type="text" ng-model="condition.condition" class="fieldInput" /></td>
<td><input type="text" size="3" ng-model="condition.magnitude" class="fieldInput integer" /></td>
<td><a ng-click="removeCondition(obj.equipEffect.addedConditions, condition)">X</a></td>
</tr>
</tbody>
</table>
<button ng-click="addCondition(obj.equipEffect.addedConditions)">Add</button>
</div>
</fieldset>
<fieldset class="fieldSet" id="hasUseEffectDisplay" ng-ds-fade="obj.hasUseEffect">
<legend>When used</legend>
<div class="fieldWithLabel">
<label for="use_boostHP" class="label">Boost current HP (range):</label>
<div class="field">
<input type="text" size="3" id="use_boostHP_Min" class="fieldInput integer" ng-model="obj.useEffect.increaseCurrentHP.min" />
-
<input type="text" size="3" id="use_boostHP_Max" class="fieldInput integer" ng-model="obj.useEffect.increaseCurrentHP.max" />
</div>
</div>
<div class="fieldWithLabel">
<label for="use_boostAP" class="label">Boost current AP (range):</label>
<div class="field">
<input type="text" size="3" id="use_boostAP_Min" class="fieldInput integer" ng-model="obj.useEffect.increaseCurrentAP.min" />
-
<input type="text" size="3" id="use_boostAP_Max" class="fieldInput integer" ng-model="obj.useEffect.increaseCurrentAP.max" />
</div>
</div>
<div class="fieldWithLabel">
<label for="use_conditionsSource" class="label">Apply actor condition</label>
<table class="field" id="use_conditionsSource">
<thead><tr>
<th id="condition">Condition</th>
<th id="magnitude">Magnitude</th>
<th id="duration">Duration</th>
<th id="chance">Chance</th>
<th></th>
</tr></thead>
<tbody>
<tr ng-repeat="condition in obj.useEffect.conditionsSource">
<td><input type="text" ng-model="condition.condition" class="fieldInput" /></td>
<td><input type="text" size="3" ng-model="condition.magnitude" class="fieldInput integer" /></td>
<td><input type="text" size="3" ng-model="condition.duration" class="fieldInput integer" /></td>
<td><input type="text" size="3" ng-model="condition.chance" class="fieldInput" /></td>
<td><a ng-click="removeCondition(obj.useEffect.conditionsSource, condition)">X</a></td>
</tr>
</tbody>
</table>
<button ng-click="addCondition(obj.useEffect.conditionsSource)">Add</button>
</div>
</fieldset>
<fieldset class="fieldSet" id="hasHitEffectDisplay" ng-ds-fade="obj.hasHitEffect">
<legend>When making a successful hit</legend>
<div class="fieldWithLabel">
<label for="hit_boostHP" class="label">Boost current HP (range):</label>
<div class="field">
<input type="text" size="3" id="hit_boostHP_Min" class="fieldInput integer" ng-model="obj.hitEffect.increaseCurrentHP.min" />
-
<input type="text" size="3" id="hit_boostHP_Max" class="fieldInput integer" ng-model="obj.hitEffect.increaseCurrentHP.max" />
</div>
</div>
<div class="fieldWithLabel">
<label for="hit_boostAP" class="label">Boost current AP (range):</label>
<div class="field">
<input type="text" size="3" id="hit_boostAP_Min" class="fieldInput integer" ng-model="obj.hitEffect.increaseCurrentAP.min" />
-
<input type="text" size="3" id="hit_boostAP_Max" class="fieldInput integer" ng-model="obj.hitEffect.increaseCurrentAP.max" />
</div>
</div>
<div class="fieldWithLabel">
<label for="hit_conditionsSource" class="label">Apply actor condition to source</label>
<table class="field" id="hit_conditionsSource">
<thead><tr>
<th id="condition">Condition</th>
<th id="magnitude">Magnitude</th>
<th id="duration">Duration</th>
<th id="chance">Chance</th>
<th></th>
</tr></thead>
<tbody>
<tr ng-repeat="condition in obj.hitEffect.conditionsSource">
<td><input type="text" ng-model="condition.condition" class="fieldInput" /></td>
<td><input type="text" size="3" ng-model="condition.magnitude" class="fieldInput integer" /></td>
<td><input type="text" size="3" ng-model="condition.duration" class="fieldInput integer" /></td>
<td><input type="text" size="3" ng-model="condition.chance" class="fieldInput" /></td>
<td><a ng-click="removeCondition(obj.hitEffect.conditionsSource, condition)">X</a></td>
</tr>
</tbody>
</table>
<button ng-click="addCondition(obj.hitEffect.conditionsSource)">Add</button>
</div>
<div class="fieldWithLabel">
<label for="hit_conditionsTarget" class="label">Apply actor condition to target</label>
<table class="field" id="hit_conditionsTarget">
<thead><tr>
<th id="condition">Condition</th>
<th id="magnitude">Magnitude</th>
<th id="duration">Duration</th>
<th id="chance">Chance</th>
<th></th>
</tr></thead>
<tbody>
<tr ng-repeat="condition in obj.hitEffect.conditionsTarget">
<td><input type="text" ng-model="condition.condition" class="fieldInput" /></td>
<td><input type="text" size="3" ng-model="condition.magnitude" class="fieldInput integer" /></td>
<td><input type="text" size="3" ng-model="condition.duration" class="fieldInput integer" /></td>
<td><input type="text" size="3" ng-model="condition.chance" class="fieldInput" /></td>
<td><a ng-click="removeCondition(obj.hitEffect.conditionsTarget, condition)">X</a></td>
</tr>
</tbody>
</table>
<button ng-click="addCondition(obj.hitEffect.conditionsTarget)">Add</button>
</div>
</fieldset>
<fieldset class="fieldSet" id="hasKillEffectDisplay" ng-ds-fade="obj.hasKillEffect">
<legend>On every kill</legend>
<div class="fieldWithLabel">
<label for="kill_boostHP" class="label">Boost current HP (range):</label>
<div class="field">
<input type="text" size="3" id="kill_boostHP_Min" class="fieldInput integer" ng-model="obj.killEffect.increaseCurrentHP.min" />
-
<input type="text" size="3" id="kill_boostHP_Max" class="fieldInput integer" ng-model="obj.killEffect.increaseCurrentHP.max" />
</div>
</div>
<div class="fieldWithLabel">
<label for="kill_boostAP" class="label">Boost current AP (range):</label>
<div class="field">
<input type="text" size="3" id="kill_boostAP_Min" class="fieldInput integer" ng-model="obj.killEffect.increaseCurrentAP.min" />
-
<input type="text" size="3" id="kill_boostAP_Max" class="fieldInput integer" ng-model="obj.killEffect.increaseCurrentAP.max" />
</div>
</div>
<div class="fieldWithLabel">
<label for="kill_conditionsSource" class="label">Apply actor condition</label>
<table class="field" id="kill_conditionsSource">
<thead><tr>
<th id="condition">Condition</th>
<th id="magnitude">Magnitude</th>
<th id="duration">Duration</th>
<th id="chance">Chance</th>
<th></th>
</tr></thead>
<tbody>
<tr ng-repeat="condition in obj.killEffect.conditionsSource">
<td><input type="text" ng-model="condition.condition" class="fieldInput" /></td>
<td><input type="text" size="3" ng-model="condition.magnitude" class="fieldInput integer" /></td>
<td><input type="text" size="3" ng-model="condition.duration" class="fieldInput integer" /></td>
<td><input type="text" size="3" ng-model="condition.chance" class="fieldInput" /></td>
<td><a ng-click="removeCondition(obj.killEffect.conditionsSource, condition)">X</a></td>
</tr>
</tbody>
</table>
<button ng-click="addCondition(obj.killEffect.conditionsSource)">Add</button>
</div>
</fieldset>
<div class="endSets"> </div>

View File

@@ -1,5 +1,44 @@
<div>
<p>id: {{obj.id}}</p>
<input type="text" ng-model="obj.id"><br />
<input type="text" ng-model="obj.name"><br />
</div>
<h3>Item Category</h3>
<fieldset class="fieldSet">
<legend>General</legend>
<div class="fieldWithLabel">
<label for="id" class="label">Internal id:</label>
<input class="field" type="text" size="30" id="id" ng-model="obj.id" class="fieldInput"/>
</div>
<div class="fieldWithLabel">
<label for="name" class="label">Display name:</label>
<input class="field" type="text" size="30" id="name" ng-model="obj.name" class="fieldInput"/>
</div>
<div class="fieldWithLabel">
<label for="actionType" class="label">Action type:</label>
<select class="field" id="actionType" ng-model="obj.actionType">
<option value="0">Non-usable</option>
<option value="1">Usable</option>
<option value="2">Equippable</option>
</select>
</div>
<div class="fieldWithLabel" ng-ds-fade="obj.actionType == 2">
<label for="inventorySlot" class="label">Equippable inventory slot:</label>
<select class="field" id="inventorySlot" ng-model="obj.inventorySlot">
<option value="-1">None</option>
<option value="0">Weapon</option>
<option value="1">Shield</option>
<option value="2">Head</option>
<option value="3">Body</option>
<option value="4">Hand</option>
<option value="5">Feet</option>
<option value="6">Neck</option>
<option value="7">Ring</option>
</select>
</div>
<div class="fieldWithLabel">
<label for="size" class="label">Size:</label>
<select class="field" id="size" ng-model="obj.size">
<option value="0">None</option>
<option value="1">Light</option>
<option value="2">Standard</option>
<option value="3">Large</option>
</select>
</div>
</fieldset>
<div class="endSets"> </div>

View File

@@ -23,6 +23,7 @@
<th id="logText">Logtext</th>
<th id="rewardExperience">Experience</th>
<th id="finishesQuest">Finishes quest</th>
<th></th>
</tr></thead>
<tbody>
<tr ng-repeat="stage in obj.stages">

View File

@@ -82,230 +82,6 @@
<div class="hidden" id="templates">
<!-- ========================================================= -->
<!-- Item editor -->
<div id="editItem">
<h3>Item</h3>
<fieldset class="fieldSet">
<legend>General</legend>
<div class="fieldWithLabel">
<div id="itemimage" class="field"><input type="hidden" id="iconID" /></div>
</div>
<div class="fieldWithLabel">
<label for="name" class="label">Display name:</label>
<input class="field" type="text" size="30" id="name" class="fieldInput"/>
</div>
<div class="fieldWithLabel">
<label for="id" class="label">Internal ID:</label>
<input class="field" type="text" size="30" id="id" class="fieldInput" />
</div>
<div class="fieldWithLabel">
<label for="category" class="label">Category:</label>
<select class="field" id="category">
</select>
</div>
<div class="fieldWithLabel">
<label for="displaytype" class="label">Display as:</label>
<select class="field" id="displaytype">
<option value="0">Ordinary item</option>
<option value="1">Quest item (yellow)</option>
<option value="2">Legendary (green)</option>
<option value="3">Extraordinary (blue)</option>
<option value="4">Rare (purple)</option>
</select>
</div>
<div class="fieldWithLabel">
<label for="baseMarketCost" class="label">Base market cost (gold):</label>
<input class="field" type="text" size="7" id="baseMarketCost" readonly="readonly" class="fieldInput integer" title="The actual price is adjusted 15% depending on if the item is being bought or sold. Set to 0 to prohibit selling this item type (for example, for a quest item)." />
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasManualPrice" />Item has manually specified store price</div>
</div>
<div class="fieldWithLabel">
<label for="marketCost_Sell" class="label">Actual price (gold):</label>
<div class="field">
<span>Sell: <input type="text" size="7" id="marketCost_Sell" class="fieldInput integer" readonly="readonly" /></span>
<span>Buy: <input type="text" size="7" id="marketCost_Buy" class="fieldInput integer" readonly="readonly" /></span>
</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasEquipEffect" />Has equip effect</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasUseEffect" />Has use effect</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasHitEffect" />Has effect on every hit</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasKillEffect" />Has effect on every kill</div>
</div>
</fieldset>
<fieldset class="fieldSet" id="hasEquipEffectDisplay">
<legend>When equipped</legend>
<div class="fieldWithLabel">
<label for="equip_boostMaxHP" class="label">Boost max HP:</label>
<input type="text" size="5" id="equip_boostMaxHP" class="field fieldInput integer" />
</div>
<div class="fieldWithLabel">
<label for="equip_boostMaxAP" class="label">Boost max AP:</label>
<input type="text" size="5" id="equip_boostMaxAP" class="field fieldInput integer" />
</div>
<div class="fieldWithLabel">
<label for="equip_moveCostPenalty" class="label">Move cost penalty (AP):</label>
<input type="text" size="5" id="equip_moveCostPenalty" class="field fieldInput integer" />
</div>
<div class="fieldWithLabel">
<label for="equip_attackCost" class="label">Attack cost (AP):</label>
<input class="field" type="text" size="5" id="equip_attackCost" class="fieldInput integer" />
</div>
<div class="fieldWithLabel">
<label for="equip_attackChance" class="label">Attack chance:</label>
<div class="field"><input type="text" size="5" id="equip_attackChance" class="fieldInput integer" />%</div>
</div>
<div class="fieldWithLabel">
<label for="equip_attackDamage" class="label">Attack damage (range):</label>
<div class="field"><input type="text" size="3" id="equip_attackDamage_Min" class="fieldInput integer" /> - <input type="text" size="3" id="equip_attackDamage_Max" class="fieldInput integer" /></div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="equip_hasCritical" />Has critical chance</div>
</div>
<div id="equip_hasCriticalDisplay">
<div class="fieldWithLabel">
<label for="equip_criticalChance" class="label">Critical skill:</label>
<div class="field"><input type="text" size="5" id="equip_criticalChance" class="fieldInput integer" />%</div>
</div>
<div class="fieldWithLabel">
<label for="equip_criticalMultiplier" class="label">Critical multiplier:</label>
<input class="field" type="text" size="5" id="equip_criticalMultiplier" class="fieldInput integer" />
</div>
</div>
<div class="fieldWithLabel">
<label for="equip_blockChance" class="label">Block chance:</label>
<div class="field"><input type="text" size="5" id="equip_blockChance" class="fieldInput integer" />%</div>
</div>
<div class="fieldWithLabel">
<label for="equip_damageResistance" class="label">Damage resistance:</label>
<input class="field" type="text" size="5" id="equip_damageResistance" class="fieldInput integer" />
</div>
<div class="fieldWithLabel">
<label for="equip_conditions" class="label">Apply actor condition</label>
<table class="field" id="equip_conditions">
<thead><tr>
<th id="condition">Condition</th>
<th id="magnitude">Magnitude</th>
</tr></thead>
<tbody>
</tbody>
</table>
<div id="add">Add</div>
</div>
</fieldset>
<fieldset class="fieldSet" id="hasUseEffectDisplay">
<legend>When used</legend>
<div class="fieldWithLabel">
<label for="use_boostHP" class="label">Boost current HP (range):</label>
<div class="field"><input type="text" size="3" id="use_boostHP_Min" class="fieldInput" /> - <input type="text" size="3" id="use_boostHP_Max" class="fieldInput integer" /></div>
</div>
<div class="fieldWithLabel">
<label for="use_boostAP" class="label">Boost current AP (range):</label>
<div class="field"><input type="text" size="3" id="use_boostAP_Min" class="fieldInput" /> - <input type="text" size="3" id="use_boostAP_Max" class="fieldInput integer" /></div>
</div>
<div class="fieldWithLabel">
<label for="use_conditionsSource" class="label">Apply actor condition</label>
<table class="field" id="use_conditionsSource">
<thead><tr>
<th id="condition">Condition</th>
<th id="magnitude">Magnitude</th>
<th id="duration">Duration</th>
<th id="chance">Chance</th>
</tr></thead>
<tbody>
</tbody>
</table>
<div id="add">Add</div>
</div>
</fieldset>
<fieldset class="fieldSet" id="hasHitEffectDisplay">
<legend>When making a successful hit</legend>
<div class="fieldWithLabel">
<label for="hit_boostHP" class="label">Boost current HP (range):</label>
<div class="field"><input type="text" size="3" id="hit_boostHP_Min" class="fieldInput" /> - <input type="text" size="3" id="hit_boostHP_Max" class="fieldInput integer" /></div>
</div>
<div class="fieldWithLabel">
<label for="hit_boostAP" class="label">Boost current AP (range):</label>
<div class="field"><input type="text" size="3" id="hit_boostAP_Min" class="fieldInput" /> - <input type="text" size="3" id="hit_boostAP_Max" class="fieldInput integer" /></div>
</div>
<div class="fieldWithLabel">
<label for="hit_conditionsSource" class="label">Apply actor condition to source</label>
<table class="field" id="hit_conditionsSource">
<thead><tr>
<th id="condition">Condition</th>
<th id="magnitude">Magnitude</th>
<th id="duration">Duration</th>
<th id="chance">Chance</th>
</tr></thead>
<tbody>
</tbody>
</table>
<div id="add">Add</div>
</div>
<div class="fieldWithLabel">
<label for="hit_conditionsTarget" class="label">Apply actor condition to target</label>
<table class="field" id="hit_conditionsTarget">
<thead><tr>
<th id="condition">Condition</th>
<th id="magnitude">Magnitude</th>
<th id="duration">Duration</th>
<th id="chance">Chance</th>
</tr></thead>
<tbody>
</tbody>
</table>
<div id="add">Add</div>
</div>
</fieldset>
<fieldset class="fieldSet" id="hasKillEffectDisplay">
<legend>On every kill</legend>
<div class="fieldWithLabel">
<label for="kill_boostHP" class="label">Boost current HP (range):</label>
<div class="field"><input type="text" size="3" id="kill_boostHP_Min" class="fieldInput" /> - <input type="text" size="3" id="kill_boostHP_Max" class="fieldInput integer" /></div>
</div>
<div class="fieldWithLabel">
<label for="kill_boostAP" class="label">Boost current AP (range):</label>
<div class="field"><input type="text" size="3" id="kill_boostAP_Min" class="fieldInput" /> - <input type="text" size="3" id="kill_boostAP_Max" class="fieldInput integer" /></div>
</div>
<div class="fieldWithLabel">
<label for="kill_conditionsSource" class="label">Apply actor condition</label>
<table class="field" id="kill_conditionsSource">
<thead><tr>
<th id="condition">Condition</th>
<th id="magnitude">Magnitude</th>
<th id="duration">Duration</th>
<th id="chance">Chance</th>
</tr></thead>
<tbody>
</tbody>
</table>
<div id="add">Add</div>
</div>
</fieldset>
<div class="endSets"> </div>
</div>
<div id="dialog-equipConditions">
<div class="fieldWithLabel">
<label for="condition" class="label">Actor condition id:</label>
<input type="text" size="30" id="condition" class="field fieldInput"/>
</div>
<div class="fieldWithLabel">
<label for="magnitude" class="label">Magnitude:</label>
<input type="text" size="5" id="magnitude" class="field fieldInput integer"/>
</div>
</div>
<!-- ========================================================= -->
<!-- Dialogue editor -->

View File

@@ -10,6 +10,11 @@ var ATEditor = (function(ATEditor, _) {
prep.quest = function(o) {
};
prep.item = function(o) {
o.hasEquipEffect = ATEditor.utils.hasValues(o.equipEffect);
o.equipEffect.hasCritical = o.equipEffect.increaseCriticalSkill || o.equipEffect.setCriticalMultiplier;
o.hasUseEffect = ATEditor.utils.hasValues(o.useEffect);
o.hasHitEffect = ATEditor.utils.hasValues(o.hitEffect);
o.hasKillEffect = ATEditor.utils.hasValues(o.killEffect);
};
prep.droplist = function(o) {
};
@@ -39,18 +44,45 @@ var ATEditor = (function(ATEditor, _) {
if (!o.hasAbilityEffect) { delete o.abilityEffect; }
delete o.hasRoundEffect;
delete o.hasFullRoundEffect;
if (o.abilityEffect) { delete o.abilityEffect.hasCritical; }
if (o.abilityEffect) {
if (!o.abilityEffect.hasCritical) {
delete o.abilityEffect.increaseCriticalSkill;
delete o.abilityEffect.setCriticalMultiplier;
}
delete o.abilityEffect.hasCritical;
}
delete o.hasAbilityEffect;
};
unprep.quest = function(o) {
};
unprep.item = function(o) {
if (!o.hasEquipEffect) { delete o.equipEffect; }
if (o.equipEffect) {
if (!o.equipEffect.hasCritical) {
delete o.equipEffect.increaseCriticalSkill;
delete o.equipEffect.setCriticalMultiplier;
}
delete o.equipEffect.hasCritical;
}
if (_.isObject(o.category)) { o.category = o.category.id; }
if (!o.hasUseEffect) { delete o.useEffect; }
if (!o.hasHitEffect) { delete o.hitEffect; }
if (!o.hasKillEffect) { delete o.killEffect; }
delete o.hasEquipEffect;
delete o.hasUseEffect;
delete o.hasHitEffect;
delete o.hasKillEffect;
};
unprep.droplist = function(o) {
};
unprep.dialogue = function(o) {
};
unprep.monster = function(o) {
if (!o.hasCritical) {
delete o.criticalSkill;
delete o.criticalMultiplier;
}
delete o.hasCritical;
delete o.hasConversation;
delete o.hasCombatTraits;
delete o.hasHitEffect;

View File

@@ -12,6 +12,19 @@ var ATEditor = (function(ATEditor, _) {
}
}
}
function copyDefaults(o, defaults) {
var key;
for (key in defaults) {
var v = defaults[key];
if (!o[key]) {
o[key] = v;
} else if (_.isObject(v)) {
copyDefaults(o[key], v);
}
}
}
function removeAngularFields(o) {
var key;
for (key in o) {
@@ -92,6 +105,7 @@ var ATEditor = (function(ATEditor, _) {
ATEditor.utils = {
deepClone: deepClone
,removeDefaults: removeDefaults
,copyDefaults: copyDefaults
,removeAngularFields: removeAngularFields
,compact: compact
,hasValues: hasValues