1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-27 13:34:28 +00:00

Spell v3.2

This commit is contained in:
Steffo 2019-02-19 00:28:13 +01:00
parent ea3fb96eeb
commit 8cf1afdd2f
2 changed files with 47 additions and 9 deletions

View file

@ -217,11 +217,12 @@ class SHIP:
class SPELL: class SPELL:
HEADER = "🔍 La magia <b>{name}</b> ha le seguenti proprietà (v{version}):\n" HEADER = "🔍 La magia <b>{name}</b> ha le seguenti proprietà (v{version}):\n"
ACCURACY = "Precisione - <b>{accuracy}%</b>\n" ACCURACY = "Precisione - <b>{accuracy}%</b>\n"
DAMAGE = "Danni - <b>{number}d{type}{constant}</b>\n" DAMAGE = "Danni - <b>{number}d{type}{constant}</b> <i>(in media {avg})</i>\n"
TYPE = "Tipo - <b>{type}</b>\n" TYPE = "Tipo - <b>{type}</b>\n"
REPEAT = "Multiattacco - <b>×{repeat}</b>\n" REPEAT = "Multiattacco - <b>×{repeat}</b>\n"
HEALING = "Cura - <b>{number}d{type}{constant}</b>\n" HEALING = "Cura - <b>{number}d{type}{constant}</b> <i>(in media {avg})</i>\n"
STAT = "Statist. - <b>{name} {change}</b>\n" STAT = "Attrib. - <b>{name}{change}</b>\n"
STATUS_EFFECT = "Infligge - <b>{effect}</b> (<b>{chance}%</b> di probabilità)"
NOTHING = "<i>Chi la usa sguazza nell'acqua, senza ottenere alcun effetto.</i>" NOTHING = "<i>Chi la usa sguazza nell'acqua, senza ottenere alcun effetto.</i>"
class ERRORS: class ERRORS:

View file

@ -10,6 +10,7 @@ class SpellType(enum.Flag):
DAMAGING = enum.auto() DAMAGING = enum.auto()
HEALING = enum.auto() HEALING = enum.auto()
STATS = enum.auto() STATS = enum.auto()
STATUS_EFFECT = enum.auto()
class DamageComponent: class DamageComponent:
@ -60,7 +61,8 @@ class DamageComponent:
string += s(strings.SPELL.DAMAGE, string += s(strings.SPELL.DAMAGE,
words={"number": str(self.dice_number), words={"number": str(self.dice_number),
"type": str(self.dice_type), "type": str(self.dice_type),
"constant": constant}) "constant": constant,
"avg": str(self.avg)})
for dmg_type in self.damage_types: for dmg_type in self.damage_types:
string += s(strings.SPELL.TYPE, words={"type": dmg_type}) string += s(strings.SPELL.TYPE, words={"type": dmg_type})
string += s(strings.SPELL.ACCURACY, words={"accuracy": str(self.miss_chance)}) string += s(strings.SPELL.ACCURACY, words={"accuracy": str(self.miss_chance)})
@ -84,6 +86,10 @@ class HealingComponent:
self.dice_type = random.sample(self.dice_type_distribution, 1)[0] self.dice_type = random.sample(self.dice_type_distribution, 1)[0]
self.constant = random.randrange(math.floor(-self.dice_type / 4), math.ceil(self.dice_type / 4) + 1) self.constant = random.randrange(math.floor(-self.dice_type / 4), math.ceil(self.dice_type / 4) + 1)
@property
def avg(self):
return self.dice_number * (self.dice_type + 1) / 2
def stringify(self) -> str: def stringify(self) -> str:
string = "" string = ""
if self.constant > 0: if self.constant > 0:
@ -95,7 +101,8 @@ class HealingComponent:
string += s(strings.SPELL.HEALING, string += s(strings.SPELL.HEALING,
words={"number": str(self.dice_number), words={"number": str(self.dice_number),
"type": str(self.dice_type), "type": str(self.dice_type),
"constant": constant}) "constant": constant,
"avg": str(self.avg)})
return string return string
@ -139,12 +146,33 @@ class StatsComponent:
return string return string
class StatusEffectComponent:
all_status_effects = ["Bruciatura", "Sanguinamento", "Paralisi", "Veleno",
"Congelamento", "Iperveleno", "Sonno", "Stordimento",
"Rallentamento", "Radicamento", "Rigenerazione", "Morte",
"Affaticamento", "Glitch", "Accecamento", "Silenzio",
"Esilio", "Invisibilità", "Rapidità", "Splendore"]
def __init__(self):
# ENSURE THE SEED IS ALREADY SET WHEN CREATING THIS COMPONENT!!!
self.chance = random.randrange(1, 101)
self.effect = random.sample(self.all_status_effects, 1)[0]
def stringify(self) -> str:
return s(strings.SPELL.STATUS_EFFECT, words={
"chance": str(self.chance),
"effect": self.effect
})
class Spell: class Spell:
version = "3.2" version = "3.2"
damaging_spell_chance = 0.8 damaging_spell_chance = 0.9
healing_spell_chance = 0.8 # If not a damaging spell healing_spell_chance = 0.9 # If not a damaging spell
additional_stats_chance = 0.2 # In addition to the damage/healing additional_stats_chance = 0.1 # In addition to the damage/healing
additional_status_effect_chance = 0.1 # In addition to the rest
def __init__(self, name: str): def __init__(self, name: str):
seed = name.capitalize() seed = name.capitalize()
@ -159,6 +187,8 @@ class Spell:
self.spell_type |= SpellType.HEALING self.spell_type |= SpellType.HEALING
if random.random() < self.additional_stats_chance: if random.random() < self.additional_stats_chance:
self.spell_type |= SpellType.STATS self.spell_type |= SpellType.STATS
if random.random() < self.additional_status_effect_chance:
self.spell_type |= SpellType.STATUS_EFFECT
# Damaging spells # Damaging spells
if self.spell_type & SpellType.DAMAGING: if self.spell_type & SpellType.DAMAGING:
self.damage_component = DamageComponent() self.damage_component = DamageComponent()
@ -169,11 +199,16 @@ class Spell:
self.healing_component = HealingComponent() self.healing_component = HealingComponent()
else: else:
self.healing_component = None self.healing_component = None
# Status spells # Stats spells
if self.spell_type & SpellType.STATS: if self.spell_type & SpellType.STATS:
self.stats_component = StatsComponent() self.stats_component = StatsComponent()
else: else:
self.stats_component = None self.stats_component = None
# Status effect spells
if self.spell_type & SpellType.STATUS_EFFECT:
self.status_effect_component = StatusEffectComponent()
else:
self.status_effect_component = None
def stringify(self) -> str: def stringify(self) -> str:
@ -184,6 +219,8 @@ class Spell:
string += self.healing_component.stringify() string += self.healing_component.stringify()
if self.spell_type & SpellType.STATS: if self.spell_type & SpellType.STATS:
string += self.stats_component.stringify() string += self.stats_component.stringify()
if self.spell_type & SpellType.STATUS_EFFECT:
string += self.status_effect_component.stringify()
if self.spell_type == SpellType(0): if self.spell_type == SpellType(0):
string += s(strings.SPELL.NOTHING) string += s(strings.SPELL.NOTHING)
return string return string