Skip to content

Commit

Permalink
Merge pull request #36 from minidogg/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
minidogg authored Mar 26, 2024
2 parents c7d51c9 + edff26a commit 1c131d3
Show file tree
Hide file tree
Showing 14 changed files with 197 additions and 42 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# warehouse-inc
# Warehouse INC
An online clicker game worked on by a bunch of my friends in a discord server.

# Hosts
Expand Down
1 change: 1 addition & 0 deletions log.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Logging stuff for better collab
15 changes: 14 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,27 @@
<link rel="stylesheet" href="stylesheets/save.css">
<link rel="stylesheet" href="stylesheets/menu.css">
<link rel="stylesheet" href="stylesheets/notification.css">
<link rel="stylesheet" href="stylesheets/popup.css">
<link rel="icon" type="image/x-icon" href="src\images\favicon.ico">
</head>

<body>
<div id="coverDiv"></div>

<div id="popup">
<h1 id="popupHeader">Sussy baka?</h1>
<div id="popupHtml">
<input type="text" placeholder="Maybe?" style="width:100%;">
</div>
<button id="popupSubmit">Submit</button>
</div>

<div class="leftContainer">
<!-- some stuff related to collecting resources -->
<h1 id="companyName" class="coolFade">Loading...</h1>
<div class="resourcesContainer">
<span style="width:100%;">
<p id="realResourceCount" class="coolFade">Total Sugar: 0</p>
<p id="resourceCount" class="coolFade">Sugar Ready For Collecting: 0</p>
<button id="clickButton" onclick="showNotification('You collected your sugar!', 1000)">Collect Sugar</button>

Expand All @@ -54,7 +65,6 @@ <h1 id="companyName" class="coolFade">Loading...</h1>
<div class="buyContainer">
<h1 id="companyName" class="coolFade">Warehouse Store</h1>
<div class="upgradebuttons">

</div>
</div>

Expand Down Expand Up @@ -92,6 +102,9 @@ <h1 id="companyName" class="coolFade">Warehouse Store</h1>
<!-- This should always be the last script/element here -->
<script>
render.render()
setInterval(()=>{
render.render()
},20)
</script>


Expand Down
3 changes: 3 additions & 0 deletions src/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ var game = {version:version}
function addProperty(obj,property,value){
if(!obj.hasOwnProperty(property))obj[property]=value
}
function removeProperty(obj, property){
if(obj.hasOwnProperty(property))delete obj[property]
}

//slightly unrelated but its cool.
document.getElementById("coverDiv").classList.add("coverDivAnimate")
45 changes: 37 additions & 8 deletions src/scripts/name.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,49 @@
// generates a random name for your warehouse :3
function randomName() {
var nameAdjs = ['Tired', 'High', 'Hungry', 'Agitated', 'Excited', 'Grumpy', 'Sleepy', 'Angry', 'Bored'];
var nameNouns = ['Cartel Leader', 'Addict', 'Mafia Boss', 'Discord Moderator', 'Internet Troll', 'Slacker', 'Loser', 'Scammer'];
addProperty(game, "name", nameAdjs[Math.floor(Math.random() * nameAdjs.length)] + ' ' + nameNouns[Math.floor(Math.random() * nameNouns.length)])
var goldenNames = ["Sugar Smuggling Minor", "Unlucky Crafter", "Code Mob", "Shadow Dev", "Really Bad Dev", "Abstract Melon"]
async function randomName(overwrite=false) {
const nameAdjs = ['Tired', 'High', 'Hungry', 'Agitated', 'Excited', 'Grumpy', 'Sleepy', 'Angry', 'Bored', 'Thirsty', 'Extremely High', 'Illegal', 'Scamming', 'Scammed', 'Screaming', 'Drug Promoting', 'Your Friendly',"Sugar Smuggling"];
const nameNouns = ['Cartel Leader', 'Addict', 'Mafia Boss', 'Discord Moderator', 'Internet Troll', 'Slacker', 'Loser', 'Scammer', 'Karen', 'Drug Lord', 'Mother', 'Minor', 'Crack Addict',"Mafia"];
const creatorNameAdjs = ['Unlucky', 'Code', 'Shadow', 'Really Bad', 'Abstract'];
const creatorNameNouns = ['Crafter', 'Mob', 'Dev', 'Melon'];


var name = 'this shouldn\'t be your name and if it does then something probably went wrong';
if (Math.random() > 0.075) {
name = nameAdjs[Math.floor(Math.random() * nameAdjs.length)] + ' ' + nameNouns[Math.floor(Math.random() * nameNouns.length)]
} else {
let mode = Math.floor(Math.random() * 3);
if (mode == 0) {
name = creatorNameAdjs[Math.floor(Math.random() * creatorNameAdjs.length)] + ' ' + nameNouns[Math.floor(Math.random() * nameNouns.length)]
} else if (mode == 1) {
name = nameAdjs[Math.floor(Math.random() * nameAdjs.length)] + ' ' + creatorNameNouns[Math.floor(Math.random() * creatorNameNouns.length)]
} else if (mode == 2) {
name = creatorNameAdjs[Math.floor(Math.random() * creatorNameAdjs.length)] + ' ' + creatorNameNouns[Math.floor(Math.random() * creatorNameNouns.length)]
}
}

if (overwrite) removeProperty(game, "name");
addProperty(game, "name", name);
addProperty(game, "goldenName", goldenNames.includes(name));


saving.save()
}
render.renderFunctions.push(() => {
document.getElementById('companyName').textContent = game.name + "'s Warehouse"

if(game.goldenName==true)document.getElementById('companyName').style.color = "gold"
})

// todo: update this to an actual prompt
document.getElementById('companyName').onclick = () => {
game.name = prompt("Name?")
render.render()
document.getElementById('companyName').onclick = async () => {
const name = await showPrompt("Company Name","Unluckycrafter",100);
if (!name) {
randomName(true);
} else {
game.name = name;
}
render.render();
}


window.addEventListener("load", randomName)
randomName()
26 changes: 12 additions & 14 deletions src/scripts/resources.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,33 @@
addProperty(game, "sugar", 0);
addProperty(game, "collectableSugar", 0);
addProperty(game, "multiplier", 1);
addProperty(game, "productionspeed", 1000)

var sugar = {};

sugar.updateSugarCount = () => {
document.getElementById("resourceCount").textContent = "Sugar Ready For Collecting: " + FormatNumbers(game.sugar.toString());
document.getElementById("resourceCount").textContent = "Sugar Ready For Collecting: " + game.collectableSugar
document.getElementById("realResourceCount").textContent = "Sugar: " + game.sugar
}

sugar.startSugarGeneration = () => {
setInterval(() => {
game.sugar += game.multiplier;
sugar.updateSugarCount();
game.collectableSugar += game.multiplier;
}, game.productionspeed);
}

sugar.showNotification = (message) => {
const notificationElement = document.getElementById("notification");
notificationElement.textContent = message;
notificationElement.classList.add("notification-show");
render.renderFunctions.push(()=>{
sugar.updateSugarCount();
})


setTimeout(() => {
notificationElement.classList.remove("notification-show");
}, 3000); // Adjust the duration here (in milliseconds)
}

sugar.collectSugar = () => {
game.resourcesCollected = game.sugar;
game.sugar = 0;
showNotification("You collected " + game.collectableSugar + " sugar!");

game.sugar= game.sugar + game.collectableSugar;
game.collectableSugar = 0;
sugar.updateSugarCount();
// sugar.showNotification("You collected " + game.resourcesCollected + " sugar!"); this will not be in here melon
}

document.getElementById("clickButton").addEventListener("click", () => {
Expand Down
25 changes: 16 additions & 9 deletions src/scripts/save.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//saving system code will go here.
//saving system code will go here.stringify
var saving = {}

saving.save = () => {
Expand All @@ -19,7 +19,7 @@ saving.loadSave = () => {

saving.resetSave = () => {
// todo: Make this into an actual popup instead of basic alerts
if (prompt("Are you sure you want to reset you save and lose all progress? Type 'yes' to confirm")) {
if (prompt("Are you sure you want to reset your save and lose all progress? Type 'yes' to confirm").toString() == 'yes') {
game.autoSave = false
document.getElementById("coverDiv").classList.remove("coverDivAnimate")
setTimeout(() => {
Expand All @@ -34,12 +34,19 @@ saving.loadSave()

saving.autoSave = () => {
console.log("Auto saving")

if (game.autoSave == true) saving.save()

setTimeout(() => { saving.autoSave() }, game.autoSaveRate)

if (game.autoSave == true) {
saving.save();
}else{
return
}
setTimeout(() => {
document.querySelector('.save-icon').style.display = 'block';
}, 500);
document.querySelector('.save-icon').style.display = 'none';
setTimeout(() => { saving.autoSave() }, game.autoSaveRate);
}

addProperty(game, "autoSaveRate", 1000)
addProperty(game, "autoSave", true)
saving.autoSave()
addProperty(game, "autoSaveRate", 1000);
addProperty(game, "autoSave", true);
saving.autoSave();
49 changes: 49 additions & 0 deletions src/scripts/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,52 @@ function colorLog(text,color="lime",fontSize="15px"){
}

document.body.scrollTop = document.body.scrollHeight;

const genRanHex = size => [...Array(size)].map(() => Math.floor(Math.random() * 16).toString(16)).join('');

showNotification = (message) => {
const notificationElement = document.getElementById("notification");
notificationElement.textContent = message;
notificationElement.classList.add("notification-show");

setTimeout(() => {
notificationElement.classList.remove("notification-show");
}, 3000); // Adjust the duration here (in milliseconds)
}


document.querySelector("#popup").classList.add("popupClose")

showPopup = (title,html,callback)=>{
document.querySelector("#popup").classList.remove("popupClose")
document.querySelector("#popupHeader").textContent = title
document.querySelector("#popupHtml").innerHTML = ""
document.querySelector("#popupHtml").appendChild(html)

let thisCallback = (ev)=>{
callback(ev)
document.querySelector("#popup").classList.add("popupClose")
}

document.body.querySelector("#popupSubmit").onclick = thisCallback
document.querySelector("#popup").onkeydown = (ev)=>{

if(ev.key=="Enter"){
thisCallback()
}

}
}
showPrompt = async (title,placeholder="",maxLen=-1)=>{
return await new Promise((resolve, reject) => {
let input = document.createElement("input")
input.type = "text"
input.placeholder = placeholder
input.maxLength = maxLen
input.style.width = "100%"

showPopup(title,input,()=>{
resolve(input.value)
})
})
}
15 changes: 15 additions & 0 deletions src/stylesheets/input.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,19 @@ button:active {
position: absolute;
bottom: 15px;
right: 10px;
}

input[type="text"] {
all:unset;
color:black;

border:none;

background-color: #218cff;
font-size: 2vmin;
border-radius:1vmin;

text-align: center;

padding:10px;
}
8 changes: 0 additions & 8 deletions src/stylesheets/menu.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,6 @@
color: white;

display: grid;
grid-template-columns: repeat(auto-fit, 1fr);
grid-template-rows: 1fr;
grid-column-gap: 0px;
grid-row-gap: 0px;

max-height: 5vh;
height:5vh;
overflow-y: scroll;

border: black solid 2px;
}
Expand Down
1 change: 1 addition & 0 deletions src/stylesheets/misc.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
margin-top: 0vh;
padding: 1vh 0;
background-color: #333;
cursor: pointer;
}

/* New style for #name */
Expand Down
34 changes: 34 additions & 0 deletions src/stylesheets/popup.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#popup{
background-color: gray;
z-index: 10000;
position: fixed;
top:20vh;
left:70vh;


width:fit-content;
height: fit-content;
padding: 2vmin;



border-radius: 10px;

transition:top 0.5s ease-in-out;
}

#popupSubmit{
display:block;
margin:auto;

margin-top:10px;
}

#popupHeader{
text-align: center;
font-size:5vmin;
}

.popupClose{
top: 110vh!important;;
}
10 changes: 10 additions & 0 deletions src/stylesheets/resources.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@

text-align: center;

}
#realResourceCount{
font-size: 2.5vmin!important;

color:white;
width:25vw;
margin-left:2.5vw;

text-align: center;

}
#clickButton{
margin-top:0.5vh;
Expand Down
5 changes: 4 additions & 1 deletion src/stylesheets/save.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
width: 100px;
height: 100px;
position: absolute;
bottom: 10px;
bottom: 1vh;
left: 10px;
background-image: url("https://github.com/minidogg/warehouse-inc/blob/dev/src/images/save-icon.png?raw=true");
background-size: 100px;
animation-name: spin;
animation-duration: 1s;
animation-iteration-count: infinite;
animation-timing-function: linear;
display: none;

transition:bottom 0.5s;
}

@keyframes spin {
Expand Down

0 comments on commit 1c131d3

Please sign in to comment.