-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Modify game odds to 48.7% win and 52% lose. - Update Towers to have 10 rows. - Reduce spacing in Mines for closer layout. - Ensure Sidebar appears only once on stats/homepage. - Add a chatbox on the right side for user interaction, displaying username and profile picture (or first character if no picture). - Include a footer on every page with the text "Made by @darksplice on Discord" along with a Discord icon. [skip gpt_engineer]
- Loading branch information
1 parent
8e9653c
commit e819cc9
Showing
5 changed files
with
94 additions
and
28 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import { Input } from "@/components/ui/input"; | ||
import { Button } from "@/components/ui/button"; | ||
|
||
const ChatBox = () => { | ||
const [messages, setMessages] = useState([]); | ||
const [newMessage, setNewMessage] = useState(''); | ||
const [user, setUser] = useState(JSON.parse(localStorage.getItem('user'))); | ||
|
||
useEffect(() => { | ||
// Simulating incoming messages | ||
const interval = setInterval(() => { | ||
const randomMessage = { | ||
username: `User${Math.floor(Math.random() * 1000)}`, | ||
message: `Random message ${Math.floor(Math.random() * 100)}`, | ||
timestamp: new Date().toLocaleTimeString(), | ||
}; | ||
setMessages(prev => [...prev, randomMessage].slice(-50)); // Keep last 50 messages | ||
}, 5000); | ||
|
||
return () => clearInterval(interval); | ||
}, []); | ||
|
||
const handleSendMessage = () => { | ||
if (newMessage.trim()) { | ||
const message = { | ||
username: user.username, | ||
message: newMessage, | ||
timestamp: new Date().toLocaleTimeString(), | ||
}; | ||
setMessages(prev => [...prev, message].slice(-50)); // Keep last 50 messages | ||
setNewMessage(''); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="w-1/4 bg-darkBlue-lighter p-4 overflow-hidden flex flex-col h-screen"> | ||
<h2 className="text-xl font-bold mb-4">Chat</h2> | ||
<div className="flex-grow overflow-y-auto mb-4"> | ||
{messages.map((msg, index) => ( | ||
<div key={index} className="mb-2"> | ||
<span className="font-bold">{msg.username}: </span> | ||
<span>{msg.message}</span> | ||
<span className="text-xs text-gray-400 ml-2">{msg.timestamp}</span> | ||
</div> | ||
))} | ||
</div> | ||
<div className="flex"> | ||
<Input | ||
type="text" | ||
value={newMessage} | ||
onChange={(e) => setNewMessage(e.target.value)} | ||
placeholder="Type a message..." | ||
className="flex-grow mr-2" | ||
/> | ||
<Button onClick={handleSendMessage}>Send</Button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ChatBox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters