Skip to content

Commit

Permalink
Merge pull request #16 from TrinityUniversity/prestige2
Browse files Browse the repository at this point in the history
Prestige2
  • Loading branch information
jamestrinity authored May 6, 2024
2 parents b2f767b + fde4751 commit 4dfdee6
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 22 deletions.
2 changes: 1 addition & 1 deletion server/app/models/CodeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ object CodeGen extends App {
"com.mysql.cj.jdbc.Driver",
"jdbc:mysql://72.167.227.244:3306/hb_lewisclicker?user=hb_lcdb&password=c5dpy4wfgh6ogu2piu",

"/Users/joeya/Documents/compsci/Web Apps/group-projects-cookieclicker/server/app", //REPLACE WITH YOUR LOCAL FILE PATH TO APP
"C:/Users/wenig/Desktop/School_Stuff/WebApps/group-projects-cookieclicker/server/app/models", //REPLACE WITH YOUR LOCAL FILE PATH TO APP

"models", None, None, true, false
)
Expand Down
15 changes: 15 additions & 0 deletions server/app/views/clicker.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,17 @@ <h3>Papers: <span class="papers">800</span></h3>
<div class="overlay" id="overlay">
<div class="overlay-content">
<!-- Content of the overlay -->



<h3>Menu</h3>
<button onclick="closeOverlay()"><i class="fa-solid fa-x"></i>&nbsp; Close Menu</button>
<button onclick="window.location = '@routes.SaveStateController.getTopTenPlayers';"><i class="fa fa-list"></i>&nbsp; Leaderboard</button>
<button onclick="window.location = '@routes.UserController.login';"><i class="fa fa-user"></i>&nbsp; Log In</button>
<button onclick="closeOverlay()" id="doPrestige"> Prestige</button>

</div>

</div>


Expand Down Expand Up @@ -75,7 +81,9 @@ <h4>{{name}}</h4>
<div class = "text">
<p>PPC:<span class ="ppc">1</span></p>
<p>PPS:<span class ="pps">0</span></p>
<div style="display:none" id="ppDisplay"><p > PP on Prestige: <span class="pp"> 0</span> </p></div>
</div>

</div>
<div class = "rightnavbar">
<div id="upgradenavbutton">Upgrades</div>
Expand Down Expand Up @@ -104,4 +112,11 @@ <h4>{{name}}</h4>
}
</script>

<div style="display:none" id="ppCurrentDisplay"><p> Current PP: <span id="ppCurrentNumber"> 0</span> </p></div>
</div>


</body>
</html>

}
156 changes: 136 additions & 20 deletions server/public/JS/clicker.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@

import { powerUpIntervals, upgrades } from "./upgrades.js";
import { formatNumber } from "./format.js";
import { defaultSkills } from "./defaultValues.js";
import { defaultSkills, defaultValues } from "./defaultValues.js";




//im so sorry -n
let prestigeMultiplier = 8 //so it works when points are 0
let prestigeMultiplier = 1 //so it works when points are 0
let actualPrestigeMultiplier = 8

//gameState object
let gameState = {current_papers: 55150000, total_papers: 0, prestigePoints: 0, agCount:0, guCount:0, taCount: 0, ppc:1, pps: 0,}

//THIS GAME STATE IS 5 PAPERS OFF OF GETTING THE FIRST PRESTIGE POINT
let gameState = {current_papers: 10, total_papers_ever: 0, total_papers_current_prestige:999999999995, prestigePoints: 1, agCount:0, guCount:0, taCount: 0, apCount:0, raCount:0, ppc:999999999995, pps: 0,}



//grabs html sources for the papers
Expand All @@ -25,11 +30,17 @@ const bgm = new Audio('/versionedAssets/audio/bgm.mp3')
bgm.volume = 0.2



//grabs html sources for the ppc and pps
let ppcText = document.querySelector('.ppc')
let ppsText = document.querySelector('.pps')
let ppText = document.querySelector('.pp')

const prestigeButton = document.getElementById("doPrestige");
prestigeButton.addEventListener('click', function(){
doPrestige();
})

function clickPaper(event) {
//sfx
const click = new Audio('/versionedAssets/audio/click.wav')
Expand All @@ -38,6 +49,8 @@ function clickPaper(event) {
//updates papers
paperDisplay.innerHTML = formatNumber(gameState.current_papers += (gameState.ppc * (gameState.prestigePoints * prestigeMultiplier)))
//PAPERS UPDATE HERE
gameState.total_papers_current_prestige += (gameState.ppc * (gameState.prestigePoints * prestigeMultiplier));
gameState.total_papers_ever += (gameState.ppc * (gameState.prestigePoints * prestigeMultiplier));

//animation for click
const x = event.offsetX
Expand Down Expand Up @@ -66,6 +79,7 @@ function clickPaper(event) {

function buyUpgrade(upgrade) {

//skills
if (upgrade === 'GRADE_REAPER') {
if( defaultSkills[0].active === true && gameState.current_papers < 100000) return
let graderReaperGif = document.getElementById('lewisimg')
Expand All @@ -89,6 +103,8 @@ function buyUpgrade(upgrade) {
defaultSkills[1].active = false
skillTimer('Jam_Skate_Sesh')
}else{
//buy an upgrade

//finds the upgrade that matches the name
const matchedUpgrade = upgrades.find((up) =>{
if(up.name === upgrade)return up
Expand Down Expand Up @@ -129,6 +145,12 @@ function buyUpgrade(upgrade) {
//adds to count & level
matchedUpgrade.count++
matchedUpgrade.levelDisplay.innerHTML = matchedUpgrade.count

if (matchedUpgrade.name === 'AutoGrader') gameState.agCount++
if (matchedUpgrade.name === 'TA') gameState.taCount++
if (matchedUpgrade.name === 'GradeUp') gameState.guCount++
if (matchedUpgrade.name === 'AutoPaper') gameState.apCount++
if (matchedUpgrade.name === 'ResearchAssistant') gameState.raCount++

//checks to see if we are at a power-level interval
index = powerUpIntervals.indexOf(parseFloat(matchedUpgrade.levelDisplay.innerHTML))
Expand Down Expand Up @@ -168,18 +190,17 @@ const timeout= (div) => {

//updates the game state every 100ms
setInterval(() => {

gameState.current_papers += ((gameState.pps / 10) * (gameState.prestigePoints * prestigeMultiplier))
gameState.current_papers += ((gameState.pps / 10) * (gameState.prestigePoints * prestigeMultiplier));
gameState.total_papers_current_prestige += ((gameState.pps / 10) * (gameState.prestigePoints * prestigeMultiplier));
gameState.total_papers_ever += ((gameState.pps / 10) * (gameState.prestigePoints * prestigeMultiplier));
//PAPERS ADDED
//once you hit 1 million papers, start accumulating prestige points

if(gameState.current_papers >=1000000000000){ //this will change to papers across the prestige, easier to test rn with current
doPrestigeStuff();
if(gameState.total_papers_current_prestige >=1000000000000){ //this will change to papers across the prestige, easier to test rn with current
calculatePrestige();
}
paperDisplay.innerHTML = formatNumber(gameState.current_papers)
ppsText.innerHTML = formatNumber(gameState.pps)
ppcText.innerHTML = formatNumber(gameState.ppc)

bgm.play()
}, 100)

Expand All @@ -201,21 +222,116 @@ upgradeNavBTN.addEventListener('click', function(){

})

function doPrestigeStuff(){

//calculates prestige points
gameState.prestigePoints = Math.round(Math.log10(gameState.current_papers))-11
//log10 of a trillion is 11.something, rounds it so at 1 trillion u have one prestige point

//puts prestige multiplies in effect
prestigeMultiplier = actualPrestigeMultiplier
//display prestige thing
document.getElementById("ppDisplay").style.display="flex"
ppText.innerHTML = formatNumber(gameState.prestigePoints)
function calculatePrestige(){
document.getElementById("ppDisplay").style.display="flex" //shows points u would get if u prestiged
ppText.innerHTML = formatNumber(Math.round(Math.log10(gameState.total_papers_current_prestige))-11)
}

function doPrestige(){
if((Math.round(Math.log10(gameState.total_papers_current_prestige))-11) < 1){
alert("You would not gain any points if you prestiged right now");
} else{
//log10 of a trillion is 11.something, rounds it so at 1 trillion u have one prestige point

prestigeMultiplier = actualPrestigeMultiplier//turns prestige multiplier on
gameState.prestigePoints += Math.round(Math.log10(gameState.total_papers_current_prestige))-11 //gives prestige points
gameState.total_papers_current_prestige = 0; //resets papers on prestige
gameState.current_papers = 0; //resets current papers
document.getElementById("ppCurrentDisplay").style.display="flex" //shows current prestige points
document.getElementById("ppCurrentNumber").innerHTML = formatNumber(gameState.prestigePoints - 1);
ppText.innerHTML = 0
document.getElementById("ppDisplay").style.display = "none"

gameState.agCount = 0;
gameState.taCount = 0;
gameState.guCount = 0;
gameState.apCount = 0;
gameState.raCount = 0;

assignUpgrades('AutoGrader');
assignUpgrades('TA', 1);
assignUpgrades('GradleUpdate', 2);
assignUpgrades('AdjunctProfessor', 3);
assignUpgrades('RollerskatingAssistance', 4);

}
}


//sets all upgrades, ppc/pps, and html to be off of the counts
function assignUpgrades(upgrade, index){

const matchedUpgrade = upgrades.find((up) =>{
if(up.name === upgrade)return up
})
console.log(matchedUpgrade)
if (matchedUpgrade.name === 'AutoGrader'){
console.log("AutoGrader found " + "ag count is " + gameState.agCount)
if (gameState.agCount === 0){
console.log("AutoGrader begins to reset")
gameState.ppc = 1
ppcText.innerHTML = 1

//update html to show that it is reset
//reset level
matchedUpgrade.levelDisplay.innerHTML = 0
matchedUpgrade.level = 0
//reset cost
matchedUpgrade.cost = 10
matchedUpgrade.costDisplay.innerHTML = 10
matchedUpgrade.costmultiplier = 1.07
//reset rate
matchedUpgrade.rate = 1
matchedUpgrade.rateDisplay.innerHTML = 1
matchedUpgrade.papermultiplier = 1.03
//reset count
matchedUpgrade.count = 0;
} else{
gameState.ppc = gameState.agCount * defaultValues[0].rate
ppcText.innerHTML = gameState.ppc

matchedUpgrade.levelDisplay.innerHTML = gameState.agCount
matchedUpgrade.level = gameState.agCount

matchedUpgrade.cost = defaultValues[0].cost
}
}else{

if (matchedUpgrade.name === "TA") matchedUpgrade.count = gameState.taCount
if (matchedUpgrade.name === "GradleUpdate") matchedUpgrade.count = gameState.taCount
if (matchedUpgrade.name === "AdjunctProfessor") matchedUpgrade.count = gameState.taCount
if (matchedUpgrade.name === "RollerskatingAssistance") matchedUpgrade.count = gameState.taCount
const nextlevelPara = document.getElementById(`${matchedUpgrade.name}nextp`)
console.log(matchedUpgrade.count)

//update html to show that it is reset
//reset level
matchedUpgrade.levelDisplay.innerHTML = matchedUpgrade.count
matchedUpgrade.level = matchedUpgrade.count
//reset cost
if (matchedUpgrade.count != 0 ){
matchedUpgrade.cost = matchedUpgrade.count*defaultValues[index].cost
matchedUpgrade.rate = matchedUpgrade.count * defaultValues[index].rate
gameState.pps += (matchedUpgrade.count * matchedUpgrade.rate)
}
else{ //if 0 count
console.log("setting cost to " + defaultValues[index].cost)
matchedUpgrade.cost = defaultValues[index].cost
matchedUpgrade.rate = defaultValues[index].rate
gameState.pps = 0
}

matchedUpgrade.costDisplay.innerHTML = matchedUpgrade.cost
//reset rate

matchedUpgrade.rateDisplay.innerHTML = defaultValues[index].rate
nextlevelPara.innerHTML = `+${matchedUpgrade.rate} papers per second`

}

ppsText.innerHTML = gameState.pps
ppcText.innerHTML = gameState.ppc
}

window.clickPaper = clickPaper
window.buyUpgrade = buyUpgrade
Expand Down
2 changes: 1 addition & 1 deletion server/public/stylesheets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ body {
border-top-left-radius: 10px;
align-items: center;
justify-content: space-between;
width: 330px;
width: 500px;
height: 60px;
padding: 10px 20px;
margin-bottom: 20px;
Expand Down

0 comments on commit 4dfdee6

Please sign in to comment.