Spaces:
Runtime error
Runtime error
File size: 21,331 Bytes
025687f 2452398 025687f 581e199 55f0dce 025687f 5825182 025687f a2a5d31 025687f c255694 2f63a42 dbae951 a05a2de 025687f 2f63a42 025687f 55f0dce 025687f a2a5d31 025687f a2a5d31 025687f a2a5d31 025687f a2a5d31 025687f a2a5d31 025687f a2a5d31 025687f a2a5d31 025687f a2a5d31 025687f a2a5d31 025687f a2a5d31 025687f a2a5d31 025687f a2a5d31 025687f a2a5d31 025687f a2a5d31 025687f a2a5d31 581e199 025687f a2a5d31 025687f a2a5d31 025687f a2a5d31 025687f a05a2de 581e199 17a347d a2a5d31 025687f 581e199 025687f a2a5d31 025687f 6e6388e 17a347d effe13f 581e199 6e6388e 1467c05 581e199 1467c05 dace851 a2a5d31 581e199 3a1196e a2a5d31 581e199 6e6388e 17a347d 1467c05 17a347d 581e199 17a347d 1467c05 581e199 a05a2de 17a347d c255694 a05a2de ff5593c 3a1196e ff5593c a2a5d31 ff5593c a2a5d31 ff5593c c255694 ff5593c dbae951 ff5593c a2a5d31 ff5593c a2a5d31 ff5593c 17a347d ff5593c dbae951 ff5593c a2a5d31 ff5593c effe13f 55f0dce c255694 55f0dce c255694 55f0dce dbae951 c255694 a05a2de effe13f 55f0dce effe13f 55f0dce effe13f 55f0dce dace851 ff5593c a2a5d31 025687f ff5593c a2a5d31 025687f effe13f 55f0dce ff5593c a2a5d31 025687f ff5593c a2a5d31 025687f 55f0dce effe13f 55f0dce c255694 a05a2de c255694 a05a2de c255694 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 |
from base.attribute import Attribute
from base.constant import *
from utils.damage import *
from typing import List, Union
from dataclasses import dataclass
class BaseSkill:
_skill_name: Union[List[str], str] = ""
skill_level: int = 0
skill_stack: int = 1
_damage_base: Union[List[int], int] = 0
_damage_rand: Union[List[int], int] = 0
_attack_power_cof: Union[List[float], float] = 0.
_surplus_cof: Union[List[float], float] = 0.
_weapon_damage_cof: Union[List[float], float] = 0.
damage_gain: float = 1.
attack_power_cof_gain: float = 1.
surplus_cof_gain: float = 1.
weapon_damage_cof_gain: float = 1.
global_damage_factor: float = 1.
skill_damage_addition: int = 0
extra_damage_addition: int = 0
_skill_pve_addition: Union[List[int], int] = 0
_skill_shield_gain: Union[List[int], int] = 0
skill_critical_strike: int = 0
skill_critical_power: int = 0
@property
def skill_name(self):
if not isinstance(self._skill_name, list):
return ""
if self.skill_level > len(self._skill_name):
return self._skill_name[-1]
else:
return self._skill_name[self.skill_level - 1]
@skill_name.setter
def skill_name(self, skill_name):
if isinstance(skill_name, list):
self._skill_name = skill_name
else:
self._skill_name = [skill_name]
@property
def damage_base(self):
if not isinstance(self._damage_base, list):
return 0
if self.skill_level > len(self._damage_base):
damage_base = self._damage_base[-1]
else:
damage_base = self._damage_base[self.skill_level - 1]
return damage_base * self.damage_gain
@damage_base.setter
def damage_base(self, damage_base):
if isinstance(damage_base, list):
self._damage_base = damage_base
else:
self._damage_base = [damage_base]
@property
def damage_rand(self):
if not isinstance(self._damage_rand, list):
return 0
if self.skill_level > len(self._damage_rand):
damage_rand = self._damage_rand[-1]
else:
damage_rand = self._damage_rand[self.skill_level - 1]
return damage_rand * self.damage_gain
@damage_rand.setter
def damage_rand(self, damage_rand):
if isinstance(damage_rand, list):
self._damage_rand = damage_rand
else:
self._damage_rand = [damage_rand]
@property
def attack_power_cof(self):
if not isinstance(self._attack_power_cof, list):
return 0
if self.skill_level > len(self._attack_power_cof):
attack_power_cof = self._attack_power_cof[-1]
else:
attack_power_cof = self._attack_power_cof[self.skill_level - 1]
return attack_power_cof * self.attack_power_cof_gain
@attack_power_cof.setter
def attack_power_cof(self, attack_power_cof):
if isinstance(attack_power_cof, list):
self._attack_power_cof = attack_power_cof
else:
self._attack_power_cof = [attack_power_cof]
@property
def surplus_cof(self):
if not isinstance(self._surplus_cof, list):
return 0
if self.skill_level > len(self._surplus_cof):
surplus_cof = self._surplus_cof[-1]
else:
surplus_cof = self._surplus_cof[self.skill_level - 1]
return SURPLUS_COF(surplus_cof * self.surplus_cof_gain)
@surplus_cof.setter
def surplus_cof(self, surplus_cof):
if isinstance(surplus_cof, list):
self._surplus_cof = surplus_cof
else:
self._surplus_cof = [surplus_cof]
@property
def weapon_damage_cof(self):
if not isinstance(self._weapon_damage_cof, list):
return 0
if self.skill_level > len(self._weapon_damage_cof):
weapon_damage_cof = self._weapon_damage_cof[-1]
else:
weapon_damage_cof = self._weapon_damage_cof[self.skill_level - 1]
return WEAPON_DAMAGE_COF(weapon_damage_cof * self.weapon_damage_cof_gain)
@weapon_damage_cof.setter
def weapon_damage_cof(self, weapon_damage_cof):
if isinstance(weapon_damage_cof, list):
self._weapon_damage_cof = weapon_damage_cof
else:
self._weapon_damage_cof = [weapon_damage_cof]
@property
def skill_shield_gain(self):
if not isinstance(self._skill_shield_gain, list):
return 0
if self.skill_level > len(self._skill_shield_gain):
return self._skill_shield_gain[-1]
else:
return self._skill_shield_gain[self.skill_level - 1]
@skill_shield_gain.setter
def skill_shield_gain(self, skill_shield_gain):
if isinstance(skill_shield_gain, list):
self._skill_shield_gain = skill_shield_gain
else:
self._skill_shield_gain = [skill_shield_gain]
@property
def skill_pve_addition(self):
if not isinstance(self._skill_pve_addition, list):
return 0
if self.skill_level > len(self._skill_pve_addition):
return self._skill_pve_addition[-1]
else:
return self._skill_pve_addition[self.skill_level - 1]
@skill_pve_addition.setter
def skill_pve_addition(self, skill_pve_addition):
if isinstance(skill_pve_addition, list):
self._skill_pve_addition = skill_pve_addition
else:
self._skill_pve_addition = [skill_pve_addition]
@dataclass
class Skill(BaseSkill):
skill_id: int
activate: bool = True
interval: int = 0
bind_skill: int = 0
tick: int = 1
max_stack: int = 1
last_dot: bool = True
pre_effects: list = None
pre_buffs: dict = None
pre_target_buffs: dict = None
post_effects: list = None
post_buffs: dict = None
post_target_buffs: dict = None
def __post_init__(self):
if not self.pre_effects:
self.pre_effects = []
if not self.pre_buffs:
self.pre_buffs = {}
if not self.pre_target_buffs:
self.pre_target_buffs = {}
if not self.post_effects:
self.post_effects = []
if not self.post_buffs:
self.post_buffs = {}
if not self.post_target_buffs:
self.post_target_buffs = {}
@property
def display_name(self):
return f"{self.skill_name}#{self.skill_id}-{self.skill_level}-{self.skill_stack}"
def pre_record(self, parser):
for (buff_id, buff_level), buff_stack in self.pre_buffs.items():
buff_level = buff_level if buff_level else self.skill_level
parser.refresh_buff(buff_id, buff_level, buff_stack)
for (buff_id, buff_level), buff_stack in self.pre_target_buffs.items():
buff_level = buff_level if buff_level else self.skill_level
parser.refresh_target_buff(buff_id, buff_level, buff_stack)
for effect in self.pre_effects:
effect(parser)
def record(self, critical, parser):
pass
def post_record(self, parser):
for (buff_id, buff_level), buff_stack in self.post_buffs.items():
buff_level = buff_level if buff_level else self.skill_level
parser.refresh_buff(buff_id, buff_level, buff_stack)
for (buff_id, buff_level), buff_stack in self.post_target_buffs.items():
buff_level = buff_level if buff_level else self.skill_level
parser.refresh_target_buff(buff_id, buff_level, buff_stack)
for effect in self.post_effects:
effect(parser)
def parse(self, critical, parser):
self.pre_record(parser)
self.record(critical, parser)
self.post_record(parser)
def __call__(self, attribute: Attribute):
return 0
class DotSkill(Skill):
def record(self, critical, parser):
super().record(critical, parser)
bind_skill = parser.current_school.skills[self.bind_skill]
if not parser.current_dot_ticks[self.bind_skill]:
parser.current_dot_stacks[self.bind_skill] = 0
parser.current_dot_ticks[self.bind_skill] = bind_skill.tick
parser.current_dot_stacks[self.bind_skill] = min(
parser.current_dot_stacks.get(self.bind_skill, 0) + 1, bind_skill.max_stack
)
parser.current_dot_snapshot[self.bind_skill] = parser.current_buff_stacks.copy()
class DotConsumeSkill(Skill):
def consume_next(self, parser):
tick = min(parser.current_dot_ticks[self.bind_skill], self.tick)
parser.current_next_dot[self.bind_skill] = tick
def consume_last(self, parser):
if not (last_dot := parser.current_last_dot.pop(self.bind_skill, None)):
return
skill_tuple, status_tuple = last_dot
skill_id, skill_level, skill_stack = skill_tuple
parser.current_dot_ticks[skill_id] += 1
tick = min(parser.current_dot_ticks[skill_id], self.tick)
parser.current_records[(skill_id, skill_level, skill_stack * tick)][status_tuple].append(
parser.current_records[skill_tuple][status_tuple].pop()
)
parser.current_dot_ticks[skill_id] -= tick
def record(self, critical, parser):
super().record(critical, parser)
if self.last_dot:
self.consume_last(parser)
else:
self.consume_next(parser)
class Damage(Skill):
def record(self, critical, parser):
super().record(critical, parser)
skill_stack = parser.current_dot_stacks[self.skill_id]
skill_tuple = (self.skill_id, self.skill_level, skill_stack)
status_tuple = parser.status(self.skill_id)
parser.current_records[skill_tuple][status_tuple].append(
(parser.current_frame - parser.start_frame, critical)
)
return skill_tuple, status_tuple
class DotDamage(Damage):
def record(self, critical, parser):
skill_tuple, status_tuple = super().record(critical, parser)
if tick := parser.current_next_dot.pop(self.skill_id, None):
_, _, skill_stack = skill_tuple
parser.current_records[(self.skill_id, self.skill_level, skill_stack * tick)][status_tuple].append(
parser.current_records[skill_tuple][status_tuple].pop()
)
parser.current_dot_ticks[self.skill_id] -= tick
else:
parser.current_last_dot[self.skill_id] = (skill_tuple, status_tuple)
parser.current_dot_ticks[self.skill_id] -= 1
class NpcDamage(Damage):
pass
class PetDamage(Damage):
def __call__(self, attribute: Attribute):
attack_power = int(attribute.attack_power * 0.87 + attribute.surplus * 59 / 1664)
damage = init_result(
self.damage_base, self.damage_rand,
self.attack_power_cof, attack_power, 0, 0, 0, 0
) * self.skill_stack * self.global_damage_factor * attribute.global_damage_factor
damage = damage_addition_result(
damage, attribute.damage_addition + self.skill_damage_addition, self.extra_damage_addition
)
damage = overcome_result(damage, attribute.overcome,
attribute.level_shield_base + attribute.shield_base,
attribute.shield_gain + self.skill_shield_gain,
0,
attribute.shield_constant)
critical_power_gain = attribute.critical_power_gain + self.skill_critical_power
critical_damage = critical_result(damage, attribute.base_critical_power, critical_power_gain)
damage = level_reduction_result(damage, attribute.level_reduction)
critical_damage = level_reduction_result(critical_damage, attribute.level_reduction)
damage = strain_result(damage, attribute.base_strain, attribute.strain_gain)
critical_damage = strain_result(critical_damage, attribute.base_strain, attribute.strain_gain)
damage = pve_addition_result(damage, attribute.pve_addition + self.skill_pve_addition)
critical_damage = pve_addition_result(critical_damage, attribute.pve_addition + self.skill_pve_addition)
damage = vulnerable_result(damage, attribute.vulnerable)
critical_damage = vulnerable_result(critical_damage, attribute.vulnerable)
critical_strike = min(1, attribute.critical_strike + self.skill_critical_strike / DECIMAL_SCALE)
expected_damage = critical_strike * critical_damage + (1 - critical_strike) * damage
return damage, critical_damage, expected_damage, critical_strike
class PureSkill(Skill):
def __call__(self, attribute: Attribute):
damage = init_result(self.damage_base, self.damage_rand, 0, 0, 0, 0, 0, 0)
damage = level_reduction_result(damage, attribute.level_reduction)
damage = vulnerable_result(damage, attribute.vulnerable)
return damage, damage, damage, 0
class PhysicalSkill(Skill):
def __call__(self, attribute: Attribute):
damage = init_result(
self.damage_base, self.damage_rand,
self.attack_power_cof, attribute.physical_attack_power,
self.weapon_damage_cof, attribute.weapon_damage,
self.surplus_cof, attribute.surplus
) * self.skill_stack * self.global_damage_factor * attribute.global_damage_factor
damage = damage_addition_result(
damage, attribute.physical_damage_addition + self.skill_damage_addition, self.extra_damage_addition
)
damage = overcome_result(damage, attribute.physical_overcome,
attribute.level_shield_base + attribute.physical_shield_base,
attribute.physical_shield_gain + self.skill_shield_gain,
attribute.physical_shield_ignore,
attribute.shield_constant)
critical_power_gain = attribute.physical_critical_power_gain + self.skill_critical_power
critical_damage = critical_result(damage, attribute.base_physical_critical_power, critical_power_gain)
damage = level_reduction_result(damage, attribute.level_reduction)
critical_damage = level_reduction_result(critical_damage, attribute.level_reduction)
damage = strain_result(damage, attribute.base_strain, attribute.strain_gain)
critical_damage = strain_result(critical_damage, attribute.base_strain, attribute.strain_gain)
damage = pve_addition_result(damage, attribute.pve_addition + self.skill_pve_addition)
critical_damage = pve_addition_result(critical_damage, attribute.pve_addition + self.skill_pve_addition)
damage = vulnerable_result(damage, attribute.physical_vulnerable)
critical_damage = vulnerable_result(critical_damage, attribute.physical_vulnerable)
critical_strike = min(1, attribute.physical_critical_strike + self.skill_critical_strike / DECIMAL_SCALE)
expected_damage = critical_strike * critical_damage + (1 - critical_strike) * damage
return damage, critical_damage, expected_damage, critical_strike
class MagicalSkill(Skill):
def __call__(self, attribute: Attribute):
damage = init_result(
self.damage_base, self.damage_rand,
self.attack_power_cof, attribute.magical_attack_power,
self.weapon_damage_cof, attribute.weapon_damage,
self.surplus_cof, attribute.surplus
) * self.skill_stack * self.global_damage_factor * attribute.global_damage_factor
damage = damage_addition_result(
damage, attribute.magical_damage_addition + self.skill_damage_addition, self.extra_damage_addition
)
damage = overcome_result(damage, attribute.magical_overcome,
attribute.level_shield_base + attribute.magical_shield_base,
attribute.magical_shield_gain + self.skill_shield_gain,
attribute.magical_shield_ignore,
attribute.shield_constant)
critical_power_gain = attribute.magical_critical_power_gain + self.skill_critical_power
critical_damage = critical_result(damage, attribute.base_magical_critical_power, critical_power_gain)
damage = level_reduction_result(damage, attribute.level_reduction)
critical_damage = level_reduction_result(critical_damage, attribute.level_reduction)
damage = strain_result(damage, attribute.base_strain, attribute.strain_gain)
critical_damage = strain_result(critical_damage, attribute.base_strain, attribute.strain_gain)
damage = pve_addition_result(damage, attribute.pve_addition + self.skill_pve_addition)
critical_damage = pve_addition_result(critical_damage, attribute.pve_addition + self.skill_pve_addition)
damage = vulnerable_result(damage, attribute.magical_vulnerable)
critical_damage = vulnerable_result(critical_damage, attribute.magical_vulnerable)
critical_strike = min(1, attribute.magical_critical_strike + self.skill_critical_strike / DECIMAL_SCALE)
expected_damage = critical_strike * critical_damage + (1 - critical_strike) * damage
return damage, critical_damage, expected_damage, critical_strike
class AdaptiveSkill(Skill):
def __call__(self, attribute: Attribute):
damage = init_result(
self.damage_base, self.damage_rand,
self.attack_power_cof, attribute.attack_power,
self.weapon_damage_cof, attribute.weapon_damage,
self.surplus_cof, attribute.surplus
) * self.skill_stack * self.global_damage_factor * attribute.global_damage_factor
damage = damage_addition_result(
damage, attribute.damage_addition + self.skill_damage_addition, self.extra_damage_addition
)
damage = overcome_result(damage, attribute.overcome,
attribute.level_shield_base + attribute.shield_base,
attribute.shield_gain + self.skill_shield_gain,
attribute.shield_ignore,
attribute.shield_constant)
critical_power_gain = attribute.critical_power_gain + self.skill_critical_power
critical_damage = critical_result(damage, attribute.base_critical_power, critical_power_gain)
damage = level_reduction_result(damage, attribute.level_reduction)
critical_damage = level_reduction_result(critical_damage, attribute.level_reduction)
damage = strain_result(damage, attribute.base_strain, attribute.strain_gain)
critical_damage = strain_result(critical_damage, attribute.base_strain, attribute.strain_gain)
damage = pve_addition_result(damage, attribute.pve_addition + self.skill_pve_addition)
critical_damage = pve_addition_result(critical_damage, attribute.pve_addition + self.skill_pve_addition)
damage = vulnerable_result(damage, attribute.vulnerable)
critical_damage = vulnerable_result(critical_damage, attribute.vulnerable)
critical_strike = min(1, attribute.critical_strike + self.skill_critical_strike / DECIMAL_SCALE)
expected_damage = critical_strike * critical_damage + (1 - critical_strike) * damage
return damage, critical_damage, expected_damage, critical_strike
class PureDamage(PureSkill, Damage):
pass
class PhysicalDamage(PhysicalSkill, Damage):
@Damage.attack_power_cof.getter
def attack_power_cof(self):
return PHYSICAL_ATTACK_POWER_COF(super().attack_power_cof + self.interval)
class MagicalDamage(MagicalSkill, Damage):
@Damage.attack_power_cof.getter
def attack_power_cof(self):
return MAGICAL_ATTACK_POWER_COF(super().attack_power_cof + self.interval)
class MixingDamage(AdaptiveSkill, Damage):
@Damage.attack_power_cof.getter
def attack_power_cof(self):
return MAGICAL_ATTACK_POWER_COF(super().attack_power_cof + self.interval)
class PhysicalDotDamage(PhysicalSkill, DotDamage):
@Damage.attack_power_cof.getter
def attack_power_cof(self):
return PHYSICAL_DOT_ATTACK_POWER_COF(super().attack_power_cof, self.interval)
class MagicalDotDamage(MagicalSkill, DotDamage):
@Damage.attack_power_cof.getter
def attack_power_cof(self):
return MAGICAL_DOT_ATTACK_POWER_COF(super().attack_power_cof, self.interval)
class MixingDotDamage(AdaptiveSkill, DotDamage):
@Damage.attack_power_cof.getter
def attack_power_cof(self):
return MAGICAL_DOT_ATTACK_POWER_COF(super().attack_power_cof, self.interval)
class PhysicalNpcDamage(PhysicalSkill, NpcDamage):
@Damage.attack_power_cof.getter
def attack_power_cof(self):
return PHYSICAL_ATTACK_POWER_COF(super().attack_power_cof + self.interval)
class MagicalNpcDamage(MagicalSkill, NpcDamage):
@Damage.attack_power_cof.getter
def attack_power_cof(self):
return MAGICAL_ATTACK_POWER_COF(super().attack_power_cof + self.interval)
class MagicalPetDamage(MagicalSkill, PetDamage):
@Damage.attack_power_cof.getter
def attack_power_cof(self):
return MAGICAL_ATTACK_POWER_COF(super().attack_power_cof + self.interval)
|