Refactor content editor - Added views for updating, exporting and importing quests and actor conditions.

This commit is contained in:
Oskar Wiksten
2013-01-28 18:25:47 +01:00
parent 004a67f2c9
commit c33cd6bd2a
8 changed files with 333 additions and 320 deletions

View File

@@ -47,6 +47,13 @@ var ATEditor = (function(ATEditor, model, importExport) {
controllers.QuestController = function($scope, $routeParams) {
$scope.datasource = model.quests;
$scope.obj = $scope.datasource.findById($routeParams.id);
$scope.addQuestStage = function() {
$scope.obj.stages.push({});
};
$scope.removeQuestStage = function(stage) {
var idx = $scope.obj.stages.indexOf(stage);
$scope.obj.stages.splice(idx, 1);
};
};
controllers.ItemController = function($scope, $routeParams) {
$scope.datasource = model.items;

View File

@@ -1,7 +1,33 @@
var ATEditor = (function(ATEditor, _) {
var defaults = {
monster: {
actorcondition: {
isStacking: 0
,isPositive: 0
,roundEffect: { visualEffectID: -1, increaseCurrentHP: {}, increaseCurrentAP: {} }
,fullRoundEffect: { visualEffectID: -1, increaseCurrentHP: {}, increaseCurrentAP: {} }
,abilityEffect: { increaseAttackDamage: {} }
}
,quest: {
showInLog: 0
,stages: []
}
,item: {
displaytype: 0
,hasManualPrice: 0
,equipEffect: { increaseAttackDamage: {}, addedConditions: [] }
,useEffect: { increaseCurrentHP: {}, increaseCurrentAP: {}, conditionsSource: [], conditionsTarget: [] }
,hitEffect: { increaseCurrentHP: {}, increaseCurrentAP: {}, conditionsSource: [], conditionsTarget: [] }
,killEffect: { increaseCurrentHP: {}, increaseCurrentAP: {}, conditionsSource: [], conditionsTarget: [] }
}
,droplist: {
quantity: {}
}
,dialogue: {
rewards: []
,replies: []
}
,monster: {
size: "1x1"
,maxHP: 1
,maxAP: 10
@@ -11,6 +37,11 @@ var ATEditor = (function(ATEditor, _) {
,attackDamage: {}
,hitEffect: { increaseCurrentHP: {}, increaseCurrentAP: {}, conditionsSource: [], conditionsTarget: [] }
}
,itemcategory: {
actionType: 0
,inventorySlot: -1
,size: 0
}
};
ATEditor.defaults = {
@@ -21,7 +52,7 @@ var ATEditor = (function(ATEditor, _) {
}
},
removeDefaults: function(type, o) {
return ATEditor.utils.cleanCopy(o, defaults[type]);
return ATEditor.utils.removeDefaults(o, defaults[type]);
}
};

View File

@@ -1,5 +1,156 @@
<div>
<p>id: {{obj.id}}</p>
<input type="text" ng-model="obj.id"><br />
<input type="text" ng-model="obj.name"><br />
</div>
<h3>Actor condition</h3>
<fieldset class="fieldSet">
<legend>General</legend>
<div class="fieldWithLabel">
<div id="actorconditionimage" class="field"><input type="hidden" id="iconID" ng-model="obj.iconID" /></div>
</div>
<div class="fieldWithLabel">
<label for="id" class="label">Internal ID:</label>
<input type="text" size="30" id="id" class="field fieldInput" ng-model="obj.id"/>
</div>
<div class="fieldWithLabel">
<label for="name" class="label">Display name:</label>
<input type="text" size="30" id="name" class="field fieldInput" ng-model="obj.name" />
</div>
<div class="fieldWithLabel">
<label for="category" class="label">Category:</label>
<select class="field fieldInput" id="category" ng-model="obj.category">
<option value="0">Spiritual</option>
<option value="1">Mental</option>
<option value="2">Physical Capacity</option>
<option value="3">Blood Disorder</option>
</select>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="isPositive" ng-model="obj.isPositive" ng-true-value="1" ng-false-value="0" />Positive effect</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="isStacking" ng-model="obj.isStacking" ng-true-value="1" ng-false-value="0" />Allow stacked effects</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasRoundEffect" ng-model="obj.hasRoundEffect" />Has effect every round (every 6s)</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasFullRoundEffect" ng-model="obj.hasFullRoundEffect" />Has effect every full round (every 25:th s)</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasAbilityEffect" ng-model="obj.hasAbilityEffect" />Has constant ability effect</div>
</div>
</fieldset>
<fieldset class="fieldSet" id="hasRoundEffectDisplay" ng-ds-fade="obj.hasRoundEffect">
<legend>Every round (6s)</legend>
<div class="fieldWithLabel">
<label for="round_visualEffectID" class="label">Visual effect:</label>
<select class="field fieldInput" id="round_visualEffectID" ng-model="obj.roundEffect.visualEffectID">
<option value="-1">None</option>
<option value="0">Red splatter</option>
<option value="1">Blue swirl</option>
<option value="2">Green splatter</option>
</select>
</div>
<div class="fieldWithLabel">
<label for="round_boostHP" class="label">Boost current HP (range):</label>
<div class="field">
<input type="text" size="3" id="round_boostHP_Min" class="fieldInput integer" ng-model="obj.roundEffect.increaseCurrentHP.min" />
-
<input type="text" size="3" id="round_boostHP_Max" class="fieldInput integer" ng-model="obj.roundEffect.increaseCurrentHP.max" />
</div>
</div>
<div class="fieldWithLabel">
<label for="round_boostAP" class="label">Boost current AP (range):</label>
<div class="field">
<input type="text" size="3" id="round_boostAP_Min" class="fieldInput integer" ng-model="obj.roundEffect.increaseCurrentAP.min" />
-
<input type="text" size="3" id="round_boostAP_Max" class="fieldInput integer" ng-model="obj.roundEffect.increaseCurrentAP.max" />
</div>
</div>
</fieldset>
<fieldset class="fieldSet" id="hasFullRoundEffectDisplay" ng-ds-fade="obj.hasFullRoundEffect">
<legend>Every full round (25s)</legend>
<div class="fieldWithLabel">
<label for="fullround_visualEffectID" class="label">Visual effect:</label>
<select class="field fieldInput" id="fullround_visualEffectID" ng-model="obj.fullRoundEffect.visualEffectID">
<option value="-1">None</option>
<option value="0">Red splatter</option>
<option value="1">Blue swirl</option>
<option value="2">Green splatter</option>
</select>
</div>
<div class="fieldWithLabel">
<label for="fullround_boostHP" class="label">Boost current HP (range):</label>
<div class="field">
<input type="text" size="3" id="fullround_boostHP_Min" class="fieldInput integer" ng-model="obj.fullRoundEffect.increaseCurrentHP.min" />
-
<input type="text" size="3" id="fullround_boostHP_Max" class="fieldInput integer" ng-model="obj.fullRoundEffect.increaseCurrentHP.max" />
</div>
</div>
<div class="fieldWithLabel">
<label for="fullround_boostAP" class="label">Boost current AP (range):</label>
<div class="field">
<input type="text" size="3" id="fullround_boostAP_Min" class="fieldInput integer" ng-model="obj.fullRoundEffect.increaseCurrentAP.min" />
-
<input type="text" size="3" id="fullround_boostAP_Max" class="fieldInput integer" ng-model="obj.fullRoundEffect.increaseCurrentAP.max" />
</div>
</div>
</fieldset>
<fieldset class="fieldSet" id="hasAbilityEffectDisplay" ng-ds-fade="obj.hasAbilityEffect">
<legend>Constant ability effect</legend>
<div class="fieldWithLabel">
<label for="boostMaxHP" class="label">Boost max HP:</label>
<input type="text" size="5" id="boostMaxHP" class="field fieldInput integer" ng-model="obj.abilityEffect.increaseMaxHP" />
</div>
<div class="fieldWithLabel">
<label for="boostMaxAP" class="label">Boost max AP:</label>
<input type="text" size="5" id="boostMaxAP" class="field fieldInput integer" ng-model="obj.abilityEffect.increaseMaxAP" />
</div>
<div class="fieldWithLabel">
<label for="moveCostPenalty" class="label">Move cost penalty (AP):</label>
<input type="text" size="5" id="moveCostPenalty" class="field fieldInput integer" ng-model="obj.abilityEffect.increaseMoveCost" />
</div>
<div class="fieldWithLabel">
<label for="increaseUseItemCost" class="label">Increase use cost (AP):</label>
<input class="field" type="text" size="5" id="increaseUseItemCost" class="fieldInput integer" ng-model="obj.abilityEffect.increaseUseItemCost" />
</div>
<div class="fieldWithLabel">
<label for="increaseReequipCost" class="label">Increase re-equip cost (AP):</label>
<input class="field" type="text" size="5" id="increaseReequipCost" class="fieldInput integer" ng-model="obj.abilityEffect.increaseReequipCost" />
</div>
<div class="fieldWithLabel">
<label for="attackCost" class="label">Attack cost (AP):</label>
<input class="field" type="text" size="5" id="attackCost" class="fieldInput integer" ng-model="obj.abilityEffect.increaseAttackCost" />
</div>
<div class="fieldWithLabel">
<label for="attackChance" class="label">Attack chance:</label>
<div class="field"><input type="text" size="5" id="attackChance" class="fieldInput integer" ng-model="obj.abilityEffect.increaseAttackChance" />%</div>
</div>
<div class="fieldWithLabel">
<label for="attackDamage" class="label">Attack damage (range):</label>
<div class="field">
<input type="text" size="3" id="attackDamage_Min" class="fieldInput integer" ng-model="obj.abilityEffect.increaseAttackDamage.min" />
-
<input type="text" size="3" id="attackDamage_Max" class="fieldInput integer" ng-model="obj.abilityEffect.increaseAttackDamage.max" />
</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasCritical" ng-model="obj.abilityEffect.hasCritical" />Has critical chance</div>
</div>
<div id="hasCriticalDisplay" ng-ds-fade="obj.abilityEffect.hasCritical">
<div class="fieldWithLabel">
<label for="criticalChance" class="label">Critical skill:</label>
<div class="field"><input type="text" size="5" id="criticalChance" class="fieldInput integer" ng-model="obj.abilityEffect.increaseCriticalSkill" />%</div>
</div>
<div class="fieldWithLabel">
<label for="criticalMultiplier" class="label">Critical multiplier:</label>
<input class="field" type="text" size="5" id="criticalMultiplier" class="fieldInput integer" ng-model="obj.abilityEffect.setCriticalMultiplier" />
</div>
</div>
<div class="fieldWithLabel">
<label for="blockChance" class="label">Block chance:</label>
<div class="field"><input type="text" size="5" id="blockChance" class="fieldInput integer" ng-model="obj.abilityEffect.increaseBlockChance" />%</div>
</div>
<div class="fieldWithLabel">
<label for="damageResistance" class="label">Damage resistance:</label>
<input class="field" type="text" size="5" id="damageResistance" class="fieldInput integer" ng-model="obj.abilityEffect.increaseDamageResistance" />
</div>
</fieldset>
<div class="endSets"> </div>

View File

@@ -1,5 +1,40 @@
<div>
<p>id: {{obj.id}}</p>
<input type="text" ng-model="obj.id"><br />
<input type="text" ng-model="obj.name"><br />
</div>
<h3>Quest</h3>
<fieldset class="fieldSet">
<legend>General</legend>
<div class="fieldWithLabel">
<label for="id" class="label">Internal ID:</label>
<input type="text" size="30" id="id" class="field fieldInput" ng-model="obj.id" />
</div>
<div class="fieldWithLabel">
<label for="name" class="label">Display name:</label>
<input type="text" size="30" id="name" class="field fieldInput" ng-model="obj.name" />
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="showInLog" ng-model="obj.showInLog" ng-true-value="1" ng-false-value="0" />Show in quest log</div>
</div>
</fieldset>
<fieldset class="fieldSet">
<legend>Stages</legend>
<div class="fieldWithLabel">
<label for="stages" class="label">Stages shown in quest log</label>
<table class="field" id="stages">
<thead><tr>
<th id="progress">Progress</th>
<th id="logText">Logtext</th>
<th id="rewardExperience">Experience</th>
<th id="finishesQuest">Finishes quest</th>
</tr></thead>
<tbody>
<tr ng-repeat="stage in obj.stages">
<td><input type="text" size="3" ng-model="stage.progress" class="fieldInput integer" /></td>
<td><input type="text" ng-model="stage.logText" class="fieldInput" /></td>
<td><input type="text" size="7" ng-model="stage.rewardExperience" class="fieldInput integer" /></td>
<td><input type="checkbox" ng-model="stage.finishesQuest" ng-true-value="1" ng-false-value="0" /></td>
<td><a ng-click="removeQuestStage(stage)">X</a></td>
</tr>
</tbody>
</table>
<button ng-click="addQuestStage()">Add</button>
</div>
</fieldset>
<div class="endSets"> </div>

View File

@@ -397,66 +397,6 @@
</div>
<!-- ========================================================= -->
<!-- Quest editor -->
<div id="editQuest">
<h3>Quest</h3>
<fieldset class="fieldSet">
<legend>General</legend>
<div class="fieldWithLabel">
<label for="id" class="label">Internal ID:</label>
<input type="text" size="30" id="id" class="field fieldInput"/>
</div>
<div class="fieldWithLabel">
<label for="name" class="label">Display name:</label>
<input type="text" size="30" id="name" class="field fieldInput"/>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="showInLog" />Show in quest log</div>
</div>
</fieldset>
<fieldset class="fieldSet">
<legend>Stages</legend>
<div class="fieldWithLabel">
<label for="stages" class="label">Stages shown in quest log</label>
<table class="field" id="stages">
<thead><tr>
<th id="progress">Progress</th>
<th id="logText">Logtext</th>
<th id="rewardExperience">Experience</th>
<th id="finishesQuest">Finishes quest</th>
</tr></thead>
<tbody>
</tbody>
</table>
<div id="add">Add</div>
</div>
</fieldset>
<div class="endSets"> </div>
</div>
<div id="dialog-questlog">
<div class="fieldWithLabel">
<label for="progress" class="label">Progress stage (#):</label>
<input type="text" size="4" id="progress" class="field fieldInput integer"/>
</div>
<div class="fieldWithLabel">
<label for="logText" class="label">Logtext displayed in quest log:</label>
<textarea rows="4" cols="40" id="logText"></textarea>
</div>
<div class="fieldWithLabel">
<label for="rewardExperience" class="label">Experience reward for reaching this stage:</label>
<input type="text" size="7" id="rewardExperience" class="field fieldInput integer"/>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="finishesQuest" />Finishes quest</div>
</div>
</div>
<!-- ========================================================= -->
<!-- Dialogue editor -->
@@ -599,223 +539,8 @@
<input type="text" size="5" id="value" class="field fieldInput integer"/>
</div>
</div>
<!-- ========================================================= -->
<!-- Actor condition editor -->
<div id="editActorCondition">
<h3>Actor condition</h3>
<fieldset class="fieldSet">
<legend>General</legend>
<div class="fieldWithLabel">
<div id="actorconditionimage" class="field"><input type="hidden" id="iconID" /></div>
</div>
<div class="fieldWithLabel">
<label for="id" class="label">Internal ID:</label>
<input type="text" size="30" id="id" class="field fieldInput"/>
</div>
<div class="fieldWithLabel">
<label for="name" class="label">Display name:</label>
<input type="text" size="30" id="name" class="field fieldInput"/>
</div>
<div class="fieldWithLabel">
<label for="category" class="label">Category:</label>
<select class="field fieldInput" id="category">
<option value="0">Spiritual</option>
<option value="1">Mental</option>
<option value="2">Physical Capacity</option>
<option value="3">Blood Disorder</option>
</select>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="isPositive" />Positive effect</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="isStacking" />Allow stacked effects</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasRoundEffect" />Has effect every round (every 6s)</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasFullRoundEffect" />Has effect every full round (every 25:th s)</div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasAbilityEffect" />Has constant ability effect</div>
</div>
</fieldset>
<fieldset class="fieldSet" id="hasRoundEffectDisplay">
<legend>Every round (6s)</legend>
<div class="fieldWithLabel">
<label for="round_visualEffectID" class="label">Visual effect:</label>
<select class="field fieldInput" id="round_visualEffectID">
<option value="-1">None</option>
<option value="0">Red splatter</option>
<option value="1">Blue swirl</option>
<option value="2">Green splatter</option>
</select>
</div>
<div class="fieldWithLabel">
<label for="round_boostHP" class="label">Boost current HP (range):</label>
<div class="field"><input type="text" size="3" id="round_boostHP_Min" class="fieldInput" /> - <input type="text" size="3" id="round_boostHP_Max" class="fieldInput integer" /></div>
</div>
<div class="fieldWithLabel">
<label for="round_boostAP" class="label">Boost current AP (range):</label>
<div class="field"><input type="text" size="3" id="round_boostAP_Min" class="fieldInput" /> - <input type="text" size="3" id="round_boostAP_Max" class="fieldInput integer" /></div>
</div>
</fieldset>
<fieldset class="fieldSet" id="hasFullRoundEffectDisplay">
<legend>Every full round (25s)</legend>
<div class="fieldWithLabel">
<label for="fullround_visualEffectID" class="label">Visual effect:</label>
<select class="field fieldInput" id="fullround_visualEffectID">
<option value="-1">None</option>
<option value="0">Red splatter</option>
<option value="1">Blue swirl</option>
<option value="2">Green splatter</option>
</select>
</div>
<div class="fieldWithLabel">
<label for="fullround_boostHP" class="label">Boost current HP (range):</label>
<div class="field"><input type="text" size="3" id="fullround_boostHP_Min" class="fieldInput" /> - <input type="text" size="3" id="fullround_boostHP_Max" class="fieldInput integer" /></div>
</div>
<div class="fieldWithLabel">
<label for="fullround_boostAP" class="label">Boost current AP (range):</label>
<div class="field"><input type="text" size="3" id="fullround_boostAP_Min" class="fieldInput" /> - <input type="text" size="3" id="fullround_boostAP_Max" class="fieldInput integer" /></div>
</div>
</fieldset>
<fieldset class="fieldSet" id="hasAbilityEffectDisplay">
<legend>Constant ability effect</legend>
<div class="fieldWithLabel">
<label for="boostMaxHP" class="label">Boost max HP:</label>
<input type="text" size="5" id="boostMaxHP" class="field fieldInput integer" />
</div>
<div class="fieldWithLabel">
<label for="boostMaxAP" class="label">Boost max AP:</label>
<input type="text" size="5" id="boostMaxAP" class="field fieldInput integer" />
</div>
<div class="fieldWithLabel">
<label for="moveCostPenalty" class="label">Move cost penalty (AP):</label>
<input type="text" size="5" id="moveCostPenalty" class="field fieldInput integer" />
</div>
<div class="fieldWithLabel">
<label for="attackCost" class="label">Attack cost (AP):</label>
<input class="field" type="text" size="5" id="attackCost" class="fieldInput integer" />
</div>
<div class="fieldWithLabel">
<label for="attackChance" class="label">Attack chance:</label>
<div class="field"><input type="text" size="5" id="attackChance" class="fieldInput integer" />%</div>
</div>
<div class="fieldWithLabel">
<label for="attackDamage" class="label">Attack damage (range):</label>
<div class="field"><input type="text" size="3" id="attackDamage_Min" class="fieldInput integer" /> - <input type="text" size="3" id="attackDamage_Max" class="fieldInput integer" /></div>
</div>
<div class="fieldWithLabel">
<div class="label"><input type="checkbox" id="hasCritical" />Has critical chance</div>
</div>
<div id="hasCriticalDisplay">
<div class="fieldWithLabel">
<label for="criticalChance" class="label">Critical skill:</label>
<div class="field"><input type="text" size="5" id="criticalChance" class="fieldInput integer" />%</div>
</div>
<div class="fieldWithLabel">
<label for="criticalMultiplier" class="label">Critical multiplier:</label>
<input class="field" type="text" size="5" id="criticalMultiplier" class="fieldInput integer" />
</div>
</div>
<div class="fieldWithLabel">
<label for="blockChance" class="label">Block chance:</label>
<div class="field"><input type="text" size="5" id="blockChance" class="fieldInput integer" />%</div>
</div>
<div class="fieldWithLabel">
<label for="damageResistance" class="label">Damage resistance:</label>
<input class="field" type="text" size="5" id="damageResistance" class="fieldInput integer" />
</div>
</fieldset>
<div class="endSets"> </div>
</div>
<!-- ========================================================= -->
<!-- Import / Export dialog form -->
<div id="dialog-import">
<div id="description" class="importexport-description">This data corresponds to the files named res/values/content_*.xml in the source code.</div>
<div id="importsections">
<h3 class="import-actorconditions"><a href="#">Actor conditions</a></h3>
<div class="import-actorconditions">
<div><textarea id="value" rows="9" cols="80"></textarea></div>
<div id="import">Import</div>
</div>
<h3 class="import-quests"><a href="#">Quests</a></h3>
<div class="import-quests">
<div><textarea id="value" rows="9" cols="80"></textarea></div>
<div id="import">Import</div>
</div>
<h3 class="import-items"><a href="#">Items</a></h3>
<div class="import-items">
<div><textarea id="value" rows="9" cols="80"></textarea></div>
<div id="import">Import</div>
</div>
<h3 class="import-droplists"><a href="#">Droplists</a></h3>
<div class="import-droplists">
<div><textarea id="value" rows="9" cols="80"></textarea></div>
<div id="import">Import</div>
</div>
<h3 class="import-dialogue"><a href="#">Dialogue</a></h3>
<div class="import-dialogue">
<div><textarea id="value" rows="9" cols="80"></textarea></div>
<div id="import">Import</div>
</div>
<h3 class="import-monsters"><a href="#">Monsters</a></h3>
<div class="import-monsters">
<div><textarea id="value" rows="9" cols="80"></textarea></div>
<div id="import">Import</div>
</div>
</div>
</div>
<div id="dialog-export">
<div id="description" class="importexport-description">This data corresponds to the files named res/values/content_*.xml in the source code.</div>
<div id="exportsections">
<h3 class="export-actorconditions"><a href="#">Actor conditions</a></h3>
<div class="export-actorconditions">
<div><textarea id="value" rows="9" cols="80"></textarea></div>
</div>
<h3 class="export-quests"><a href="#">Quests</a></h3>
<div class="export-quests">
<div><textarea id="value" rows="9" cols="80"></textarea></div>
</div>
<h3 class="export-items"><a href="#">Items</a></h3>
<div class="export-items">
<div><textarea id="value" rows="9" cols="80"></textarea></div>
</div>
<h3 class="export-droplists"><a href="#">Droplists</a></h3>
<div class="export-droplists">
<div><textarea id="value" rows="9" cols="80"></textarea></div>
</div>
<h3 class="export-dialogue"><a href="#">Dialogue</a></h3>
<div class="export-dialogue">
<div><textarea id="value" rows="9" cols="80"></textarea></div>
</div>
<h3 class="export-monsters"><a href="#">Monsters</a></h3>
<div class="export-monsters">
<div><textarea id="value" rows="9" cols="80"></textarea></div>
</div>
</div>
</div>
<!-- ========================================================= -->
<!-- Select images dialog -->

View File

@@ -2,6 +2,10 @@ var ATEditor = (function(ATEditor, _) {
var prep = {};
prep.actorcondition = function(o) {
o.hasRoundEffect = ATEditor.utils.hasValues(_.omit(o.roundEffect, 'visualEffectID'));
o.hasFullRoundEffect = ATEditor.utils.hasValues(_.omit(o.fullRoundEffect, 'visualEffectID'));
o.abilityEffect.hasCritical = o.abilityEffect.increaseCriticalSkill || o.abilityEffect.setCriticalMultiplier;
o.hasAbilityEffect = ATEditor.utils.hasValues(o.abilityEffect);
};
prep.quest = function(o) {
};
@@ -24,11 +28,19 @@ var ATEditor = (function(ATEditor, _) {
_.each(objs, function(o) {
ATEditor.defaults.addDefaults(section.id, o);
if (p) { p(o); }
ATEditor.utils.convertIntegersToStrings(o);
});
}
var unprep = {};
unprep.actorcondition = function(o) {
if (!o.hasRoundEffect) { delete o.roundEffect; }
if (!o.hasFullRoundEffect) { delete o.fullRoundEffect; }
if (!o.hasAbilityEffect) { delete o.abilityEffect; }
delete o.hasRoundEffect;
delete o.hasFullRoundEffect;
if (o.abilityEffect) { delete o.abilityEffect.hasCritical; }
delete o.hasAbilityEffect;
};
unprep.quest = function(o) {
};
@@ -49,8 +61,12 @@ var ATEditor = (function(ATEditor, _) {
function prepareObjectsForExport(section, objs) {
var p = unprep[section.id];
return _.map(objs, function(o) {
o = ATEditor.defaults.removeDefaults(section.id, o);
o = ATEditor.utils.deepClone(o);
ATEditor.utils.removeAngularFields(o);
if (p) { p(o); }
ATEditor.utils.convertStringsToIntegers(o);
ATEditor.defaults.removeDefaults(section.id, o);
ATEditor.utils.compact(o);
return o;
});
}

View File

@@ -60,21 +60,21 @@ var ATEditor = (function(ATEditor, DataStore, FieldList, _) {
};
_import(model.actorConditions, [
{id: "bless", name: "Bless", isPositive: true, iconID: "actorconditions_1:38", category: 0, hasAbilityEffect: 1, attackChance: 15, blockChance: 5}
,{id: "poison_weak", name: "Weak Poison", iconID: "actorconditions_1:60", category: 3, hasRoundEffect: 1, round_visualEffectID: 2, round_boostHP_Min: -1, round_boostHP_Max: -1}
{id: "bless", name: "Bless", isPositive: 1, iconID: "actorconditions_1:38", category: 0, abilityEffect: { increaseAttackChance: 15, increaseBlockChance: 5} }
,{id: "poison_weak", name: "Weak Poison", iconID: "actorconditions_1:60", category: 3, roundEffect: { visualEffectID: 2, increaseCurrentHP: { min: -1, max: -1} } }
]);
_import(model.quests, [
{id: "testQuest", name: "Test quest", stages: [ { progress: 10, logText: "Stage 10"} , { progress: 20, logText: "Stage 20", finishesQuest: 1 } ] }
{id: "testQuest", name: "Test quest", showInLog: 1, stages: [ { progress: 10, logText: "Stage 10"} , { progress: 20, logText: "Stage 20", finishesQuest: 1 } ] }
]);
_import(model.items, [
{id: "item0", iconID: "items_weapons:0", name: "Longsword", category: 'lsword', baseMarketCost: 51, hasEquipEffect: 1, equip_attackChance: 10, equip_attackDamage_Min: 2, equip_attackDamage_Max: 4, equip_attackCost: 4}
,{id: "dmg_ring1", iconID: "items_jewelry:0", name: "Ring of damage +1", category: 'ring', baseMarketCost: 62, hasEquipEffect: 1, equip_attackDamage_Min: 1, equip_attackDamage_Max: 1}
{id: "item0", iconID: "items_weapons:0", name: "Longsword", category: 'lsword', baseMarketCost: 51, equipEffect: { increaseAttackChance: 10, increaseAttackDamage: { min: 2, max: 4 }, increaseAttackCost: 4 } }
,{id: "dmg_ring1", iconID: "items_jewelry:0", name: "Ring of damage +1", category: 'ring', baseMarketCost: 62, equipEffect: { increaseAttackDamage: { min: 1, max: 1 } } }
]);
_import(model.droplists, [
{id: "merchant1", items: [ { itemID: 'dmg_ring1', quantity_Min: 4, quantity_Max: 5, chance: 100 } , { itemID: 'item0', quantity_Min: 1, quantity_Max: 1, chance: 100 } ] }
{id: "merchant1", items: [ { itemID: 'dmg_ring1', quantity: { min: 4, max: 5 }, chance: 100 } , { itemID: 'item0', quantity: { min: 1, max: 1 }, chance: 100 } ] }
]);
_import(model.dialogue, [
@@ -91,6 +91,6 @@ var ATEditor = (function(ATEditor, DataStore, FieldList, _) {
}
addExampleModelItems(model);
ATEditor.model = model;
ATEditor.model = ATEditor.model || model;
return ATEditor;
})(ATEditor, ATEditor.DataStore, ATEditor.FieldList, _);

View File

@@ -12,43 +12,91 @@ var ATEditor = (function(ATEditor, _) {
}
}
}
function cleanCopy(o, defaults) {
if (!o) { return null; }
o = _.clone(o);
if (defaults) {
removeDefaults(o, defaults);
}
for (var key in o) {
function removeAngularFields(o) {
var key;
for (key in o) {
var v = o[key];
if (key.charAt(0) === '$') {
delete o[key];
} else if (_.isArray(v) || _.isObject(v)) {
removeAngularFields(v);
}
}
for (var key in o) {
}
function compact(o) {
if (!o) { return null; }
var key;
for (key in o) {
var v = o[key];
if (!v) {
delete o[key];
} else if (_.isArray(v)) {
if (!_.some(v)) {
delete o[key];
} else {
o[key] = _.map(v, function(o) { cleanCopy(o); });
}
if (_.isArray(v)) {
v = _.map(v, compact);
} else if (_.isObject(v)) {
v = cleanCopy(v);
if (v) {
o[key] = v;
} else {
delete o[key];
}
v = compact(v);
}
if (!hasValues(v)) {
delete o[key];
} else {
o[key] = v;
}
}
if (!_.some(_.keys(o))) { return null; }
if (!hasValues(o)) { return null; }
return o;
}
function hasValues(o) {
if (_.isArray(o)) {
return _.some(o, hasValues);
} else if (_.isObject(o)) {
var key;
for (key in o) {
if (hasValues(o[key])) {
return true;
}
}
return false;
}
return o;
}
function convertStringsToIntegers(o) {
var key;
for (key in o) {
var v = o[key];
if (_.isString(v)) {
v = parseInt(v);
if (!_.isNaN(v)) {
o[key] = v;
}
} else if (_.isArray(v)) {
convertStringsToIntegers(v);
} else if (_.isObject(v)) {
convertStringsToIntegers(v);
}
}
}
function convertIntegersToStrings(o) {
var key;
for (key in o) {
var v = o[key];
if (_.isNumber(v)) {
o[key] = String(v);
} else if (_.isArray(v)) {
convertIntegersToStrings(v);
} else if (_.isObject(v)) {
convertIntegersToStrings(v);
}
}
}
ATEditor.utils = {
deepClone: deepClone
,cleanCopy: cleanCopy
,removeDefaults: removeDefaults
,removeAngularFields: removeAngularFields
,compact: compact
,hasValues: hasValues
,convertStringsToIntegers: convertStringsToIntegers
,convertIntegersToStrings: convertIntegersToStrings
};
return ATEditor;