RapidGameFramework
Reusable Godot managers for data-driven small games
Loading...
Searching...
No Matches
battle_sequence_manager.gd
Go to the documentation of this file.
1extends RefCounted
2
3
9
10const STANDARD := "standard"
11const RAID := "raid"
12
13var mode := STANDARD
14var raid_total := 3
15var raid_step := 0
16
17
18
19func select_mode(selected_mode:String) -> void:
20 mode = selected_mode if selected_mode in [STANDARD, RAID] else STANDARD
21 raid_step = 0
22
23
24
25func start_sequence(selected_mode:String) -> void:
26 select_mode(selected_mode)
27 if mode == RAID:
28 raid_step = 1
29
30
31
32func complete_fight(player_won:bool) -> void:
33 if not player_won:
34 raid_step = 0
35 return
36 if mode == RAID and raid_step > 0 and raid_step < raid_total:
37 raid_step += 1
38 else:
39 raid_step = 0
40
41
42
43func is_raid_active() -> bool:
44 return mode == RAID and raid_step > 0
45
46
47func is_sequence_complete() -> bool:
48 return mode == STANDARD or raid_step == 0
49
50
51
52func get_reward_multiplier() -> float:
53 if mode == RAID:
54 return 1.0 + (float(max(raid_step, 1) - 1) * 0.55)
55 return 1.0
56
57
58
59func tune_opponent(card:Dictionary) -> Dictionary:
60 var tuned = card.duplicate(true)
61 if mode != RAID:
62 return tuned
63 var step = max(raid_step, 1)
64 tuned["health"] = int(tuned.get("health", 1)) + ((step - 1) * 7)
65 tuned["attack"] = int(tuned.get("attack", 1)) + (step - 1) * 2
66 tuned["defense"] = int(tuned.get("defense", 0)) + int((step - 1) / 2)
67 tuned["name"] = "%s Raid %d" % [tuned.get("name", "Opponent"), step]
68 return tuned
69
70
71func get_label() -> String:
72 if mode == RAID:
73 return "Raid %d/%d" % [max(raid_step, 1), raid_total]
74 return "Standard Battle"
75
76
77
78func get_state() -> Dictionary:
79 return {
80 "mode": mode,
81 "raid_total": raid_total,
82 "raid_step": raid_step
83 }
84
85
86
87func apply_state(state:Dictionary) -> void:
88 mode = str(state.get("mode", STANDARD))
89 raid_total = int(state.get("raid_total", 3))
90 raid_step = int(state.get("raid_step", 0))