Skip to content

Commit

Permalink
clean up some things
Browse files Browse the repository at this point in the history
  • Loading branch information
linomp committed Jul 12, 2024
1 parent 7ce9e28 commit a8bda86
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
7 changes: 5 additions & 2 deletions mvp/client/ui/src/components/MachineData.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -142,15 +142,18 @@
flex-direction: column;
gap: 1rem;
margin-top: 2em;
align-items: center; /* Center horizontally */
align-items: center;
width: 80%;
}
.message-card {
border-radius: 8px;
padding: 1em;
width: 80%;
width: 100%;
text-align: center;
border: 1px solid #ccc;
transition: opacity 0.3s;
font-size: smaller;
}
.message-card.WARNING {
Expand Down
2 changes: 1 addition & 1 deletion mvp/client/ui/src/components/SessionData.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
}
.highlight-funds {
color: #00da86;
color: #00b971;
font-weight: bold;
}
</style>
1 change: 0 additions & 1 deletion mvp/client/ui/src/pages/HomePage.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@
.game-area {
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
gap: 2em;
flex-wrap: wrap;
Expand Down
7 changes: 4 additions & 3 deletions mvp/server/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
# Financials
INITIAL_CASH = 0
REVENUE_PER_DAY = 20
MAINTENANCE_COST = 40
MAINTENANCE_COST = 50
SENSOR_COST = 30
PREDICTION_MODEL_COST = 50
DEMAND_PEAK_EVENT_PROBABILITY = 0.2
PREDICTION_MODEL_COST = 80
DEMAND_PEAK_EVENT_PROBABILITY = 0.25
DEMAND_PEAK_BONUS_MULTIPLIER = 2
11 changes: 5 additions & 6 deletions mvp/server/core/game/GameSession.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async def advance_one_turn(self) -> list[MachineState] | None:

# if there is a demand peak bonus up to this point, multiply the player cash for this turn!
if "demand_peak_bonus" in self.user_messages:
self.cash_multiplier = 2
self.cash_multiplier = DEMAND_PEAK_BONUS_MULTIPLIER

self.user_messages.pop("demand_peak_bonus", None)

Expand All @@ -101,22 +101,21 @@ async def advance_one_turn(self) -> list[MachineState] | None:
# Player earns money for the production at every timestep,
# proportional to the health of the machine (bad health = less efficient production)
self.available_funds += self.cash_multiplier * (
self.machine_state.health_percentage / 50) * REVENUE_PER_DAY / TIMESTEPS_PER_MOVE
self.machine_state.health_percentage / 60) * REVENUE_PER_DAY / TIMESTEPS_PER_MOVE

# Publish state every 2 steps (to reduce the load on the MQTT broker)
if self.current_step % 2 == 0:
self.state_publish_function(self)
self.state_publish_function(self)

await asyncio.sleep(GAME_TICK_INTERVAL)

if (random.random() < DEMAND_PEAK_EVENT_PROBABILITY) or os.getenv("DEV_FORCE_DEMAND_PEAK_EVENT", False):
self.current_step += 1
self.user_messages["demand_peak_bonus"] = UserMessage(
type="INFO",
content="Demand Peak! - Skip maintenance and earn 2x cash in the next turn!"
content=f"Demand Peak! - Skip maintenance and earn {DEMAND_PEAK_BONUS_MULTIPLIER}x cash in the next turn!"
)

self.update_rul_prediction()
self.current_step += 1
self.cash_multiplier = 1

if os.getenv("COLLECT_MACHINE_HISTORY", False):
Expand Down

0 comments on commit a8bda86

Please sign in to comment.