Gannnaja commited on
Commit
a9a03e3
·
verified ·
1 Parent(s): 8e624b0

Upload pages/index.js with huggingface_hub

Browse files
Files changed (1) hide show
  1. pages/index.js +112 -0
pages/index.js ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { useState, useEffect } from 'react'
2
+ import Header from '../components/Header'
3
+ import NationCard from '../components/NationCard'
4
+ import ResourcePanel from '../components/ResourcePanel'
5
+ import ActionButton from '../components/ActionButton'
6
+ import { FaIndustry, FaSeedling, FaMoneyBillWave, FaFistRaised } from 'react-icons/fa'
7
+
8
+ const NATIONS = [
9
+ { id: 1, name: 'Industrial Union', flagCode: 'us', population: 15000000 },
10
+ { id: 2, name: 'Agrarian Republic', flagCode: 'fr', population: 12000000 },
11
+ { id: 3, name: 'Mercantile Federation', flagCode: 'gb', population: 18000000 },
12
+ { id: 4, name: 'Military State', flagCode: 'ru', population: 20000000 },
13
+ ]
14
+
15
+ export default function Home() {
16
+ const [selectedNation, setSelectedNation] = useState(null)
17
+ const [resources, setResources] = useState({
18
+ food: 100,
19
+ industry: 100,
20
+ commerce: 100,
21
+ military: 100
22
+ })
23
+ const [year, setYear] = useState(1)
24
+ const [isRunning, setIsRunning] = useState(false)
25
+
26
+ useEffect(() => {
27
+ let interval
28
+ if (isRunning) {
29
+ interval = setInterval(() => {
30
+ setYear(prev => prev + 1)
31
+ setResources(prev => ({
32
+ food: Math.max(0, prev.food + Math.floor(Math.random() * 10) - 3),
33
+ industry: Math.max(0, prev.industry + Math.floor(Math.random() * 10) - 3),
34
+ commerce: Math.max(0, prev.commerce + Math.floor(Math.random() * 10) - 3),
35
+ military: Math.max(0, prev.military + Math.floor(Math.random() * 10) - 3),
36
+ }))
37
+ }, 2000)
38
+ }
39
+ return () => clearInterval(interval)
40
+ }, [isRunning])
41
+
42
+ const handleAction = (resource) => {
43
+ setResources(prev => ({
44
+ ...prev,
45
+ [resource]: prev[resource] + 10
46
+ }))
47
+ }
48
+
49
+ return (
50
+ <div className="min-h-screen bg-gray-50">
51
+ <Header />
52
+
53
+ <main className="container mx-auto p-4">
54
+ {!selectedNation ? (
55
+ <div>
56
+ <h2 className="text-xl font-bold mb-4">Choose Your Nation</h2>
57
+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">
58
+ {NATIONS.map(nation => (
59
+ <NationCard
60
+ key={nation.id}
61
+ nation={nation}
62
+ onSelect={setSelectedNation}
63
+ />
64
+ ))}
65
+ </div>
66
+ </div>
67
+ ) : (
68
+ <div>
69
+ <div className="flex justify-between items-center mb-4">
70
+ <h2 className="text-xl font-bold">{selectedNation.name}</h2>
71
+ <p className="text-gray-600">Year: {year}</p>
72
+ </div>
73
+
74
+ <ResourcePanel resources={resources} />
75
+
76
+ <div className="grid grid-cols-2 md:grid-cols-4 gap-4 mb-6">
77
+ <ActionButton
78
+ icon={<FaSeedling />}
79
+ label="Grow Food"
80
+ onClick={() => handleAction('food')}
81
+ />
82
+ <ActionButton
83
+ icon={<FaIndustry />}
84
+ label="Build Industry"
85
+ onClick={() => handleAction('industry')}
86
+ />
87
+ <ActionButton
88
+ icon={<FaMoneyBillWave />}
89
+ label="Develop Commerce"
90
+ onClick={() => handleAction('commerce')}
91
+ />
92
+ <ActionButton
93
+ icon={<FaFistRaised />}
94
+ label="Train Military"
95
+ onClick={() => handleAction('military')}
96
+ />
97
+ </div>
98
+
99
+ <div className="flex justify-center">
100
+ <button
101
+ onClick={() => setIsRunning(!isRunning)}
102
+ className={`px-6 py-3 rounded-lg ${isRunning ? 'bg-red-500 hover:bg-red-600' : 'bg-green-500 hover:bg-green-600'} text-white font-bold transition-colors`}
103
+ >
104
+ {isRunning ? 'Pause Simulation' : 'Start Simulation'}
105
+ </button>
106
+ </div>
107
+ </div>
108
+ )}
109
+ </main>
110
+ </div>
111
+ )
112
+ }