Skip to content

Commit

Permalink
Remove showCount XML attribute.
Browse files Browse the repository at this point in the history
book8sect138: Avoid duplicates in sell objects.
cracrayol committed Nov 10, 2019

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 09d3124 commit 11e02df
Showing 12 changed files with 15 additions and 17 deletions.
6 changes: 2 additions & 4 deletions src/ts/controller/mechanics/mechanicsEngine.ts
Original file line number Diff line number Diff line change
@@ -763,11 +763,8 @@ const mechanicsEngine = {
// Object can be used directly from the section, without picking it?
const useOnSection = ($(rule).attr("useOnSection") === "true");

// Show arrows count for quiver
const showCount = ($(rule).attr("showCount") === "true");

// Add the object to the available objects on the section
sectionState.addObjectToSection(objectId, price, unlimited, count, showCount, useOnSection);
sectionState.addObjectToSection(objectId, price, unlimited, count, useOnSection);

sectionState.markRuleAsExecuted(rule);
},
@@ -822,6 +819,7 @@ const mechanicsEngine = {
price,
count: 0,
});
except.push(id); // Avoid duplicates
}
}
}
5 changes: 2 additions & 3 deletions src/ts/model/sectionState.ts
Original file line number Diff line number Diff line change
@@ -260,11 +260,10 @@ class SectionState {
* @param unlimited True if there are an infinite number of this kind of object on the section
* @param count Only applies if id = 'quiver' (number of arrows on the quiver), 'arrow' (number of arrows), or 'money' (number of Gold Crowns),
* or if price is is not zero (-> you buy "count" items for one "price")
* @param showCount Only applies if id = 'quiver' (show the number of arrows on the quiver)
* @param useOnSection The object is allowed to be used on the section (not picked object)?
*/
public addObjectToSection(objectId: string , price: number = 0, unlimited: boolean = false, count: number = 0 ,
showCount: boolean = false , useOnSection: boolean = false ) {
useOnSection: boolean = false ) {

// Special cases:
if ( objectId === "money" ) {
@@ -282,7 +281,7 @@ class SectionState {
price,
unlimited,
count: (objectId === Item.QUIVER || objectId === Item.ARROW || objectId === Item.MONEY || price > 0 ? count : 0 ),
showCount: (objectId === Item.QUIVER ? showCount : false),
showCount: false,
useOnSection,
});
}
4 changes: 3 additions & 1 deletion src/ts/views/viewsUtils/objectsTable.ts
Original file line number Diff line number Diff line change
@@ -86,11 +86,13 @@ class ObjectsTable {
price : 0,
unlimited : false,
count,
showCount : (obj === Item.QUIVER && this.type === ObjectsTableType.INVENTORY),
useOnSection : false,
};
}

// Show arrows count of quiver only in action chart or count > 0
info.showCount = (info.id === Item.QUIVER && (info.count > 0 || this.type === ObjectsTableType.INVENTORY));

this.objects.push( new ObjectsTableItem( info, this.type ) );
}
}
2 changes: 1 addition & 1 deletion src/www/data/mechanics-10.xml
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@

<object objectId="sword" />
<object objectId="bow" />
<object objectId="quiver" count="6" showCount="true" />
<object objectId="quiver" count="6" />
<object objectId="rope" />
<object objectId="laumspurpotion4" />
<object objectId="lantern" />
2 changes: 1 addition & 1 deletion src/www/data/mechanics-11.xml
Original file line number Diff line number Diff line change
@@ -44,7 +44,7 @@

<object objectId="sword" />
<object objectId="bow" />
<object objectId="quiver" count="6" showCount="true" />
<object objectId="quiver" count="6" />
<object objectId="rope" />
<object objectId="laumspurpotion4" />
<object objectId="lantern" />
2 changes: 1 addition & 1 deletion src/www/data/mechanics-12.xml
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@

<object objectId="sword" />
<object objectId="bow" />
<object objectId="quiver" count="6" showCount="true" />
<object objectId="quiver" count="6" />
<object objectId="rope" />
<object objectId="laumspurpotion4" />
<object objectId="lantern" />
2 changes: 1 addition & 1 deletion src/www/data/mechanics-13.xml
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@

<object objectId="sword" />
<object objectId="bow" />
<object objectId="quiver" count="6" showCount="true" />
<object objectId="quiver" count="6" />
<object objectId="axe" />
<object objectId="meal" index="0" />
<object objectId="meal" index="1" />
2 changes: 1 addition & 1 deletion src/www/data/mechanics-6.xml
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@
<object objectId="laumspurpotion4" />
<object objectId="warhammer" />
<object objectId="bow" />
<object objectId="quiver" count="6" showCount="true" />
<object objectId="quiver" count="6" />
<object objectId="meal" index="0" />
<object objectId="meal" index="1" />
<object objectId="meal" index="2" />
2 changes: 1 addition & 1 deletion src/www/data/mechanics-7.xml
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@

<object objectId="sword" />
<object objectId="bow" />
<object objectId="quiver" count="6" showCount="true" />
<object objectId="quiver" count="6" />
<object objectId="rope" />
<object objectId="laumspurpotion4" />
<object objectId="lantern" />
2 changes: 1 addition & 1 deletion src/www/data/mechanics-8.xml
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@

<object objectId="sword" />
<object objectId="bow" />
<object objectId="quiver" count="6" showCount="true" />
<object objectId="quiver" count="6" />
<object objectId="rope" />
<object objectId="laumspurpotion4" />
<object objectId="lantern" />
2 changes: 1 addition & 1 deletion src/www/data/mechanics-9.xml
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@

<object objectId="sword" />
<object objectId="bow" />
<object objectId="quiver" count="6" showCount="true" />
<object objectId="quiver" count="6" />
<object objectId="rope" />
<object objectId="laumspurpotion4" />
<object objectId="lantern" />
1 change: 0 additions & 1 deletion src/www/data/mechanics.xsd
Original file line number Diff line number Diff line change
@@ -186,7 +186,6 @@
<xs:attribute name="objectId" type="xs:string" use="required" />
<xs:attribute name="price" type="xs:string" />
<xs:attribute name="count" type="xs:nonNegativeInteger" />
<xs:attribute name="showCount" type="xs:boolean" />
<xs:attribute name="useOnSection" type="xs:boolean" />
<xs:attribute name="unlimited" type="xs:boolean" />
<xs:attribute name="index" type="xs:nonNegativeInteger" />

0 comments on commit 11e02df

Please sign in to comment.