Célzás
This commit is contained in:
@@ -32,7 +32,6 @@ action_text = TextRenderer(110, 215, 210)
|
|||||||
menu_open = 0
|
menu_open = 0
|
||||||
menu_queue = []
|
menu_queue = []
|
||||||
menu = []
|
menu = []
|
||||||
enemy_selector = []
|
|
||||||
|
|
||||||
battle_id = 0
|
battle_id = 0
|
||||||
|
|
||||||
@@ -47,22 +46,6 @@ def switch(game):
|
|||||||
inventory = copy.deepcopy(battle_data.battles[battle_id]["inventory"])
|
inventory = copy.deepcopy(battle_data.battles[battle_id]["inventory"])
|
||||||
battle_music = assets.sounds[battle_data.battles[battle_id]["mus_id"]].play(loops=True)
|
battle_music = assets.sounds[battle_data.battles[battle_id]["mus_id"]].play(loops=True)
|
||||||
|
|
||||||
def open_menu(data):
|
|
||||||
global menu
|
|
||||||
|
|
||||||
whose, junk, aparty, eparty = data
|
|
||||||
menu = []
|
|
||||||
|
|
||||||
party_idx = party_members.index(whose)
|
|
||||||
for i, m in enumerate(party_menus[party_idx]):
|
|
||||||
menu.append(MenuItem(m[0], 19, 64-(i*13), None, None, None, None, menu_action, (whose, aparty, eparty, m[1])))
|
|
||||||
|
|
||||||
for i, m in enumerate(menu):
|
|
||||||
m.up = menu[(i - 1) % len(menu)]
|
|
||||||
m.down = menu[(i + 1) % len(menu)]
|
|
||||||
|
|
||||||
menu[0].select()
|
|
||||||
|
|
||||||
def close_menu():
|
def close_menu():
|
||||||
global menu, menu_open
|
global menu, menu_open
|
||||||
menu = []
|
menu = []
|
||||||
@@ -107,14 +90,12 @@ def open_spell_menu(user, aparty, eparty):
|
|||||||
|
|
||||||
def spell_action(data):
|
def spell_action(data):
|
||||||
user, spell, aparty, eparty = data
|
user, spell, aparty, eparty = data
|
||||||
|
name, mp_cost, (action_name, func, target_type) = spell
|
||||||
|
|
||||||
name, mp_cost, action = spell
|
open_target_menu(
|
||||||
|
user, aparty, eparty, target_type,
|
||||||
action_name, func, target_type = action
|
lambda targets: action_queue.append(func(user, targets[0])),
|
||||||
|
lambda *a: open_spell_menu(user, aparty, eparty))
|
||||||
action_queue.append(func(user, [p for p in eparty if not p.ko][0]))
|
|
||||||
|
|
||||||
close_menu()
|
|
||||||
|
|
||||||
|
|
||||||
def open_item_menu(user, aparty, eparty):
|
def open_item_menu(user, aparty, eparty):
|
||||||
@@ -153,20 +134,68 @@ def open_item_menu(user, aparty, eparty):
|
|||||||
|
|
||||||
def item_action(data):
|
def item_action(data):
|
||||||
user, item, aparty, eparty = data
|
user, item, aparty, eparty = data
|
||||||
|
name, amount, (action_name, func, target_type) = item
|
||||||
|
|
||||||
name, amount, action = item
|
def use(targets):
|
||||||
|
action_queue.append(func(user, targets[0]))
|
||||||
action_name, func, target_type = action
|
|
||||||
|
|
||||||
action_queue.append(
|
|
||||||
func(user, user)
|
|
||||||
)
|
|
||||||
|
|
||||||
item[1] -= 1
|
item[1] -= 1
|
||||||
|
|
||||||
|
open_target_menu(user, aparty, eparty, target_type, use,
|
||||||
|
lambda *a: open_item_menu(user, aparty, eparty))
|
||||||
|
|
||||||
|
def open_target_menu(user, aparty, eparty, target_type, on_pick, back):
|
||||||
|
"""
|
||||||
|
target_type: "enemy", "ally", "self", "all_enemies", "all_allies"
|
||||||
|
on_pick: called with a LIST of targets
|
||||||
|
back: called when the player cancels (reopens the previous menu)
|
||||||
|
"""
|
||||||
|
global menu
|
||||||
|
|
||||||
|
# No selection needed
|
||||||
|
if target_type == None:
|
||||||
|
on_pick([user]); close_menu(); return
|
||||||
|
|
||||||
|
pool = eparty if target_type else aparty
|
||||||
|
candidates = [c for c in pool if not c.ko] # drop the `not c.ko` for revive items
|
||||||
|
if not candidates:
|
||||||
|
return
|
||||||
|
|
||||||
|
menu = []
|
||||||
|
for i, c in enumerate(candidates):
|
||||||
|
menu.append(MenuItem(
|
||||||
|
c.name, 19, 64 - (i * 13),
|
||||||
|
None, None, None, None,
|
||||||
|
target_picked, (c, on_pick),
|
||||||
|
back
|
||||||
|
))
|
||||||
|
|
||||||
|
for i, m in enumerate(menu):
|
||||||
|
m.up = menu[(i - 1) % len(menu)]
|
||||||
|
m.down = menu[(i + 1) % len(menu)]
|
||||||
|
menu[0].select()
|
||||||
|
|
||||||
|
|
||||||
|
def target_picked(data):
|
||||||
|
target, on_pick = data
|
||||||
|
on_pick([target])
|
||||||
close_menu()
|
close_menu()
|
||||||
|
|
||||||
# !!! CHATGPT VÉGE !!!
|
def open_menu(data):
|
||||||
|
global menu
|
||||||
|
|
||||||
|
whose, junk, aparty, eparty = data
|
||||||
|
menu = []
|
||||||
|
|
||||||
|
party_idx = party_members.index(whose)
|
||||||
|
for i, m in enumerate(party_menus[party_idx]):
|
||||||
|
menu.append(MenuItem(m[0], 19, 64-(i*13), None, None, None, None, menu_action, (whose, aparty, eparty, m[1])))
|
||||||
|
|
||||||
|
for i, m in enumerate(menu):
|
||||||
|
m.up = menu[(i - 1) % len(menu)]
|
||||||
|
m.down = menu[(i + 1) % len(menu)]
|
||||||
|
|
||||||
|
menu[0].select()
|
||||||
|
|
||||||
|
|
||||||
def menu_action(data):
|
def menu_action(data):
|
||||||
user, aparty, eparty, action = data
|
user, aparty, eparty, action = data
|
||||||
@@ -177,18 +206,14 @@ def menu_action(data):
|
|||||||
return
|
return
|
||||||
|
|
||||||
case "phys_att":
|
case "phys_att":
|
||||||
action_queue.append(
|
def queue_attack(targets):
|
||||||
Action(
|
action_queue.append(Action(
|
||||||
"Physical Attack",
|
"Physical Attack", user, targets[0],
|
||||||
user,
|
Damage(166, 0, 0, 0), StatusChange(0, 0, 0),
|
||||||
[p for p in eparty if not p.ko][0],
|
battle_data.anim_default))
|
||||||
Damage(166, 0, 0, 0),
|
|
||||||
StatusChange(0, 0, 0),
|
|
||||||
battle_data.anim_default
|
|
||||||
)
|
|
||||||
)
|
|
||||||
close_menu()
|
|
||||||
|
|
||||||
|
open_target_menu(user, aparty, eparty, "enemy", queue_attack,
|
||||||
|
lambda *a: open_menu((user, 0, aparty, eparty)))
|
||||||
case "magic":
|
case "magic":
|
||||||
open_spell_menu(user, aparty, eparty)
|
open_spell_menu(user, aparty, eparty)
|
||||||
|
|
||||||
@@ -199,6 +224,7 @@ def menu_action(data):
|
|||||||
print(f"Unknown action: {action}")
|
print(f"Unknown action: {action}")
|
||||||
close_menu()
|
close_menu()
|
||||||
|
|
||||||
|
# !!! CHATGPT VÉGE !!!
|
||||||
def update(game, dt):
|
def update(game, dt):
|
||||||
global menu_open, cur_action, action_timer
|
global menu_open, cur_action, action_timer
|
||||||
|
|
||||||
@@ -275,9 +301,6 @@ def draw(game):
|
|||||||
for m in menu:
|
for m in menu:
|
||||||
m.render()
|
m.render()
|
||||||
|
|
||||||
for s in enemy_selector:
|
|
||||||
s.render()
|
|
||||||
|
|
||||||
party_text.render()
|
party_text.render()
|
||||||
ene_text.render()
|
ene_text.render()
|
||||||
menu_text.render()
|
menu_text.render()
|
||||||
|
|||||||
Reference in New Issue
Block a user