|
1 | 1 | import React, {SyntheticEvent, useState} from 'react' |
2 | 2 | import './App.css' |
3 | 3 | import {Board, Faction, Run} from './Board.ts' |
4 | | -import {Consumable, PowerupCtr} from "./components/Powerup.tsx"; |
| 4 | +import {Consumable, KindDescriptions, PowerupCtr} from "./components/Powerup.tsx"; |
5 | 5 | import {RandomShop} from "./Shop.tsx"; |
6 | 6 | import LeaderJSX from "./components/Leader.tsx"; |
7 | | -import {Cell} from "./Cell.ts"; |
| 7 | +import {Cell, Kind} from "./Cell.ts"; |
8 | 8 | import {CellItem} from "./components/CellItem.tsx"; |
9 | 9 | import Header from "./components/Header.tsx"; |
| 10 | +import Share from "./components/Share.tsx"; |
| 11 | +import {Party} from "./flavour.ts"; |
| 12 | +import "@radix-ui/themes/styles.css"; |
| 13 | +import {Theme} from "@radix-ui/themes"; |
10 | 14 |
|
11 | | -const singleRun = new Run(42069); |
| 15 | +const singleRun = new Run(555); |
12 | 16 | const baseBoard = new Board(singleRun); |
13 | 17 |
|
14 | 18 | export enum Stage { |
@@ -106,78 +110,92 @@ function App() { |
106 | 110 | "--faction-NAT": singleRun.parties[Faction.NAT].color + opacity, |
107 | 111 | } |
108 | 112 |
|
| 113 | + const kinds = Object.values(singleRun.modifiers.generation.kindShare) |
| 114 | + const parties = Object.values(singleRun.parties).filter((party: Party) => party.order <= singleRun.getCurrentLevel.factions); |
109 | 115 |
|
110 | 116 | return ( |
111 | 117 | <> |
112 | | - <div onKeyDown={expandKeyboard} tabIndex={0} style={injectCSS}> |
113 | | - |
114 | | - <div id="bleed"></div> |
115 | | - {stage === Stage.Game && |
116 | | - <div> |
117 | | - <div id={"GB"}> |
118 | | - <div className={selectTiles ? 'gb-selection' : ''} |
119 | | - id={"GB-inner"} |
120 | | - style={{ |
121 | | - display: 'grid', |
122 | | - grid: `repeat(${singleRun.getCurrentLevel.size},40px) / repeat(${singleRun.getCurrentLevel.size},40px)` |
123 | | - }}> |
124 | | - {baseBoard.map((cell, i) => { |
125 | | - return (<CellItem key={i} cell={cell} click={onClickCell}> |
126 | | - {cell.owned ? '×' : cell.faction} |
127 | | - </CellItem>) |
128 | | - })} |
129 | | - <div className={"sourceHighlight"} style={{ |
130 | | - "--sh-top": baseBoard.origin[0] * 40 + "px", |
131 | | - "--sh-left": (baseBoard.origin[1]) * 40 + "px", |
132 | | - "--sh-bottom": (baseBoard.w - baseBoard.origin[0] - 1) * 40 + "px", |
133 | | - "--sh-right": (baseBoard.h - baseBoard.origin[1] - 1) * 40 + "px", |
134 | | - "--sh-bg": singleRun.parties[baseBoard.getOrigin.faction].color |
135 | | - }}></div> |
136 | | - </div> |
137 | | - |
138 | | - </div> |
139 | | - <div className="center"> |
140 | | - <div className="card"> |
141 | | - {Object.values(singleRun.parties) |
142 | | - .filter((party, i) => party.order <= singleRun.getCurrentLevel.factions) |
143 | | - .map((party, i) => { |
144 | | - return <div className={"populismActivator-outer"}> |
145 | | - <button className={"populismActivator"} |
146 | | - style={{background: party.color}} |
147 | | - onClick={() => expand(Faction[party.faction] as Faction)} |
148 | | - > |
149 | | - {party.name}, |
150 | | - {i},{party.weight} |
151 | | - |
152 | | - </button> |
153 | | - </div> |
| 118 | + <Theme> |
| 119 | + <div onKeyDown={expandKeyboard} tabIndex={0} style={injectCSS}> |
| 120 | + |
| 121 | + <div id="bleed"></div> |
| 122 | + {stage === Stage.Game && |
| 123 | + <div> |
| 124 | + <div id={"GB"}> |
| 125 | + <Share shares={kinds.map(sh => sh.weight)} |
| 126 | + desc={kinds.map(sh => sh.description || "")} |
| 127 | + colors={kinds.map(kind => kind.color)} |
| 128 | + text={kinds.map(kind => kind.icon)}/> |
| 129 | + <Share shares={parties.map(sh => sh.weight)} |
| 130 | + colors={parties.map(party => party.color)} |
| 131 | + text={parties.map(sh => sh.name)}/> |
| 132 | + |
| 133 | + <div className={selectTiles ? 'gb-selection' : ''} |
| 134 | + id={"GB-inner"} |
| 135 | + style={{ |
| 136 | + display: 'grid', |
| 137 | + grid: `repeat(${singleRun.getCurrentLevel.size},40px) / repeat(${singleRun.getCurrentLevel.size},40px)` |
| 138 | + }}> |
| 139 | + {baseBoard.map((cell, i) => { |
| 140 | + return (<CellItem key={i} cell={cell} click={onClickCell}> |
| 141 | + {cell.owned ? '×' : cell.faction} |
| 142 | + </CellItem>) |
154 | 143 | })} |
| 144 | + <div className={"sourceHighlight"} style={{ |
| 145 | + "--sh-top": baseBoard.origin[0] * 40 + "px", |
| 146 | + "--sh-left": (baseBoard.origin[1]) * 40 + "px", |
| 147 | + "--sh-bottom": (baseBoard.w - baseBoard.origin[0] - 1) * 40 + "px", |
| 148 | + "--sh-right": (baseBoard.h - baseBoard.origin[1] - 1) * 40 + "px", |
| 149 | + "--sh-bg": singleRun.parties[baseBoard.getOrigin.faction].color |
| 150 | + }}></div> |
| 151 | + </div> |
155 | 152 |
|
156 | 153 | </div> |
| 154 | + <div className="center"> |
| 155 | + <div className="card"> |
| 156 | + {Object.values(singleRun.parties) |
| 157 | + .filter((party, i) => party.order <= singleRun.getCurrentLevel.factions) |
| 158 | + .map((party, i) => { |
| 159 | + return <div className={"populismActivator-outer"}> |
| 160 | + <button className={"populismActivator"} |
| 161 | + style={{background: party.color}} |
| 162 | + onClick={() => expand(Faction[party.faction] as Faction)} |
| 163 | + > |
| 164 | + {party.name}, |
| 165 | + {i},{party.weight} |
| 166 | + |
| 167 | + </button> |
| 168 | + </div> |
| 169 | + })} |
| 170 | + |
| 171 | + </div> |
| 172 | + </div> |
157 | 173 | </div> |
| 174 | + } |
| 175 | + <div className="powerupCtr"> |
| 176 | + Powerups<br/> |
| 177 | + { |
| 178 | + powerup ? <PowerupDescription/> : singleRun.powerups.map(((consumable, i) => { |
| 179 | + return consumable.button({ |
| 180 | + onSelect: () => { |
| 181 | + onClickPowerup(consumable, i) |
| 182 | + } |
| 183 | + }) |
| 184 | + })) |
| 185 | + } |
158 | 186 | </div> |
159 | | - } |
160 | | - <div className="powerupCtr"> |
161 | | - Powerups<br/> |
| 187 | + <LeaderJSX run={singleRun}/> |
| 188 | + <Header stage={stage} run={singleRun} board={baseBoard}/> |
| 189 | + |
162 | 190 | { |
163 | | - powerup ? <PowerupDescription/> : singleRun.powerups.map(((consumable, i) => { |
164 | | - return consumable.button({ |
165 | | - onSelect: () => { |
166 | | - onClickPowerup(consumable, i) |
167 | | - } |
168 | | - }) |
169 | | - })) |
| 191 | + stage === Stage.Shop && <> |
| 192 | + {singleRun.powerups.length} / {singleRun.modifiers.powerups.max} Powerup Slots |
| 193 | + <RandomShop run={singleRun} setCount={setCount} nextStage={nextStage}/> |
| 194 | + </> |
170 | 195 | } |
171 | | - </div> |
172 | | - <LeaderJSX run={singleRun}/> |
173 | | - <Header stage={stage} run={singleRun} board={baseBoard}/> |
174 | | - |
175 | | - {stage === Stage.Shop && <> |
176 | | - {singleRun.powerups.length} / {singleRun.modifiers.powerups.max} Powerup Slots |
177 | | - <RandomShop run={singleRun} setCount={setCount} nextStage={nextStage}/> |
178 | | - </>} |
179 | 196 |
|
180 | | - </div> |
| 197 | + </div> |
| 198 | + </Theme> |
181 | 199 | </> |
182 | 200 | ) |
183 | 201 | } |
|
0 commit comments