-
-
Save codemasher/46280bf95b3990bc54ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
YUI.add("hom-points", function(t){ | |
var n = t.Lang, e = t.namespace("hom"), o = function(t){ | |
return Math.max(0, Math.min(+t, 1)) | |
}; | |
e.Points = t.Base.create("Points", t.Base, [], { | |
initializer : function(){ | |
this.publish("valueChange", {emitFacade: !1, preventable: !1}), this.after([ | |
"devotionChange", | |
"fellowshipChange", | |
"honorChange", | |
"resilienceChange", | |
"valorChange" | |
], function(t){ | |
var n = this.get("total"); | |
n -= t.prevVal.total, n += t.newVal.total, this.set("total", Math.max(0, n)), this.fire("valueChange", t) | |
}, this) | |
}, update : function(t){ | |
var n = e.Points.parseBits(t); | |
return n ? (this.set("character", n), this.setAttrs(e.Points.parseObject(n)), void this.fire("updateSuccess", t)) : void this.fire("updateFailure", n === !1 ? !0 : !1) | |
}, getValues: function(t){ | |
return this.getAttrs(t || ["devotion", "fellowship", "honor", "resilience", "valor"]) | |
} | |
}, { | |
ATTRS : { | |
character : { | |
valueFn: function(){ | |
return HOM.character | |
} | |
}, | |
total : {value: 0, validator: n.isNumber}, | |
valor : {value: {total: 0, count: 0, destroyer: 0, tormented: 0}}, | |
honor : {value: {total: 0, count: 0, pvp: 0}}, | |
devotion : {value: {total: 0, count: 0, rare: 0, unique: 0}}, | |
fellowship: {value: {total: 0, count: 0, heroes: 0, pets: 0, rare: 0}}, | |
resilience: { | |
value: { | |
total : 0, | |
count : 0, | |
vabbian : 0, | |
obsidian : 0, | |
kurzick_luxon: 0 | |
} | |
} | |
}, parseBits: function(n){ | |
var e, o, r = (t.namespace("hom"), HOM.character), i = { | |
devotion : {}, | |
fellowship: {}, | |
honor : {}, | |
resilience: {}, | |
valor : {} | |
}, s = new t.Base64Codec(n); | |
if(0 === +n){ | |
return !1; | |
} | |
o = 0; | |
for(e in r.resilience){ | |
e.length ? i.resilience[e] = s.get(1) : s.get(1), o++; | |
} | |
s.get(32 - o), o = 0; | |
for(e in r.fellowship){ | |
e.length ? i.fellowship[e] = s.get(1) : s.get(1), o++; | |
} | |
s.get(32 - o), o = 0; | |
for(e in r.honor){ | |
e.length ? i.honor[e] = s.get(1) : s.get(1), o++; | |
} | |
s.get(64 - o), o = 0; | |
for(e in r.valor){ | |
e.length ? i.valor[e] = s.get(1) : s.get(1), o++; | |
} | |
return s.get(64 - o), i.devotion = { | |
common : s.get(7), | |
uncommon: s.get(7), | |
rare : s.get(7), | |
unique : s.get(7) | |
}, i | |
}, putBits : function(n){ | |
var e, o, r = (t.namespace("hom"), HOM.character), i = new t.Base64Codec(""); | |
o = 0; | |
for(e in r.resilience){ | |
i.put(n.resilience[e] || 0, 1), o++; | |
} | |
i.put(0, 32 - o), o = 0; | |
for(e in r.fellowship){ | |
i.put(n.fellowship[e] || 0, 1), o++; | |
} | |
i.put(0, 32 - o), o = 0; | |
for(e in r.honor){ | |
i.put(n.honor[e] || 0, 1), o++; | |
} | |
i.put(0, 64 - o), o = 0; | |
for(e in r.valor){ | |
i.put(n.valor[e] || 0, 1), o++; | |
} | |
return i.put(0, 64 - o), i.put(n.devotion.common || 0, 7), i.put(n.devotion.uncommon || 0, 7), i.put(n.devotion.rare || 0, 7), i.put(n.devotion.unique || 0, 7), i.putBoundary(), i.str | |
}, parseObject : function(n){ | |
var o = {}, r = 0; | |
return t.each(n, function(t, n){ | |
"function" == typeof e.Points[n + "Points"] && (o[n] = e.Points[n + "Points"](t), r += o[n].total) | |
}), t.merge(o, {total: r}) | |
}, devotionPoints : function(t){ | |
var n = 0, e = t.common + t.uncommon + t.rare + t.unique; | |
return e && n++, t.rare && n++, t.unique && n++, e >= 20 && (n += 2), e >= 30 && n++, e >= 40 && n++, e >= 50 && n++, { | |
possible: HOM.cols.details.devotion.total, | |
total : n, | |
count : e, | |
rare : t.rare, | |
unique : t.unique | |
} | |
}, fellowshipPoints : function(n){ | |
var e, o = HOM.rules.items.fellowship, r = 0, i = 0, s = 0, u = 0, a = 0; | |
for(e in n){ | |
n.hasOwnProperty(e) && n[e] && (e == o.pet ? s++ : -1 != t.Array.indexOf(o.rare, e) ? (a = 1, s++) : u++); | |
} | |
return i = u + s, u && r++, s && r++, a && r++, i >= 5 && (r += 2), i >= 10 && r++, i >= 20 && r++, i >= 30 && r++, { | |
possible: HOM.cols.details.fellowship.total, | |
total : r, | |
count : i, | |
heroes : u, | |
pets : s, | |
rare : a | |
} | |
}, honorPoints : function(n){ | |
var e, o, r = HOM.rules.items.honor, i = 3, s = 0, u = 0; | |
for(e in n){ | |
n.hasOwnProperty(e) && n[e] && (o || -1 == t.Array.indexOf(r.codex_commander, e) || (o = !0, u++), -1 != t.Array.indexOf(r.pvp, e) && u++, s++); | |
} | |
return s && (i += 2), u && (i += 3), s >= 5 && (i += 3), s >= 10 && i++, s >= 15 && i++, s >= 20 && i++, s >= 25 && i++, s >= 30 && i++, s >= 35 && i++, s >= 40 && i++, { | |
possible: HOM.cols.details.honor.total, | |
total : i, | |
count : s, | |
pvp : u | |
} | |
}, resiliencePoints : function(n){ | |
var e, o = HOM.rules.items.resilience, r = 0, i = 0, s = 0, u = 0, a = 0; | |
for(e in n){ | |
n.hasOwnProperty(e) && n[e] && (i++, -1 != t.Array.indexOf(o.vabbian, e) ? s = 1 : -1 != t.Array.indexOf(o.obsidian, e) ? u = 1 : -1 != t.Array.indexOf(o.kurzick_luxon, e) && (a = 1)); | |
} | |
return i && r++, i >= 3 && r++, i >= 5 && (r += 2), i >= 7 && r++, a && r++, s && r++, u && r++, { | |
possible : HOM.cols.details.resilience.total, | |
total : r, | |
count : i, | |
vabbian : s, | |
obsidian : u, | |
kurzick_luxon: a | |
} | |
}, valorPoints : function(n){ | |
var e, o, r = HOM.rules.items.valor, i = 0, s = 0, u = 0, a = 0; | |
for(o in n){ | |
n.hasOwnProperty(o) && n[o] && (-1 != t.Array.indexOf(r.destroyer, o) ? s++ : -1 != t.Array.indexOf(r.tormented, o) ? u++ : -1 != t.Array.indexOf(r.oppressor, o) && a++); | |
} | |
return e = s + u + a, e && i++, s && i++, u && i++, a && i++, e >= 5 && i++, e >= 11 && (i += 2), e >= 15 && i++, { | |
possible : HOM.cols.details.valor.total, | |
total : i, | |
count : e, | |
destroyer: s, | |
tormented: u, | |
oppressor: a | |
} | |
} | |
}), e.points = new e.Points, e.rules = { | |
valor : [ | |
{ | |
points: 1, test: function(t){ | |
return o(t.count >= 1) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.destroyer >= 1) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.tormented >= 1) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.oppressor >= 1) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 5) | |
} | |
}, { | |
points: 2, test: function(t){ | |
return o(t.count / 11) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 15) | |
} | |
} | |
], honor : [ | |
{ | |
points: 3, test: function(){ | |
return o(!0) | |
} | |
}, { | |
points: 2, test: function(t){ | |
return o(t.count >= 1) | |
} | |
}, { | |
points: 3, test: function(t){ | |
return o(t.pvp >= 1) | |
} | |
}, { | |
points: 3, test: function(t){ | |
return o(t.count / 5) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 10) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 15) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 20) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 25) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 30) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 35) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 40) | |
} | |
} | |
], devotion : [ | |
{ | |
points: 1, test: function(t){ | |
return o(t.count >= 1) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.rare >= 1) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.unique >= 1) | |
} | |
}, { | |
points: 2, test: function(t){ | |
return o(t.count / 20) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 30) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 40) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 50) | |
} | |
} | |
], fellowship: [ | |
{ | |
points: 1, test: function(t){ | |
return o(t.heroes >= 1) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.pets >= 1) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.rare >= 1) | |
} | |
}, { | |
points: 2, test: function(t){ | |
return o(t.count / 5) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 10) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 20) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 30) | |
} | |
} | |
], resilience: [ | |
{ | |
points: 1, test: function(t){ | |
return o(t.count >= 1) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 3) | |
} | |
}, { | |
points: 2, test: function(t){ | |
return o(t.count / 5) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.count / 7) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.kurzick_luxon) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.vabbian) | |
} | |
}, { | |
points: 1, test: function(t){ | |
return o(t.obsidian) | |
} | |
} | |
] | |
} | |
}, "@VERSION@", {requires: ["base", "arena-base64"]}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment