Csatarendszer adatcentrikusítása
This commit is contained in:
97
src/battle_data.py
Normal file
97
src/battle_data.py
Normal file
@@ -0,0 +1,97 @@
|
||||
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 (remove stoneskin)", user, target, Damage(0, 0, 0, 0), StatusChange(2, 0, 0))
|
||||
|
||||
MOVES = {
|
||||
"attack": ("Physical attack", move_attack, True),
|
||||
"fire": ("Fira (fire magic)", move_fire, True),
|
||||
"ice": ("Blizzara (ice magic)", move_ice, True),
|
||||
"cure": ("Cure (heal ally)", move_cure, False),
|
||||
"defend": ("Defend (self def_up)", move_defend, None), # self-only, forced
|
||||
"break": ("Break (inflict stone)", move_break, True),
|
||||
"death": ("Death (instant KO)", move_death, True),
|
||||
"phoenix": ("Phoenix Down (revive ally)",move_phoenix, False),
|
||||
"unstone": ("Esuna (cure stone)", move_softenup,False),
|
||||
}
|
||||
|
||||
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, _ = 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("Terra", 100, 35, 100, 30, 30, 30, False, False),
|
||||
Combatant("Locke", 80, 45, 130, 15, 10, 10, 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"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user