139 lines
5.0 KiB
Python
139 lines
5.0 KiB
Python
import random
|
|
from battle import Combatant, Action, Damage, StatusChange
|
|
|
|
def move_attack(user, target):
|
|
return Action("Attack", user, target, Damage(user.attack, 0, 0, 0), StatusChange(0, 0, 0))
|
|
|
|
def move_fire(user, target):
|
|
return Action("Fira", user, target, Damage(0, 45, 0, 0), StatusChange(0, 0, 0))
|
|
|
|
def move_ice(user, target):
|
|
return Action("Blizzara", user, target, Damage(0, 0, 45, 0), StatusChange(0, 0, 0))
|
|
|
|
def move_cure(user, target):
|
|
return Action("Cure", user, target, Damage(0, 0, 0, 42), StatusChange(0, 0, 0))
|
|
|
|
def move_defend(user, target):
|
|
return Action("Defend", user, target, Damage(0, 0, 0, 0), StatusChange(0, 0, 1))
|
|
|
|
def move_break(user, target):
|
|
return Action("Break", user, target, Damage(0, 0, 0, 0), StatusChange(0, 1, 0))
|
|
|
|
def move_death(user, target):
|
|
return Action("Death", user, target, Damage(0, 0, 0, 0), StatusChange(1, 0, 0))
|
|
|
|
def move_phoenix(user, target):
|
|
return Action("Phoenix Down", user, target, Damage(0, 0, 0, 30), StatusChange(2, 0, 0))
|
|
|
|
def move_softenup(user, target):
|
|
return Action("Esuna", user, target, Damage(0, 0, 0, 0), StatusChange(2, 0, 0))
|
|
|
|
def enemy_turn_test(e,ep, ap,d):
|
|
living = [p for p in ap if not p.ko]
|
|
if not living:
|
|
return None
|
|
|
|
# weighted move pool -- enemies get the same toolkit as the party
|
|
offensive = ["attack", "fire", "ice", "death"]
|
|
support = ["break"]
|
|
self_only = ["defend"]
|
|
|
|
# if an ally is KO'd, occasionally try to revive/cure instead of attacking
|
|
ko_allies = [a for a in ep if a.ko and a is not e]
|
|
hurt_allies = [a for a in ep if not a.ko and a.hp < a.maxhp]
|
|
|
|
roll = random.random()
|
|
|
|
if ko_allies and roll < 0.15:
|
|
act = "phoenix"
|
|
target = random.choice(ko_allies)
|
|
elif hurt_allies and roll < 0.30:
|
|
act = "cure"
|
|
target = random.choice(hurt_allies)
|
|
elif not e.def_up and roll < 0.40:
|
|
act = "defend"
|
|
target = e
|
|
elif roll < 0.55:
|
|
act = "break"
|
|
target = random.choice(living)
|
|
elif roll < 0.65:
|
|
act = "death"
|
|
target = random.choice(living)
|
|
else:
|
|
act = random.choice(["attack", "fire", "ice"])
|
|
target = random.choice(living)
|
|
|
|
_, builder, _ = d["moves"][act]
|
|
print(f" ({e.name} chooses {act} -> {target.name})")
|
|
return builder(e, target)
|
|
|
|
battles = [
|
|
{ "enemies": [
|
|
Combatant("Six-Seven kid", 120, 30, 80, 20, 0, 50, False, False),
|
|
Combatant("Ice Sprite", 60, 15, 150, 10, 0, 200, False, True ),
|
|
Combatant("Magma Brute", 200, 40, 40, 60, 999, -50, True, False),
|
|
],
|
|
"party_members": [
|
|
Combatant("Locke", 80, 45, 130, 15, 10, 10, False, False),
|
|
Combatant("Terra", 100, 35, 100, 30, 30, 30, False, False),
|
|
Combatant("Celes", 110, 25, 90, 50, 40, 40, False, False),
|
|
Combatant("Cyan", 130, 38, 70, 40, 20, 20, False, False),
|
|
],
|
|
"enemy_turn_func": enemy_turn_test,
|
|
"mus_id": "mus_fnafsux",
|
|
"init_ai_data": {
|
|
"moves": {
|
|
"attack": ("Physical attack", move_attack, True),
|
|
"fire": ("Fira", move_fire, True),
|
|
"ice": ("Blizzara", move_ice, True),
|
|
"cure": ("Cure", move_cure, False),
|
|
"defend": ("Defend", move_defend, None),
|
|
"break": ("Break", move_break, True),
|
|
"death": ("Death", move_death, True),
|
|
"phoenix": ("Phoenix Down", move_phoenix, False),
|
|
"unstone": ("Esuna", move_softenup,False),
|
|
}
|
|
},
|
|
"menus": [
|
|
[ # Locke
|
|
["Attack", "phys_att"],
|
|
["", "unselectable"],
|
|
["", "unselectable"],
|
|
["Item", "items"]
|
|
],
|
|
[ # Terra
|
|
["Attack", "phys_att"],
|
|
["Magic", "magic"],
|
|
["", "unselectable"],
|
|
["Item", "items"]
|
|
],
|
|
[ # Celes
|
|
["Attack", "phys_att"],
|
|
["Magic", "magic"],
|
|
["", "unselectable"],
|
|
["Item", "items"]
|
|
],
|
|
[ # Cyan
|
|
["Attack", "phys_att"],
|
|
["", "unselectable"],
|
|
["", "unselectable"],
|
|
["Item", "items"]
|
|
]
|
|
],
|
|
"spells": [
|
|
[], # Locke
|
|
[ # Terra
|
|
["Fira", 0, ("Fira", move_fire, True)],
|
|
["Blizzara", 0, ("Blizzara", move_ice, True)],
|
|
],
|
|
[ # Celes
|
|
["Fira", 0, ("Fira", move_fire, True)],
|
|
["Blizzara", 0, ("Blizzara", move_ice, True)],
|
|
],
|
|
[] # Cyan
|
|
],
|
|
"inventory": [
|
|
["Phoenix Down",67, ("Phoenix Down", move_phoenix, False)]
|
|
]
|
|
}
|
|
] |