Skip to content

Commit

Permalink
Fix money generation and UI duplication
Browse files Browse the repository at this point in the history
Updated the game logic to ensure players receive $1 every 3 seconds. Resolved the issue causing duplicate top bars in the Plinko, Towers, and Mines pages.
[skip gpt_engineer]
  • Loading branch information
lovable-dev[bot] committed Sep 26, 2024
1 parent b100b54 commit 7f67cfb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
17 changes: 17 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@ const App = () => {
setIsLoading(false);
}, []);

useEffect(() => {
if (user) {
const interval = setInterval(() => {
setUser(prevUser => {
const updatedUser = {
...prevUser,
balance: prevUser.balance + 1
};
localStorage.setItem('user', JSON.stringify(updatedUser));
return updatedUser;
});
}, 3000);

return () => clearInterval(interval);
}
}, [user]);

if (isLoading) {
return <LoadingScreen />;
}
Expand Down
2 changes: 0 additions & 2 deletions src/pages/Mines.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useEffect } from 'react';
import { Button } from "@/components/ui/button";
import Header from '../components/Header';

const Mines = () => {
const [user, setUser] = useState(JSON.parse(localStorage.getItem('user')));
Expand Down Expand Up @@ -87,7 +86,6 @@ const Mines = () => {

return (
<div className="min-h-screen bg-darkBlue text-white flex flex-col">
<Header user={user} />
<div className="flex-1 p-8 flex">
<div className="w-1/3 pr-4">
<div className="bg-darkBlue-lighter rounded-lg p-6 mb-8">
Expand Down
2 changes: 0 additions & 2 deletions src/pages/Plinko.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useEffect, useRef } from 'react';
import { Button } from "@/components/ui/button";
import Header from '../components/Header';

const Plinko = () => {
const [user, setUser] = useState(JSON.parse(localStorage.getItem('user')));
Expand Down Expand Up @@ -67,7 +66,6 @@ const Plinko = () => {

return (
<div className="min-h-screen bg-darkBlue text-white flex flex-col">
<Header user={user} />
<div className="flex-1 p-8 flex">
<div className="w-1/3 pr-4">
<div className="bg-darkBlue-lighter rounded-lg p-6 mb-4">
Expand Down
2 changes: 0 additions & 2 deletions src/pages/Towers.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState, useEffect } from 'react';
import { Button } from "@/components/ui/button";
import Header from '../components/Header';

const difficultySettings = {
easy: { levels: 4, successRate: 0.7, multiplier: 1.2 },
Expand Down Expand Up @@ -89,7 +88,6 @@ const Towers = () => {

return (
<div className="min-h-screen bg-darkBlue text-white flex flex-col">
<Header user={user} />
<div className="flex-1 p-8 flex">
<div className="w-1/3 pr-4">
<div className="bg-darkBlue-lighter rounded-lg p-6 mb-8">
Expand Down

0 comments on commit 7f67cfb

Please sign in to comment.