Skip to content

Commit

Permalink
element.min, max
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed May 6, 2015
1 parent a48888e commit a5e1515
Showing 1 changed file with 38 additions and 4 deletions.
42 changes: 38 additions & 4 deletions src/main/java/net/aufdemrand/denizencore/objects/Element.java
Original file line number Diff line number Diff line change
Expand Up @@ -1299,10 +1299,44 @@ public String getAttribute(Attribute attribute) {
}

// <--[tag]
// @attribute <el@element.add_int[<#>]>
// @attribute <el@element.max[<#.#>]>
// @returns Element(Decimal)
// @group math
// @description
// Returns the higher number: this element or the specified one.
// -->
if (attribute.startsWith("max")
&& attribute.hasContext(1)) {
if (!isDouble()) {
dB.echoError("Element '" + element + "' is not a valid number!");
return null;
}
return new Element(Math.max(asDouble(), new Element(attribute.getContext(1)).asDouble()))
.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <el@element.min[<#.#>]>
// @returns Element(Decimal)
// @group math
// @description
// Returns the lower number: this element or the specified one.
// -->
if (attribute.startsWith("min")
&& attribute.hasContext(1)) {
if (!isDouble()) {
dB.echoError("Element '" + element + "' is not a valid number!");
return null;
}
return new Element(Math.min(asDouble(), new Element(attribute.getContext(1)).asDouble()))
.getAttribute(attribute.fulfill(1));
}

// <--[tag]
// @attribute <el@element.add_int[<#>]>
// @returns Element(Number)
// @group math
// @description
// Returns the element plus a number, using integer math.
// -->
if (attribute.startsWith("add_int")
Expand All @@ -1317,7 +1351,7 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <el@element.div[<#>]>
// @returns Element(Decimal)
// @returns Element(Number)
// @group math
// @description
// Returns the element divided by a number.
Expand All @@ -1334,7 +1368,7 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <el@element.mul_int[<#>]>
// @returns Element(Decimal)
// @returns Element(Number)
// @group math
// @description
// Returns the element multiplied by a number.
Expand All @@ -1351,7 +1385,7 @@ public String getAttribute(Attribute attribute) {

// <--[tag]
// @attribute <el@element.sub_int[<#>]>
// @returns Element(Decimal)
// @returns Element(Number)
// @group math
// @description
// Returns the element minus a number.
Expand Down

0 comments on commit a5e1515

Please sign in to comment.