Browse Source

add constants and form items necessary for gun game

Kirk Trombley 3 years ago
parent
commit
3fa0db8e14

+ 6 - 0
client/src/components/screens/Lobby/Lobby.jsx

@@ -17,6 +17,7 @@ import {
   NIGHTMARE,
   RAMP,
   RAMP_HARD,
+  GUN_GAME,
 } from "../../../domain/constants";
 
 export const GameInfo = () => {
@@ -82,6 +83,11 @@ export const GameInfo = () => {
           You will not be able to adjust your view
         </span>
       )}
+      {gameMode === GUN_GAME && (
+        <span className={styles.label}>
+          You will need to score over 4000 points to progress through each round
+        </span>
+      )}
       {roundPointCap && (
         <span className={styles.label}>
           Only {roundPointCap} total points will be up for grabs each round

+ 19 - 0
client/src/components/util/GameCreationForm/GameCreationForm.jsx

@@ -14,6 +14,8 @@ import {
   NIGHTMARE,
   RAMP,
   RAMP_HARD,
+  GUN_GAME,
+  DIFFICULTY_TIERED,
 } from "../../../domain/constants";
 import useCountryLookup from "../../../hooks/useCountryLookup";
 import Loading from "../Loading";
@@ -64,6 +66,11 @@ const PRESETS = {
     clockMode: RACE,
     scoreMethod: RAMP,
   },
+  GUN_GAME: {
+    ...DEFAULTS,
+    gameMode: GUN_GAME,
+    generationMethod: DIFFICULTY_TIERED,
+  },
 };
 
 export const LastSettingsButton = ({ onClick }) => (
@@ -189,6 +196,9 @@ const GameCreationForm = ({ afterCreate, lastSettings = null }) => {
           <Item value={PRESETS.BOOTLEG_GG_DUEL} display="⭐">
             Legally Distinct from Geoguessr Duels
           </Item>
+          <Item value={PRESETS.GUN_GAME} display="⭐">
+            Gun Game
+          </Item>
         </Dropdown>
         {lastSettings && (
           <LastSettingsButton onClick={() => setPreset(lastSettings)} />
@@ -212,6 +222,9 @@ const GameCreationForm = ({ afterCreate, lastSettings = null }) => {
             <Item value={3600} display={ms(60 * 60 * 1000)}>
               1 Hour
             </Item>
+            <Item value={7 * 24 * 3600} display={ms(7 * 24 * 60 * 60 * 1000)}>
+              &quot;Limitless&quot; (1 Week)
+            </Item>
           </Dropdown>
           <Dropdown selected={rounds} onSelect={setRounds} open="rounds">
             <Item value={1}>1 Round</Item>
@@ -230,6 +243,9 @@ const GameCreationForm = ({ afterCreate, lastSettings = null }) => {
             <Item value={URBAN} display="🏙️">
               Urban Centers
             </Item>
+            <Item value={DIFFICULTY_TIERED} display="🎲">
+              Difficulty Tiered
+            </Item>
           </Dropdown>
           <CountryDropdown
             countryLookup={countryLookup}
@@ -244,6 +260,9 @@ const GameCreationForm = ({ afterCreate, lastSettings = null }) => {
             <Item value={FROZEN} display="❄️">
               Frozen
             </Item>
+            <Item value={GUN_GAME} display="🔫">
+              Gun Game
+            </Item>
           </Dropdown>
           <Dropdown
             selected={clockMode}

+ 2 - 0
client/src/domain/constants.js

@@ -9,11 +9,13 @@ export const ERROR = "ERROR"; // Error state
 // Generation Methods
 export const RANDOM_STREET_VIEW = "RANDOMSTREETVIEW";
 export const URBAN = "URBAN";
+export const DIFFICULTY_TIERED = "DIFFICULTY_TIERED";
 
 // Game Config Options
 export const NORMAL = "NORMAL";
 export const TIME_BANK = "TIMEBANK";
 export const FROZEN = "FROZEN";
+export const GUN_GAME = "GUN_GAME";
 export const RACE = "RACE";
 export const COUNTRY_RACE = "COUNTRYRACE";
 export const DISTANCE = "DISTANCE";

+ 4 - 0
server/app/point_gen/__init__.py

@@ -124,6 +124,10 @@ class PointStore:
         In the event that the configured source cannot reasonably supply enough points,
         most likely due to time constraints, this will raise an ExhaustedSourceError.
         """
+        # in the case of using the "difficulty tiered" generator there is some special logic
+        if config.generation_method == GenMethodEnum.diff_tiered:
+            # TODO - actually implement this, for now just fail
+            raise ExhaustedSourceError
         try:
             point_tasks = [self.get_point(config.generation_method, config.country_lock) for _ in range(config.rounds)]
             gathered = asyncio.gather(*point_tasks)

+ 2 - 0
server/app/schemas.py

@@ -11,11 +11,13 @@ CountryCode = constr(to_lower=True, min_length=2, max_length=2)
 class GenMethodEnum(str, Enum):
     rsv = "RANDOMSTREETVIEW"
     urban = "URBAN"
+    diff_tiered = "DIFFICULTY_TIERED"
 
 
 class GameModeEnum(str, Enum):
     normal = "NORMAL"
     frozen = "FROZEN"
+    gun_game = "GUN_GAME"
 
 
 class ClockModeEnum(str, Enum):