Skip to content

Commit

Permalink
Calculate presentation/fun scores from upgrade field
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrankel committed Dec 7, 2023
1 parent 6132668 commit 989258c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 41 deletions.
8 changes: 4 additions & 4 deletions src/simulation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ pub struct Simulation {
pub tech_debt: f64,

/// Fun factor, determines the score.
pub fun_factor: f64,
pub fun_score: f64,
/// Presentation factor, determines the score.
pub presentation_factor: f64,
pub presentation_score: f64,

/// Minimum size for new entities.
pub entity_size_min: f32,
Expand All @@ -65,8 +65,8 @@ impl Default for Simulation {
lines: 0.0,
entities: 0.0,
tech_debt: 0.0,
fun_factor: 0.0,
presentation_factor: 0.0,
fun_score: 0.0,
presentation_score: 0.0,
entity_size_min: 8.0,
entity_size_max: 8.0,
entity_colors: vec![
Expand Down
4 changes: 2 additions & 2 deletions src/simulation/score.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ impl Simulation {
pub fn calculate_scores(&self) -> [f64; 6] {
let mut scores: [f64; 6] = [
// Fun
calculate_score(self.fun_factor, 0.0, 70.0),
calculate_score(self.fun_score, 0.0, 70.0),
// Presentation
calculate_score(self.presentation_factor, 0.0, 40.0),
calculate_score(self.presentation_score, 0.0, 40.0),
// Theme Interpretation
calculate_score(self.entities, 0.0, 1e9),
// Entities
Expand Down
68 changes: 33 additions & 35 deletions src/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ pub struct Upgrade {
/// The description of the upgrade. This will be shown as a tooltip.
pub description: String,
/// How much this upgrade contributes to the Presentation score of your submission.
pub presentation_score: f32,
/// How much this upgrade contributes to the Theme Interpretation score of your submission.
pub theme_score: f32,
pub presentation_score: f64,
/// How much this upgrade contributes to the Fun score of your submission.
pub fun_score: f32,
pub fun_score: f64,

/// How many lines of code this upgrade costs without tech debt scaling.
pub base_cost: f64,
Expand Down Expand Up @@ -98,7 +96,6 @@ impl Default for Upgrade {
name: "Unnamed".to_string(),
description: "Undefined.".to_string(),
presentation_score: 0.0,
theme_score: 0.0,
fun_score: 0.0,

base_cost: 0.0,
Expand Down Expand Up @@ -178,9 +175,12 @@ fn process_new_installed_upgrades(
mut simulation: ResMut<Simulation>,
) {
for event in events.read() {
upgrade_list[event.0].remaining -= 1;
let upgrade = &mut upgrade_list[event.0];
upgrade.remaining -= 1;
simulation.upgrades += 1;
simulation.tech_debt += upgrade_list[event.0].tech_debt;
simulation.tech_debt += upgrade.tech_debt;
simulation.presentation_score += upgrade.presentation_score;
simulation.fun_score += upgrade.fun_score;
}
}

Expand Down Expand Up @@ -238,6 +238,9 @@ macro_rules! generate_upgrade_list {

generate_upgrade_list!(
|world|

// Tutorial upgrades

DarkMode: Upgrade {
name: "Dark Mode".to_string(),
description: "Rite of passage for all developers. Required to write code.".to_string(),
Expand Down Expand Up @@ -271,14 +274,12 @@ generate_upgrade_list!(
MovementPlugin: Upgrade {
name: "MovementPlugin".to_string(),
description: "Allows entities to move. Makes your game more fun.".to_string(),
fun_score: 1.0,
fun_score: 5.0,
base_cost: 5.0,
install: Some(world.register_system(|
mut physics_settings: ResMut<PhysicsSettings>,
mut simulation: ResMut<Simulation>,
| {
physics_settings.speed_multiplier = UNIT_SPEED;
simulation.fun_factor += 5.0;
})),
..default()
},
Expand Down Expand Up @@ -312,11 +313,12 @@ generate_upgrade_list!(
..default()
},

// Upgrades that increase presentation
// Upgrades that make your game prettier

EntitySkinPlugin: Upgrade {
name: "EntitySkinPlugin".to_string(),
description: "Adds a new entity skin with a random color.".to_string(),
description: "Adds a new entity skin with a random color. Makes your game prettier.".to_string(),
presentation_score: 10.0,
base_cost: 10.0,
cost_scale_factor: 1.2,
weight: 1.0,
Expand All @@ -332,47 +334,43 @@ generate_upgrade_list!(
alpha: 1.0,
}
);
simulation.presentation_factor += 10.0;
}),
),
..default()
},
EntitySizePlugin: Upgrade {
name: "EntitySizePlugin".to_string(),
description: "Increases the maximum entity size. Makes your game prettier.".to_string(),
presentation_score: 10.0,
base_cost: 10.0,
cost_scale_factor: 1.2,
weight: 1.0,
remaining: 2,
install: Some(
world.register_system(|mut simulation: ResMut<Simulation>| {
simulation.entity_size_max += 4.0;
}),
),
..default()
},

// Upgrades that increase fun
// Upgrades that make your game more fun

SpeedupPlugin: Upgrade {
name: "SpeedupPlugin".to_string(),
description: "Increases the entity movement speed. Makes your game more fun.".to_string(),
fun_score: 1.0,
fun_score: 10.0,
base_cost: 10.0,
cost_scale_factor: 1.2,
weight: 1.0,
remaining: 5,
install: Some(world.register_system(|
mut physics_settings: ResMut<PhysicsSettings>,
mut simulation: ResMut<Simulation>,
| {
physics_settings.speed_multiplier += UNIT_SPEED;
simulation.fun_factor += 10.0;
})),
..default()
},
EntitySizePlugin: Upgrade {
name: "EntitySizePlugin".to_string(),
description: "Increases the maximum entity size. Makes your game prettier.".to_string(),
presentation_score: 1.0,
base_cost: 10.0,
cost_scale_factor: 1.2,
weight: 1.0,
remaining: 2,
install: Some(
world.register_system(|mut simulation: ResMut<Simulation>| {
simulation.entity_size_max += 4.0;
simulation.fun_factor += 10.0;
}),
),
..default()
},

// Passive entity spawning

Expand Down Expand Up @@ -418,7 +416,7 @@ generate_upgrade_list!(
..default()
},

// Upgrades related to code
// Programming upgrades

ImportLibrary: Upgrade {
name: "Import Library".to_string(),
Expand Down Expand Up @@ -514,7 +512,7 @@ generate_upgrade_list!(
..default()
},

// Misc
// Miscellaneous

DesignDocument: Upgrade {
name: "Design Document".to_string(),
Expand Down

0 comments on commit 989258c

Please sign in to comment.