Bläddra i källkod

Update GameCreationForm to allow urban option

Kirk Trombley 5 år sedan
förälder
incheckning
2a2a22e41d
2 ändrade filer med 12 tillägg och 4 borttagningar
  1. 11 4
      client/src/components/util/GameCreationForm.jsx
  2. 1 0
      client/src/domain/genMethods.js

+ 11 - 4
client/src/components/util/GameCreationForm.jsx

@@ -5,7 +5,7 @@ import Loading from "./Loading";
 import Button from "./Button";
 import { createGame } from "../../domain/apiMethods";
 import Dropdown from "./Dropdown";
-import { MAP_CRUNCH, RANDOM_STREET_VIEW } from "../../domain/genMethods";
+import { MAP_CRUNCH, RANDOM_STREET_VIEW, URBAN } from "../../domain/genMethods";
 
 const Container = styled.div`
   display: flex;
@@ -39,6 +39,8 @@ export default ({ afterCreate }) => {
     return <Loading/>
   }
 
+  const invalidCombo = genMethod === URBAN && onlyAmerica;
+
   const onCreateGame = async () => {
     setLoading(true);
     const gameId = await createGame(timer, rounds, onlyAmerica, genMethod);
@@ -85,14 +87,19 @@ export default ({ afterCreate }) => {
           options={{
             "Map Crunch": MAP_CRUNCH,
             "Random Street View": RANDOM_STREET_VIEW,
+            "Urban Centers": URBAN,
           }}
           onChange={setGenMethod}
         >
-          Generator: {genMethod === MAP_CRUNCH ? "Map Crunch" : "RSV" }
+          Generator: {
+            genMethod === MAP_CRUNCH ? "Map Crunch" : 
+            genMethod === RANDOM_STREET_VIEW ? "RSV" :
+            "Urban Centers"
+          }
         </Dropdown>
       </DropdownContainer>
-      <StartButton onClick={onCreateGame}>
-        New Game
+      <StartButton onClick={onCreateGame} disabled={invalidCombo}>
+        { invalidCombo ? "Incompatible Options" : "New Game" }
       </StartButton>
     </Container>
   );

+ 1 - 0
client/src/domain/genMethods.js

@@ -1,2 +1,3 @@
 export const MAP_CRUNCH = "MAPCRUNCH"
 export const RANDOM_STREET_VIEW = "RANDOMSTREETVIEW"
+export const URBAN = "URBAN"