89 lines
2.3 KiB
Python
89 lines
2.3 KiB
Python
from types import SimpleNamespace
|
|
|
|
import pytest
|
|
|
|
from core.basic.character import calc_carry
|
|
from core.basic.character.calc_carry import CalcCarryMixin
|
|
from core.equipment.version_0.sundry import sundry_7
|
|
|
|
|
|
class StatusTarget:
|
|
def __init__(self):
|
|
self.status_calls = []
|
|
|
|
def SetStatus(self, **kwargs):
|
|
self.status_calls.append(kwargs)
|
|
|
|
|
|
def make_carry(output_type: str):
|
|
return SimpleNamespace(
|
|
输出类型=output_type,
|
|
角色='test-role',
|
|
职业='test-job',
|
|
STR=8700,
|
|
INT=8700,
|
|
AtkP=4500,
|
|
AtkM=4500,
|
|
AtkI=4500,
|
|
PAtkP=1,
|
|
PAtkM=1,
|
|
PAtkI=1,
|
|
ElementDB={'火': 0},
|
|
buff=1,
|
|
SkillAttack=1,
|
|
jade_effect=SimpleNamespace(SkillAttack=0, AttackP=0),
|
|
Attack=0,
|
|
AttackP=1,
|
|
ElementIncrease=1,
|
|
system_buff_marriage_correction=15,
|
|
)
|
|
|
|
|
|
def test_marriage_attributes_enable_system_buff_correction():
|
|
target = StatusTarget()
|
|
|
|
sundry_7(target, 4, 2)
|
|
|
|
assert target.system_buff_marriage_correction == 15
|
|
assert {'体精': 10, '力智': 15} in target.status_calls
|
|
|
|
|
|
def test_marriage_correction_resets_when_attribute_is_not_selected():
|
|
target = StatusTarget()
|
|
sundry_7(target, 4, 2)
|
|
|
|
sundry_7(target, 4, 0)
|
|
|
|
assert target.system_buff_marriage_correction == 0
|
|
|
|
|
|
@pytest.mark.parametrize(
|
|
('output_type', 'expected_correction'),
|
|
[
|
|
('物理百分比', 15),
|
|
('魔法百分比', 0),
|
|
],
|
|
)
|
|
def test_system_buff_applies_marriage_correction_by_main_stat(
|
|
monkeypatch, output_type, expected_correction
|
|
):
|
|
monkeypatch.setattr(calc_carry, '获取基础属性', lambda *_: (818, 818, 818, 818))
|
|
carry = make_carry(output_type)
|
|
|
|
ratios = CalcCarryMixin.calc_damage_ration(carry, DSB=True, BUFF=False)
|
|
|
|
system_buff = (8700 - 818 - expected_correction) * 3.08 + 2886
|
|
assert ratios[0] == pytest.approx((8700 + system_buff) / 250 + 1)
|
|
|
|
|
|
def test_system_buff_matches_2604_sheet_light_nen_example():
|
|
carry = make_carry('魔法百分比')
|
|
carry.角色 = '格斗家(女)'
|
|
carry.职业 = '气功师'
|
|
|
|
ratios = CalcCarryMixin.calc_damage_ration(carry, DSB=True, BUFF=False)
|
|
|
|
final_intelligence = (ratios[0] - 1) * 250
|
|
assert final_intelligence - 8700 == pytest.approx(27162.56)
|
|
assert final_intelligence == pytest.approx(35862.56)
|