Skip to content

Commit

Permalink
Quantum spell order
Browse files Browse the repository at this point in the history
  • Loading branch information
konsumlamm committed Apr 15, 2024
1 parent 62e04bf commit 953f073
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/scripts/spell_book.gd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ enum Spells {
STRIKE,
LIGHTNING,
RAIN_OF_BLOOD,
FISH
FISH,
}

const spell_item_script_types = [
Expand Down
30 changes: 19 additions & 11 deletions src/scripts/world.gd
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,7 @@ var room_idx: int = -1
var room: Node2D

const Spell = SpellBook.Spells
const spell_order = [
Spell.SPEED,
Spell.FISH,
Spell.SLOWDOWN,
Spell.PUSH_BACK,
Spell.MAGIC_BOOST,
Spell.STRIKE,
Spell.SHIELD,
Spell.LIGHTNING,
Spell.RAIN_OF_BLOOD,
]
var spell_order := []
var next_spell_idx := 0

## Spawn a new room.
Expand All @@ -47,6 +37,24 @@ func load_room(scene: PackedScene):
$Player.position = room.find_child("PlayerMarker").position

func _ready():
var common := []
var rare := []
var ultra := []
for spell_item in SpellBook.spell_item_scripts:
if spell_item.spell == Spell.PLACEHOLDER:
continue
match spell_item.rank:
SpellBook.SpellRank.COMMON:
common.append(spell_item.spell)
SpellBook.SpellRank.RARE:
rare.append(spell_item.spell)
SpellBook.SpellRank.ULTRA:
ultra.append(spell_item.spell)
common.shuffle()
rare.shuffle()
ultra.shuffle()
spell_order = common + rare + ultra

load_room(main_room)

func check_room_cleared():
Expand Down

0 comments on commit 953f073

Please sign in to comment.