oh-my-dear-ai commited on
Commit
8c9e35f
·
1 Parent(s): b64d569

[opt] del feeble

Browse files
Files changed (1) hide show
  1. app.py +39 -33
app.py CHANGED
@@ -246,34 +246,40 @@ with gr.Blocks(css=css) as demo:
246
  info="Select a strategy:",
247
  )
248
 
249
- def show_plant_boxes(currency, acquisition_rate):
250
- # Update the state variable
251
-
 
 
 
 
 
 
 
252
  inventory = {}
253
  species_set = set()
254
  species_count = 0
255
  for _, row in df.iterrows():
256
  # Check if the plant should be shown based on the selected currency
257
- if row[currency] != 0:
258
- if acquisition_rate == 0 or row["tier"] != "feeble":
259
- species_set.add(row["species"])
260
- # Create the Number component for the plant inventory
261
- inventory[f"{row['species']}_{row['tier']}"] = gr.Number(
262
- label=PLANTS_LABLES[row["species"]],
263
- info=f"{PLANTS_TIERS[row['tier']]} ${row[currency]}",
264
- value=0,
265
- precision=0,
266
- minimum=0,
267
- maximum=500,
268
- step=10,
269
- visible=True,
270
- elem_classes=(
271
- f"first-{currency}-box"
272
- if len(species_set) > species_count
273
- else None
274
- ),
275
- )
276
- species_count = len(species_set)
277
  else:
278
  # If not shown, create a dummy invisible component
279
  inventory[f"{row['species']}_{row['tier']}"] = gr.Number(visible=False)
@@ -283,7 +289,7 @@ with gr.Blocks(css=css) as demo:
283
 
284
  # Create the dynamic plant inventory inputs
285
  with gr.Row() as inventory_row:
286
- inventory = show_plant_boxes(currency_radio.value, acquisition_rate.value)
287
 
288
  # Add a row for the Clear and Calculate buttons
289
  with gr.Row():
@@ -308,20 +314,20 @@ with gr.Blocks(css=css) as demo:
308
  # Update the inventory when the currency changes
309
  currency_radio.change(
310
  fn=lambda selected_currency, hva_rate: show_plant_boxes(
311
- selected_currency, hva_rate
312
  ), # Adjusted function to return only the components
313
- inputs=[currency_radio, acquisition_rate],
314
  outputs=inventory, # Update each child in the inventory_row
315
  )
316
 
317
  # Update the inventory when the acquisition rate changes
318
- acquisition_rate.change(
319
- fn=lambda selected_currency, hva_rate: show_plant_boxes(
320
- selected_currency, hva_rate
321
- ), # Adjusted function to return only the components
322
- inputs=[currency_radio, acquisition_rate],
323
- outputs=inventory, # Update each child in the inventory_row
324
- )
325
 
326
  # Launch the Gradio application
327
  demo.queue(api_open=False)
 
246
  info="Select a strategy:",
247
  )
248
 
249
+ # selected_plants = gr.CheckboxGroup(
250
+ # choices=list(PLANTS_LABLES.values()),
251
+ # type="index",
252
+ # label="Plants",
253
+ # info="Select plants:",
254
+ # value=list(PLANTS_LABLES.values()),
255
+ # interactive=True,
256
+ # )
257
+
258
+ def show_plant_boxes(currency):
259
  inventory = {}
260
  species_set = set()
261
  species_count = 0
262
  for _, row in df.iterrows():
263
  # Check if the plant should be shown based on the selected currency
264
+ if row[currency] != 0 and row["tier"] != "feeble":
265
+ species_set.add(row["species"])
266
+ # Create the Number component for the plant inventory
267
+ inventory[f"{row['species']}_{row['tier']}"] = gr.Number(
268
+ label=PLANTS_LABLES[row["species"]],
269
+ info=f"{PLANTS_TIERS[row['tier']]} ${row[currency]}",
270
+ value=0,
271
+ precision=0,
272
+ minimum=0,
273
+ maximum=500,
274
+ step=10,
275
+ visible=True,
276
+ elem_classes=(
277
+ f"first-{currency}-box"
278
+ if len(species_set) > species_count
279
+ else None
280
+ ),
281
+ )
282
+ species_count = len(species_set)
 
283
  else:
284
  # If not shown, create a dummy invisible component
285
  inventory[f"{row['species']}_{row['tier']}"] = gr.Number(visible=False)
 
289
 
290
  # Create the dynamic plant inventory inputs
291
  with gr.Row() as inventory_row:
292
+ inventory = show_plant_boxes(currency_radio.value)
293
 
294
  # Add a row for the Clear and Calculate buttons
295
  with gr.Row():
 
314
  # Update the inventory when the currency changes
315
  currency_radio.change(
316
  fn=lambda selected_currency, hva_rate: show_plant_boxes(
317
+ selected_currency
318
  ), # Adjusted function to return only the components
319
+ inputs=[currency_radio],
320
  outputs=inventory, # Update each child in the inventory_row
321
  )
322
 
323
  # Update the inventory when the acquisition rate changes
324
+ # acquisition_rate.change(
325
+ # fn=lambda selected_currency, hva_rate: show_plant_boxes(
326
+ # selected_currency, hva_rate
327
+ # ), # Adjusted function to return only the components
328
+ # inputs=[currency_radio, acquisition_rate],
329
+ # outputs=inventory, # Update each child in the inventory_row
330
+ # )
331
 
332
  # Launch the Gradio application
333
  demo.queue(api_open=False)