Added barebones build class
This commit is contained in:
parent
f6e68a74b8
commit
21ef3d59ff
4 changed files with 151 additions and 31 deletions
|
@ -1 +1,4 @@
|
|||
Hello!
|
||||
#Hello!
|
||||
##We don't have a name for this project yet
|
||||
###Nor have we publicly released it.
|
||||
Authors: **hppeng** and **ferricles**
|
||||
|
|
127
build.js
127
build.js
|
@ -1,29 +1,102 @@
|
|||
//Turns the input amount of skill points into a 3-decimal precision percentage.
|
||||
function skillPointsToPercentage(skp){
|
||||
if (skp<=0){
|
||||
return 0.0;
|
||||
}else if(skp>=150){
|
||||
return 0.808;
|
||||
}else{
|
||||
return(-0.0000000066695* Math.pow(Math.E, -0.00924033 * skp + 18.9) + 1.0771);
|
||||
//return(-0.0000000066695* Math.pow(Math.E, -0.00924033 * skp + 18.9) + 1.0771).toFixed(3);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 151; i++) {
|
||||
console.log(i, ", ",skillPointsToPercentage(i));
|
||||
}
|
||||
|
||||
|
||||
/*Class that represents a wynn player's build.
|
||||
*/
|
||||
class Build{
|
||||
constructor(helmet,chestplate,leggings,boots,ring1,ring2,bracelet,necklace,level){
|
||||
this.helmet = helmet;
|
||||
this.chestplate = chestplate;
|
||||
this.leggings = leggings;
|
||||
this.boots = boots;
|
||||
this.ring1 = ring1;
|
||||
this.ring2 = ring2;
|
||||
this.bracelet = bracelet;
|
||||
this.necklace = necklace;
|
||||
this.level = level;
|
||||
item_fields = [ "name", "displayName", "tier", "set", "slots", "type", "armorType", "color", "lore", "material", "drop", "quest", "restrict", "nDam", "fDam", "wDam", "aDam", "tDam", "eDam", "atkSpd", "hp", "fDef", "wDef", "aDef", "tDef", "eDef", "lvl", "classReq", "strReq", "dexReq", "intReq", "agiReq", "defReq", "hprPct", "mr", "sdPct", "mdPct", "ls", "ms", "xpb", "lb", "ref", "str", "dex", "int", "agi", "def", "thorns", "expoding", "spd", "atkTier", "poison", "hpBonus", "spRegen", "eSteal", "hprRaw", "sdRaw", "mdRaw", "fDamPct", "wDamPct", "aDamPct", "tDamPct", "eDamPct", "fDefPct", "wDefPct", "aDefPct", "tDefPct", "eDefPct", "accessoryType", "fixID", "skin", "category", "spPct1", "spRaw1", "spPct2", "spRaw2", "spPct3", "spRaw3", "spPct4", "spRaw4", "rainbowRaw", "sprint", "sprintReg", "jh", "lq", "gXp", "gSpd" ];
|
||||
/*Turns the input amount of skill points into a float precision percentage.
|
||||
* @param skp - the integer skillpoint count to be converted
|
||||
*/
|
||||
static skillPointsToPercentage(skp){
|
||||
if (skp<=0){
|
||||
return 0.0;
|
||||
}else if(skp>=150){
|
||||
return 0.808;
|
||||
}else{
|
||||
return(-0.0000000066695* Math.pow(Math.E, -0.00924033 * skp + 18.9) + 1.0771);
|
||||
//return(-0.0000000066695* Math.pow(Math.E, -0.00924033 * skp + 18.9) + 1.0771).toFixed(3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Turns the input amount of levels into skillpoints available.
|
||||
*
|
||||
* @param level - the integer level count te be converted
|
||||
*/
|
||||
static levelToSkillPoints(level){
|
||||
if(level < 1){
|
||||
return 0;
|
||||
}else if(level >= 101){
|
||||
return 200;
|
||||
}else{
|
||||
return (level - 1) * 2;
|
||||
}
|
||||
}
|
||||
/*Construct a build.
|
||||
*/
|
||||
constructor(level,helmet,chestplate,leggings,boots,ring1,ring2,bracelet,necklace,weapon){
|
||||
if(helmet.type.valueOf() != "helmet".valueOf()){
|
||||
throw new TypeError("No such helmet named ", helmet.name);
|
||||
}else{
|
||||
this.helmet = helmet;
|
||||
}
|
||||
if(chestplate.type.valueOf() != "chestplate"){
|
||||
throw new TypeError("No such chestplate named ", chestplate.name);
|
||||
}else{
|
||||
this.chestplate = chestplate;
|
||||
}
|
||||
if(leggings.type.valueOf() != "leggings"){
|
||||
throw new TypeError("No such leggings named ", leggings.name);
|
||||
}else{
|
||||
this.leggings = leggings;
|
||||
}
|
||||
if(boots.type.valueOf() != "boots"){
|
||||
throw new TypeError("No such boots named ", boots.name);
|
||||
}else{
|
||||
this.boots = boots;
|
||||
}
|
||||
if(ring1.type.valueOf() != "rings"){
|
||||
throw new TypeError("No such ring named ", ring1.name);
|
||||
}else{
|
||||
this.ring1 = ring1;
|
||||
}
|
||||
if(ring2.type.valueOf() != "rings"){
|
||||
throw new TypeError("No such ring named ", ring2.name);
|
||||
}else{
|
||||
this.ring2 = ring2;
|
||||
}
|
||||
if(bracelet.type.valueOf() != "bracelet"){
|
||||
throw new TypeError("No such bracelet named ", bracelet.name);
|
||||
}else{
|
||||
this.bracelet = bracelet;
|
||||
}
|
||||
if(necklace.type.valueOf() != "necklace"){
|
||||
throw new TypeError("No such necklace named ", necklace.name);
|
||||
}else{
|
||||
this.necklace = necklace;
|
||||
}
|
||||
if(weapon.type.valueOf() == "wand" || weapon.type.valueOf() == "bow" || weapon.type.valueOf() == "dagger" || weapon.type.valueOf() == "spear" || weapon.type.valueOf() == "relik"){
|
||||
this.necklace = necklace;
|
||||
}else{
|
||||
throw new TypeError("No such weapon named ", weapon.name);
|
||||
}
|
||||
if(level < 1){ //Should these be constants?
|
||||
this.level = 1;
|
||||
}else if (level > 106){
|
||||
this.level = 106;
|
||||
}else{
|
||||
this.level = level;
|
||||
}
|
||||
this.skillpoints = levelToSkillPoints(this.level)
|
||||
}
|
||||
|
||||
/*Returns build in string format
|
||||
*/ TODO
|
||||
toString(){
|
||||
return this.helmet.name + ", " + this.chestplate.name + ", " + this.leggings.name + ", " + this.boots.name + ", " + this.ring1.name + ", " + this.ring2.name + ", " + this.bracelet.name + ", " + this.necklace.name + ", " + this.weapon.name;
|
||||
}
|
||||
|
||||
/* Getters */ TODO
|
||||
getHealth()
|
||||
/* Setters */ TODO
|
||||
|
||||
}
|
||||
|
||||
export{Build};
|
11
index.html
11
index.html
|
@ -111,10 +111,14 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="center" style="grid-column:3;grid-row:3">
|
||||
Calculate
|
||||
<button class = "button" id = "calc-button" onclick = "calculateBuild()">
|
||||
Calculate
|
||||
</button>
|
||||
</div>
|
||||
<div class="center" style="grid-column:4;grid-row:3">
|
||||
Reset
|
||||
<button class = "reset" id = "reset-button" onclick = "resetFields()">
|
||||
Reset
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="skillpoints">
|
||||
|
@ -140,6 +144,7 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
<script src="test.js"></script>
|
||||
<script type="module" src="build.js"></script>
|
||||
<script type="module" src="test.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
39
test.js
39
test.js
|
@ -1,3 +1,4 @@
|
|||
import {Build} from "./build.js"
|
||||
const DB_VERSION = 1;
|
||||
// @See https://github.com/mdn/learning-area/blob/master/javascript/apis/client-side-storage/indexeddb/video-store/index.js
|
||||
|
||||
|
@ -155,3 +156,41 @@ request.onupgradeneeded = function(e) {
|
|||
console.log("DB setup complete...");
|
||||
}
|
||||
|
||||
function calculateBuild(){
|
||||
//TODO: implement level changing
|
||||
let player_build = new Build(
|
||||
106,
|
||||
itemMap.get(document.getElementById("helmet-choice").value),
|
||||
itemMap.get(document.getElementById("chestplate-choice").value),
|
||||
itemMap.get(document.getElementById("leggings-choice").value),
|
||||
itemMap.get(document.getElementById("boots-choice").value),
|
||||
itemMap.get(document.getElementById("ring1-choice").value),
|
||||
itemMap.get(document.getElementById("ring2-choice").value),
|
||||
itemMap.get(document.getElementById("bracelet-choice").value),
|
||||
itemMap.get(document.getElementById("necklace-choice").value),
|
||||
itemMap.get(document.getElementById("weapon-choice").value),
|
||||
);
|
||||
console.log(player_build.toString())
|
||||
}
|
||||
|
||||
function resetFields(){
|
||||
document.getElementById("helmet-choice").value = "";
|
||||
document.getElementById("helmet-powder").value = "";
|
||||
document.getElementById("chestplate-choice").value = "";
|
||||
document.getElementById("chestplate-powder").value = "";
|
||||
document.getElementById("leggings-choice").value = "";
|
||||
document.getElementById("leggings-powder").value = "";
|
||||
document.getElementById("boots-choice").value = "";
|
||||
document.getElementById("boots-powder").value = "";
|
||||
document.getElementById("ring1-choice").value = "";
|
||||
document.getElementById("ring2-choice").value = "";
|
||||
document.getElementById("bracelet-choice").value = "";
|
||||
document.getElementById("necklace-choice").value = "";
|
||||
document.getElementById("weapon-choice").value = "";
|
||||
document.getElementById("weapon-powder").value = "";
|
||||
document.getElementById("str-skp").value = "";
|
||||
document.getElementById("dex-skp").value = "";
|
||||
document.getElementById("int-skp").value = "";
|
||||
document.getElementById("def-skp").value = "";
|
||||
document.getElementById("agi-skp").value = "";
|
||||
}
|
Loading…
Reference in a new issue