From a55d6f04a01103cf6853fe06d726920b923704a0 Mon Sep 17 00:00:00 2001 From: Waldemar Tomme Date: Sun, 28 Jan 2024 13:47:34 +0100 Subject: [PATCH 1/2] Jokes now have an effectiveness scaling based on stamina --- godot/scenes/Joke Button.gd | 2 +- godot/scenes/crowd/person.gd | 2 +- godot/types/joke.gd | 17 +++++++++++++++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/godot/scenes/Joke Button.gd b/godot/scenes/Joke Button.gd index c06a19c..e7ac194 100644 --- a/godot/scenes/Joke Button.gd +++ b/godot/scenes/Joke Button.gd @@ -22,7 +22,7 @@ func _map_action_to_joke_type(): return Joke.JokeType.Joke3 func _get_joke(type): - return Joke.new(type, stamina_categories[randi_range(0, stamina_categories.size() - 1)]) + return Joke.get_random_joke(type) func _ready(): stamina_label = find_child("StaminaLabel") diff --git a/godot/scenes/crowd/person.gd b/godot/scenes/crowd/person.gd index 465259a..e975837 100644 --- a/godot/scenes/crowd/person.gd +++ b/godot/scenes/crowd/person.gd @@ -142,7 +142,7 @@ func on_joke_start(): is_listening = true func on_hear_joke(joke: Joke): - var mood_change = profile.joke_mood_mapping.get(joke.type, 0) + var mood_change = profile.joke_mood_mapping.get(joke.type, 0) * joke.effectiveness if joke.type == last_joke_heard: mood_change = min(0, mood_change) update_mood(mood_change) diff --git a/godot/types/joke.gd b/godot/types/joke.gd index 515bc6a..a21590e 100644 --- a/godot/types/joke.gd +++ b/godot/types/joke.gd @@ -7,12 +7,25 @@ enum JokeType { Bottle, } +const EFFECTIVENESS_SCALING: float = 1 +const STAMINA_CATEGORIES: Array[float] = [ + 1, + 5, + 10, +] + var type: JokeType var required_stamina: int +var effectiveness: float static func get_bottle_joke(): - return Joke.new(JokeType.Bottle, 0) + return Joke.new(JokeType.Bottle, 0, 1) -func _init(type, required_stamina): +static func get_random_joke(type): + var stamina = STAMINA_CATEGORIES[randi_range(0, STAMINA_CATEGORIES.size() - 1)] + return Joke.new(type, stamina, stamina * EFFECTIVENESS_SCALING) + +func _init(type, required_stamina, effectiveness): self.type = type self.required_stamina = required_stamina + self.effectiveness = effectiveness From 6c753bd7ad126ebebc84a18ceab941e1a564fa3f Mon Sep 17 00:00:00 2001 From: Waldemar Tomme Date: Sun, 28 Jan 2024 13:50:37 +0100 Subject: [PATCH 2/2] Remove stamina categories from joke button --- godot/scenes/Joke Button.gd | 2 -- godot/scenes/joke_button.tscn | 7 +++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/godot/scenes/Joke Button.gd b/godot/scenes/Joke Button.gd index e7ac194..01f9e12 100644 --- a/godot/scenes/Joke Button.gd +++ b/godot/scenes/Joke Button.gd @@ -4,8 +4,6 @@ signal button_pressed(joke) @export_enum("joke_button_1", "joke_button_2", "joke_button_3") var action: String @export var sprite: Sprite2D - -@export var stamina_categories: Array[int] @export var type_sprites: Array[Texture2D] var stamina_label: RichTextLabel diff --git a/godot/scenes/joke_button.tscn b/godot/scenes/joke_button.tscn index f9991e7..7bd4d3d 100644 --- a/godot/scenes/joke_button.tscn +++ b/godot/scenes/joke_button.tscn @@ -1,15 +1,14 @@ [gd_scene load_steps=5 format=3 uid="uid://r1i7ln2hpwq5"] [ext_resource type="Script" path="res://scenes/Joke Button.gd" id="1_lofpb"] -[ext_resource type="Texture2D" uid="uid://br2j6yu0f7x37" path="res://sprites/room/bubble_blue.svg" id="2_ivsb5"] -[ext_resource type="Texture2D" uid="uid://b2vtyqcfr5ukt" path="res://sprites/room/bubble_green.svg" id="3_26ki8"] -[ext_resource type="Texture2D" uid="uid://03ch1nqrnm6c" path="res://sprites/room/bubble_red.svg" id="4_o1r21"] +[ext_resource type="Texture2D" uid="uid://huokdqy7birm" path="res://sprites/room/bubble_blue.svg" id="2_ivsb5"] +[ext_resource type="Texture2D" uid="uid://bsda544aynmha" path="res://sprites/room/bubble_green.svg" id="3_26ki8"] +[ext_resource type="Texture2D" uid="uid://cttngp4bj5fh2" path="res://sprites/room/bubble_red.svg" id="4_o1r21"] [node name="Joke Button" type="Node2D" node_paths=PackedStringArray("sprite")] script = ExtResource("1_lofpb") action = "joke_button_1" sprite = NodePath("Sprite2D") -stamina_categories = Array[int]([1, 5, 10]) type_sprites = Array[Texture2D]([ExtResource("3_26ki8"), ExtResource("2_ivsb5"), ExtResource("4_o1r21")]) [node name="Sprite2D" type="Sprite2D" parent="."]