1
0
Fork 0
mirror of https://github.com/Acamaeda/The-Modding-Tree.git synced 2024-11-24 17:31:50 +00:00

Brought things up to some minimal standard of usability

This commit is contained in:
Acamaeda 2020-09-24 17:46:57 -04:00
parent b55185d96c
commit e876386729
4 changed files with 96 additions and 27 deletions

View file

@ -132,10 +132,11 @@
<br><br>
<span v-if="layer!='c'">Your best {{layers[layer].resource}} is {{formatWhole(player[layer].best)}}<br></span>
<span v-if="player[layer].total">You have made a total of {{formatWhole(player[layer].total)}} {{layers[layer].resource}}<br></span>
<div v-if="layer=='aefaf'">
<div v-if="layers[layer].milestones">
<table>
<tr v-if="milestoneShown(player.c.best.gte(8))"><td v-bind:class="{ milestone: player.c.best.lt(8)&&player.c.best.lt(1)&&player.c.best.lt(1), milestoneDone: player.c.best.gte(8)||player.c.best.gte(1)||player.c.best.gte(1) }"><h3>8 Boosters</h3><br>Keep Prestige Upgrades on reset</td></tr>
<tr v-if="milestoneShown(player.c.best.gte(15))"><td v-bind:class="{ milestone: player.c.best.lt(15), milestoneDone: player.c.best.gte(15) }"><h3>15 Boosters</h3><br>You can buy max Boosters</td></tr>
<tr v-for="id in Object.keys(layers[layer].milestones)">
<div><td v-if="milestoneShown(layer, id)" v-bind:class="{milestone: !player[layer].milestones.includes(id), milestoneDone: player[layer].milestones.includes(id)}"><h3>{{layers[layer].milestones[id].requirementDesc}}</h3><br>{{layers[layer].milestones[id].effectDesc}}<br><span v-if="(layers[layer].milestones[id].toggles)&&(player[layer].milestones.includes(id))" v-for="toggle in layers[layer].milestones[id].toggles"><button class="smallUpg can" v-bind:style="{'background-color': layers[toggle[0]].color}" v-on:click="toggleAuto(toggle)">{{player[toggle[0]][toggle[1]]?"ON":"OFF"}}</button>&nbsp;</span></td></tr>
</tr>
</table>
</div>
<br><br>

View file

@ -171,7 +171,7 @@ function format(decimal, precision=3) {
var slog = decimal.slog()
if (slog.gte(1e6)) return "F" + format(slog.floor())
else return Decimal.pow(10, slog.sub(slog.floor())).toStringWithDecimalPlaces(3) + "F" + commaFormat(slog.floor(), 0)
} else if (decimal.gte("1e1000")) return "e"+formatWhole(decimal.log10())
} else if (decimal.gte("1e1000")) return (Math.floor(decimal.mantissa) + formatWhole("e"+formatWhole(decimal.log10())))
else if (decimal.gte(1e9)) return exponentialFormat(decimal, precision)
else if (decimal.gte(1e3)) return commaFormat(decimal, 0)
else return commaFormat(decimal, precision)
@ -253,14 +253,19 @@ function layerUnl(layer) {
}
function rowReset(row, layer) {
switch(row) {
case 0:
player.points = new Decimal(0);
break;
for (lr in ROW_LAYERS[row]){
console.log(lr)
if(layers[lr].doReset)
layers[lr].doReset(layer)
else
if(layers[layer].row > layers[lr].row) fullLayerReset(lr)
}
}
function fullLayerReset(layer) {
player[layer] = layers[layer].startData();
}
function addPoints(layer, gain) {
player[layer].points = player[layer].points.add(gain).max(0)
player[layer].best = player[layer].best.max(player[layer].points)
@ -303,8 +308,9 @@ function doReset(layer, force=false) {
}
prevOnReset = {...player} //Deep Copy
if (row == 0) rowReset(0, layer)
else for (let x = row; x >= 1; x--) rowReset(x, layer)
player.points = (row == 0 ? new Decimal(0) : new Decimal(10))
for (let x = row; x >= 0; x--) rowReset(x, layer)
prevOnReset = undefined
updateTemp()
@ -368,13 +374,14 @@ function resetRow(row) {
player[layers[layer]].unl = false
if (player[layers[layer]].order) player[layers[layer]].order = 0
}
player.points = new Decimal(10)
updateTemp();
resizeCanvas();
}
function toggleAuto(layer, end="") {
player[layer]["auto"+end] = !player[layer]["auto"+end]
function toggleAuto(toggle) {
player[toggle[0]][toggle[1]] = !player[toggle[0]][toggle[1]]
}
@ -407,13 +414,16 @@ function adjustMSDisp() {
player.msDisplay = displays[(displays.indexOf(player.msDisplay)+1)%4]
}
function milestoneShown(complete, auto=false) {
function milestoneShown(layer, id) {
complete = player[layer].milestones.includes(id)
auto = layers[layer].milestones[id].toggles
switch(player.msDisplay) {
case "always":
return true;
break;
case "automation":
return auto||!complete
return (auto)||!complete
break;
case "incomplete":
return !complete
@ -448,6 +458,13 @@ function toNumber(x) {
return x
}
function updateMilestones(layer){
for (id in layers[layer].milestones){
if (!(player[layer].milestones.includes(id)) && layers[layer].milestones[id].done())
player[layer].milestones.push(id)
}
}
function addTime(diff, layer) {
let data = player
let time = data.timePlayed
@ -490,7 +507,10 @@ function gameLoop(diff) {
for (layer in layers){
if (layers[layer].automate) layers[layer].automate();
}
for (layer in layers){
if (layers[layer].milestones) updateMilestones(layer);
}
if (player.hasNaN&&!NaNalert) {

View file

@ -5,6 +5,8 @@ var layers = {
points: new Decimal(0),
best: new Decimal(0),
upgrades: [],
milestones: [],
beep: false,
}},
color: "#4BEC13",
requires() {return new Decimal(10)}, // Can be a function that takes requirement increases into account
@ -34,6 +36,19 @@ var layers = {
eff = layer.c.effect();
return "which are boosting waffles by "+format(eff.waffleBoost)+" and increasing the Ice Cream cap by "+format(eff.icecreamCap)
},
milestones: {
0: {requirementDesc: "3 Lollipops",
done() {return player.c.best.gte(3)},
effectDesc: "Makes this green",
},
1: {requirementDesc: "4 Lollipops",
done() {return player.c.best.gte(4)},
effectDesc: "You can toggle beep and boop (which do nothing)",
toggles: [
["c", "beep"], // Each toggle is defined by a layer and the data toggled for that layer
["f", "boop"]],
}
},
upgrades: {
rows: 1,
cols: 3,
@ -65,6 +80,9 @@ var layers = {
}
},
},
doReset(layer){
if(layers[layer].row > layers["c"].row) fullLayerReset('c') // This is actually the default behavior
},
convertToDecimal() {
// Convert any layer-specific values (besides points, total, and best) to Decimal
},
@ -79,29 +97,31 @@ var layers = {
resetsNothing() {return false},
incr_order: [], // Array of layer names to have their order increased when this one is first unlocked
},
f: {
startData() { return {
unl: false,
points: new Decimal(0),
best: new Decimal(0),
boop: false,
}},
color: "#FE0102",
requires() {return new Decimal(200)}, // Can be a function that takes requirement increases into account
resource: "butts", // Name of prestige currency
baseResource: "points", // Name of resource prestige is based on
requires() {return new Decimal(200)},
resource: "things",
baseResource: "points",
baseAmount() {return player.points},
type: "normal", // normal: cost to gain currency depends on amount gained. static: cost depends on how much you already have
exponent: 0.5, // Prestige currency exponent
resCeil: false, // True if the resource needs to be rounded up
type: "normal",
exponent: 0.5,
resCeil: false,
gainMult() {
mult = new Decimal(1)
return new Decimal(1)
},
gainExp() {
return new Decimal(1)
},
row: 1,
effect() {return},
layerShown() {return true}, // Condition for when layer appears
layerShown() {return true},
resetsNothing() {return false},
branches: [["c", 1]] // Each pair corresponds to a line added to the tree when this node is unlocked. The letter is the other end of the line, and the number affects the color, 1 is default
},
@ -111,7 +131,7 @@ function layerShown(layer){
return layers[layer].layerShown();
}
const LAYERS = Object.keys(layers);
var LAYERS = Object.keys(layers);
var ROW_LAYERS = {}
for (layer in layers){
@ -121,3 +141,14 @@ for (layer in layers){
ROW_LAYERS[row][layer]=layer;
}
function addLayer(layerName, layerData){ // Call this to add layers from a different file!
layers[name] = layerData
LAYERS = Object.keys(layers);
ROW_LAYERS = {}
for (layer in layers){
row = layers[layer].row
if(!ROW_LAYERS[row]) ROW_LAYERS[row] = {}
ROW_LAYERS[row][layer]=layer;
}
}

View file

@ -5,7 +5,9 @@ var layers = {
points: new Decimal(0),
best: new Decimal(0),
upgrades: [],
milestones: [],
challs: [],
beep:false,
}},
color: "#4BEC13",
requires() {return new Decimal(10)}, // Can be a function that takes requirement increases into account
@ -66,6 +68,20 @@ var layers = {
}
},
},
milestones: {
0: {requirementDesc: "3 Lollipops",
done() {return player.c.best.gte(3)},
effectDesc: "Makes this green",
},
1: {requirementDesc: "4 Lollipops",
done() {return player.c.best.gte(4)},
effectDesc: "You can toggle beep and boop (which do nothing)",
toggles: [
["c", "beep"], // Each toggle is defined by a layer and the data toggled for that layer
["f", "boop"]
],
}
},
challs: {
rows: 1,
cols: 1,
@ -101,6 +117,7 @@ var layers = {
unl: false,
points: new Decimal(0),
best: new Decimal(0),
boop: false,
}},
color: "#FE0102",
requires() {return new Decimal(200)},
@ -111,7 +128,7 @@ var layers = {
exponent: 0.5,
resCeil: false,
gainMult() {
mult = new Decimal(1)
return new Decimal(1)
},
gainExp() {
return new Decimal(1)