Hi there! I'm @NextDev2, and like my pfp suggests, I code... a lot.
We make web apps (VueJS stock trading game shown right here)
<script setup>
import { ref, onMounted, onBeforeUnmount } from "vue";
let Companies = ["🥽Goggle", "🟩Macrohard", "🍊Orange", "🎥NetPix", "📺MePipe"];
let Stories = [
//hope these are good
{
text: "Goggle misses out on huge partnership opportunity 😔",
impact: -100,
company: 0,
},
{
text: "Macrohard accused of being monopolist with CSCode ⚖️",
impact: -25,
company: 1,
},
{
text: "MePipe gains traction after deal with NetPix 🚀",
impact: 200,
company: 4,
weight: 3,
},
{
text: "NetPix nearly bought by Orange--stocks crash historically 📉",
impact: -400,
company: 3,
},
{ text: "Users unhappy with Orange's jOS update 👎", impact: -50, company: 2 },
{ text: "Goggle releases ironOS Bob--stocks soar 🚀", impact: 300, company: 0 },
{
text: "Macrohard releases cutting-edge browser--users can't be happier 😃",
impact: 100,
company: 1,
},
{ text: "MePipe sued for user surveillance ⚖️", impact: -500, company: 4, weight: 1 },
{ text: "NetPix recovers with a new blockbuster series 📈", impact: 500, company: 3 },
{
text: "Orange announces major innovation--investors excited 🌟",
impact: 300,
company: 2,
},
{
text: 'MePipe creator goes viral after "DOGEDOGEDOGE" drops🐶',
impact: 250,
company: 4,
weight: 2,
},
{
text: 'MePipe wins lawsuit against its "endless scroll" technique',
impact: 500,
company: 4,
weight: 3,
},
];
let Stocks = ref([13600, 24200, 14650, 8001, 1]);
let currentStory = ref("");
let investmentTip = ref("");
let newsHistory = ref([]);
let userBalance = ref(236343); // Initial balance
let userPortfolio = ref({
"🥽Goggle": 2,
"🟩Macrohard": 2,
"🍊Orange": 3,
"🎥NetPix": 5,
"📺MePipe": 2,
});
function ChooseStory() {
let totalWeight = Stories.reduce((sum, story) => sum + (story.weight || 1), 0);
let randomWeight = Math.random() * totalWeight;
for (let i = 0; i < Stories.length; i++) {
if (randomWeight < (Stories[i].weight || 1)) {
return i;
}
randomWeight -= Stories[i].weight || 1;
}
return Stories.length - 1; // Fallback in case of rounding errors
}
function SetStocks() {
let i = ChooseStory();
currentStory.value = Stories[i].text;
newsHistory.value.push(currentStory.value); // Add current story to news history
let companyIndex = Stories[i].company;
let impact = Stories[i].impact;
// Update stock value
Stocks.value[companyIndex] = Math.max(Stocks.value[companyIndex] + impact, 1);
}
function buyStock(company, index) {
if (userBalance.value >= Stocks.value[index] && Stocks.value[index] > 1) {
userPortfolio.value[company] = (userPortfolio.value[company] || 0) + 1;
userBalance.value -= Stocks.value[index];
}
}
function sellStock(company, index) {
if (userPortfolio.value[company] > 0) {
userPortfolio.value[company]--;
userBalance.value += Stocks.value[index];
}
}
function provideInvestmentTip() {
let bestCompany = Companies.reduce(
(best, company, index) => {
if (Stocks.value[index] < Stocks.value[best.index] && Stocks.value[index] > 1) {
return { company, index };
}
return best;
},
{ company: Companies[0], index: 0 }
);
if (Stocks.value[bestCompany.index] > 1) {
investmentTip.value = `Consider investing in ${bestCompany.company} - their stock is currently undervalued!`;
} else {
investmentTip.value = `No investment recommendations at this time.`;
}
}
// Automatic news rotation, investment tips, and market corrections
let newsInterval;
let tipInterval;
onMounted(() => {
newsInterval = setInterval(SetStocks, 5000); // Change every 5 seconds
tipInterval = setInterval(provideInvestmentTip, 10000); // Change every 10 seconds
});
onBeforeUnmount(() => {
clearInterval(newsInterval);
clearInterval(tipInterval);
});
// Initialize the stocks and story
SetStocks();
provideInvestmentTip();
</script>
<template>
<div>
<h1>Welcome to VueGopoly!</h1>
<hr />
<h2>The companies of this small Stock Trade are shown here</h2>
<div class="stocks-container">
<div v-for="(company, index) in Companies" :key="index" class="stock-item">
<h3>{{ company }}: ${{ Stocks[index] }}</h3>
<h3 v-if="Stocks[index] <= 1">BANKRUPT</h3>
<button
@click="buyStock(company, index)"
:disabled="userBalance < Stocks[index] || Stocks[index] <= 1"
>
Buy
</button>
<button
@click="sellStock(company, index)"
:disabled="userPortfolio[company] <= 0"
>
Sell
</button>
</div>
</div>
<hr />
<h4>Investment Tip</h4>
<p>{{ investmentTip }}</p>
<hr />
<h4>Breaking News!</h4>
<p>{{ currentStory }}</p>
<hr />
<h4>Your Portfolio</h4>
<p>Balance: ${{ userBalance }}</p>
<div v-for="(count, company) in userPortfolio" :key="company">
<h3>{{ company }}: {{ count }} shares</h3>
</div>
<hr />
</div>
</template>
<style>
div {
font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS", sans-serif;
}
.stocks-container {
display: flex;
flex-wrap: wrap;
}
.stock-item {
flex: 1 1 45%; /* Adjust as needed for spacing */
margin: 10px;
}
</style>
and games (in progress) with C++ and SDL2.
Find me mostly in Chess Universe (link here: https://www.chess.com/club/chess-universe)
and I wish to see you there!